Vì sao reranker sửa được kết quả đầu của RAG?
Reranking: cross-encoder xếp lại các chunk đứng đầu của bộ tìm kiếm · Thực hành · 5 phút · rag, embeddings · học sau Chunking: kích thước chunk, phần chồng lấn và chỗ cắt trong RAG
Reranker là mô hình thứ hai đọc câu hỏi cùng với từng chunk tìm được và chấm xem chunk đó trả lời câu hỏi tốt đến đâu. Nó xếp lại vài kết quả đầu của bộ tìm kiếm, nhưng không tìm được chunk mà bộ tìm kiếm đã bỏ sót.
1 Đoán trước
2 Xem
Search, then rerank
1 / 3ask:“What is the daily limit if I don’t pay?” (answer: 1,000)
1 · search: top 3 by cosine (question and chunk embedded apart)
- A✗ Every account starts on the Free plan. The Pro plan costs $20 a month, billed in advance. It allows 50,0000.40
- C✓ address and your API key appears at once. It allows 1,000 requests per day. Requests over the daily limit return0.39
- B✗ requests per day, and support answers within four hours. The Free plan needs no card: sign up with an email0.37
2 · reranker: reads the question and each chunk together
- C✓ address and your API key appears at once. It allows 1,000 requests per day. Requests over the daily limit return-6.4
- B✗ requests per day, and support answers within four hours. The Free plan needs no card: sign up with an email-10.2
- A✗ Every account starts on the Free plan. The Pro plan costs $20 a month, billed in advance. It allows 50,000-10.8
Search alone returns A ✗ · after the reranker: C ✓, which holds the answer
search: all-MiniLM-L6-v2, cosine · reranker: ms-marco-MiniLM-L6-v2, relevance score · measured 2026-10-23
The search ranks the Pro chunk first. The reranker reads each of the top 3 with the question and lifts C, the one with 1,000.
Bộ tìm kiếm chọn danh sách ngắn theo độ nghe giống; reranker đọc từng mẩu cùng câu hỏi và xếp lại danh sách đó, nhưng chỉ danh sách đó.
Bộ tìm kiếm so hai embedding làm riêng rẽ: của chunk, làm một lần lúc lập chỉ mục, và của câu hỏi. Đủ nhanh cho hàng triệu chunk. Reranker (mô hình chấm điểm từng cặp câu hỏi–chunk) đọc cả hai đoạn trong một lượt, nên mỗi chữ của câu hỏi gặp mỗi chữ của chunk. Chính xác hơn, nhưng chạy một lần cho mỗi cặp, nên nó chỉ xem vài mẩu đầu.
4 Bạn là model
Bạn là reranker. Với bốn câu hỏi, đọc top 3 chunk của bộ tìm kiếm và chọn chunk mà ms-marco-MiniLM-L6-v2 chấm điểm cao nhất.
you are the reranker · read the question and the search’s top 3, pick the chunk ms-marco-MiniLM-L6-v2 puts first
“What is the daily limit if I don’t pay?”
search: all-MiniLM-L6-v2, cosine · reranker: ms-marco-MiniLM-L6-v2, relevance score · measured 2026-10-23
You are the reranker. Which chunk answers the question?5 Kiểm tra
Vài thói quen giúp ích. Lấy rộng, rerank, giữ ít: lấy top 20 đến 100 chunk, rerank, dán 3 đến 5 chunk tốt nhất. Reranker không khôi phục được ngữ cảnh mà chỗ cắt đã làm mất, nên sửa chunking trước. Nó cũng có thể sai: ở đây nó đẩy chunk có 50,000 của gói Pro xuống dưới hai chunk không có. Hãy thử bằng câu hỏi thật.
7 Nói lại bằng lời bạn
8 Nhiệm vụ · 5 phút
Chép key miễn phí trên trang của Jina (không cần thẻ) và POST tới https://api.jina.ai/v1/rerank với model "jina-reranker-v3.5", query “How many requests per day does the free plan allow?” và hai chunk B, C làm documents (B: “requests per day, and support answers within four hours. The Free plan needs no card: sign up with an email”; C: “address and your API key appears at once. It allows 1,000 requests per day. Requests over the daily limit return”). Reranker lớn hơn có vẫn chọn B không?
Ba câu nhanh
Rút ngẫu nhiên từ bộ câu hỏi của bài; lần sau sẽ khác.
Xong chưa?
Nhận email khi có bài mới
Bài mới nằm trong bản tin hằng tuần, chỉ gửi vào tuần có bài. Bạn xác nhận qua email trước; hủy đăng ký chỉ với một lần bấm.
Đọc thêm
Nguồn
- Reranker scores: raw relevance logits of cross-encoder/ms-marco-MiniLM-L6-v2 (https://huggingface.co/cross-encoder/ms-marco-MiniLM-L6-v2: BERT, 6 layers, 384 wide, trained on MS MARCO; default activation Identity) on 2026-10-23 by scripts/explain-data/reranking.ts, a plain TS forward pass (pooler + classifier on the shared BERT encoder of scripts/explain-data/semantic-search.ts) that reproduces the model card example 8.607138, -4.320078
- Search scores: cosine similarities with sentence-transformers/all-MiniLM-L6-v2, same script and date; the free-plan scores equal the chunking lesson’s (0.753, 0.637, 0.572)
- The page and its five 20-word chunks are the chunking lesson’s (app/components/explain/lessons/chunking-data.ts); the questions are in app/components/explain/lessons/reranking-data.ts
- Scores used (search cosine → reranker logit, chunks A–E): “don’t pay” A 0.404 → −10.76, B 0.373 → −10.22, C 0.387 → −6.43; carry over C 0.497 → −4.22, B 0.452 → −5.07, D 0.397 → −0.59; error C 0.321 → −9.46, D 0.293 → −7.09; free plan B 0.753 → 7.03, C 0.637 → 4.55, A 0.572 → −1.93; Pro plan A 0.613 → −0.56, C 0.596 → 4.14, B 0.594 → 3.77; cut by paragraph (the chunking lesson’s fix), free plan: the Free paragraph is first for both, cosine 0.780 and reranker 9.46 (next: Pro paragraph 4.33)
- https://sbert.net/examples/cross_encoder/applications/README.html (checked 2026-10-23): “A Cross-Encoder does not produce a sentence embedding”; retrieve e.g. the top 100 with a bi-encoder, then re-rank them with a cross-encoder
- https://jina.ai/reranker/ (checked 2026-10-23): endpoint https://api.jina.ai/v1/rerank (model, query, documents, top_n); recommended text model jina-reranker-v3.5; “New users get an auto-generated API key with free tokens usable across any of our models”; aifree.dev catalog jina-ai-free-api-tokens (verified 2026-10-12): 10M tokens per new API key, no card
Đăng Oct 23, 2026 · cập nhật Oct 23, 2026