Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Hash to Vector embedding sources to detect if source and embedding are out of sync #464

Open
bsbodden opened this issue Jun 11, 2024 · 0 comments

Comments

@bsbodden
Copy link
Contributor

See https://github.com/redis/redis-om-spring/blob/main/redis-om-spring/src/main/java/com/redis/om/spring/annotations/Vectorize.java

Ideally a new annotation on the Hash field with connect it to the Vectorize annotation 'source' something like:

@Document
public class DocWithCustomModelOpenAIEmbedding {
  @Id
  private String id;

  @Indexed
  @NonNull
  private String name;

  @Indexed( //
            schemaFieldType = SchemaFieldType.VECTOR, //
            algorithm = VectorAlgorithm.HNSW, //
            type = VectorType.FLOAT32, //
            dimension = 3072, //
            distanceMetric = DistanceMetric.COSINE, //
            initialCapacity = 10
  )
  private float[] textEmbedding;

  @Vectorize( //
              destination = "textEmbedding", //
              embeddingType = EmbeddingType.SENTENCE, //
              provider = EmbeddingProvider.OPENAI, //
              openAiEmbeddingModel = EmbeddingModel.TEXT_EMBEDDING_3_LARGE, //
              trackChanges = true // <==== This will tell OM to hash the field into a private JSON or Hash field like `_text_hash` matching the name of the field below
  )
  @NonNull
  private String text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant