Inconsistent embeddings between LlamaCppEmbeddings and llama.cpp #21568
Labels
🤖:bug
Related to a bug, vulnerability, unexpected error with an existing feature
Ɑ: embeddings
Related to text embedding models module
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
Description
I have downloaded the Llama-3-8B model from https://huggingface.co/SanctumAI/Meta-Llama-3-8B-Instruct-GGUF and tried to run it in the typical Langchain flow to save the embeddings in a vector store.
However, I found several errors. The first, is that the call to
embed_query
(or similarlyembed_documents
) returns the error above. Analyzing the implementation of the method, it turns out that theself.client.embed(text)
function returnsList[List[float]]
instead ofList[float]
:So, for the example above,
self.client.embed("Hello world")
returns as much lists as tokens (4 tokens, so 4 different embeddings):However, running the same embedding on
llama.cpp
binary through:$ ./embedding -m models/meta-llama-3-8b-instruct.Q4_K_M.gguf -p "Hello world" --seed 198 -1.294132, -2.531020, 2.608500, ...
just a single embedding. So:
System Info
System Information
Package Information
Packages not installed (Not Necessarily a Problem)
The following packages were not found:
The text was updated successfully, but these errors were encountered: