[{"data":1,"prerenderedAt":1340},["ShallowReactive",2],{"page-\u002Fprompt-engineering\u002F17-handling-hallucination-and-uncertainty":3},{"id":4,"title":5,"body":6,"description":1333,"extension":1334,"meta":1335,"navigation":93,"path":1336,"seo":1337,"stem":1338,"__hash__":1339},"content\u002Fprompt-engineering\u002F17-handling-hallucination-and-uncertainty.md","17 — Handling Hallucination & Uncertainty",{"type":7,"value":8,"toc":1320},"minimark",[9,13,18,196,200,220,286,290,364,413,465,469,535,625,629,667,724,728,761,808,812,880,884,989,993,1127,1131,1168,1190,1194,1316],[10,11,5],"h1",{"id":12},"_17-handling-hallucination-uncertainty",[14,15,17],"h2",{"id":16},"what-hallucination-mechanistically-is","What Hallucination Mechanistically Is",[19,20,23],"code-wrapper",{"filename":21,"language":22},"hallucination_mechanism.py","python",[24,25,29],"pre",{"className":26,"code":27,"language":22,"meta":28,"style":28},"language-python shiki shiki-themes github-light github-dark","# Hallucination = fluent, confident, plausible-sounding output that is factually wrong.\n# A fabricated citation, a nonexistent API method, a legal case that doesn't exist.\n#\n# The model has NO built-in mechanism separating \"things I'm recalling with high\n# confidence\" from \"things I'm generating because they're a plausible continuation.\"\n# Both produce the same kind of fluent, confident-sounding token stream.\n#\n# Fluency and confidence-sounding are properties of HOW text is generated,\n# not signals the model separately tracks about WHETHER the content is true.\n\n# Hallucination is NOT a bug — it's an expected consequence of the mechanism.\n# Most likely to surface where training data was thin, contradictory, or absent:\nHALLUCINATION_RISK_ZONES = {\n    \"obscure_facts\": \"training data was thin or inconsistent\",\n    \"recent_events\": \"past training cutoff — info may not exist in training at all\",\n    \"exact_citations\": \"high-precision, low-redundancy facts — hard to reproduce reliably\",\n    \"precise_numbers\": \"exact statistics are rarely memorized precisely\",\n    \"version_specific_apis\": \"training data mixes many versions; model blends across them\",\n}\n","",[30,31,32,41,47,53,59,65,71,76,82,88,95,101,107,122,138,151,164,177,190],"code",{"__ignoreMap":28},[33,34,37],"span",{"class":35,"line":36},"line",1,[33,38,40],{"class":39},"sdCPZ","# Hallucination = fluent, confident, plausible-sounding output that is factually wrong.\n",[33,42,44],{"class":35,"line":43},2,[33,45,46],{"class":39},"# A fabricated citation, a nonexistent API method, a legal case that doesn't exist.\n",[33,48,50],{"class":35,"line":49},3,[33,51,52],{"class":39},"#\n",[33,54,56],{"class":35,"line":55},4,[33,57,58],{"class":39},"# The model has NO built-in mechanism separating \"things I'm recalling with high\n",[33,60,62],{"class":35,"line":61},5,[33,63,64],{"class":39},"# confidence\" from \"things I'm generating because they're a plausible continuation.\"\n",[33,66,68],{"class":35,"line":67},6,[33,69,70],{"class":39},"# Both produce the same kind of fluent, confident-sounding token stream.\n",[33,72,74],{"class":35,"line":73},7,[33,75,52],{"class":39},[33,77,79],{"class":35,"line":78},8,[33,80,81],{"class":39},"# Fluency and confidence-sounding are properties of HOW text is generated,\n",[33,83,85],{"class":35,"line":84},9,[33,86,87],{"class":39},"# not signals the model separately tracks about WHETHER the content is true.\n",[33,89,91],{"class":35,"line":90},10,[33,92,94],{"emptyLinePlaceholder":93},true,"\n",[33,96,98],{"class":35,"line":97},11,[33,99,100],{"class":39},"# Hallucination is NOT a bug — it's an expected consequence of the mechanism.\n",[33,102,104],{"class":35,"line":103},12,[33,105,106],{"class":39},"# Most likely to surface where training data was thin, contradictory, or absent:\n",[33,108,110,114,118],{"class":35,"line":109},13,[33,111,113],{"class":112},"snvgF","HALLUCINATION_RISK_ZONES",[33,115,117],{"class":116},"svdQ7"," =",[33,119,121],{"class":120},"ssxIu"," {\n",[33,123,125,129,132,135],{"class":35,"line":124},14,[33,126,128],{"class":127},"sJ6F3","    \"obscure_facts\"",[33,130,131],{"class":120},": ",[33,133,134],{"class":127},"\"training data was thin or inconsistent\"",[33,136,137],{"class":120},",\n",[33,139,141,144,146,149],{"class":35,"line":140},15,[33,142,143],{"class":127},"    \"recent_events\"",[33,145,131],{"class":120},[33,147,148],{"class":127},"\"past training cutoff — info may not exist in training at all\"",[33,150,137],{"class":120},[33,152,154,157,159,162],{"class":35,"line":153},16,[33,155,156],{"class":127},"    \"exact_citations\"",[33,158,131],{"class":120},[33,160,161],{"class":127},"\"high-precision, low-redundancy facts — hard to reproduce reliably\"",[33,163,137],{"class":120},[33,165,167,170,172,175],{"class":35,"line":166},17,[33,168,169],{"class":127},"    \"precise_numbers\"",[33,171,131],{"class":120},[33,173,174],{"class":127},"\"exact statistics are rarely memorized precisely\"",[33,176,137],{"class":120},[33,178,180,183,185,188],{"class":35,"line":179},18,[33,181,182],{"class":127},"    \"version_specific_apis\"",[33,184,131],{"class":120},[33,186,187],{"class":127},"\"training data mixes many versions; model blends across them\"",[33,189,137],{"class":120},[33,191,193],{"class":35,"line":192},19,[33,194,195],{"class":120},"}\n",[14,197,199],{"id":198},"the-naive-fix-and-why-its-weak","The Naive Fix (And Why It's Weak)",[19,201,204],{"filename":202,"language":203},"naive_anti_hallucination.md","markdown",[24,205,208],{"className":206,"code":207,"language":203,"meta":28,"style":28},"language-markdown shiki shiki-themes github-light github-dark","\u003C!-- ANTI-PATTERN: close to useless -->\nDon't hallucinate. Only tell me true things.\n",[30,209,210,215],{"__ignoreMap":28},[33,211,212],{"class":35,"line":36},[33,213,214],{"class":39},"\u003C!-- ANTI-PATTERN: close to useless -->\n",[33,216,217],{"class":35,"line":43},[33,218,219],{"class":120},"Don't hallucinate. Only tell me true things.\n",[19,221,223],{"filename":222,"language":22},"why_naive_fails.py",[24,224,226],{"className":26,"code":225,"language":22,"meta":28,"style":28},"# WHY THIS FAILS: the model doesn't have a labeled internal flag for \"this specific\n# claim is a hallucination\" that this instruction could suppress. Asking it not to\n# hallucinate is asking it to distinguish confident-recall from plausible-generation\n# at the moment of production — when both processes look identical from the inside.\n#\n# It's like telling someone \"don't misremember things\" — well-intentioned but gives\n# no new capability to act on.\n#\n# What ACTUALLY helps:\n# 1. Give the model an explicit, low-cost way to express PARTIAL confidence\n# 2. Force it to ground claims in provided material rather than parametric memory\n# 3. Structure the task so fabrication has a clear, nameable ALTERNATIVE\n",[30,227,228,233,238,243,248,252,257,262,266,271,276,281],{"__ignoreMap":28},[33,229,230],{"class":35,"line":36},[33,231,232],{"class":39},"# WHY THIS FAILS: the model doesn't have a labeled internal flag for \"this specific\n",[33,234,235],{"class":35,"line":43},[33,236,237],{"class":39},"# claim is a hallucination\" that this instruction could suppress. Asking it not to\n",[33,239,240],{"class":35,"line":49},[33,241,242],{"class":39},"# hallucinate is asking it to distinguish confident-recall from plausible-generation\n",[33,244,245],{"class":35,"line":55},[33,246,247],{"class":39},"# at the moment of production — when both processes look identical from the inside.\n",[33,249,250],{"class":35,"line":61},[33,251,52],{"class":39},[33,253,254],{"class":35,"line":67},[33,255,256],{"class":39},"# It's like telling someone \"don't misremember things\" — well-intentioned but gives\n",[33,258,259],{"class":35,"line":73},[33,260,261],{"class":39},"# no new capability to act on.\n",[33,263,264],{"class":35,"line":78},[33,265,52],{"class":39},[33,267,268],{"class":35,"line":84},[33,269,270],{"class":39},"# What ACTUALLY helps:\n",[33,272,273],{"class":35,"line":90},[33,274,275],{"class":39},"# 1. Give the model an explicit, low-cost way to express PARTIAL confidence\n",[33,277,278],{"class":35,"line":97},[33,279,280],{"class":39},"# 2. Force it to ground claims in provided material rather than parametric memory\n",[33,282,283],{"class":35,"line":103},[33,284,285],{"class":39},"# 3. Structure the task so fabrication has a clear, nameable ALTERNATIVE\n",[14,287,289],{"id":288},"prompting-for-calibrated-uncertainty","Prompting for Calibrated Uncertainty",[19,291,293],{"filename":292,"language":203},"calibrated_uncertainty.md",[24,294,296],{"className":206,"code":295,"language":203,"meta":28,"style":28},"For each claim in your answer, tag it with your confidence:\n[HIGH] — you're confident this is accurate based on well-established\n  information.\n[MEDIUM] — you believe this is likely correct but it's the kind of\n  detail (exact date, exact figure, niche fact) where you could be wrong.\n[LOW] — you're genuinely unsure and are providing your best guess; flag\n  it clearly as such rather than stating it plainly.\n\nIf you cannot support a claim at even LOW confidence, state that you\ndon't know rather than guessing.\n",[30,297,298,303,315,320,330,335,345,350,354,359],{"__ignoreMap":28},[33,299,300],{"class":35,"line":36},[33,301,302],{"class":120},"For each claim in your answer, tag it with your confidence:\n",[33,304,305,308,312],{"class":35,"line":43},[33,306,307],{"class":120},"[",[33,309,311],{"class":310},"sSQSC","HIGH",[33,313,314],{"class":120},"] — you're confident this is accurate based on well-established\n",[33,316,317],{"class":35,"line":49},[33,318,319],{"class":120},"  information.\n",[33,321,322,324,327],{"class":35,"line":55},[33,323,307],{"class":120},[33,325,326],{"class":310},"MEDIUM",[33,328,329],{"class":120},"] — you believe this is likely correct but it's the kind of\n",[33,331,332],{"class":35,"line":61},[33,333,334],{"class":120},"  detail (exact date, exact figure, niche fact) where you could be wrong.\n",[33,336,337,339,342],{"class":35,"line":67},[33,338,307],{"class":120},[33,340,341],{"class":310},"LOW",[33,343,344],{"class":120},"] — you're genuinely unsure and are providing your best guess; flag\n",[33,346,347],{"class":35,"line":73},[33,348,349],{"class":120},"  it clearly as such rather than stating it plainly.\n",[33,351,352],{"class":35,"line":78},[33,353,94],{"emptyLinePlaceholder":93},[33,355,356],{"class":35,"line":84},[33,357,358],{"class":120},"If you cannot support a claim at even LOW confidence, state that you\n",[33,360,361],{"class":35,"line":90},[33,362,363],{"class":120},"don't know rather than guessing.\n",[19,365,367],{"filename":366,"language":203},"calibrated_output_example.md",[24,368,370],{"className":206,"code":369,"language":203,"meta":28,"style":28},"The company was founded in 2014 [HIGH]. Its headquarters moved to Austin\nsometime around 2019 [MEDIUM] — I recall this but am not fully certain\nof the exact year. I don't have reliable information on its current\nemployee count [LOW\u002FUNKNOWN] and would recommend checking a current\nsource rather than relying on my answer for that figure.\n",[30,371,372,382,392,397,408],{"__ignoreMap":28},[33,373,374,377,379],{"class":35,"line":36},[33,375,376],{"class":120},"The company was founded in 2014 [",[33,378,311],{"class":310},[33,380,381],{"class":120},"]. Its headquarters moved to Austin\n",[33,383,384,387,389],{"class":35,"line":43},[33,385,386],{"class":120},"sometime around 2019 [",[33,388,326],{"class":310},[33,390,391],{"class":120},"] — I recall this but am not fully certain\n",[33,393,394],{"class":35,"line":49},[33,395,396],{"class":120},"of the exact year. I don't have reliable information on its current\n",[33,398,399,402,405],{"class":35,"line":55},[33,400,401],{"class":120},"employee count [",[33,403,404],{"class":310},"LOW\u002FUNKNOWN",[33,406,407],{"class":120},"] and would recommend checking a current\n",[33,409,410],{"class":35,"line":61},[33,411,412],{"class":120},"source rather than relying on my answer for that figure.\n",[19,414,416],{"filename":415,"language":22},"calibration_principle.py",[24,417,419],{"className":26,"code":418,"language":22,"meta":28,"style":28},"# This works because it changes the RESPONSE SHAPE the model is optimizing toward.\n# A flat, uniformly confident answer is no longer the only available shape.\n# The explicit tagging format gives the model a concrete, low-friction way to\n# express graded confidence instead of forcing an all-or-nothing choice.\n#\n# This is the same principle as Chapter 7: the model produces what the format\n# makes EASY to produce. A format with no slot for \"I'm not sure\" tends to\n# produce full confidence even when unwarranted, purely because there's nowhere\n# else for the uncertainty to go.\n",[30,420,421,426,431,436,441,445,450,455,460],{"__ignoreMap":28},[33,422,423],{"class":35,"line":36},[33,424,425],{"class":39},"# This works because it changes the RESPONSE SHAPE the model is optimizing toward.\n",[33,427,428],{"class":35,"line":43},[33,429,430],{"class":39},"# A flat, uniformly confident answer is no longer the only available shape.\n",[33,432,433],{"class":35,"line":49},[33,434,435],{"class":39},"# The explicit tagging format gives the model a concrete, low-friction way to\n",[33,437,438],{"class":35,"line":55},[33,439,440],{"class":39},"# express graded confidence instead of forcing an all-or-nothing choice.\n",[33,442,443],{"class":35,"line":61},[33,444,52],{"class":39},[33,446,447],{"class":35,"line":67},[33,448,449],{"class":39},"# This is the same principle as Chapter 7: the model produces what the format\n",[33,451,452],{"class":35,"line":73},[33,453,454],{"class":39},"# makes EASY to produce. A format with no slot for \"I'm not sure\" tends to\n",[33,456,457],{"class":35,"line":78},[33,458,459],{"class":39},"# produce full confidence even when unwarranted, purely because there's nowhere\n",[33,461,462],{"class":35,"line":84},[33,463,464],{"class":39},"# else for the uncertainty to go.\n",[14,466,468],{"id":467},"grounding-requiring-citations-to-provided-material","Grounding: Requiring Citations to Provided Material",[19,470,472],{"filename":471,"language":203},"grounding_prompt.md",[24,473,475],{"className":206,"code":474,"language":203,"meta":28,"style":28},"Answer the question using only the information in the \u003Csources>\nprovided below. For every factual claim in your answer, include a\ncitation in the form [source N] pointing to the specific source it came\nfrom. If the sources don't contain enough information to answer fully,\nsay so explicitly rather than filling the gap from general knowledge.\n\n\u003Csources>\n[source 1] {{retrieved document 1}}\n[source 2] {{retrieved document 2}}\n\u003C\u002Fsources>\n\nQuestion: {{user question}}\n",[30,476,477,482,487,492,497,502,506,511,516,521,526,530],{"__ignoreMap":28},[33,478,479],{"class":35,"line":36},[33,480,481],{"class":120},"Answer the question using only the information in the \u003Csources>\n",[33,483,484],{"class":35,"line":43},[33,485,486],{"class":120},"provided below. For every factual claim in your answer, include a\n",[33,488,489],{"class":35,"line":49},[33,490,491],{"class":120},"citation in the form [source N] pointing to the specific source it came\n",[33,493,494],{"class":35,"line":55},[33,495,496],{"class":120},"from. If the sources don't contain enough information to answer fully,\n",[33,498,499],{"class":35,"line":61},[33,500,501],{"class":120},"say so explicitly rather than filling the gap from general knowledge.\n",[33,503,504],{"class":35,"line":67},[33,505,94],{"emptyLinePlaceholder":93},[33,507,508],{"class":35,"line":73},[33,509,510],{"class":120},"\u003Csources>\n",[33,512,513],{"class":35,"line":78},[33,514,515],{"class":120},"[source 1] {{retrieved document 1}}\n",[33,517,518],{"class":35,"line":84},[33,519,520],{"class":120},"[source 2] {{retrieved document 2}}\n",[33,522,523],{"class":35,"line":90},[33,524,525],{"class":120},"\u003C\u002Fsources>\n",[33,527,528],{"class":35,"line":97},[33,529,94],{"emptyLinePlaceholder":93},[33,531,532],{"class":35,"line":103},[33,533,534],{"class":120},"Question: {{user question}}\n",[19,536,538],{"filename":537,"language":22},"grounding_principle.py",[24,539,541],{"className":26,"code":540,"language":22,"meta":28,"style":28},"# This is Chapter 12's RAG pattern, restated as a hallucination mitigation.\n# A model asked to FIND AND CITE SUPPORT for each claim behaves very differently\n# from one asked to RECALL AND STATE a fact from parametric memory.\n#\n# The former has a natural check: a claim that can't be traced to a citation is,\n# by the task's own rules, out of scope.\n# The latter has no equivalent built-in check.\n#\n# The citation requirement also gives YOU a cheap verification mechanism:\n# a human (or automated check) can spot-verify that a cited claim actually\n# appears in the referenced source — impossible against an uncited parametric claim.\n\n# GROUNDING IS NOT AIRTIGHT:\n# The model can still MISREAD or OVER-GENERALIZE from a real source — citing\n# source 2 for a claim source 2 doesn't quite support. A distinct failure mode\n# from pure fabrication, worth checking separately. \"It cited something\" ≠\n# \"the citation is accurate.\"\n",[30,542,543,548,553,558,562,567,572,577,581,586,591,596,600,605,610,615,620],{"__ignoreMap":28},[33,544,545],{"class":35,"line":36},[33,546,547],{"class":39},"# This is Chapter 12's RAG pattern, restated as a hallucination mitigation.\n",[33,549,550],{"class":35,"line":43},[33,551,552],{"class":39},"# A model asked to FIND AND CITE SUPPORT for each claim behaves very differently\n",[33,554,555],{"class":35,"line":49},[33,556,557],{"class":39},"# from one asked to RECALL AND STATE a fact from parametric memory.\n",[33,559,560],{"class":35,"line":55},[33,561,52],{"class":39},[33,563,564],{"class":35,"line":61},[33,565,566],{"class":39},"# The former has a natural check: a claim that can't be traced to a citation is,\n",[33,568,569],{"class":35,"line":67},[33,570,571],{"class":39},"# by the task's own rules, out of scope.\n",[33,573,574],{"class":35,"line":73},[33,575,576],{"class":39},"# The latter has no equivalent built-in check.\n",[33,578,579],{"class":35,"line":78},[33,580,52],{"class":39},[33,582,583],{"class":35,"line":84},[33,584,585],{"class":39},"# The citation requirement also gives YOU a cheap verification mechanism:\n",[33,587,588],{"class":35,"line":90},[33,589,590],{"class":39},"# a human (or automated check) can spot-verify that a cited claim actually\n",[33,592,593],{"class":35,"line":97},[33,594,595],{"class":39},"# appears in the referenced source — impossible against an uncited parametric claim.\n",[33,597,598],{"class":35,"line":103},[33,599,94],{"emptyLinePlaceholder":93},[33,601,602],{"class":35,"line":109},[33,603,604],{"class":39},"# GROUNDING IS NOT AIRTIGHT:\n",[33,606,607],{"class":35,"line":124},[33,608,609],{"class":39},"# The model can still MISREAD or OVER-GENERALIZE from a real source — citing\n",[33,611,612],{"class":35,"line":140},[33,613,614],{"class":39},"# source 2 for a claim source 2 doesn't quite support. A distinct failure mode\n",[33,616,617],{"class":35,"line":153},[33,618,619],{"class":39},"# from pure fabrication, worth checking separately. \"It cited something\" ≠\n",[33,621,622],{"class":35,"line":166},[33,623,624],{"class":39},"# \"the citation is accurate.\"\n",[14,626,628],{"id":627},"explicitly-permitting-i-dont-know","Explicitly Permitting \"I Don't Know\"",[19,630,632],{"filename":631,"language":203},"i_dont_know_permission.md",[24,633,635],{"className":206,"code":634,"language":203,"meta":28,"style":28},"It's fine, and expected, for you to not know the answer to some\nquestions — especially ones about recent events, niche technical\ndetails, or exact figures. Saying \"I don't know\" or \"I'm not sure, but\nhere's my best guess\" is a better answer than a confident-sounding guess\npresented as fact. You will not be penalized for expressing uncertainty\nor declining to answer.\n",[30,636,637,642,647,652,657,662],{"__ignoreMap":28},[33,638,639],{"class":35,"line":36},[33,640,641],{"class":120},"It's fine, and expected, for you to not know the answer to some\n",[33,643,644],{"class":35,"line":43},[33,645,646],{"class":120},"questions — especially ones about recent events, niche technical\n",[33,648,649],{"class":35,"line":49},[33,650,651],{"class":120},"details, or exact figures. Saying \"I don't know\" or \"I'm not sure, but\n",[33,653,654],{"class":35,"line":55},[33,655,656],{"class":120},"here's my best guess\" is a better answer than a confident-sounding guess\n",[33,658,659],{"class":35,"line":61},[33,660,661],{"class":120},"presented as fact. You will not be penalized for expressing uncertainty\n",[33,663,664],{"class":35,"line":67},[33,665,666],{"class":120},"or declining to answer.\n",[19,668,670],{"filename":669,"language":22},"why_permission_matters.py",[24,671,673],{"className":26,"code":672,"language":22,"meta":28,"style":28},"# WHY THIS MATTERS: a model's default behavior, absent this permission, skews\n# toward attempting a complete, confident-sounding answer. Plausibly because\n# training data consists mostly of people writing confidently (Q&A content,\n# reference material, technical docs rarely model someone saying \"I don't know\"\n# mid-explanation). A fluent complete-sounding answer is a more statistically\n# typical continuation than an honest hedge.\n#\n# Explicitly telling the model that hedging\u002Fdeclining is acceptable and rewarded\n# counteracts that default directly — same way confidence-tagging gives uncertainty\n# a concrete place to go rather than a flat \"answer or don't\" binary.\n",[30,674,675,680,685,690,695,700,705,709,714,719],{"__ignoreMap":28},[33,676,677],{"class":35,"line":36},[33,678,679],{"class":39},"# WHY THIS MATTERS: a model's default behavior, absent this permission, skews\n",[33,681,682],{"class":35,"line":43},[33,683,684],{"class":39},"# toward attempting a complete, confident-sounding answer. Plausibly because\n",[33,686,687],{"class":35,"line":49},[33,688,689],{"class":39},"# training data consists mostly of people writing confidently (Q&A content,\n",[33,691,692],{"class":35,"line":55},[33,693,694],{"class":39},"# reference material, technical docs rarely model someone saying \"I don't know\"\n",[33,696,697],{"class":35,"line":61},[33,698,699],{"class":39},"# mid-explanation). A fluent complete-sounding answer is a more statistically\n",[33,701,702],{"class":35,"line":67},[33,703,704],{"class":39},"# typical continuation than an honest hedge.\n",[33,706,707],{"class":35,"line":73},[33,708,52],{"class":39},[33,710,711],{"class":35,"line":78},[33,712,713],{"class":39},"# Explicitly telling the model that hedging\u002Fdeclining is acceptable and rewarded\n",[33,715,716],{"class":35,"line":84},[33,717,718],{"class":39},"# counteracts that default directly — same way confidence-tagging gives uncertainty\n",[33,720,721],{"class":35,"line":90},[33,722,723],{"class":39},"# a concrete place to go rather than a flat \"answer or don't\" binary.\n",[14,725,727],{"id":726},"self-review-for-risky-claims","Self-Review for Risky Claims",[19,729,731],{"filename":730,"language":203},"self_review_prompt.md",[24,732,734],{"className":206,"code":733,"language":203,"meta":28,"style":28},"Review the answer you just gave. Identify any specific factual claims —\nnames, dates, statistics, exact quotations, citations — that you are\nnot highly confident are accurate. List them separately, and for each,\nstate whether you'd recommend the reader independently verify it before\nrelying on it.\n",[30,735,736,741,746,751,756],{"__ignoreMap":28},[33,737,738],{"class":35,"line":36},[33,739,740],{"class":120},"Review the answer you just gave. Identify any specific factual claims —\n",[33,742,743],{"class":35,"line":43},[33,744,745],{"class":120},"names, dates, statistics, exact quotations, citations — that you are\n",[33,747,748],{"class":35,"line":49},[33,749,750],{"class":120},"not highly confident are accurate. List them separately, and for each,\n",[33,752,753],{"class":35,"line":55},[33,754,755],{"class":120},"state whether you'd recommend the reader independently verify it before\n",[33,757,758],{"class":35,"line":61},[33,759,760],{"class":120},"relying on it.\n",[19,762,764],{"filename":763,"language":22},"self_review_limits.py",[24,765,767],{"className":26,"code":766,"language":22,"meta":28,"style":28},"# This is Chapter 11's self-verification applied specifically to hallucination.\n# It inherits the SAME limitation: a model reviewing its own output uses the same\n# underlying judgment that produced the (possibly wrong) claim.\n#\n# It catches genuinely useful cases (the model has latent signal that a particular\n# claim was shakier) without being a reliable universal detector.\n# Treat \"no risky claims found\" as WEAK EVIDENCE, not proof of accuracy.\n# Especially for claims your eval process (Chapter 19) considers high-stakes.\n",[30,768,769,774,779,784,788,793,798,803],{"__ignoreMap":28},[33,770,771],{"class":35,"line":36},[33,772,773],{"class":39},"# This is Chapter 11's self-verification applied specifically to hallucination.\n",[33,775,776],{"class":35,"line":43},[33,777,778],{"class":39},"# It inherits the SAME limitation: a model reviewing its own output uses the same\n",[33,780,781],{"class":35,"line":49},[33,782,783],{"class":39},"# underlying judgment that produced the (possibly wrong) claim.\n",[33,785,786],{"class":35,"line":55},[33,787,52],{"class":39},[33,789,790],{"class":35,"line":61},[33,791,792],{"class":39},"# It catches genuinely useful cases (the model has latent signal that a particular\n",[33,794,795],{"class":35,"line":67},[33,796,797],{"class":39},"# claim was shakier) without being a reliable universal detector.\n",[33,799,800],{"class":35,"line":73},[33,801,802],{"class":39},"# Treat \"no risky claims found\" as WEAK EVIDENCE, not proof of accuracy.\n",[33,804,805],{"class":35,"line":78},[33,806,807],{"class":39},"# Especially for claims your eval process (Chapter 19) considers high-stakes.\n",[14,809,811],{"id":810},"domain-specific-risk-table","Domain-Specific Risk Table",[19,813,815],{"filename":814,"language":203},"risk_table.md",[24,816,818],{"className":206,"code":817,"language":203,"meta":28,"style":28},"| Task type                    | Why risk is elevated                              | Mitigation                                      |\n|------------------------------|---------------------------------------------------|-------------------------------------------------|\n| Citations \u002F bibliographic    | Exact titles, authors, years are high-precision   | Require retrieval\u002Fgrounding; never trust        |\n|                              | low-redundancy facts                              | unverified generated citations                  |\n| Legal case names \u002F statutes  | Same precision problem, high real-world stakes    | Ground in actual legal database; treat any      |\n|                              |                                                   | unverified citation as provisional              |\n| Version-specific APIs        | Training data mixes library versions; model can   | Ground in current, version-specific docs        |\n|                              | blend details across versions that never coexisted| rather than memory                              |\n| Numerical statistics         | Exact numbers rarely memorized precisely;         | Require cited source for any number that        |\n|                              | plausible-sounding wrong number is common         | matters, or compute via tool (Chapter 13)       |\n| Recent events past cutoff    | Information may not exist in training data at all | Explicit \"if after your knowledge cutoff, say   |\n|                              |                                                   | so\" instruction, or retrieval                   |\n",[30,819,820,825,830,835,840,845,850,855,860,865,870,875],{"__ignoreMap":28},[33,821,822],{"class":35,"line":36},[33,823,824],{"class":120},"| Task type                    | Why risk is elevated                              | Mitigation                                      |\n",[33,826,827],{"class":35,"line":43},[33,828,829],{"class":120},"|------------------------------|---------------------------------------------------|-------------------------------------------------|\n",[33,831,832],{"class":35,"line":49},[33,833,834],{"class":120},"| Citations \u002F bibliographic    | Exact titles, authors, years are high-precision   | Require retrieval\u002Fgrounding; never trust        |\n",[33,836,837],{"class":35,"line":55},[33,838,839],{"class":120},"|                              | low-redundancy facts                              | unverified generated citations                  |\n",[33,841,842],{"class":35,"line":61},[33,843,844],{"class":120},"| Legal case names \u002F statutes  | Same precision problem, high real-world stakes    | Ground in actual legal database; treat any      |\n",[33,846,847],{"class":35,"line":67},[33,848,849],{"class":120},"|                              |                                                   | unverified citation as provisional              |\n",[33,851,852],{"class":35,"line":73},[33,853,854],{"class":120},"| Version-specific APIs        | Training data mixes library versions; model can   | Ground in current, version-specific docs        |\n",[33,856,857],{"class":35,"line":78},[33,858,859],{"class":120},"|                              | blend details across versions that never coexisted| rather than memory                              |\n",[33,861,862],{"class":35,"line":84},[33,863,864],{"class":120},"| Numerical statistics         | Exact numbers rarely memorized precisely;         | Require cited source for any number that        |\n",[33,866,867],{"class":35,"line":90},[33,868,869],{"class":120},"|                              | plausible-sounding wrong number is common         | matters, or compute via tool (Chapter 13)       |\n",[33,871,872],{"class":35,"line":97},[33,873,874],{"class":120},"| Recent events past cutoff    | Information may not exist in training data at all | Explicit \"if after your knowledge cutoff, say   |\n",[33,876,877],{"class":35,"line":103},[33,878,879],{"class":120},"|                              |                                                   | so\" instruction, or retrieval                   |\n",[14,881,883],{"id":882},"tips-tricks","💡 Tips & Tricks",[19,885,887],{"filename":886,"language":22},"tips.py",[24,888,890],{"className":26,"code":889,"language":22,"meta":28,"style":28},"# [Debug] When you suspect a hallucinated fact, ask the model directly in a fresh\n# turn: \"how confident are you in that specific claim, and why?\" Sometimes surfaces\n# a hedge the original answer didn't include — but not reliably.\n\n# [Idiom] Pair uncertainty-tagging with a short explanation of WHY a claim is\n# tagged at a given level, not just the tag alone. The explanation is a useful\n# signal to a human reviewer and tends to make the tagging itself more careful.\n\n# [Performance] For any task where factual precision matters, grounding (Chapter 12)\n# is a far higher-leverage investment than prompt wording alone. A well-grounded\n# prompt with mediocre wording beats a beautifully-worded ungrounded prompt.\n\n# [Idiom] Explicitly separate \"creative\" and \"factual\" sections when a task mixes\n# both: \"write a product description, but the specifications must exactly match\n# the provided spec sheet.\" An unmarked mix is a common source of creative-writing-\n# style embellishment applied to the factual part.\n\n# [Safety] Log which claims were grounded (cited) vs ungrounded (parametric) for\n# any hallucination-sensitive production feature. Cheap to compute at generation\n# time, expensive to reconstruct after the fact if a claim causes a problem.\n",[30,891,892,897,902,907,911,916,921,926,930,935,940,945,949,954,959,964,969,973,978,983],{"__ignoreMap":28},[33,893,894],{"class":35,"line":36},[33,895,896],{"class":39},"# [Debug] When you suspect a hallucinated fact, ask the model directly in a fresh\n",[33,898,899],{"class":35,"line":43},[33,900,901],{"class":39},"# turn: \"how confident are you in that specific claim, and why?\" Sometimes surfaces\n",[33,903,904],{"class":35,"line":49},[33,905,906],{"class":39},"# a hedge the original answer didn't include — but not reliably.\n",[33,908,909],{"class":35,"line":55},[33,910,94],{"emptyLinePlaceholder":93},[33,912,913],{"class":35,"line":61},[33,914,915],{"class":39},"# [Idiom] Pair uncertainty-tagging with a short explanation of WHY a claim is\n",[33,917,918],{"class":35,"line":67},[33,919,920],{"class":39},"# tagged at a given level, not just the tag alone. The explanation is a useful\n",[33,922,923],{"class":35,"line":73},[33,924,925],{"class":39},"# signal to a human reviewer and tends to make the tagging itself more careful.\n",[33,927,928],{"class":35,"line":78},[33,929,94],{"emptyLinePlaceholder":93},[33,931,932],{"class":35,"line":84},[33,933,934],{"class":39},"# [Performance] For any task where factual precision matters, grounding (Chapter 12)\n",[33,936,937],{"class":35,"line":90},[33,938,939],{"class":39},"# is a far higher-leverage investment than prompt wording alone. A well-grounded\n",[33,941,942],{"class":35,"line":97},[33,943,944],{"class":39},"# prompt with mediocre wording beats a beautifully-worded ungrounded prompt.\n",[33,946,947],{"class":35,"line":103},[33,948,94],{"emptyLinePlaceholder":93},[33,950,951],{"class":35,"line":109},[33,952,953],{"class":39},"# [Idiom] Explicitly separate \"creative\" and \"factual\" sections when a task mixes\n",[33,955,956],{"class":35,"line":124},[33,957,958],{"class":39},"# both: \"write a product description, but the specifications must exactly match\n",[33,960,961],{"class":35,"line":140},[33,962,963],{"class":39},"# the provided spec sheet.\" An unmarked mix is a common source of creative-writing-\n",[33,965,966],{"class":35,"line":153},[33,967,968],{"class":39},"# style embellishment applied to the factual part.\n",[33,970,971],{"class":35,"line":166},[33,972,94],{"emptyLinePlaceholder":93},[33,974,975],{"class":35,"line":179},[33,976,977],{"class":39},"# [Safety] Log which claims were grounded (cited) vs ungrounded (parametric) for\n",[33,979,980],{"class":35,"line":192},[33,981,982],{"class":39},"# any hallucination-sensitive production feature. Cheap to compute at generation\n",[33,984,986],{"class":35,"line":985},20,[33,987,988],{"class":39},"# time, expensive to reconstruct after the fact if a claim causes a problem.\n",[14,990,992],{"id":991},"️-edge-cases-gotchas","⚠️ Edge Cases & Gotchas",[19,994,996],{"filename":995,"language":22},"edge_cases.py",[24,997,999],{"className":26,"code":998,"language":22,"meta":28,"style":28},"# [Gotcha] A confidently-worded REFUSAL is not the same as accurate uncertainty\n# signal. A model can hedge on a CORRECT answer just as easily as confidently\n# state a wrong one. Over-cautious hedging is miscalibrated in the opposite\n# direction, with real costs (user ignores a correct answer because it was\n# needlessly hedged).\n\n# [Gotcha] Grounding fails silently when retrieved sources themselves are wrong,\n# outdated, or irrelevant. A model faithfully citing a real but incorrect source\n# produces an answer that looks maximally trustworthy while still being wrong.\n# Citation presence ≠ citation quality.\n\n# [Gotcha] Asking \"are you sure?\" REPEATEDLY can degrade a correct answer into an\n# incorrect hedge or reversal. A model pressed hard enough on a genuinely correct\n# claim can flip to a wrong one to satisfy apparent pressure. A single clearly-\n# scoped self-review is more reliable than repeated adversarial pressure.\n\n# [Gotcha] A model can hallucinate the CITATION FORMAT itself, not just the fact.\n# Producing a citation that looks structurally correct (plausible journal name,\n# year, page numbers) but points to a source that doesn't exist — more dangerous\n# than an obviously-fabricated fact because the surface plausibility invites less\n# scrutiny, not more.\n\n# [Gotcha] Uncertainty tags can become a ROTE FORMATTING EXERCISE rather than\n# genuine calibration. Watch for a suspiciously uniform distribution (everything\n# MEDIUM) as a sign tagging has become habit rather than judgment.\n",[30,1000,1001,1006,1011,1016,1021,1026,1030,1035,1040,1045,1050,1054,1059,1064,1069,1074,1078,1083,1088,1093,1098,1104,1109,1115,1121],{"__ignoreMap":28},[33,1002,1003],{"class":35,"line":36},[33,1004,1005],{"class":39},"# [Gotcha] A confidently-worded REFUSAL is not the same as accurate uncertainty\n",[33,1007,1008],{"class":35,"line":43},[33,1009,1010],{"class":39},"# signal. A model can hedge on a CORRECT answer just as easily as confidently\n",[33,1012,1013],{"class":35,"line":49},[33,1014,1015],{"class":39},"# state a wrong one. Over-cautious hedging is miscalibrated in the opposite\n",[33,1017,1018],{"class":35,"line":55},[33,1019,1020],{"class":39},"# direction, with real costs (user ignores a correct answer because it was\n",[33,1022,1023],{"class":35,"line":61},[33,1024,1025],{"class":39},"# needlessly hedged).\n",[33,1027,1028],{"class":35,"line":67},[33,1029,94],{"emptyLinePlaceholder":93},[33,1031,1032],{"class":35,"line":73},[33,1033,1034],{"class":39},"# [Gotcha] Grounding fails silently when retrieved sources themselves are wrong,\n",[33,1036,1037],{"class":35,"line":78},[33,1038,1039],{"class":39},"# outdated, or irrelevant. A model faithfully citing a real but incorrect source\n",[33,1041,1042],{"class":35,"line":84},[33,1043,1044],{"class":39},"# produces an answer that looks maximally trustworthy while still being wrong.\n",[33,1046,1047],{"class":35,"line":90},[33,1048,1049],{"class":39},"# Citation presence ≠ citation quality.\n",[33,1051,1052],{"class":35,"line":97},[33,1053,94],{"emptyLinePlaceholder":93},[33,1055,1056],{"class":35,"line":103},[33,1057,1058],{"class":39},"# [Gotcha] Asking \"are you sure?\" REPEATEDLY can degrade a correct answer into an\n",[33,1060,1061],{"class":35,"line":109},[33,1062,1063],{"class":39},"# incorrect hedge or reversal. A model pressed hard enough on a genuinely correct\n",[33,1065,1066],{"class":35,"line":124},[33,1067,1068],{"class":39},"# claim can flip to a wrong one to satisfy apparent pressure. A single clearly-\n",[33,1070,1071],{"class":35,"line":140},[33,1072,1073],{"class":39},"# scoped self-review is more reliable than repeated adversarial pressure.\n",[33,1075,1076],{"class":35,"line":153},[33,1077,94],{"emptyLinePlaceholder":93},[33,1079,1080],{"class":35,"line":166},[33,1081,1082],{"class":39},"# [Gotcha] A model can hallucinate the CITATION FORMAT itself, not just the fact.\n",[33,1084,1085],{"class":35,"line":179},[33,1086,1087],{"class":39},"# Producing a citation that looks structurally correct (plausible journal name,\n",[33,1089,1090],{"class":35,"line":192},[33,1091,1092],{"class":39},"# year, page numbers) but points to a source that doesn't exist — more dangerous\n",[33,1094,1095],{"class":35,"line":985},[33,1096,1097],{"class":39},"# than an obviously-fabricated fact because the surface plausibility invites less\n",[33,1099,1101],{"class":35,"line":1100},21,[33,1102,1103],{"class":39},"# scrutiny, not more.\n",[33,1105,1107],{"class":35,"line":1106},22,[33,1108,94],{"emptyLinePlaceholder":93},[33,1110,1112],{"class":35,"line":1111},23,[33,1113,1114],{"class":39},"# [Gotcha] Uncertainty tags can become a ROTE FORMATTING EXERCISE rather than\n",[33,1116,1118],{"class":35,"line":1117},24,[33,1119,1120],{"class":39},"# genuine calibration. Watch for a suspiciously uniform distribution (everything\n",[33,1122,1124],{"class":35,"line":1123},25,[33,1125,1126],{"class":39},"# MEDIUM) as a sign tagging has become habit rather than judgment.\n",[14,1128,1130],{"id":1129},"spot-the-bug","🧠 Spot the Bug",[19,1132,1134],{"filename":1133,"language":203},"spot_the_bug.md",[24,1135,1137],{"className":206,"code":1136,"language":203,"meta":28,"style":28},"Answer the user's question. Be accurate and don't make anything up. If\nyou're not sure, use your best judgment to give the most likely correct\nanswer anyway, since an incomplete answer is not helpful to the user.\n\nQuestion: What was the exact vote count in the {{obscure 1970s local\nelection}}?\n",[30,1138,1139,1144,1149,1154,1158,1163],{"__ignoreMap":28},[33,1140,1141],{"class":35,"line":36},[33,1142,1143],{"class":120},"Answer the user's question. Be accurate and don't make anything up. If\n",[33,1145,1146],{"class":35,"line":43},[33,1147,1148],{"class":120},"you're not sure, use your best judgment to give the most likely correct\n",[33,1150,1151],{"class":35,"line":49},[33,1152,1153],{"class":120},"answer anyway, since an incomplete answer is not helpful to the user.\n",[33,1155,1156],{"class":35,"line":55},[33,1157,94],{"emptyLinePlaceholder":93},[33,1159,1160],{"class":35,"line":61},[33,1161,1162],{"class":120},"Question: What was the exact vote count in the {{obscure 1970s local\n",[33,1164,1165],{"class":35,"line":67},[33,1166,1167],{"class":120},"election}}?\n",[1169,1170,1171,1175,1184,1187],"details",{},[1172,1173,1174],"summary",{},"Answer",[1176,1177,1178,1179,1183],"p",{},"The instruction directly undermines its own stated goal. \"Don't make anything up\" is immediately followed by \"if you're not sure, give the most likely correct answer anyway\" — which is an explicit instruction to ",[1180,1181,1182],"strong",{},"fabricate a plausible-sounding guess"," rather than disclose uncertainty, for exactly the category of fact (obscure, low-redundancy, highly specific historical statistic) most likely to be outside reliable parametric memory.",[1176,1185,1186],{},"This is the naive \"don't hallucinate\" instruction made actively WORSE by then explicitly authorizing a confident guess as the fallback. The fix removes the contradiction and replaces \"guess anyway\" with explicit permission to express uncertainty: \"Saying 'I don't have reliable information on this and would be guessing if I gave you a specific number' is a better answer than a confident guess.\" If precision matters, ground the question in an actual source (archived election record, retrieval tool).",[1176,1188,1189],{},"The lesson: an instruction that says \"don't hallucinate\" but then tells the model to answer confidently anyway when uncertain is not a hallucination mitigation — it's an explicit request for one, dressed up in language that sounds like the opposite.",[14,1191,1193],{"id":1192},"key-takeaways","Key Takeaways",[19,1195,1197],{"filename":1196,"language":22},"key_takeaways.py",[24,1198,1200],{"className":26,"code":1199,"language":22,"meta":28,"style":28},"\"\"\"\nHandling hallucination & uncertainty.\n\"\"\"\n\n# 1. Hallucination is an EXPECTED consequence of how LLMs generate text, not a\n#    malfunction. Fluency and confidence-sounding are properties of generation,\n#    not signals the model tracks about truthfulness. \"Just don't hallucinate\"\n#    is weak — the model can't distinguish confident-recall from plausible-generation.\n\n# 2. Prompting can change BEHAVIOR at the boundary of knowledge (hedging, citing,\n#    declining) but CANNOT make parametric knowledge more accurate. Grounding in\n#    retrieved sources (Chapter 12) is the strongest lever, not clever wording.\n\n# 3. Give uncertainty a concrete place to go: confidence tagging, citation\n#    requirements, plain permission to say \"I don't know.\" A format with no slot\n#    for uncertainty tends to produce full confidence even when unwarranted.\n\n# 4. Grounding requires claims traceable to provided sources → checkable by humans\n#    and automated groundedness checks. But a faithfully-cited WRONG source still\n#    produces a wrong answer. Citation presence ≠ citation quality.\n\n# 5. Precision-heavy, low-redundancy tasks (citations, exact statistics, version-\n#    specific APIs, recent events) carry structurally elevated risk regardless of\n#    prompt quality. Default to retrieval or tool-based grounding, not parametric recall.\n",[30,1201,1202,1207,1212,1216,1220,1225,1230,1235,1240,1244,1249,1254,1259,1263,1268,1273,1278,1282,1287,1292,1297,1301,1306,1311],{"__ignoreMap":28},[33,1203,1204],{"class":35,"line":36},[33,1205,1206],{"class":127},"\"\"\"\n",[33,1208,1209],{"class":35,"line":43},[33,1210,1211],{"class":127},"Handling hallucination & uncertainty.\n",[33,1213,1214],{"class":35,"line":49},[33,1215,1206],{"class":127},[33,1217,1218],{"class":35,"line":55},[33,1219,94],{"emptyLinePlaceholder":93},[33,1221,1222],{"class":35,"line":61},[33,1223,1224],{"class":39},"# 1. Hallucination is an EXPECTED consequence of how LLMs generate text, not a\n",[33,1226,1227],{"class":35,"line":67},[33,1228,1229],{"class":39},"#    malfunction. Fluency and confidence-sounding are properties of generation,\n",[33,1231,1232],{"class":35,"line":73},[33,1233,1234],{"class":39},"#    not signals the model tracks about truthfulness. \"Just don't hallucinate\"\n",[33,1236,1237],{"class":35,"line":78},[33,1238,1239],{"class":39},"#    is weak — the model can't distinguish confident-recall from plausible-generation.\n",[33,1241,1242],{"class":35,"line":84},[33,1243,94],{"emptyLinePlaceholder":93},[33,1245,1246],{"class":35,"line":90},[33,1247,1248],{"class":39},"# 2. Prompting can change BEHAVIOR at the boundary of knowledge (hedging, citing,\n",[33,1250,1251],{"class":35,"line":97},[33,1252,1253],{"class":39},"#    declining) but CANNOT make parametric knowledge more accurate. Grounding in\n",[33,1255,1256],{"class":35,"line":103},[33,1257,1258],{"class":39},"#    retrieved sources (Chapter 12) is the strongest lever, not clever wording.\n",[33,1260,1261],{"class":35,"line":109},[33,1262,94],{"emptyLinePlaceholder":93},[33,1264,1265],{"class":35,"line":124},[33,1266,1267],{"class":39},"# 3. Give uncertainty a concrete place to go: confidence tagging, citation\n",[33,1269,1270],{"class":35,"line":140},[33,1271,1272],{"class":39},"#    requirements, plain permission to say \"I don't know.\" A format with no slot\n",[33,1274,1275],{"class":35,"line":153},[33,1276,1277],{"class":39},"#    for uncertainty tends to produce full confidence even when unwarranted.\n",[33,1279,1280],{"class":35,"line":166},[33,1281,94],{"emptyLinePlaceholder":93},[33,1283,1284],{"class":35,"line":179},[33,1285,1286],{"class":39},"# 4. Grounding requires claims traceable to provided sources → checkable by humans\n",[33,1288,1289],{"class":35,"line":192},[33,1290,1291],{"class":39},"#    and automated groundedness checks. But a faithfully-cited WRONG source still\n",[33,1293,1294],{"class":35,"line":985},[33,1295,1296],{"class":39},"#    produces a wrong answer. Citation presence ≠ citation quality.\n",[33,1298,1299],{"class":35,"line":1100},[33,1300,94],{"emptyLinePlaceholder":93},[33,1302,1303],{"class":35,"line":1106},[33,1304,1305],{"class":39},"# 5. Precision-heavy, low-redundancy tasks (citations, exact statistics, version-\n",[33,1307,1308],{"class":35,"line":1111},[33,1309,1310],{"class":39},"#    specific APIs, recent events) carry structurally elevated risk regardless of\n",[33,1312,1313],{"class":35,"line":1117},[33,1314,1315],{"class":39},"#    prompt quality. Default to retrieval or tool-based grounding, not parametric recall.\n",[1317,1318,1319],"style",{},"html pre.shiki code .sdCPZ, html code.shiki .sdCPZ{--shiki-default:#6A737D;--shiki-github-dark:#6A737D}html pre.shiki code .snvgF, html code.shiki .snvgF{--shiki-default:#005CC5;--shiki-github-dark:#79B8FF}html pre.shiki code .svdQ7, html code.shiki .svdQ7{--shiki-default:#D73A49;--shiki-github-dark:#F97583}html pre.shiki code .ssxIu, html code.shiki .ssxIu{--shiki-default:#24292E;--shiki-github-dark:#E1E4E8}html pre.shiki code .sJ6F3, html code.shiki .sJ6F3{--shiki-default:#032F62;--shiki-github-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .github-dark .shiki span {color: var(--shiki-github-dark);background: var(--shiki-github-dark-bg);font-style: var(--shiki-github-dark-font-style);font-weight: var(--shiki-github-dark-font-weight);text-decoration: var(--shiki-github-dark-text-decoration);}html.github-dark .shiki span {color: var(--shiki-github-dark);background: var(--shiki-github-dark-bg);font-style: var(--shiki-github-dark-font-style);font-weight: var(--shiki-github-dark-font-weight);text-decoration: var(--shiki-github-dark-text-decoration);}html pre.shiki code .sSQSC, html code.shiki .sSQSC{--shiki-default:#032F62;--shiki-default-text-decoration:underline;--shiki-github-dark:#DBEDFF;--shiki-github-dark-text-decoration:underline}",{"title":28,"searchDepth":43,"depth":43,"links":1321},[1322,1323,1324,1325,1326,1327,1328,1329,1330,1331,1332],{"id":16,"depth":43,"text":17},{"id":198,"depth":43,"text":199},{"id":288,"depth":43,"text":289},{"id":467,"depth":43,"text":468},{"id":627,"depth":43,"text":628},{"id":726,"depth":43,"text":727},{"id":810,"depth":43,"text":811},{"id":882,"depth":43,"text":883},{"id":991,"depth":43,"text":992},{"id":1129,"depth":43,"text":1130},{"id":1192,"depth":43,"text":1193},"The mechanism of hallucination, calibrated uncertainty prompting, grounding with citations, explicit I-don't-know permission, self-review for risky claims, and domain-specific risk patterns. Code-first reference for mid-to-senior engineers.","md",{},"\u002Fprompt-engineering\u002F17-handling-hallucination-and-uncertainty",{"title":5,"description":1333},"prompt-engineering\u002F17-handling-hallucination-and-uncertainty","qYXHSWQgPIosApJPJg6zWfRVqdUtTACT3AGs7nW4pUw",1789924651096]