การเชื่อมโยงข้อกล่าวอ้างกับแหล่งที่มา
เก็บ URL ชื่อเอกสาร คำพูดอ้างอิง และวันที่ไว้กับข้อกล่าวอ้าง
การเชื่อมโยงข้อกล่าวอ้างกับแหล่งที่มา เป็นบทเรียน Claude Architect ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Claude Architect และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Claude Architect มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Why Provenance Matters
In a multi-agent research system, the coordinator aggregates findings from subagents that each pulled facts from different documents. The aggregated answer is only trustworthy if every claim can be traced back to where it came from.
A claim-to-source mapping binds each factual statement to its origin: the URL, the document name, the exact quote, and the publication date. Without that binding, you have an assertion no human reviewer can verify and no downstream agent can audit.
For the Architect exam, provenance lives in Domain 4 (Prompt Engineering & Structured Output) and recurs in Scenario 3 (Multi-Agent Research) and Scenario 6 (Structured Data Extraction).
The Four Anchors of a Source
A source mapping should always carry four anchors so a human or another agent can re-locate and re-verify the evidence:
- URL — where the document lives (or a stable identifier).
- Document name — a human-readable title.
- Quote — the verbatim text that supports the claim, not a paraphrase.
- Publication date — when the source was published or last updated.
The verbatim quote is what lets a reviewer confirm the model did not hallucinate or overstate. The date is what lets you resolve conflicts later, as we'll see.
Model the Mapping as Structured Output
Don't ask the model to weave citations into prose where they're easy to drop. Instead, force a structured shape with a JSON Schema via a tool. Pairing tool_use with a schema eliminates syntax errors and enforces that required fields are present.
Each claim becomes an object that carries its own source anchors. This is the foundation of a verifiable provenance record.
extract_claims = {
"name": "record_claims",
"description": "Record each factual claim with its full source provenance.",
"input_schema": {
"type": "object",
"properties": {
"claims": {
"type": "array",
"items": {
"type": "object",
"properties": {
"claim": {"type": "string"},
"source_url": {"type": "string"},
"document_name": {"type": "string"},
"quote": {"type": "string"},
"publication_date": {"type": "string"}
},
"required": ["claim", "quote", "document_name"]
}
}
},
"required": ["claims"]
}
}Required Fields: Only What's Always Present
A subtle but exam-critical rule: mark a field required only if it is always present in the source. If you require a field that may be absent, the model will fabricate a value to satisfy the schema.
A blog post may have no formal publication_date; an internal PDF may have no source_url. So claim, quote, and document_name are required (you always have them), while source_url and publication_date stay optional. An empty date is honest; an invented one is a provenance failure.
Force Structured Output with tool_choice
To guarantee you get the provenance object back instead of free-form prose, constrain the model with tool_choice. Setting {"type": "tool", "name": "record_claims"} forces that specific tool, so every response arrives as schema-validated JSON.
Using "any" would guarantee some tool is called; forcing the named tool is the tightest guarantee when you only have one extraction tool.
resp = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=2048,
tools=[extract_claims],
tool_choice={"type": "tool", "name": "record_claims"},
messages=[{
"role": "user",
"content": (
"Extract every factual claim from the document below. "
"For each, attach the verbatim quote, document name, "
"and the source URL and publication date if present.\n\n"
f"<document>{source_text}</document>"
),
}],
)Verbatim Quotes Reduce Hallucination
Requiring a verbatim quote (not a paraphrase) is a reliability lever, not just bookkeeping. When the model must copy the exact supporting text, it is far harder to assert something the source never said.
Reinforce this with explicit criteria in the prompt and 2-4 few-shot examples. Few-shot examples are especially effective for output format, edge cases, and reducing hallucination — the model generalizes the pattern rather than merely repeating your samples.
PROMPT = (
"Rules:\n"
"- 'quote' MUST be copied verbatim from the document. Never paraphrase.\n"
"- If a claim has no exact supporting sentence, DO NOT emit it.\n"
"- Leave 'publication_date' empty if the document states no date.\n\n"
"Example:\n"
"claim: 'Revenue grew 12% in Q3.'\n"
"quote: 'Third-quarter revenue rose 12% year over year.'\n"
"document_name: 'FY24 Q3 Earnings Release'\n"
)Carry Provenance Across Subagents
In a hub-and-spoke research system, subagents do not inherit the coordinator's conversation history. Every subagent must return its findings with source mappings attached, because the coordinator has no other way to know where a fact came from.
The coordinator then aggregates these self-contained claim objects. If a subagent returns a bare sentence with no quote or document name, that fact is unverifiable the moment it leaves the subagent's context — treat it as missing provenance, not as a valid finding.
# Each subagent returns claim objects, not loose prose.
subagent_result = {
"agent": "market-research",
"claims": [
{
"claim": "EV sales reached 14M units in 2023.",
"quote": "Global EV sales hit 14 million units in 2023.",
"document_name": "IEA Global EV Outlook 2024",
"source_url": "https://iea.org/evo-2024",
"publication_date": "2024-04-23",
}
],
}
# Coordinator aggregates self-contained, traceable claims.
aggregated.extend(subagent_result["claims"])Annotate Conflicts — Don't Pick Arbitrarily
When two sources disagree on a statistic, the wrong move is to silently pick one. The right move is to annotate the conflict and surface both claims with their sources.
Often the publication date resolves the apparent contradiction: a 2021 figure and a 2024 figure aren't contradictory — they're a time series. This is exactly why the date anchor earns its place in every mapping. Preserve both, label them, and let a human (or a date-aware rule) adjudicate.
conflict = {
"metric": "global_ev_sales_units",
"values": [
{"value": "6.6M", "document_name": "IEA EV Outlook 2022",
"publication_date": "2022-05-23"},
{"value": "14M", "document_name": "IEA EV Outlook 2024",
"publication_date": "2024-04-23"},
],
"note": "Not contradictory: different reporting years. Dates resolve it.",
}Detect Missing Sources via Self-Correction
Self-correction works by extracting two values you can compare. For provenance, have the model emit each claim alongside a flag for whether a supporting quote was actually found, then validate programmatically that every claim carries one.
This catches the silent failure where a confident sentence ships with no evidence behind it. Validation here is structural — perfect for a retry loop.
def validate_provenance(claims):
problems = []
for c in claims:
if not c.get("quote", "").strip():
problems.append(f"No quote: {c['claim']!r}")
if not c.get("document_name"):
problems.append(f"No document_name: {c['claim']!r}")
return problems # empty list == provenance completeRetry With Feedback — But Know Its Limits
If validation finds a structural gap (missing quote, malformed date), use retry-with-feedback: send the model the original document, its own wrong output, and the exact validation error. This reliably fixes format and structural mistakes.
Critical boundary: retry does not help when the information is simply absent from the source. If the document genuinely has no publication date, no amount of retrying will conjure one — and you must not let it. Mark the field empty and move on, rather than looping forever.
problems = validate_provenance(claims)
if problems:
retry = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=2048,
tools=[extract_claims],
tool_choice={"type": "tool", "name": "record_claims"},
messages=[
{"role": "user", "content": f"<document>{source_text}</document>"},
{"role": "assistant", "content": prior_output},
{"role": "user", "content":
"These claims lack a verbatim quote or document_name: "
+ "; ".join(problems)
+ ". Add the exact supporting quote, or DROP the claim "
"if no supporting text exists. Do not invent sources."},
],
)Render Provenance by Content Type
Once claims are mapped, present them in the format that fits the content. Render financials as tables, news as prose, and technical findings as lists — each with its source anchors visible.
For human oversight, a footnote or trailing column carrying the document name, date, and a link makes verification a glance instead of an investigation. Provenance you can't see is provenance no one will check.
| Metric | Value | Source | Date |
|---------------|-------|---------------------------|------------|
| EV sales 2023 | 14M | IEA Global EV Outlook 2024| 2024-04-23 |
| EV sales 2022 | 6.6M | IEA Global EV Outlook 2022| 2022-05-23 |
<!-- Financials -> table. News -> prose. Tech findings -> list. -->Quick Check: Conflicting Stats
A multi-agent research system aggregates a market-size figure that two subagents reported differently: a primary source says "$4.2B (report dated 2021)" and another says "$7.1B (report dated 2024)." The coordinator must produce a verifiable answer for a human reviewer.
Recap: Claim-to-Source Mappings
Key takeaways for the exam and for production systems:
- Bind every claim to four anchors: URL, document name, verbatim quote, publication date.
- Enforce the shape with tool_use + JSON Schema and force it via
tool_choice. - Mark a field required only if always present — never require a possibly-absent field, or the model fabricates it.
- Subagents don't inherit history, so each must return self-contained, traceable claims.
- Annotate conflicts; let dates resolve apparent contradictions instead of picking arbitrarily.
- Use retry-with-feedback for structural gaps — but accept that retry can't supply info absent from the source.
- Render by content type (tables/prose/lists) with sources visible for human oversight.
คำถามที่พบบ่อย
บทเรียน “การเชื่อมโยงข้อกล่าวอ้างกับแหล่งที่มา” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “การเชื่อมโยงข้อกล่าวอ้างกับแหล่งที่มา” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Claude Architect ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Claude Architect มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “การเชื่อมโยงข้อกล่าวอ้างกับแหล่งที่มา”
เก็บ URL ชื่อเอกสาร คำพูดอ้างอิง และวันที่ไว้กับข้อกล่าวอ้าง คุณปฏิบัติ Claude Architect ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Claude Architect หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Claude Architect บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน
บทเรียน “การเชื่อมโยงข้อกล่าวอ้างกับแหล่งที่มา” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Claude Architect นี้ได้ไหม
ได้ บทเรียน Claude Architect ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- การเชื่อมโยงข้อกล่าวอ้างกับแหล่งที่มา
- ข้อมูลและวันที่ที่ขัดแย้งกัน
- ตัวชี้วัดรวมซ่อนความล้มเหลว
- การสุ่มตัวอย่างแบบแบ่งชั้นและการปรับเทียบ