mirror of
https://github.com/ollama/ollama-python.git
synced 2026-07-21 09:05:23 -04:00
Embeddings underperform compared to Llama cpp #175
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @codinguncut on GitHub (Nov 30, 2024).
Originally assigned to: @jmorganca on GitHub.
I benchmarked document embeddings of ollama==0.4.2 vs. llama_cpp_python==0.2.69.
I used pretrained LLM models to create document embeddings and scikit-learn LogisticRegression to classify the documents.
The Llama results are in the same general ballpark, but especially Qwen2.5 1.5b is performing much worse in ollama python than in llama-cpp-python.
The classification code is exactly the same between libraries, and I assume the models pulled are similar too. I don't know what causes the difference, whether it is a difference in pooling, or quantification, or random sampling error.
On a separate note, Llama-cpp-python is also 4x faster than ollama python.
These are my results:
ollama==0.4.2,
ollama.embed(model=model_name, input=[...])llama_cpp_ptyon==0.2.69
To check for a potential model mismatch I also pulled the same models used as in llama-cpp and ran them in ollama python:
In the above iteration Qwen2-1.5B is doing much better, but Qwen2.5-3B is still performing much worse.
Full source code below:
@nirajgadhe commented on GitHub (Jan 29, 2025):
Yes even we are having he same issue . We have Llama3.1 70b installed on two servers. In one of the servers we have Llama.cpp based API and setup. And in the other we have Ollama based setup. The Ollama setup is giving results which are not as good as the llama.cpp setup.