Embeddings turn text into lists of numbers — vectors — so that similar meanings end up close together, which is what makes search-by-meaning and retrieval work. A chat model is the wrong tool for this: you need a model trained for embeddings, such as bge-m3, and llama-server must be told to run in embedding mode. The server README documents --embedding, --embeddings as restricting the server to only support the embedding use case, to be used only with dedicated embedding models.
Related guide: How to Get Embeddings from the Ollama API
Start a dedicated embedding server
llama-server -m bge-m3-Q8_0.gguf --embedding --pooling mean -c 8192 --port 8081
Use a separate port from your chat server: llama-server serves a single model per process, so the chat model and the embedding model are two processes. The README also documents --pooling for how the token vectors are combined — mean, cls, last or rank — and says to use the model default if unspecified; check the embedding model’s own documentation for which pooling it expects.
Call the embeddings endpoint
curl http://localhost:8081/v1/embeddings -H "Content-Type: application/json" -d '{"model": "bge-m3", "input": "The lighthouse keeper trims the lamp."}'
The reply contains an embedding array of numbers. The README says the OpenAI-compatible endpoint normalizes embeddings with the Euclidean norm, and that it requires a pooling type other than none. Compare two texts you know are similar and two you know are unrelated: the similar pair’s vectors should be closer. The exact dimension count depends on the model — bge-m3 produces 1024 dimensions in the linked test — so read the length of the array your model returns rather than assuming it.
Expected result. We checked the llama.cpp server README for the –embedding flag, the –pooling option and the embeddings endpoints, and the linked test for the bge-m3 example and the one-model-per-process rule. We did not run this software ourselves for this guide, so no output here is a recorded result; steps marked UNTESTED were checked against the sources below, not run.
Limits
An embedding model cannot generate text, and a chat model run with –embedding will produce poor vectors — use a dedicated embedding model. Embeddings are not a search engine by themselves: you still need to store the vectors and compare them. We did not run llama-server, so no vector here is a recorded result.
Sources
- llama.cpp server README — –embedding/–embeddings: restrict to only support embedding use case, use only with dedicated embedding models, default disabled; –pooling types for embeddings; POST /embedding and POST /v1/embeddings endpoints
- llama-server test — embedding model bge-m3 in Q8_0, 1024 dimensions, served as a second llama-server process because the server serves a single model per process
Checked 2026-11-28.
