ค้นหาช่วงคำตอบในบริบท
การคาดการณ์โทเคนเริ่มต้นและสิ้นสุด
ค้นหาช่วงคำตอบในบริบท เป็นบทเรียน NLP Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน NLP Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส NLP Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
The Span Mindset
Under the hood, extractive QA never writes text. It picks a span: a contiguous slice of the context defined by where it starts and ends.
Predicting Two Numbers
The model's real job is to predict two positions: the start token of the answer and the end token. The slice between them is the answer.
Tokens, Not Characters
Inside the model the context is split into tokens, not raw letters. Start and end are token indexes that get mapped back to characters.
A Score Per Position
For every token the model emits a start logit and an end logit. These scores say how likely each token begins or ends the answer.
Picking the Best Pair
The chosen span is the start and end pair with the highest combined score, with the rule that end never comes before start.
Slicing With Offsets
The pipeline returns character offsets so you can slice the original context yourself and recover the exact answer text.
answer = context[result["start"]:result["end"]]Why Offsets Matter
Those offsets let you highlight the answer right inside the passage, which is great for showing users where a fact came from.
Limiting Answer Length
You can cap how long a span may be with max_answer_len. This stops the model from returning an entire sentence as the answer.
qa(question=q, context=c, max_answer_len=20)Getting Several Candidates
Set top_k to return more than one candidate span. Reviewing a few options helps when the best answer is ambiguous.
qa(question=q, context=c, top_k=3)Spans Must Be Contiguous
A span is always one continuous stretch of text. Extractive QA cannot stitch together words from different parts of the passage.
Spans Power Highlighting
Because answers are exact spans with offsets, you can highlight them in place, giving users a verifiable source for every reply. 🔦
Quick Check
How does the model decide what the answer is?
Recap
The model predicts start and end positions, picks the best valid pair, and offsets let you slice and highlight the exact answer. 📌
คำถามที่พบบ่อย
บทเรียน “ค้นหาช่วงคำตอบในบริบท” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ค้นหาช่วงคำตอบในบริบท” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส NLP Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส NLP Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ค้นหาช่วงคำตอบในบริบท”
การคาดการณ์โทเคนเริ่มต้นและสิ้นสุด คุณปฏิบัติ NLP Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน NLP Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน NLP Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน
บทเรียน “ค้นหาช่วงคำตอบในบริบท” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน NLP Academy นี้ได้ไหม
ได้ บทเรียน NLP Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- QA แบบดึงข้อมูลเทียบกับแบบสร้างคำตอบ
- เรียกใช้ไปป์ไลน์ QA
- ค้นหาช่วงคำตอบในบริบท
- จัดการกรณีไม่มีคำตอบและเอกสารยาว