A cross-encoder rerank API: hand it your query plus candidate chunks and it reorders them by true relevance. The precision step after cheap retrieval.
What it is
Cohere Rerank is a cross-encoder scoring API. Where retrieval compares a query and a chunk through their separate embeddings, a cross-encoder reads the query and each candidate together and scores true relevance, which is far more accurate but too expensive to run over a whole corpus. So you retrieve wide and cheap first, then rerank the shortlist. It runs on top of any vector database and any embedding model.
The one job
Given a query and a pile of loosely-relevant candidates, return them reordered by how well each actually answers the query, so you can keep only the top few. It is the narrowing step that turns noisy recall into a clean context window.
Reach for it when
Skip it when
A minimal look
// retrieve wide first, then rerank the shortlist for precision
const res = await fetch("https://api.cohere.com/v2/rerank", {
method: "POST",
headers: { Authorization: `Bearer ${apiKey}` },
body: JSON.stringify({ model: "rerank-v3.5", query, documents, top_n: 5 }),
});
const { results } = await res.json();
// results are ordered by relevance: [{ index, relevance_score }, ...]
const top = results.map((r) => documents[r.index]);
The principle it teaches
Retrieve wide, then narrow. Recall and precision are two separate steps: cheap embedding search casts a wide net for recall, and reranking is the narrowing that buys precision. That split is exactly Lab 2's rerank stage.
Where it fits your labs
This is a Week 2 tool. In Lab 2 you retrieve a wide candidate set from pgvector, then rerank it down to the handful of chunks that actually answer the query before they reach the model.