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

Use extend method for embeddings concatenation in mlflow_gateway #14358

Merged
merged 6 commits into from
Aug 23, 2024

Conversation

jamesev15
Copy link
Contributor

Description

There is a bug in the concatenation of embeddings obtained from MLflow that does not conform to the type hint requested by the function.

def _query(self, texts: List[str]) -> List[List[float]]:

It is logical to expect a List[List[float]] for a List[str]. However, the append method encapsulates the response in a global List.
To avoid this, the extend method should be used, which will add the embeddings of all strings at the same list level.

Testing

I have tried using OpenAI-ADA to obtain the embeddings, and the result of executing this snippet is as follows:

embeds = await MlflowAIGatewayEmbeddings().aembed_documents(texts=["hi", "how are you?"])
print(embeds)
[[[-0.03512698, -0.020624293, -0.015343423, ...], [-0.021260535, -0.011461929, -0.00033121882, ...]]]

When in reality, the expected result should be:

[[-0.03512698, -0.020624293, -0.015343423, ...], [-0.021260535, -0.011461929, -0.00033121882, ...]]

The above result complies with the expected type hint: List[List[float]] . As I mentioned, we can achieve that by using the extend method instead of the append method.

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Dec 6, 2023
Copy link

vercel bot commented Dec 6, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchain ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 23, 2024 2:43pm

@dosubot dosubot bot added Ɑ: embeddings Related to text embedding models module 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature labels Dec 6, 2023
@jamesev15
Copy link
Contributor Author

jamesev15 commented Dec 7, 2023

@hwchase17 I just want to use the extend method instead of the append method. Could you take a quick look at it? :)

@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label Jan 4, 2024
@baskaryan
Copy link
Collaborator

cc @harupy

@hwchase17 hwchase17 closed this Jan 30, 2024
@baskaryan baskaryan reopened this Jan 30, 2024
@ccurme ccurme added the community Related to langchain-community label Jun 18, 2024
@ccurme ccurme enabled auto-merge (squash) August 23, 2024 14:29
@ccurme ccurme merged commit 644e0d3 into langchain-ai:master Aug 23, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature community Related to langchain-community Ɑ: embeddings Related to text embedding models module lgtm PR looks good. Use to confirm that a PR is ready for merging. size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants