The recording
You were last reading slide 1.
LLM embeddings and reranking
Information Retrieval for AI
Session 7
28 September 2026
Seong Joon Oh - KAIST AI
Calendar: key weeks
Classes: 09:00–10:00 KST · Each row is one week
| Monday | Wednesday |
|---|---|
| 28 September LLM embeddings and reranking · today | 30 September BEIR discussion · graded Preparation note due Tue 29 Sep, 18:00 · graded Check your group and assigned role · Read the discussion procedure |
| 5 October No class · substitute holiday | 7 October Lecture |
| 12 October Lecture | 14 October Project: guided modification · 2 marks Required project work fits within class. |
| ⋮ | ⋮ |
| 9 November Lecture | 11 November Project: your own experiment · 3 marks After lecturer demonstrations. Further revisions after November are optional. |
| ⋮ | ⋮ |
| 7 December Lecture | 9 December Discussion, 09:00–10:00 Final code + report freeze: 23:59 KST · 20 marks Unchanged November work counts as your final submission. |
| 14 December Lecture | 16 December Project: lecturer-led highlights + held-out comparisons |
Individual paper-search project: 25% of the course (25 marks).
Today
- LLM embeddings: how Qwen3, Gemini and LLM2Vec turn text into vectors.
- A short bridge: retrieve candidates, then spend more computation on ranking.
- Language models as rerankers: judge one passage, compare two, or order a list.
- Compare the approaches: class rankings, reasoning before judgement, and computational cost.
Reminder: coarse retrieval with a bi-encoder
Before any query: passage → encoder → passage vector
At query time: query → encoder → query vector
score every stored vector: dot product or cosine
keep the top K candidates → reranker → final ranking
The passage encoder never sees the query, so its vectors can be computed once and stored.
Pooling turns token representations into one text vector. Contrastive training teaches the encoder to score matching pairs above non-matching pairs.
Today: How can we turn a language model into an encoder for retrieval?
Sources: Session 6 deck.
From a language model to an embedding model
Qwen3 Embedding, LLM2Vec and Gemini Embedding, read as choices inside the bi-encoder.
How do we turn a language model into this retriever?
We still need the components just described:
- Token representations that use context from the text.
- A rule that produces one vector per query or passage.
- Training pairs and a loss that reward the retrieval task.
- A matching score for the stored document vectors.
Qwen3 Embedding, LLM2Vec and Gemini Embedding make different choices for these components. Three questions separate them:
- How do we get one vector?
- What does the query encoder read?
- How is the encoder trained, and on which data?
Sources: Qwen3 Embedding technical report (2025), LLM2Vec (COLM 2024), Gemini Embedding technical report (2025); Qwen3 section 2; LLM2Vec section 2; Gemini section 3.
Architecture: obtaining a single vector
From BERT to a decoder-only LLM
Sources: BERT, §3; Hugging Face, transformer architectures. Filled cells = allowed attention. Toy examples use words as tokens.
Qwen3 takes the vector at the end of the text
The query includes a task instruction; the document does not. Source: Qwen3 Embedding technical report (2025), §2.
LLM2Vec: from decoder to text encoder
Adapted from LLM2Vec (COLM 2024), Figure 1 and §2.1. The contrastive step uses independently sampled dropout masks and mean pooling.
Gemini pools token vectors, then projects
Source: Gemini Embedding technical report (2025), §3.1. Schematic: words represent tokens; vector bars do not show actual dimensions or values.
What the query encoder reads
Retrieval input pattern
Qwen3 Embedding, Gemini Embedding and LLM2Vec all use task information on the query side for query–passage retrieval.
| Query encoder receives | Passage encoder receives |
|---|---|
| Task instruction + query | Passage text |
| Find a passage that answers this question. What does the red battery indicator mean? | A red battery indicator means the battery is low. |
Sources: Qwen3 Embedding model card; Gemini Embedding, §3.2, equation 1; LLM2Vec inference and input conventions.
Why does the instruction matter?
For the same query, the instruction changes the focus of retrieval. Example: What does the red battery indicator mean?
| Query-side instruction | Desired match | Example passage |
|---|---|---|
| Find a passage that answers this question. | An answer | A red battery indicator means the battery is low. |
| Find text with the same meaning as this question. | A paraphrase | What does it mean when the battery light is red? |
Separate case: symmetric similarity tasks
LLM2Vec uses instructions on both texts for symmetric tasks such as semantic textual similarity. That evaluation setup differs from query–passage retrieval, where the instruction is on the query side.
Constructed query, instructions and passages. Source for the symmetric-task convention: LLM2Vec input conventions.
Training: objectives and data
Qwen3, Gemini and LLM2Vec
Compare the loss, the training examples and how those examples are obtained.
Training objectives
All three learn contrastively: pull matches closer; push non-matches apart.
| Qwen3 Embedding | Gemini Embedding | LLM2Vec | |
|---|---|---|---|
| Embedding loss | InfoNCE-based | InfoNCE-style NCE | SimCSE; optional supervised contrastive loss |
| Across stages | Same loss in stages 1 and 2; data changes | Add a hard-negative term in fine-tuning | Token prediction first; then embedding contrastive loss |
| Positive pairs | Generated or labelled pairs | Title–passage, then task-specific pairs | Same sentence with different dropout; labelled pairs if supervised |
| Negatives | In-batch + hard; also query–query and passage–passage | In-batch + hard; query–passage only | Other sentences in batch; supervised version adds hard negatives |
| Hard-negative source | Mining recipe unspecified | Retrieve candidates; Gemini scores them | Supplied public dataset, in supervised training |
Sources: Qwen3, §3 · Gemini, §§3–4 · LLM2Vec, §§2, 5 · LLM2Vec loss code.
Training data and algorithm
All three start from pretrained language models. Their data and training stages differ.
| Qwen3 Embedding | Gemini Embedding | LLM2Vec | |
|---|---|---|---|
| Training stages | Synthetic pairs → curated pairs | Web pairs → task-specific training | Masked token prediction → contrastive training; optional supervision |
| Initial data | ~150M synthetic pairs | Billion-scale web corpus; title–passage pairs | Wikitext-103 + Wikipedia sentences |
| Later data | ~7M labelled + 12M selected synthetic pairs | Academic + synthetic data; multilingual and code tasks | Optional ~1.5M public E5-style examples |
| Role of an LLM | Qwen3-32B generates pairs | Gemini generates examples, filters labels and selects hard negatives | No LLM-generated data stage reported |
| Teacher-matching loss? | None reported | None reported; teacher judgements shape the data | None reported |
Sources: Qwen3, §3 and Table 6 · Gemini, §§3–4 · LLM2Vec, §§2, 5 and Appendix G.
Is this the state of the art?
Each paper was first, once
| Paper | Claim | Scope | Date |
|---|---|---|---|
| LLM2Vec | best MTEB score | models trained only on public data | 24 May 2024 |
| Gemini Embedding | first, task mean 68.32 | MTEB (Multilingual) | March 2025 |
| Qwen3-Embedding-8B | 70.58 | MTEB (Multilingual) | June 2025 |
Each claim carries a scope and a date. LLM2Vec’s is restricted to public training data. Qwen3’s own table lists Gemini at 68.37, not 68.32; the leaderboard’s version of a number can differ from the paper’s.
MTEB averages many task types: classification, clustering, STS, retrieval and more. A top mean does not say the model retrieves best.
Sources: LLM2Vec (COLM 2024), Gemini Embedding technical report (2025), Qwen3 Embedding technical report (2025); LLM2Vec section 5 and conclusion; Gemini section 1 and Table 1; Qwen3 abstract and Table 2.
What is state of the art in September 2026?
For text embedding retrieval: Voyage 4 Large leads the displayed RTEB ranking.
| RTEB rank (Borda) | Exact model / configuration | What this tells us |
|---|---|---|
| 1 | Voyage 4 Large · 2,048 dimensions · evolved_prompts=True | Leading listed configuration; proprietary API |
| 2 | NVIDIA Nemotron-3-Embed-8B-BF16 | Highest-ranked open-weight entry |
| 3 | Octen-Embedding-8B | Another leading listed retriever |
Snapshot: 27 September 2026 · RTEB Multilingual · Borda aggregates per-task rankings; this is a leaderboard snapshot, not a new evaluation. Coverage differs between entries; task-average scores are missing for these rows. The leaderboard also flags some results as potentially non-zero-shot.
embedding / sparse→Rerank candidates
score query + passage together→Final results
Sources: Live RTEB Multilingual leaderboard · MTEB model configurations · Nemotron model card. Next: how language models rerank retrieved candidates.
Nemotron turns an LLM into a retrieval encoder
Nemotron-3-Embed-8B - NVIDIA
- Architecture: Ministral-3-8B-Instruct with bidirectional attention. Average the token vectors, then L2-normalise to obtain one 4,096-dimensional vector per text.
- Training data: 50M+ samples from public question-passage datasets and LLM-generated queries and question-answer pairs.
- Retrieval: encode
query: ...andpassage: ...separately. Precompute passage vectors; rank by cosine similarity at query time. - Scope: inputs up to 32,768 tokens; evaluated across 34 languages. Shorter vector prefixes, such as 1,024 dimensions, can be used after renormalisation.
Source: NVIDIA model card, architecture, outputs and training data (accessed 28 September 2026). BF16 denotes the checkpoint's numerical precision.
Voyage 4 shares a space across model sizes
- Architecture: Voyage 4 Large uses a mixture of experts (MoE). The Large, 4, Lite and Nano models produce compatible embeddings.
- Asymmetric retrieval: embed documents with Large, then queries with Lite or Nano. Change the query model without rebuilding the document index.
- Storage: Matryoshka training supports shorter embedding prefixes; quantisation reduces the bits stored per coordinate.
What about the data? The launch post describes evaluation across retrieval domains, but does not disclose the training corpus, pair construction or negative-selection recipe. Evaluation datasets are not a description of training data.
Source: Voyage AI, The Voyage 4 model family, 15 January 2026. Architecture and capabilities are the provider's report.
Octen makes data a central design choice
Reported method: LoRA adaptation of Qwen3; train domain models, then combine their weights.
- Construct relevant pairs: synthesise queries from legal, finance, healthcare and code sources. Vary query wording, intent and noise.
- Use the positive labels: retain multiple relevant documents per query and multiple queries per document.
- Choose informative negatives: mine similar but irrelevant documents; filter false negatives so relevant passages are not pushed apart.
The lesson: training examples define which relationships the encoder learns. Corpus coverage, query realism and label quality deserve as much scrutiny as architecture. Nemotron also combines public pairs with synthetic supervision.
Illustrative example: for “Python exception handling”, another relevant tutorial is a positive, not a negative merely because it comes from a different document.
Sources: Octen Team, training pipeline, 13 January 2026, sections 2.1-2.4; Nemotron model card. Octen describes several changes together; this post does not isolate their individual gains in an ablation.
Reranking
Where reranking spends computation
| Approach | Precomputed | Work per query | Examples |
|---|---|---|---|
| One vector per passage | passage vectors | one dot product per candidate | Qwen3 Embedding, Gemini Embedding |
| One vector per token | token vectors | MaxSim over token pairs | ColBERT |
| One joint pass per pair | nothing | one model forward pass per candidate | BERT reranker, Qwen3 reranker |
| One generation per candidate, pair or list | nothing | generated tokens per call | RankGPT, pairwise prompting, Rank1 |
Sources: Khattab and Zaharia, ColBERT (SIGIR 2020), Nogueira and Cho, passage re-ranking with BERT (2019), Qwen3 Embedding technical report (2025), Sun et al., RankGPT (EMNLP 2023), Qin et al., pairwise ranking prompting (Findings of NAACL 2024), Weller et al., Rank1 (COLM 2025).
ColBERT: match query tokens to passage tokens
Encode the query and passage separately, keeping one vector per token. Add each query token’s best match.
Query red battery light. Passage the indicator glows red when the battery is low, content words only.
| query token | indicator | glows | red | battery | low | max |
|---|---|---|---|---|---|---|
| battery | 0.2 | 0.1 | 0.1 | 0.9 | 0.5 | 0.9 |
| light | 0.6 | 0.7 | 0.3 | 0.2 | 0.1 | 0.7 |
| red | 0.2 | 0.3 | 0.9 | 0.1 | 0.1 | 0.9 |
light has no exact match in the passage. It takes its best partner, glows.
Constructed dot products; no checkpoint produced this matrix.
Sources: Khattab and Zaharia, ColBERT (SIGIR 2020); equation 3.
Read the query and passage together
Query + passage → BERT → relevance score → reorder candidates
| ColBERT | BERT reranker | |
|---|---|---|
| How they meet | Match token vectors after encoding | Read both texts together |
| What can be computed before query? | Passage token vectors | None |
| How to rank | Add each query token’s best match | Predict relevance; sort by score |
Train BERT on relevant and non-relevant query–passage pairs. This is the cross-encoder from the earlier lecture.
Sources: ColBERT, §3 · Nogueira & Cho, BERT passage reranking, §2.
Language models as rerankers
Three ways to ask a language model to rank
| Ask about… | Example instruction | Turn the answer into a ranking | Main trade-off |
|---|---|---|---|
| One passage (pointwise) | “Does this passage answer the query?” | Score each passage; sort the scores | Independent calls can run in parallel |
| Two passages (pairwise) | “Which passage is more relevant, A or B?” | Combine wins or use comparisons to sort | More comparisons; check both input orders |
| A list (listwise) | “Order these passages by relevance.” | Read the returned order | More text per call; long lists need windows |
Sources: Qwen3 Embedding technical report (2025), Qin et al., pairwise ranking prompting (Findings of NAACL 2024), Sun et al., RankGPT (EMNLP 2023).
Pointwise: the Qwen3 reranker
system: Judge whether the Document meets the requirements based on the Query
and the Instruct provided. Note that the answer can only be "yes" or "no".
user: <Instruct>: {Instruction}
<Query>: {Query}
<Document>: {Document}
Use the model’s next-token scores for yes and no to obtain a relevance score:
Sources: Qwen3 Embedding technical report (2025); section 2 and Table 1; the report writes the exponent as P(yes | I, q, d).

Listwise: RankGPT’s sliding window
The prompt lists passages [1] to [w] and asks for an order such as [2] > [3] > [1] > ....
The models RankGPT used had limited context windows, so it slides:
candidates 1 ... 100, w = 20, s = 10
call 1: rerank 81-100
call 2: rerank 71-90
...
call 9: rerank 1-20
Each window overlaps the previous one by
The experiments use
Sources: Sun et al., RankGPT (EMNLP 2023); sections 3.1 and 3.2, Figure 3, section 5.1.
Pairwise: ask twice, in both orders
Given a query "{q}", which of the following two passages is more relevant to the query?
Passage A: "{d1}"
Passage B: "{d2}"
Output Passage A or Passage B:
Position bias: the model may favour the passage shown first. Pairwise ranking prompting (PRP) therefore asks in both orders:
If both answers favour the same passage, it wins. If swapping the order changes the preferred passage, count a tie.
- All pairs: each passage gets 1 point per win and 0.5 per tie.
calls, all parallel. - Sorting: heapsort with the pairwise judgement as its comparison.
calls.
The paper notes the swap is hard to apply to a listwise prompt because of its combinatorial nature: a window of
Sources: Qin et al., pairwise ranking prompting (Findings of NAACL 2024); sections 3.1-3.3, equation 2.
Change the instruction, change the ranking
Keep the query and passages fixed. Rewrite the instruction so the AI produces the target ranking.
Fixed query: Why is my laptop battery draining quickly?
| Passage | Text (fixed) |
|---|---|
| P | Rapid battery drain can result from background applications using the processor, a bright display, or power-hungry peripherals. These increase the laptop’s power consumption even when you are doing little. |
| Q | For longer battery life right now, lower the display brightness, enable battery saver, close unused applications, and disconnect peripherals. These are quick, reversible changes that need no new hardware. |
| R | If quick adjustments do not help, check the battery-health report and compare its full-charge capacity with its design capacity. A badly worn battery may need replacement; consider repair only after checking its condition. |
| S | Lithium-ion batteries lose capacity as they age because chemical reactions gradually reduce the amount of charge they can store. An older battery can therefore run for fewer hours even under the same workload. |
Starting instruction
Rank passages for a reader seeking an explanation of why the battery drains quickly. Prioritize direct explanations of power consumption, then explanations of battery ageing, ahead of troubleshooting steps or repair advice.
Observed ranking: P → S → Q → R
Saved AI run · claude-sonnet-5 · 2026-09-27. Live reruns may vary.Your target ranking
Q → R → P → S
Change the instruction to produce this order. Describe what makes a passage relevant; do not name passage letters or dictate an output order.
One chance only. You have one AI attempt. After you submit, your name and score will appear on the class leaderboard. Review your instruction carefully: you cannot retry, and a failed AI call still uses your attempt.
Sign in with your course account to run the AI. 1 attempt per student, separate from chat.
The live reranker uses the same model as course chat. It receives only your instruction, the query and the passages—not the target order. Instructions and results are saved to your course account.
Class leaderboard
Sign in to see the leaderboard.
Exercise: the class as a reranker
Query: How do vaccines train the immune system?
| Passage | Text |
|---|---|
| P | Many vaccines must be stored in a refrigerator at 2 to 8 degrees Celsius. |
| Q | After vaccination, memory B and T cells remain in the body and respond faster if the same pathogen appears later. |
| R | Edward Jenner tested the first smallpox vaccine in 1796. |
| S | A vaccine exposes the immune system to a harmless piece or a weakened form of a pathogen, so the body makes antibodies and memory cells before a real infection. |
You will receive one of two tasks. Answer independently; we will compare the groups after everyone has responded.
For this exercise, judge each pair once and choose a winner. We compare the resulting rankings; this is not a test of position bias.
Sign in with your course account to join this exercise.
Four constructed passages. Group assignments remain fixed on refresh. The lecturer reveals the class comparison when responses close.
Rank1: reason, then judge
Rank1 is pointwise. For each query-passage pair it generates a reasoning chain, then true or false:
<think> The user is asking ... </think> true
- R1 generated 635,264 traces on MS MARCO queries and passages.
- Filtering left 386,336: traces that disagreed with the labels were removed, then a first model filtered noisy negatives.
- Smaller models were fine-tuned on these traces.
The reasoning chain costs generated tokens for every candidate. It can also be shown to a user or to a RAG system.
Sources: Weller et al., Rank1 (COLM 2025); abstract, sections 1, 2.1 and 2.2.
What reranking costs
Candidate depth, computation and latency
For a reranker that scores candidates one at a time, at roughly constant cost:
- Candidate coverage: increasing
cannot decrease first-stage recall, but it may leave it unchanged. Reranking cannot recover a passage missing from the candidate list. - Pairwise and listwise methods: cost depends on the number of comparisons or windows, and the text processed per call. RankGPT’s overlapping windows depend on earlier results, limiting parallelism.
Retrieve candidates cheaply, then use the language model to judge relevance within the available compute budget.
Sources: Qin et al., pairwise ranking prompting (Findings of NAACL 2024), Sun et al., RankGPT (EMNLP 2023).
Conclusion: retrieve broadly, rank carefully
Query + instruction → retrieve candidates → rerank → top passages
| What to remember | Why it matters |
|---|---|
| LLMs can become embedding models. | Attention, pooling and training determine how text becomes a retrieval vector. |
| The instruction defines the relevance criteria. | The same query and passages can call for a different ranking. |
| A language model can judge one, compare two, or order a list. | The choice changes how judgments become a ranking—and how much computation is needed. |
| Reranking works within the candidate set. | Retrieve enough relevant passages, then spend the available budget on better ordering. |
Evaluate the whole pipeline on your task: relevance, candidate coverage and latency.