> ## Documentation Index
> Fetch the complete documentation index at: https://docs.octen.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Text Embedding

<p style={{ fontSize: "0.8rem", opacity: 0.6 }}>For AI agents: <a href="https://docs.octen.ai/capabilities/embedding.md">docs.octen.ai/capabilities/embedding.md</a></p>

Keyword matching misses meaning: "laptop won't start" and "computer fails to boot" share no words but describe the same problem.

Embeddings close that gap by turning text into vectors that capture meaning, so similar content lands close together. This is the foundation of semantic search, and the Embedding API produces these vectors with Octen's embedding models.

For the full list of parameters, see the [Embedding API reference](/api-reference/embedding).

## What are Embeddings

Embeddings are fixed-length vectors of real numbers, produced by an embedding model, that represent content in a high-dimensional space.

They preserve semantic relationships geometrically: inputs with similar meaning map to vectors that sit close together, while unrelated inputs land far apart.

An embedding is a representation, not a retrieval mechanism by itself. It gives unstructured content a standard form that can be indexed and compared for semantic retrieval.

## Why Embedding

* **Semantic search.** Match by meaning, so users can phrase queries naturally instead of guessing keywords.
* **RAG.** Retrieve the most relevant chunks of your own knowledge to ground model responses.
* **Clustering and recommendations.** Group related content and surface similar items by vector proximity.

For images and videos, use [VL Embedding](/capabilities/vl-embedding) instead.

## Why Octen

* **SOTA retrieval quality.** `octen-embedding-8b` and `octen-embedding-4b` rank #1 and #2 on the RTEB text-retrieval benchmark.
* **Flexible model choice.** Pick the model that fits your scenario and cost, from best accuracy to high-volume and low-cost.
* **Retrieval-tuned.** Mark inputs as query or document to apply the right internal prompt, and adjust output dimensions to fit your index.
* **Works with your stack.** Standard float vectors, compatible with all major vector databases; batch input supported.

## Model Choices

| Model                  | Context (tokens) | Max dimension | Best for                  |
| ---------------------- | ---------------- | ------------- | ------------------------- |
| `octen-embedding-8b`   | 32,768           | 4096          | Best accuracy             |
| `octen-embedding-4b`   | 32,768           | 2560          | Most production workloads |
| `octen-embedding-0.6b` | 32,768           | 1024          | High-volume and low-cost  |

## How It Works

1. **Embed your content.** Split large documents into chunks that each carry one coherent idea, then send the chunks in batches. The model encodes each one into a fixed-length vector, and texts with similar meaning land close together in the vector space.
2. **Build a vector index.** Store the vectors in a vector database. Its index structures, such as HNSW or IVF, locate the closest vectors quickly without scanning them all.
3. **Embed queries and retrieve.** Encode each incoming query with the same model, so queries and content share one vector space. Compare the query vector against the index with a similarity metric, such as cosine similarity, and the top matches provide the context for re-ranking or answer generation.

### Compared with other retrieval approaches

Embedding retrieval commonly serves as the semantic recall layer in modern search systems.

| Approach                  | Representation                 | How it retrieves                                                    | Strengths                                                                 | Limitations                                                               |
| :------------------------ | :----------------------------- | :------------------------------------------------------------------ | :------------------------------------------------------------------------ | :------------------------------------------------------------------------ |
| Keyword retrieval         | Tokens                         | Matches query terms with inverted indexes and statistical relevance | Stable, interpretable, strong exact matching                              | Limited semantic understanding                                            |
| Embedding retrieval       | Embeddings                     | Computes semantic similarity between query and content vectors      | Strong semantic recall; handles natural language and multilingual queries | Depends on embedding model quality; weaker for exact matching and filters |
| Hybrid retrieval          | Tokens + embeddings            | Combines keyword matching and semantic similarity                   | Balances precision and semantic recall                                    | Higher system complexity                                                  |
| Generative-only answering | Model-internal representations | Answers directly without retrieving external content                | Natural responses, simple interaction                                     | Prone to hallucinations; no real-time information; no traceable sources   |

## Scenarios

### Index documents

Embed content in batches, marked as documents.

```bash theme={null}
curl -X POST https://api.octen.ai/embedding \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "input": ["Octen is the search infrastructure for AI.", "Embeddings capture semantic meaning."],
    "model": "octen-embedding-4b",
    "input_type": "document"
  }'
```

### Embed the search query

Embed queries with the same model, marked as queries, and compare against your index.

```json theme={null}
{
  "input": ["what powers AI search?"],
  "model": "octen-embedding-4b",
  "input_type": "query"
}
```

### Cluster and recommend

Embed a set of items and compare vector proximity to group similar content or surface related items. The first two items below land close together; the third lands far away.

```json theme={null}
{
  "input": [
    "Wireless noise-cancelling headphones",
    "Bluetooth over-ear headset",
    "Espresso machine with grinder"
  ],
  "model": "octen-embedding-4b"
}
```

### Cut cost and index size

Use a smaller model, or reduce the output dimensions.

```json theme={null}
{
  "input": ["support ticket: cannot reset password"],
  "model": "octen-embedding-0.6b",
  "dimension": 512
}
```

## Next Steps

<Card title="Embedding API Reference" icon="code" href="/api-reference/embedding">
  Full request/response schema.
</Card>
