Retrieval passages-ஐ wording similarity-ஆல் rank செய்து top few-ஐ answering model-இடம்
ஒப்படைக்கிறது – contradictions, prompt injections உட்பட. ஒரு demo query-இல் planted forum injection
similarity-இல் முதலிடம் (0.584), query-யின் false premise-ஐ மறுக்கும் passage ஏழாவது
(0.509); 0.584–0.455 என்ற குறுகிய spread இரண்டையும் பிரிக்கப் போதாது. TypeSafe-இன்
classifying-RAG-passages cookbook
retrieval-க்கும் generation-க்கும் இடையே இரண்டாம் stage சேர்க்கிறது: ஒவ்வொரு passage-க்கும்
நான்கு Noul கேள்விகள், தலா ஒரு request, பிறகு code-இல் எளிய threshold logic prompt-ஐ
எது அடையும் என முடிவு செய்யும் – evidence-ஆக, flagged conflict-ஆக, அல்லது எதுவுமில்லை.
இந்த guide recipe-யின் சுருக்கம்.
நான்கு கேள்விகள்
State-இல் query + ஒரு passage (id, title, text, source type), எனவே ஒவ்வொரு கேள்வியும் passage பற்றி அல்ல, pair பற்றியது. ஒவ்வொரு query-க்கும் அதே நான்கு கேள்விகள்; state மட்டும் மாறும்:
is_relevant– passage query-யின் subject-ஐ தொடுகிறதா? (relevance floor)contains_answer_evidence– நேரடி பதிலில் பயன்படும் ஒன்றைக் கூறுகிறதா? (include அல்லது drop)contradicts_query_premise– query எடுத்துக்கொண்ட premise-உடன் முரண்படுகிறதா? (conflict block-க்கு promote)contains_prompt_injection– answering system-ஐ கட்டுப்படுத்த முயல்கிறதா? (நேரடி exclude)
எது கேட்கப்படவில்லை என்பதைக் கவனியுங்கள்: passage-ஐ include செய்வதா. அந்த முடிவு code-இல் உள்ளது; policy மாற்றுவது கேள்வியை reword செய்வதல்ல, review-க்குட்பட்ட number edit.
Code-இல் route, first match wins
THRESHOLDS = {
"injection_max": 0.70, # above this the passage never reaches the prompt
"contradicts_min": 0.70, # above this it disputes the query's premise
"relevant_min": 0.45, # below this it is not about the query at all
"evidence_min": 0.55, # above this it states something usable
}
def route(answers: dict, thresholds: dict = THRESHOLDS) -> str:
if answers["contains_prompt_injection"] > thresholds["injection_max"]:
return "exclude"
if answers["contradicts_query_premise"] > thresholds["contradicts_min"]:
return "conflicting_evidence"
if answers["is_relevant"] < thresholds["relevant_min"]:
return "exclude"
if answers["contains_answer_evidence"] > thresholds["evidence_min"]:
return "include"
return "exclude"
வரிசை முக்கியம்: injection முதலில், ஏனெனில் அது security முடிவு, evidence முடிவு அல்ல; contradiction evidence-க்கு முன், ஏனெனில் query-யின் premise-ஐ மறுக்கும் passage பொதுவாகப் பயன்படும் ஒன்றையும் கூறும் – மறு வரிசையில் சோதித்தால் conflict block-க்குப் பதில் accepted block-இல் விழும். Re-routing இலவசம் – thresholds stored answers-ஐ வாசிக்கும், policy tuning-க்கு zero API calls.
இது எதைப் பிடிக்கிறது
Headline query-இல் ("Refresh tokens expire after 30 days – window-ஐ எப்படி நீட்டிப்பது?", false premise), routing table:
| Route | rel | evid | contra | inj | Passage |
|---|---|---|---|---|---|
| exclude | 0.71 | 0.36 | 0.90 | 0.99 | forum-injection |
| conflicting_evidence | 0.49 | 0.51 | 0.92 | 0.15 | sessions-01 |
| exclude (×10) | ≤0.48 | ≤0.42 | ≤0.39 | ≤0.26 | மற்றவை |
Injection relevance floor-ஐ clear செய்கிறது (0.71) – relevance மட்டும் அதை through விட்டிருக்கும் – 0.99 injection score மட்டுமே அதை வீழ்த்துகிறது. மறுக்கும் passage 0.49 relevance / 0.51 evidence – தனியே இரண்டும் அதை வீழ்த்தியிருக்கும்; 0.92 contradiction score conflict block-இல் காப்பாற்றுகிறது. Evidence-ஆக prompt-ஐ எதுவும் அடைவதில்லை – false premise கேள்விக்குச் சரி – generator "I don't have sufficient accepted evidence" என்கிறது, conflict-ஐ பெயரிடுகிறது, 30-day setting-ஐ invent செய்யாமல் மறுக்கும் passage-ஐ quote செய்கிறது.
சாதாரண பதிலுள்ள query-இல் ("access token எவ்வளவு long live இருக்க வேண்டும்?") நான்கு passages evidence அடைகின்றன – மூன்று ranks 8, 9, 11-லிருந்து; similarity-top ranks 2–4 (தவறான வகை "lifetime", signing keys) அனைத்தும் ≤0.08 relevance-இல் வீழ்கின்றன. Injection மீண்டும் 0.99-இல் excluded. ஆறு queries, 72 passages-இல் ஒவ்வொரு dozen-இலும் குறைந்தது மூன்றில் இரண்டு excluded.
இரண்டு நேர்மையான caveats
- Injection கேள்வி filter, boundary அல்ல: threshold-க்குக் கீழ் passage prompt-ஐ அடையும், எனவே generator prompt ஒவ்வொரு passage-ஐயும் score பொருட்படுத்தாமல் untrusted text-ஆகக் கருத வேண்டும்.
- செலவு
k-உடன் scale ஆகும் – passage-க்கு ஒரு request. Passages ஒரே request-இல் batch செய்யப்படுவதில்லை, ஒவ்வொரு கேள்வியும் ஒரு pair பற்றியது என்பதால்.
Accepted + conflicting evidence தனி prompt blocks-இல் செல்லும், rules-உடன் (untrusted text, passage IDs cite, conflicts report, guess-க்குப் பதில் "insufficient"). இரண்டையும் ஒரே block-இல் இணைத்தால் generator பதிலையும் மறுப்பையும் பிரிக்க முடியாது.
இறுதி முடிவு
Similarity retrieves; judgment filters; code routes; generator labelled evidence-ஐ மட்டும் பார்க்கும். நான்கு Nouls + ஐந்து comparisons – passage-க்கு ஒரு request விலையில் injection defence + false-premise detection. Full source: TypeSafe classifying-RAG-passages cookbook; "முதலில் filter, தேவையானதை மட்டும் அனுப்பு" கொள்கை Jev 1.13 jaggedness guide-இன் failure mode 5.