embeddingollama

what is the right way to generate ollama embeddings?


In the embedding models documentation, the suggested way to generated embeddings is

ollama.embeddings({
    model: 'mxbai-embed-large',
    prompt: 'Llamas are members of the camelid family',
})

but I don't see the above syntax anywhere in the ollama-js documentation. Where is ollama.embeddings() documented? What is the canonical way to generate ollama embeddings, especially with multiple inputs?

Additionally, the ollama-js documentation says: "The Ollama JavaScript library's API is designed around the Ollama REST API".

But the REST API uses { model: …, input: … } as input while the example provided above uses { model: …, prompt: … } as input (prompt instead of input). Why this confusing inconsistency?


Solution

  • diving into the source code, it seems that ollama.embed() has superseded ollama.embeddings(). Time for ollama to update its webpages.

    Update: turns out I was correct