Skip to main content
Turn text into vectors for semantic search, similarity, and RAG with the EmbeddingAgent.
EmbeddingAgent converts text into numerical vectors for semantic search, similarity matching, and RAG applications.

How It Works


Quick Start

1

Install

2

Create Agent

3

Generate Embedding


Methods

Generate embedding for a single text.
str
required
Text to embed
str
Override model for this call
List[float]
Embedding vector
Generate embeddings for multiple texts efficiently.
List[str]
required
List of texts to embed
Batch embedding is more efficient than calling embed() multiple times.
Calculate cosine similarity between two texts.
str
required
First text
str
required
Second text
float
Cosine similarity score (0.0 to 1.0)
Find most similar texts to a query.
str
required
Query text
List[str]
required
List of candidate texts
int
default:"5"
Number of results to return

Configuration

EmbeddingConfig Parameters


Supported Models

OpenAI

  • text-embedding-3-small (default)
  • text-embedding-3-large
  • text-embedding-ada-002

Cohere

  • cohere/embed-english-v3.0
  • cohere/embed-multilingual-v3.0

Voyage

  • voyage/voyage-3
  • voyage/voyage-3-lite

Mistral

  • mistral/mistral-embed

Examples

Document Similarity Matrix

RAG Retrieval

Async Usage


Use Cases

Semantic Search

Find documents by meaning, not keywords

RAG

Retrieve relevant context for LLM prompts

Clustering

Group similar documents together

Deduplication

Find and remove duplicate content

Best Practices

Use the batch method over a loop of single embed() calls. One batched request is far cheaper and faster than many round trips for large corpora.
Vectors from different models aren’t comparable. Embed queries and documents with the same model, or similarity scores become meaningless.
Normalise vectors when your similarity metric assumes unit length. Skipping this skews rankings, especially across texts of very different lengths.
The agent produces vectors; a vector database stores and searches them. Combine the two to build retrieval-augmented generation pipelines.
Rewrite queries for better retrieval in RAG pipelines.
Synthesise multiple sources into a report.