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

# Embeddings: bring your own vectors to Infino

> Bring your own embeddings to Infino. Supply vectors from any model, store them alongside your data, and index them for fast kNN vector search.

Infino is **bring-your-own-embeddings**: it does not call an embedding model for you.
You compute vectors with whatever model you like, store them in a vector column, and
Infino builds the vector index over them.

## The pattern

1. Declare a fixed-width vector column whose dimension matches your model's output.
2. Declare a vector index on it with the **same dimension** and a distance **metric**.
3. Embed your text and append the vectors alongside the rows.

```python Python icon="python" theme={null}
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("all-MiniLM-L6-v2")   # 384-dim
def embed(text): return model.encode(text).tolist()

text = "Refunds return to the original payment method."

# dim (384) must match the model and the index spec:
docs = db.create_table(
    "docs", schema,
    infino.IndexSpec().fts("body").vector("embedding", 384, "cosine"),
)
docs.append([{"doc_id": "1", "body": text, "embedding": embed(text)}])
```

```typescript Node.js icon="node-js" theme={null}
import { pipeline } from "@huggingface/transformers";
const extractor = await pipeline("feature-extraction", "Xenova/all-MiniLM-L6-v2"); // 384-dim
const embed = async (text) => Array.from((await extractor(text, { pooling: "mean", normalize: true })).data);

const text = "Refunds return to the original payment method.";

// dim (384) must match the model and the index spec:
const docs = db.createTable(
  "docs",
  { doc_id: "large_utf8", body: "large_utf8", embedding: { vector: 384 } },
  new IndexSpec().fts("body").vector("embedding", 384, "cosine"),
);
docs.append([{ doc_id: "1", body: text, embedding: await embed(text) }]);
```

```rust Rust icon="rust" theme={null}
use infino::{IndexSpec, Metric};

// Compute embeddings with your model (e.g. via `candle`, `fastembed`, or an HTTP
// service), then append the vectors as an Arrow RecordBatch (see the Quickstart).
// dim (384) must match your model and the index spec:
let spec = IndexSpec::new().fts("body").vector("embedding", 384, Metric::Cosine);
```

> [!NOTE]
>
> Embed your **queries** with the same model at search time, and pass the query vector to
> `vector_search` (see [Search](https://infino.ai/docs/guides/search.md#vector-search)).

## Choosing a metric

Match the index metric to how your embeddings are produced:

| Metric | Use when |
| - | - |
| `cosine` | embeddings are normalized (most sentence-transformer and OpenAI models) |
| `l2sq` | you want squared Euclidean distance |
| `negdot` | you want dot-product similarity over unnormalized vectors |

## See also

* [Indexing](https://infino.ai/docs/guides/indexing.md)
* [Vector search](https://infino.ai/docs/guides/search.md#vector-search)
* [Quickstart](https://infino.ai/docs/quickstart.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.