LLM Apps in Production (RAG + Vector DB + Caching) · บทเรียน

การทดสอบและประเมินแอป RAG ของคุณ

สร้างความมั่นใจให้แอปพลิเคชัน RAG แรกของคุณด้วยการสร้างชุดทดสอบและวัดคุณภาพการดึงข้อมูลกับคำตอบด้วยตัวชี้วัดที่ใช้งานได้จริงก่อนเปิดให้บริการ

บทเรียน 4 จาก 413 ขั้นตอน

การทดสอบและประเมินแอป RAG ของคุณ เป็นบทเรียน LLM Apps in Production (RAG + Vector DB + Caching) ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน LLM Apps in Production (RAG + Vector DB + Caching) และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส LLM Apps in Production (RAG + Vector DB + Caching) มีบทเรียนทั้งหมด 4 บทเรียน

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

Why Evaluate RAG

A RAG app can look fine on a few queries and fail badly on others. Without measurement you cannot tell if a change helped or hurt.

Evaluation gives you a repeatable score to guide improvements.

Two Things to Measure

RAG quality has two parts:

  • Retrieval: did we fetch the right documents?
  • Generation: did the answer use them correctly?

A bad answer can come from either, so measure both.

Building a Test Set

Create a small set of questions with known correct answers and the documents that contain them. Even 20 to 50 examples are enough to start.

testset = [
    {'q': 'What is the refund window?',
     'answer': '30 days',
     'source': 'policy.md'}
]

Retrieval Metric: Hit Rate

Hit rate (or recall@k) checks whether the correct source appears in the top-k retrieved chunks. High hit rate means retrieval is doing its job.

def hit(retrieved, expected_source):
    return any(d.metadata['source'] == expected_source
               for d in retrieved)

Faithfulness

Faithfulness asks: is the answer supported by the retrieved context, or did the model make things up? An LLM judge can score this automatically.

Answer Relevance

Answer relevance measures whether the response actually addresses the question, regardless of sources. A faithful answer can still be off-topic.

LLM as a Judge

You can use a strong model to grade outputs against the expected answer, returning a pass or score with a reason.

judge_prompt = (
    'Question: {q}\nExpected: {gold}\n'
    'Got: {pred}\nIs it correct? Answer yes or no.'
)

Running the Evaluation

Loop over the test set, run your pipeline, and aggregate scores into a single report you can compare across versions.

scores = []
for case in testset:
    pred = rag.invoke(case['q'])
    scores.append(grade(case, pred))
print(sum(scores) / len(scores))

Comparing Configurations

Change one variable — chunk size, k, prompt, model — rerun the same test set, and compare scores. This turns guesswork into evidence-based tuning.

Watching for Regressions

Keep the test suite in CI. When a change drops a metric, you catch the regression before users do. Treat evaluation like unit tests for AI quality.

Improving From Results

Use failures to guide fixes:

  • Low hit rate? Adjust chunking or retrieval
  • Low faithfulness? Strengthen grounding instructions
  • Low relevance? Improve the prompt

Quick Check

Test your evaluation knowledge.

Recap

You learned to evaluate your RAG app:

  • Measure both retrieval and generation
  • Build a small test set with known answers
  • Use hit rate, faithfulness, and answer relevance
  • Let an LLM judge grade outputs
  • Compare configs and guard against regressions in CI

Evaluation turns RAG improvement into a measurable, repeatable process.

เริ่มต้นได้ฟรี

เรียนรู้ LLM Apps in Production (RAG + Vector DB + Caching) ด้วย AI tutor — ฟรี

เขียนและเรียกใช้โค้ดจริงในเบราว์เซอร์ของคุณ รับความช่วยเหลือทันทีจาก AI tutor 24/7 และเรียนรู้ต่อจากที่คุณหยุดบนเว็บหรือในแอป

คอร์ส
12
บทเรียน
48

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

บทเรียน “การทดสอบและประเมินแอป RAG ของคุณ” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “การทดสอบและประเมินแอป RAG ของคุณ” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส LLM Apps in Production (RAG + Vector DB + Caching) ให้อัปเกรดเป็น CoddyKit PRO คอร์ส LLM Apps in Production (RAG + Vector DB + Caching) มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “การทดสอบและประเมินแอป RAG ของคุณ”

สร้างความมั่นใจให้แอปพลิเคชัน RAG แรกของคุณด้วยการสร้างชุดทดสอบและวัดคุณภาพการดึงข้อมูลกับคำตอบด้วยตัวชี้วัดที่ใช้งานได้จริงก่อนเปิดให้บริการ คุณปฏิบัติ LLM Apps in Production (RAG + Vector DB + Caching) ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน LLM Apps in Production (RAG + Vector DB + Caching) หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน LLM Apps in Production (RAG + Vector DB + Caching) บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน

บทเรียน “การทดสอบและประเมินแอป RAG ของคุณ” ใช้เวลานานแค่ไหน

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

ฉันเขียนและรันโค้ดในบทเรียน LLM Apps in Production (RAG + Vector DB + Caching) นี้ได้ไหม

ได้ บทเรียน LLM Apps in Production (RAG + Vector DB + Caching) ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

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

  1. การเลือกผู้ให้บริการ LLM
  2. พื้นฐานการโหลดข้อมูลและแบ่งข้อความเป็นส่วน
  3. การสร้างไปป์ไลน์ RAG อย่างง่าย
  4. การทดสอบและประเมินแอป RAG ของคุณ
← กลับไปที่ LLM Apps in Production (RAG + Vector DB + Caching)