[GH-ISSUE #2937] Unable to pass embeddings to the api call #1801

Closed
opened 2026-04-12 11:50:48 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @brobles82 on GitHub (Mar 5, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/2937

Originally assigned to: @bmizerany on GitHub.

Im using this code for generate embeddings

EMBEDDINGS_RESPONSE=$(curl "http://localhost:11434/api/embeddings" -d '{
  "model": "mistral",
  "prompt": "Spiderman is color green"
}')

EMBEDDINGS=$(echo $EMBEDDINGS_RESPONSE | jq '.embedding')

And then when I try to use the embeddings as context for new request

curl  "http://localhost:11434/api/generate" -d "{
  \"model\": \"mistral\",
  \"prompt\": \"Spiderman color\",
  \"context\": $EMBEDDINGS,
  \"stream\": false
}"

I always get null

Originally created by @brobles82 on GitHub (Mar 5, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/2937 Originally assigned to: @bmizerany on GitHub. Im using this code for generate embeddings ``` EMBEDDINGS_RESPONSE=$(curl "http://localhost:11434/api/embeddings" -d '{ "model": "mistral", "prompt": "Spiderman is color green" }') EMBEDDINGS=$(echo $EMBEDDINGS_RESPONSE | jq '.embedding') ``` And then when I try to use the embeddings as context for new request ``` curl "http://localhost:11434/api/generate" -d "{ \"model\": \"mistral\", \"prompt\": \"Spiderman color\", \"context\": $EMBEDDINGS, \"stream\": false }" ``` I always get null
Author
Owner

@mxyng commented on GitHub (Mar 6, 2024):

There's a misunderstanding here. context is intended not for embedding outputs. It's intended for the token output of previous conversations so as to continue the previous response

<!-- gh-comment-id:1981923589 --> @mxyng commented on GitHub (Mar 6, 2024): There's a misunderstanding here. `context` is intended not for embedding outputs. It's intended for the token output of previous conversations so as to continue the previous response
Author
Owner

@jmorganca commented on GitHub (Mar 7, 2024):

Yes embeddings are not the same as the context variable returned by /api/generate (which is basically full list of tokens so far). Embeddings are designed for text similarity search. Feel free to ask more questions on what you're trying to do - happy to help!

<!-- gh-comment-id:1982767061 --> @jmorganca commented on GitHub (Mar 7, 2024): Yes embeddings are not the same as the `context` variable returned by `/api/generate` (which is basically full list of tokens so far). Embeddings are designed for text similarity search. Feel free to ask more questions on what you're trying to do - happy to help!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#1801