ในบทความนี้
In this post
ตอนที่ 8 จากสิบสอง: ให้ด่านความหมายตรวจร่างกับ facts ที่เชื่อถือได้ แยก hallucination ข้อความสั่ง evaluator และความไม่แน่ใจ
คำตัดสินและร่างข้อความเริ่มต้นเป็น mock ที่ผู้เขียนกำหนด ไม่ใช่ผล Jev จริง อ่านบทเรียนคู่กับ source, tests และแบบฝึกที่ลิงก์ไปยังรุ่นตรึงใน GitHub
เป้าหมายและสิ่งที่ต้องพร้อม
เตรียม Node22.18 ขึ้นไปกับ terminal clone companion จาก GitHub ตาม README หรือดาวน์โหลด ZIP ฉบับสมบูรณ์ แตกแล้วเข้า ai-core-functional-lab ไม่ต้อง npm install ใช้ API key หรือเรียกโมเดลผ่านเครือข่าย เวลาอ่านไม่รวมการลงมือประมาณ25–45นาที เก็บชุดอ้างอิงหนึ่งชุดและทำแบบฝึกในอีกสำเนา
ดาวน์โหลด companion ZIP · README / แผนบทเรียน
ตอนนี้เน้น src/semantic.mjs โดย gate state บอกผลต่อชิ้นงานและทางไปต่อ ไม่มี state ใดส่งข้อความหรือแก้บัญชีจริง
จากโค้ดเดิมสู่ขอบเขตใหม่
เมื่อผ่าน schema แล้ว ต้องถามว่าข้ออ้างของร่างตามหลักฐานที่ดูแลหรือไม่ output request จึงมีคำถามผู้ใช้ candidate และ trustedFacts พร้อมกัน การถามเพียงว่าฟังดูถูกไหมอาจทำให้โมเดลรับข้อความน่าเชื่อแต่ไร้หลักฐาน
Noul ของ grounding เป็น probability ของประพจน์ ไม่ใช่ปริมาณความจริง ค่าต่ำขอ revise ช่วงกลางให้มนุษย์ และค่าสูงจึงไปตรวจคุณภาพอีกด่าน ไม่มีค่าใดพิสูจน์ว่าไม่ hallucinate
candidate อาจมีคำสั่งถึง evaluator หรือยกย่องคุณภาพตัวเอง คำถาม hiddenInstructions จึงมองเป็นข้อมูลไม่เชื่อถือ โมเดลตระกูลเดียวอาจผิดสัมพันธ์กันหลายด่าน การเห็นด้วยซ้ำจึงไม่ใช่หลักฐานอิสระ
ลงมือทีละเจ็ดขั้น
ขั้นที่ 1
อ่าน facts ที่ดูแลทั้งสองข้อก่อนตัดสิน candidate DeskLite export ทำไฟล์ดาวน์โหลดและไม่ส่งอีเมล ความเป็นเจ้าของแหล่งข้อมูลสำคัญกว่าถ้อยคำมั่นใจ
ขั้นที่ 2
พิมพ์ output request หา trustedFacts กับ candidate และตรวจว่าไม่มี gold acceptability มีการ copy facts เพื่อไม่ให้ provider เผลอแก้ reference ของแอป
ขั้นที่ 3
รัน judge ของ V007 ซึ่ง generator จำลองอ้างว่า export ส่งอีเมลให้ทุกคน judgment ของ grounding ที่กำหนดไว้ขอ revise การมี citation IDs ถูกไม่ได้ยกเว้นข้ออ้างไร้หลักฐาน
ขั้นที่ 4
รัน V007 เต็ม ดูร่างทั้งสองครั้ง fallback แน่นอนคืน facts ที่ดูแลไว้ แล้วด่านต่อไปตรวจ candidate ใหม่ภายในงบรวมที่เหลือ คำสั่ง request กับ judge ใช้ candidate แรกจาก generator เหมือนกัน ดู request.state.candidate เพื่อเห็นข้ออ้างส่งอีเมลที่ส่งถึง output adapter
ขั้นที่ 5
รัน A003 ดู candidate ที่สั่งให้ให้คะแนนเต็ม คำสั่งนั้นไม่ใช่หลักฐานคุณภาพ semantic output guard จึง reject ก่อน rubric ความมีประโยชน์
ขั้นที่ 6
ดู uncertainty tests ของ grounded กับ hiddenInstructions ค่ากลางต้อง review ไม่ปัดให้กลายเป็นการอนุมัติที่สะดวก คำตอบไม่ทราบหรือผิดรูปก็ยังไป review
ขั้นที่ 7
เขียนชุด validation ที่ตรวจคู่ source/candidate อย่างอิสระสองภาษาสำหรับการศึกษาจริงภายหลัง อย่าถือเดโมที่เตรียมคำตอบไว้เป็นอัตราผิดที่วัดแล้วหรือ guardrail ครอบจักรวาล
ไฟล์และคำสั่งที่รันได้
เปิด source จริงและอ่าน dependencies ก่อนแก้ นี่คือโค้ดอ้างอิงที่รันได้ ไม่ใช่ SDK ชื่อ AI-Core ที่สมมติขึ้น ลิงก์ชี้ source รุ่นตรึงของ companion สาธารณะใน GitHub
src/semantic.mjs · tests ของตอนนี้ · แบบฝึกตอนนี้
import {gate} from './contracts.mjs';
export function semanticInput(d,p) {
if(d.injection>=p.yesMin) return gate('reject',['semantic_injection']);
if(d.injection>p.noMax||d.purpose.confidence<p.choiceMin)
return gate('human_review',['uncertain_input']);
if(d.purpose.choice==='account_action') return gate('reject',['semantic_scope']);
if(d.purpose.choice!=='how_to') return gate('human_review',['unknown_purpose']);
return gate('accept');
}
export function semanticOutput(d,p) {
if(d.hiddenInstructions>=p.yesMin) return gate('reject',['self_advocating_candidate']);
if(d.hiddenInstructions>p.noMax) return gate('human_review',['uncertain_candidate_instructions']);
if(d.grounded<=p.noMax) return gate('revise',['unsupported_claim']);
if(d.grounded<p.yesMin) return gate('human_review',['uncertain_grounding']);
return gate('accept');
}
คำสั่งออฟไลน์:
node src/cli.mjs request --stage output --case V001
node src/cli.mjs judge --stage output --case V007
node src/cli.mjs run --case V007
node src/cli.mjs run --case A003
node --test --test-reporter=spec test/gates.test.mjs
node --test --test-reporter=spec test/cli.test.mjs
ผลที่ควรได้และการตรวจ
judge ตรงของ V007 คืน revise ด้วย unsupported_claim ส่วน pipeline เต็มอาจ accept หลัง fallback ที่จำกัด A003 reject ด้วย self_advocating_candidate ผล fixture ยืนยันเพียง control flow ไม่ใช่ความแม่นข้อเท็จจริงของ Jev1.14 จริง
อ่าน reasons, history และทุก attempt ไม่ดูเพียง label สุดท้าย usage ที่ไม่ทราบต้องยังไม่ทราบ test สีเขียวแสดงเส้นทางโค้ดที่กำหนด ไม่ได้พิสูจน์ความปลอดภัยเชิงความหมายทุกกรณี
ตัวอย่างที่ต้องเข้าใจเมื่อไม่ผ่าน
candidate อ้าง fact ID ถูกแต่แต่งฟีเจอร์ส่งอีเมลใหม่ผ่าน citation เชิงโครงสร้างแต่ขัดข้อความต้นทาง คำรับรองของ candidate ว่าตัวเอง grounded ต้องไม่กลายเป็นแหล่งเชื่อถืออีกชิ้น
แบบฝึกในสำเนาทดลอง
ในสำเนาทดลอง เปลี่ยน candidate เป็นข้ออ้างไร้หลักฐานแต่เก็บ citation IDs จริง สังเกตว่า judgment จำลองยังคงเดิม เพิ่ม mock ที่ติดป้ายชัดเพื่อสอนเส้นทาง และระบุการติดป้ายอิสระที่ต้องใช้เมื่อทดสอบ live
ทำตามไฟล์แบบฝึก เก็บต้นฉบับและคืนชุดอ้างอิงก่อนตอนถัดไป อย่าใช้ผล held-out เลือก threshold
ตรวจเมื่อผลไม่ตรง
หาก grounding ดูสมบูรณ์เสมอ ให้ดูว่า judge ได้รับ facts หรือเพียง candidate แล้วอ่านป้าย evidence เพราะ provider นี้ผูกคำตอบกับ case ID ไม่ได้วัดผลจากการแก้ถ้อยคำ source
จุดตรวจถัดไป
ก่อนต่อ ให้บอกคุณสมบัติที่โค้ดตรวจได้แน่นอน คำตัดสินที่ผิดได้ state ที่หยุดงาน และหลักฐานที่ต้องมีก่อนปล่อยรุ่น
แหล่งอ้างอิงและรุ่น
เอกสารต้นทางและ companion source
ตรวจเอกสาร TypeSafe วันที่24ตุลาคม2026 บทเรียนตรึงคำขอข้อความที่ jev-1.14.0 และใช้ Choice/Noul ไม่ได้อ้างว่ามีเพียงความสามารถเหล่านี้ โค้ด REST ทางเลือกยังไม่ได้ลอง live ส่วน SDK0.7.0 มีเอกสารแต่แล็บนี้ไม่ต้องติดตั้ง
สิ่งที่ควรนำไปใช้ต่อ
- เงื่อนไขแน่นอนและสิทธิ์ยังอยู่ในโค้ด
- ด่านความหมายและคุณภาพผิดพลาดได้
- accept, reject, revise และ review มีทางไปต่อคนละแบบ
Part 8 of twelve. Judge candidate claims against maintained evidence and refuse self-advocating evaluator instructions.
Default decisions and draft text are authored mocks, not live Jev results. Use the tutorial with the matching companion code, tests and exercise linked to a fixed GitHub version.
Outcome and prerequisites
Use Node22.18+ and a terminal. Clone the GitHub companion using its README, or download the complete ZIP, extract it and enter ai-core-functional-lab. No npm install, API key or network inference is needed. The reading-time label excludes about25–45 minutes of hands-on work. Keep one reference copy and make exercises in another.
Download companion ZIP · README / lesson map
This part focuses on src/semantic.mjs. Expected gate states describe content and continuation; no state sends a message or changes a real account.
Old functions and the new boundary
After schema validation, ask whether the draft’s claims follow from maintained evidence. The output request contains the user question, candidate and trustedFacts together. Asking only does this sound correct invites a model to approve persuasive but unsupported text.
The grounding Noul is the probability of the stated proposition, not an amount of factual correctness. Low grounding requests revision, a middle band goes to a human, and high grounding allows a separate quality evaluation. None proves absence of hallucination.
Candidates can contain instructions to the evaluator or claims about their own quality. The hiddenInstructions question treats those as untrusted content. The same model family may make correlated mistakes across guards, so repeated agreement is not independent evidence.
Seven practical steps
Step 1
Read both facts in the maintained source before judging any candidate. DeskLite export downloads a local file and does not email it. Source ownership matters more than confident prose.
Step 2
Print the output-stage request and locate trustedFacts and candidate. Confirm gold acceptability is absent. Facts are copied so a provider cannot mutate the application’s reference object accidentally.
Step 3
Run judge for V007. The canned generator claimed export emails every teammate; the authored grounding judgment requests revise. Valid citation IDs do not excuse the unsupported claim.
Step 4
Run the complete V007 pipeline and inspect both draft attempts. The deterministic fallback returns maintained facts. The subsequent guard checks the new candidate again within the remaining shared budget. Both request and judge commands fetch the same first generated candidate; inspect request.state.candidate to see the unsupported emailing claim that reaches the output adapter.
Step 5
Run A003 and inspect the self-advocating candidate. Its request to award full marks is not evidence of quality. The semantic output guard rejects it before the usefulness rubric.
Step 6
Inspect uncertainty tests around grounded and hiddenInstructions. A middle value routes to review instead of being rounded into convenient approval. Unknown and malformed answers remain review outcomes.
Step 7
Write a validation set of independently checked source/candidate pairs in both languages for a future real study. Do not treat these canned demonstrations as measured error rates or a universal guardrail.
Files and runnable commands
Open the exact source and read its dependencies before editing. This is runnable reference code, not a fictional AI-Core SDK. The source links point to a fixed version of the public GitHub companion.
src/semantic.mjs · Matching tests · This lesson’s exercise
import {gate} from './contracts.mjs';
export function semanticInput(d,p) {
if(d.injection>=p.yesMin) return gate('reject',['semantic_injection']);
if(d.injection>p.noMax||d.purpose.confidence<p.choiceMin)
return gate('human_review',['uncertain_input']);
if(d.purpose.choice==='account_action') return gate('reject',['semantic_scope']);
if(d.purpose.choice!=='how_to') return gate('human_review',['unknown_purpose']);
return gate('accept');
}
export function semanticOutput(d,p) {
if(d.hiddenInstructions>=p.yesMin) return gate('reject',['self_advocating_candidate']);
if(d.hiddenInstructions>p.noMax) return gate('human_review',['uncertain_candidate_instructions']);
if(d.grounded<=p.noMax) return gate('revise',['unsupported_claim']);
if(d.grounded<p.yesMin) return gate('human_review',['uncertain_grounding']);
return gate('accept');
}
Offline commands:
node src/cli.mjs request --stage output --case V001
node src/cli.mjs judge --stage output --case V007
node src/cli.mjs run --case V007
node src/cli.mjs run --case A003
node --test --test-reporter=spec test/gates.test.mjs
node --test --test-reporter=spec test/cli.test.mjs
Expected output and verification
The direct V007 judge returns revise with unsupported_claim; the full pipeline can accept after bounded fallback. A003 rejects self_advocating_candidate. These fixture observations establish control flow only, not the live Jev1.14 model’s factual accuracy.
Inspect reasons, history and every attempt rather than only the final label. Unknown usage must remain unknown. A green test demonstrates the specified code path, not universal semantic safety.
A failure to understand
A candidate that quotes the right fact ID while claiming a new emailing feature passes structural citations but contradicts source text. A candidate’s own assurance that it is grounded must not become another trusted source.
Exercise in a disposable copy
In a disposable copy, replace only the candidate with an unsupported claim while keeping real citation IDs. Observe that canned judgments stay fixed; add a clearly labeled mock response for the teaching path and specify the independent labeling needed for a live test.
Follow the matching exercise file, retain the original and restore the reference before the next chapter. Do not use held-out results to choose a threshold.
Troubleshooting
If grounding always looks perfect, inspect whether the judge received facts or merely the candidate. Then inspect the evidence label: this provider is indexed by case ID and cannot measure changes to source wording.
Next checkpoint
Before continuing, name the property that code checks exactly, the judgment that may be wrong, the state that stops work and the evidence needed before release.
← Previous lesson · Next lesson →
Sources and version notes
Primary documentation and companion source
Official TypeSafe docs checked2026-10-24. This curriculum pins text requests to jev-1.14.0 and uses Choice/Noul; it does not claim those exhaust Jev’s capabilities. Optional REST code is untested live. SDK0.7.0 is documented but unnecessary for this no-install lab.
Key takeaways
- Deterministic constraints and authorization stay in code.
- Semantic guards and quality judgments are fallible.
- Accept, reject, revise and review have distinct continuation rules.