Skip to main content
Loading navigation
Back to prompt library

Integrate Ollama for Embeddings

Linked challenge: Agent for Enterprise M&A Due Diligence

Prompt source

implementation9 lines4 sectionsNo variables1 code block
Modify your LlamaIndex setup to explicitly use Ollama for generating embeddings (`OllamaEmbedding`). Describe the benefits of this approach (e.g., local control, cost savings). Ensure your `VectorStoreIndex` is built using these embeddings and demonstrate that your agent still performs accurately. Provide the updated configuration snippet.

```python
from llama_index.core import Settings
from llama_index.embeddings.ollama import OllamaEmbedding

# Configure OllamaEmbedding
Settings.embed_model = OllamaEmbedding(model_name="nomic-embed-text", base_url="http://localhost:11434")

# Re-initialize index or ensure existing index uses this setting
# ... (rebuild index if necessary or ensure it loads with new setting)
```