-
Notifications
You must be signed in to change notification settings - Fork 24
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
feat(alloydb): Add EmbeddingStore and Loader for Google AlloyDB #102
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@averikitsch Thank you! Could you please change the module name and dir name?
There are some dependencies conflict, could you please check it?
Also, if the filtering funcationality is already done, maybe the AlloyDBEmbeddingStoreIT
should extend EmbeddingStoreWithFilteringIT
.
...-alloydb-pg/src/main/java/dev/langchain4j/store/embedding/alloydb/AlloyDBEmbeddingStore.java
Outdated
Show resolved
Hide resolved
...-alloydb-pg/src/main/java/dev/langchain4j/store/embedding/alloydb/AlloyDBEmbeddingStore.java
Outdated
Show resolved
Hide resolved
...-alloydb-pg/src/main/java/dev/langchain4j/store/embedding/alloydb/AlloyDBEmbeddingStore.java
Outdated
Show resolved
Hide resolved
...-alloydb-pg/src/main/java/dev/langchain4j/store/embedding/alloydb/AlloyDBEmbeddingStore.java
Outdated
Show resolved
Hide resolved
|
||
private double calculateRelevanceScore(double distance) { | ||
switch (distanceStrategy.name()) { | ||
case "EUCLIDEAN" -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LangChain4j only support COSINE_DISTANCE
for now actually...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have created a DistanceStrategy class to enable different distances. This is important to our customers in order to tune their RAG results since different embedding models work better with specific distance calculations.
Do you have concerns about us extending this support?
Note: We will also be adding indexing methods that will allow vector indexes to be added using different distance strategies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's nice to support different distances strategy, but the score
field in EmbeddingMatch
is based on cosine similarity, so perhaps we need a clearer javadoc description on the search
method. WDYT?
...-alloydb-pg/src/main/java/dev/langchain4j/store/embedding/alloydb/AlloyDBEmbeddingStore.java
Outdated
Show resolved
Hide resolved
...lloydb-pg/src/test/java/dev/langchain4j/store/embedding/alloydb/AlloyDBEmbeddingStoreIT.java
Outdated
Show resolved
Hide resolved
7c788e2
to
e777a3e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@averikitsch Thank you! Could you please run make format
after solving all comments?
...res/langchain4j-community-alloydb-pg/src/main/java/dev/langchain4j/engine/AlloyDBEngine.java
Outdated
Show resolved
Hide resolved
...y-alloydb-pg/src/test/java/dev/langchain4j/data/document/loader/alloydb/AlloyDBLoaderIT.java
Outdated
Show resolved
Hide resolved
...y-alloydb-pg/src/test/java/dev/langchain4j/data/document/loader/alloydb/AlloyDBLoaderIT.java
Outdated
Show resolved
Hide resolved
...y-alloydb-pg/src/test/java/dev/langchain4j/data/document/loader/alloydb/AlloyDBLoaderIT.java
Outdated
Show resolved
Hide resolved
...y-alloydb-pg/src/test/java/dev/langchain4j/data/document/loader/alloydb/AlloyDBLoaderIT.java
Outdated
Show resolved
Hide resolved
...-alloydb-pg/src/main/java/dev/langchain4j/store/embedding/alloydb/AlloyDBEmbeddingStore.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@averikitsch Thank you!
|
||
private static final String USER_AGENT = "langchain4j-alloydb-pg"; | ||
private static final Logger log = LoggerFactory.getLogger(AlloyDBEngine.class.getName()); | ||
private static ConnectorConfig namedConnectorConfig; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering why this field is static
, could you please elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to not be static.
Issue
Closes #
Change
Mirror of LangChain Python implementation for Google AlloyDB (https://github.com/googleapis/langchain-google-alloydb-pg-python). Includes EmbeddingStore and Loader integrations.
General checklist
Checklist for adding new maven module
pom.xml
andlangchain4j-community-bom/pom.xml
Checklist for adding new embedding store integration
{NameOfIntegration}EmbeddingStoreIT
that extends from eitherEmbeddingStoreIT
orEmbeddingStoreWithFilteringIT
{NameOfIntegration}EmbeddingStoreRemovalIT
that extends fromEmbeddingStoreWithRemovalIT
Checklist for changing existing embedding store integration
{NameOfIntegration}EmbeddingStore
works correctly with the data persisted using the latest released version of LangChain4j