0Pricing
Vector Databases: Pinecone, Weaviate & pgvector · บทเรียน

จัดลำดับผลลัพธ์ที่ดึงมาใหม่

เพิ่มความแม่นยำของ RAG ด้วยการจัดลำดับผู้สมัครจากการค้นหาเวกเตอร์เบื้องต้นใหม่ด้วยโมเดลตัวเข้ารหัสไขว้ ก่อนส่งบริบทไปยัง LLM

จัดลำดับผลลัพธ์ที่ดึงมาใหม่ เป็นบทเรียน Vector Databases: Pinecone, Weaviate & pgvector ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Vector Databases: Pinecone, Weaviate & pgvector และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Vector Databases: Pinecone, Weaviate & pgvector มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

The Reranking Idea

Vector search is fast but approximate. Reranking takes the top candidates and reorders them with a more accurate, slower model — the two-stage retrieve-then-rerank pattern.

Bi-Encoder vs Cross-Encoder

Bi-encoders embed query and document separately (fast, used for retrieval). Cross-encoders score query+document together (slow, far more accurate) — ideal for reranking a small set.

Two-Stage Pipeline

Step 1: retrieve top 50 with the vector DB. Step 2: rerank those 50, keep the top 5. You get cross-encoder quality at near vector-search speed.

candidates = vector_db.search(query, k=50)
ranked = reranker.rank(query, candidates)
top = ranked[:5]

Using a Cross-Encoder

A cross-encoder takes pairs and outputs a relevance score. Higher means more relevant.

from sentence_transformers import CrossEncoder
model = CrossEncoder('cross-encoder/ms-marco-MiniLM-L-6-v2')
scores = model.predict([(query, doc) for doc in candidates])

Sorting by Score

Pair each document with its score and sort descending to produce the final order.

ranked = sorted(zip(candidates, scores), key=lambda x: x[1], reverse=True)
for doc, score in ranked[:5]:
    print(round(score, 3), doc[:40])

Hosted Reranking APIs

Services like Cohere Rerank and Jina offer hosted rerankers via API, removing the need to self-host a model.

POST /v1/rerank
{ "query": "...", "documents": [...], "top_n": 5 }

Choosing Candidate Count

Retrieve enough candidates that the true best answer is in the set (high recall), but not so many that reranking gets slow. 20-100 is typical.

Latency Trade-offs

Reranking adds latency proportional to candidate count. Cache results, batch the cross-encoder calls, and tune the candidate count to your SLA.

Reranking + Filters

Apply metadata filters during retrieval, then rerank only the filtered set. This keeps the reranker focused on valid candidates.

Measuring the Gain

Compare nDCG or hit rate with and without reranking on a labeled set. Reranking commonly delivers a large accuracy boost on noisy corpora.

When to Skip It

If your corpus is small and clean, or latency is critical, plain vector search may suffice. Reranking pays off most on large, diverse datasets.

Quick Check

Test your reranking knowledge.

Recap

You learned the retrieve-then-rerank pattern, the difference between bi- and cross-encoders, how to score and sort candidates, and when reranking is worth its latency cost.

คำถามที่พบบ่อย

บทเรียน “จัดลำดับผลลัพธ์ที่ดึงมาใหม่” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “จัดลำดับผลลัพธ์ที่ดึงมาใหม่” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Vector Databases: Pinecone, Weaviate & pgvector ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Vector Databases: Pinecone, Weaviate & pgvector มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “จัดลำดับผลลัพธ์ที่ดึงมาใหม่”

เพิ่มความแม่นยำของ RAG ด้วยการจัดลำดับผู้สมัครจากการค้นหาเวกเตอร์เบื้องต้นใหม่ด้วยโมเดลตัวเข้ารหัสไขว้ ก่อนส่งบริบทไปยัง LLM คุณปฏิบัติ Vector Databases: Pinecone, Weaviate & pgvector ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Vector Databases: Pinecone, Weaviate & pgvector หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Vector Databases: Pinecone, Weaviate & pgvector บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน

บทเรียน “จัดลำดับผลลัพธ์ที่ดึงมาใหม่” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Vector Databases: Pinecone, Weaviate & pgvector นี้ได้ไหม

ได้ บทเรียน Vector Databases: Pinecone, Weaviate & pgvector ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. เทคนิคการแปลงคำค้น
  2. ไปป์ไลน์ RAG หลายขั้นตอน
  3. การประเมินประสิทธิภาพระบบ RAG
  4. จัดลำดับผลลัพธ์ที่ดึงมาใหม่
← กลับไปที่ Vector Databases: Pinecone, Weaviate & pgvector