Skip to content

Embedding

The embedding model in LlamaIndex is responsible for creating numerical representations of text. By default, LlamaIndex will use the text-embedding-ada-002 model from OpenAI.

This can be explicitly updated through Settings.embedModel.

npm i llamaindex @llamaindex/openai
import { OpenAIEmbedding } from "@llamaindex/openai";
import { Settings } from "llamaindex";
Settings.embedModel = new OpenAIEmbedding({
model: "text-embedding-ada-002",
});

For local embeddings, you can use the HuggingFace embedding model.

Ollama provides a way to run embedding models locally or connect to a remote Ollama instance. This is particularly useful when you need to:

  • Run embeddings without relying on external API services
  • Use custom embedding models
  • Connect to a shared Ollama instance in your network

The ENV variable method you will find elsewhere sometimes may not work with the OllamaEmbedding class. Also note, you’ll need to change the host in the Ollama server to 0.0.0.0 to allow connections from other machines.

To use Ollama embeddings with a remote host, you need to specify the host URL in the configuration like this:

import { OllamaEmbedding } from "@llamaindex/ollama";
import { Settings } from "llamaindex";
// Configure Ollama with a remote host
Settings.embedModel = new OllamaEmbedding({
model: "nomic-embed-text",
config: {
host: "http://your-ollama-host:11434"
}
});

Most available embeddings are listed in the sidebar on the left. Additionally the following integrations exist without separate documentation:

Check the LlamaIndexTS Github for the most up to date overview of integrations.

Note for AI agents: this documentation is built for programmatic access. - Overview of all docs: https://developers.llamaindex.ai/llms.txt - Any page is available as raw Markdown by appending index.md to its URL — e.g. https://developers.llamaindex.ai/llamaparse/parse/getting_started/index.md - Agent-friendly REST search APIs live under https://developers.llamaindex.ai/api/ — search (BM25 full-text), grep (regex), read (fetch a page), and list (browse the doc tree). See https://developers.llamaindex.ai/llms.txt for parameters. - A hosted documentation MCP server is available at https://developers.llamaindex.ai/mcp. If you support MCP, you can ask the user to install it for browsing these docs directly (an alternative to the REST API). Setup: https://developers.llamaindex.ai/python/shared/mcp/