---
title: "Code search on Qdrant Cloud with papr-embed-code"
description: "Run papr-embed-code-1-0.6b in FastEmbed with no PyTorch and search code on Qdrant Cloud: setup, indexing, query instructions and production settings."
url: https://www.papr.ai/blog/papr-embed-code-qdrant
author: "Papr"
published: 2026-11-30
updated: 2026-12-01
---

# Code search on Qdrant Cloud with papr-embed-code

> **In short:** papr-embed-code-1-0.6b is an Apache 2.0 code embedding model with an ONNX build, now merged into Qdrant's FastEmbed. This guide goes from pip install to semantic code search on Qdrant Cloud, and covers the two settings the model needs: last-token pooling and an instruction on queries only.

![Search for 'retry with exponential backoff' finds keepTrying(), code that shares none of those words](https://rcbwlxuma5nuwt7a.public.blob.vercel-storage.com/blog/papr-embed-code-qdrant/cover.png)

papr-embed-code-1-0.6b is a 0.6B embedding model for code retrieval. It is licensed Apache 2.0, returns 1024-dimensional vectors, and is built on Qwen3-Embedding-0.6B. It now ships an ONNX build and is part of [FastEmbed](https://github.com/qdrant/fastembed), Qdrant's embedding library, so it runs without PyTorch and plugs straight into Qdrant. This post goes from `pip install` to semantic code search on a Qdrant Cloud cluster, and covers the two settings this model needs that most embedding models don't.

## Why a code model

Most embedding models are trained on web text. Code search is a different problem: given "retry a promise with exponential backoff", find the twelve lines of TypeScript that do it, even though they share almost no words with the query.

Qdrant tested this independently in [Does a Code-Tuned Embedding Model Pay Off?](https://qdrant.tech/blog/papr-embed-code/). They compared both papr-embed-code sizes with the Qwen3-Embedding models they started from, on code benchmarks we never trained on. Their findings:

- **Better on code it never saw.** Both sizes beat their base model: the 4B by 0.034 nDCG@10 on average, the 0.6B by 0.026.
- **A little worse on prose.** If most of what you search is prose, keep the base model.
- **Compression barely costs anything.** With 1-bit TurboQuant and rescoring, the 4B kept all of its float32 score. Compressed that way, it beat the 0.6B in float32 while using 12x less RAM.

This post covers the 0.6B, which is the one in FastEmbed. If you can afford to embed with the 4B, read their post for how to store it.

On CoIR, the standard code-retrieval benchmark (10 tasks, nDCG@10), papr-embed-code-1-0.6b averages **77.19**. We scored the ONNX build with the same harness:

|  | CoIR-10 mean | CoIR without CosQA and Text2SQL | Apps | CodeFeedback-ST | StackOverflowQA | Size |
| --- | --- | --- | --- | --- | --- | --- |
| PyTorch fp32 (published) | 77.19 | 82.43 | 79.31 | 88.52 | 93.57 | 2.4 GB |
| ONNX fp32 | 76.85 | 82.43 | 79.31 | 88.54 | 93.57 | 2.4 GB |
| ONNX int8 weights | 76.57 | 82.43 | 79.27 | 88.56 | 93.60 | 1.1 GB |

The fp32 export returns the same vectors as PyTorch (cosine 1.0 on every test text, through both onnxruntime and FastEmbed). The lower 10-task mean comes from two tasks, CosQA and SyntheticText2SQL. Their corpora are full of near-duplicate answers, so the score depends on how ties break, which changes with batch size and ordering. On the other eight tasks, all three builds average 82.43. Per-task results, including SciFact, are on the [model card](https://huggingface.co/papr-ai/papr-embed-code-1-0.6b).

The model was trained on CoIR's train splits, which is why the held-out results matter: Qdrant's unseen-code tasks above, and the 4B at #1 on MTEB's RTEB (Code) and CodeRAG leaderboards. Our [writeup](https://paprai.substack.com/p/introducing-papr-embed-schema-native) has the details.

## 1. Install

```bash
pip install "fastembed>=0.9.1" "qdrant-client>=1.15" "onnxruntime>=1.23"
```

The int8 build needs `onnxruntime>=1.23`. The fp32 build doesn't, but the newer version works for both.

## 2. Load the model in FastEmbed

papr-embed-code is merged into FastEmbed and ships in its next release. Until that release is out, register the model once. The check below makes the same code work on both: it skips registration when your FastEmbed already includes the model.

```python
from fastembed import TextEmbedding
from fastembed.common.model_description import ModelSource, PoolingType

MODEL = "papr-ai/papr-embed-code-1-0.6b"

if MODEL not in {m["model"] for m in TextEmbedding.list_supported_models()}:
    TextEmbedding.add_custom_model(
        model=MODEL,
        pooling=PoolingType.LAST_TOKEN,   # not mean, not CLS
        normalization=True,
        sources=ModelSource(hf=MODEL),
        dim=1024,
        model_file="onnx/model.onnx",
        additional_files=["onnx/model.onnx_data"],
    )
embedder = TextEmbedding(model_name=MODEL)
```

Once the release is out, the whole step is `TextEmbedding("papr-ai/papr-embed-code-1-0.6b")`, or `"papr-ai/papr-embed-code-1-0.6b-Q"` for the int8 build. Until then, for int8 use `model_file="onnx/model_quantized.onnx"` and leave out `additional_files`.

**The two settings that matter:**

1. **Last-token pooling.** This is a decoder model, so the embedding is the hidden state of the final token, L2-normalized. If you register the model yourself, set this explicitly: FastEmbed's default for custom models is mean pooling. With mean pooling you still get normal-looking vectors, but they aren't the ones the model was trained and scored on. If your results seem off, check this first.
2. **Instructions on queries, nothing on documents.** Queries take the form `Instruct: {task}\nQuery:{your query}`. Documents are embedded as-is. FastEmbed doesn't add the instruction for you, so prepend it yourself as in step 4.

## 3. Create a collection and index code

```python
import os
from qdrant_client import QdrantClient, models

client = QdrantClient(url=os.environ["QDRANT_URL"], api_key=os.environ["QDRANT_API_KEY"])

client.create_collection(
    "code",
    vectors_config=models.VectorParams(size=1024, distance=models.Distance.COSINE),
)

snippets = [
    "def chunked(xs, n):\n    for i in range(0, len(xs), n):\n        yield xs[i:i + n]",
    "async function retry(fn, tries = 3) { /* exponential backoff */ }",
    "SELECT customer_id, SUM(amount) AS total FROM orders GROUP BY customer_id ORDER BY total DESC LIMIT 10;",
]

client.upsert("code", points=[
    models.PointStruct(id=i, vector=v.tolist(), payload={"code": s})
    for i, (s, v) in enumerate(zip(snippets, embedder.embed(snippets)))   # documents: bare
])
```

Get `QDRANT_URL` and `QDRANT_API_KEY` from a free cluster at [cloud.qdrant.io](https://cloud.qdrant.io). To try it locally first, use `QdrantClient(":memory:")`, which needs no account.

## 4. Search

```python
INSTRUCT = "Instruct: Given a question about coding, retrieval code or passage that can solve user's question\nQuery:"

query = next(embedder.query_embed([INSTRUCT + "split a list into batches of fixed size"]))
hits = client.query_points("code", query=query.tolist(), limit=3).points
for h in hits:
    print(f"{h.score:.3f}", h.payload["code"].splitlines()[0])
```

The top hit is `def chunked(xs, n):`.

Pick the instruction for the kind of search you're running. These are the ones behind the published scores:

| Search | Instruction |
| --- | --- |
| Question → code or answer | `Given a question about coding, retrieval code or passage that can solve user&#39;s question` |
| Problem statement → solution | `Given a question about code problem, retrieval code that can solve user&#39;s problem` |
| Question → SQL | `Given a user&#39;s question, retrieve SQL queries that are appropriate responses to the question` |
| Code → similar code | `Given a piece for code, retrieval semantically similar code` |
| Code → its docstring | `Given a code snippet, retrieve the comment corresponding to that code.` |

All of them are in `task_prompts.json` in the model repo. The typos come from the benchmark's original instructions. We keep them because they're what the model was evaluated with.

## 5. Production notes

- **fp32 or int8.** int8 halves the download and the memory (1.1 GB instead of 2.4 GB). On the eight stable CoIR tasks it scores the same as fp32. It loses 0.24 on SciFact and more on SyntheticText2SQL, the tie-sensitive task above. Don't embed empty strings with it: that was the one input where its vectors drifted noticeably from fp32.
- **Long files.** The model truncates at 8,192 tokens, the length it was trained and scored at, and FastEmbed's CPU path slows down well before that. Chunk source files by function or class.
- **Compress in Qdrant too.** In Qdrant's tests, 1-bit TurboQuant with rescoring at 2x oversampling kept the full score, and raising `hnsw_ef` from 128 to 256 helped more than adding bits.
- **Filter by language.** If you index several languages in one collection, add a language payload filter. In Qdrant's million-snippet test, searching all six languages at once cost 0.005 to 0.007 nDCG@10.
- **Start without BM25.** In Qdrant's tests, fusing BM25 keyword search with dense search made every task worse at equal weight, and at best broke even when down-weighted.

## What's next

papr-embed-code was merged into FastEmbed on November 18 and ships in its next release, at which point step 2 becomes one line. A complete working example is [in the model repo](https://huggingface.co/papr-ai/papr-embed-code-1-0.6b/blob/main/examples/fastembed_qdrant.py). Thanks to Dylan Couzon, Anush Shetty and the Qdrant team for the independent evaluation and for reviewing the integration.

*papr-embed-code-1-0.6b: [Hugging Face](https://huggingface.co/papr-ai/papr-embed-code-1-0.6b) · Apache 2.0 · ONNX fp32 + int8 · [Papr](https://papr.ai)*

## Questions

### Does papr-embed-code need a GPU or PyTorch?

No. The ONNX build runs on CPU through FastEmbed and onnxruntime. The fp32 file is 2.4 GB and the int8 file is 1.1 GB.

### Which should I use, papr-embed-code-1-0.6b or papr-embed-code-1-4b?

The 0.6B is the one in FastEmbed and runs on CPU. The 4B scores higher on code, and Qdrant found that with 1-bit compression it beats the 0.6B at full precision while using 12x less RAM, but embedding with it costs more compute.

### Why are my search results worse than the published scores?

Check pooling first: the model needs last-token pooling, and FastEmbed's default for custom models is mean pooling. Then check that queries carry the instruction prefix and documents don't.

---

Source: [Code search on Qdrant Cloud with papr-embed-code](https://www.papr.ai/blog/papr-embed-code-qdrant) on the Papr Blog. Papr builds context intelligence for AI agents and Papr Work, a desktop app where AI builds and runs small apps for go-to-market teams.
