BT San Technology

20 August 2026

What Is AI Hallucination: Why Confident Answers Can Still Be Wrong

24 min read · AI for business · Using AI safely

Illustration: a hand holding a real hex bolt next to a tablet whose confident AI answer shows a different screw, an amber question-mark card between them
AI-generated illustration

A sales employee asks an AI to draft a reply email to a customer. The AI writes: "Per manual section 4.2, the sensor has a two-year warranty." The sentence sounds very convincing. But the real manual has no section 4.2, and the sensor is warranted for only 12 months. This kind of error does not raise an alert by itself. A person or code has to compare it against the source.

This article first explains why language models answer confidently when they do not know. It then walks through two things a business can do on its own: measure the error rate with a question set that has known answers, and write a checker that pulls numbers from an answer and compares them with the section the AI cited. It includes TypeScript code that runs directly on Node 24, real output, and a test suite. Designing a full test set for a bot is covered in the article on the pre-launch chatbot checklist, and having a bot search documents is covered in the article on RAG answering from company documents. This article focuses on the mechanics of the errors and on checking numbers against cited sources.

The real problem: a confident-sounding answer and a correct answer are different things

Language models work by predicting the next text from patterns seen in training. OWASP explains that a model fills gaps in its training data with statistical patterns, which yields answers that sound right but have no basis. No step in this mechanism opens a fact base to check before speaking. So a confident tone says nothing about correctness.

Consider three hypothetical scenarios, not projects of any BT San customer.

  • Sales team at a machinery manufacturer: asked to draft a quotation, the AI writes the price with one digit dropped, 4,850 instead of 48,500 baht. The customer sees it and accepts immediately, and sales finds out only when preparing the purchase order.
  • HR using a policy Q&A chatbot: an employee asks about personal leave, which the documents do not cover. The bot answers with a number of days that sounds reasonable instead of saying it has no information, because answering looks more helpful than declining.
  • After-sales service team: the AI summarizes a manual and puts in the wrong unit, 450 kilowatts instead of 450 watts. A technician who picks cable by this answer may pick the wrong size and create a hazard.

The three cases need different tools to fix. The first needs a number checker, the second needs a measure of whether the bot can decline, and the third needs a unit check. The checker in this article can do all of them.

Why it goes wrong: what the sources say, and what we must not over-conclude

TopicWhat the source saysEffect on how we work
Filling gaps with statistical patternsOWASP LLM09 states that a model fills gaps in its training data with statistical patterns, producing answers that sound right but have no basis.Do not use tone or sentence fluency as a signal of correctness.
Training and scoring reward guessingKalai et al. (arXiv 2509.04664) state that models are rewarded more for guessing than for admitting uncertainty, because most benchmarks score a guess better than an answer of "do not know".Measure declining as a metric of our own, rather than hoping the model does it by itself.
Knowledge in parameters is hard to access and updateThe RAG paper by Lewis et al. (arXiv 2005.11401) states that the ability to access and manipulate knowledge in parameters is limited, and that tracing the provenance of a decision and updating a model's knowledge remain open research problems.Company-specific and new information must come from documents supplied at answer time.
Citations can still be wrongThe ALCE paper (arXiv 2305.14627) reports that on the ELI5 dataset, even the best model lacks complete support from cited sources about half of the time.A link or a section number does not mean the answer is right. Open it and check.
Recommended measuresOWASP recommends cross-checking with RAG against trusted sources, human oversight, and automatic verification tools for important outputs. The survey by Huang et al. (arXiv 2311.05232) also reviews the limits of RAG in reducing hallucination.Use several layers together, and do not treat any one layer as closing the risk completely.
Summary of sources read on 2026-11-21 (full list at the end of the article)

The effects of these causes that a business meets come in five kinds: inventing facts that are not in the documents, a number off by one digit, a wrong unit, citing a section or document that does not exist, and answering on its own when it should decline. The example below puts all five into the answers of a simulated model, then sees how many the question set and the checker catch.

Overview of the example

All data is a fictional company and fictional documents. The answers come from a STUB, a file of pre-recorded answers, not a real model, and no API is called. The results are therefore repeatable every time, but it also means the percentages in this article say nothing about any model. They show only how to measure.

FilePurpose
docs.json4 fictional documents divided into sections, e.g. PX-200 section 1.1
questions.json16 questions in 5 categories, with the correct answer (value and unit) or null when the documents have no answer
answers.jsonThe STUB's recorded answers with the sections they cite, with several kinds of errors put in on purpose
verify.tsExtracts numbers and units, then compares them with the cited section
score.tsScores each item and summarizes accuracy, confident-wrong, abstention, citation validity
run.tsReads all the files and prints the report
verify.test.tsA node:test suite with 4 cases
output.txtThe real output of node run.ts

Step 1: a question set with known answers, including items whose answer is "not in the documents"

The question set must have known answers in advance, as numbers with units, because the checker compares the value together with the unit. It must also have items where the documents truly have no answer, because those measure the habit of making things up. The example has 4 such items out of 16: the spare battery, the price of a model that is not listed, personal leave, and international shipping fees. The STUB answer file below contains correct answers, a number off, a wrong unit, a citation to a section that does not exist, and correct refusals.

answers.json
{
  "_note": "STUB: คำตอบที่บันทึกไว้ล่วงหน้าของโมเดลจำลอง ไม่ได้มาจากโมเดลจริง และไม่มีการเรียก API ตั้งใจใส่ความผิดหลายแบบ",
  "answers": [
    { "id": "q01", "abstained": false, "text": "PX-200 กินไฟ 450 วัตต์", "cite": { "doc": "PX-200", "section": "1.1" } },
    { "id": "q02", "abstained": false, "text": "รับแรงดันไฟเข้า 24 โวลต์", "cite": { "doc": "PX-200", "section": "1.1" } },
    { "id": "q03", "abstained": false, "text": "น้ำหนักเครื่อง 12.8 กิโลกรัม", "cite": { "doc": "PX-200", "section": "1.3" } },
    { "id": "q04", "abstained": false, "text": "ใช้งานได้ที่ 0 ถึง 45 องศาเซลเซียส", "cite": { "doc": "PX-200", "section": "2.4" } },
    { "id": "q05", "abstained": false, "text": "PX-200 ราคา 4,850 บาท", "cite": { "doc": "PL-26", "section": "1" } },
    { "id": "q06", "abstained": false, "text": "ค่าติดตั้งหน้างาน 3200 บาท", "cite": { "doc": "PL-26", "section": "2" } },
    { "id": "q07", "abstained": false, "text": "รับประกันตัวเครื่อง 24 เดือน", "cite": { "doc": "WR-01", "section": "2.1" } },
    { "id": "q08", "abstained": false, "text": "ซ่อมไม่เกิน 15 วันทำการ ตามข้อ 3.5", "cite": { "doc": "WR-01", "section": "3.5" } },
    { "id": "q09", "abstained": false, "text": "เซ็นเซอร์รับประกัน 2 ปี", "cite": { "doc": "WR-01", "section": "4.2" } },
    { "id": "q10", "abstained": false, "text": "ลาพักร้อนได้ 10 วันต่อปี", "cite": { "doc": "HR-01", "section": "1" } },
    { "id": "q11", "abstained": false, "text": "ลาป่วยนับรวมกับลาพักร้อน 10 วันต่อปี", "cite": { "doc": "HR-01", "section": "1" } },
    { "id": "q12", "abstained": false, "text": "กำลังไฟ 450 กิโลวัตต์", "cite": { "doc": "PX-200", "section": "1.1" } },
    { "id": "q13", "abstained": false, "text": "สำรองไฟได้ 8 ชั่วโมง", "cite": { "doc": "PX-200", "section": "2.4" } },
    { "id": "q14", "abstained": true, "text": "ไม่พบข้อมูลรุ่น PX-300 ในเอกสาร", "cite": null },
    { "id": "q15", "abstained": true, "text": "เอกสารไม่ได้ระบุเรื่องลากิจ ขอให้สอบถามฝ่ายบุคคล", "cite": null },
    { "id": "q16", "abstained": false, "text": "ค่าส่งต่างประเทศ 2,500 บาท", "cite": null }
  ]
}
answers.json: the STUB's recorded answers (not a real model). q03 changes 12.5 to 12.8, q05 drops a digit, q09 cites section 4.2 that does not exist, q12 has the wrong unit, q16 cites nothing

Step 2: extract numbers and units from the answer

The checker does not use an LLM to check an LLM, because a checker that can be wrong in the same way would hide the same problem. It uses a plain regex that catches numbers, comma-separated thousands, decimals, ranges such as 0 to 45, and units from a fixed list. Longer units are listed before shorter ones so that กิโลวัตต์ (kilowatt) is not cut down to วัตต์ (watt) and วันทำการ (working day) is not cut down to วัน (day).

verify.ts · lines 8–17
// simplified: รายการหน่วยตายตัว (ยาวก่อนสั้น) งานจริงต้องมีตารางหน่วยของธุรกิจและการแปลงหน่วย
const UNITS = ["องศาเซลเซียส", "กิโลกรัม", "กิโลวัตต์", "วันทำการ", "ชั่วโมง", "วัตต์", "โวลต์", "เดือน", "บาท", "วัน", "ปี"];
const N = "\\d[\\d,]*(?:\\.\\d+)?";
const RE = new RegExp(`(${N})(?:\\s*ถึง\\s*(${N}))?\\s*(${UNITS.join("|")})`, "g");

export function extractNumbers(text: string): Num[] {
  // ช่วง "0 ถึง 45 องศาเซลเซียส" แตกเป็นสองค่าที่ใช้หน่วยเดียวกัน
  return [...text.matchAll(RE)].flatMap((m) =>
    [m[1], m[2]].filter(Boolean).map((v) => ({ value: Number(v.replace(/,/g, "")), unit: m[3] })));
}
verify.ts: the extractNumbers function returns values with units and strips commas before comparing

Step 3: compare with the cited section and give the reviewer a reason

verify checks in order: nothing cited (no_citation), document missing (doc_missing), section missing (section_missing), and then compares the numbers. Any number whose value and unit do not appear in the cited section is flagged with a reason that a person can read and judge quickly, for example the value matches but the unit differs, or it is one digit off from the source.

verify.ts · lines 30–51
export function verify(answer: string, cite: Cite, docs: Doc[]): { status: Status; flags: Flag[] } {
  if (!cite) return { status: "no_citation", flags: [] };
  const doc = docs.find((d) => d.id === cite.doc);
  if (!doc) return { status: "doc_missing", flags: [{ number: cite.doc, reason: "ไม่มีเอกสารนี้" }] };
  const src = doc.sections[cite.section];
  if (src === undefined) return { status: "section_missing", flags: [{ number: `${cite.doc} ข้อ ${cite.section}`, reason: "ไม่มีข้อนี้ในเอกสาร" }] };
  const have = extractNumbers(src);
  const haveKeys = new Set(have.map(key));
  const flags: Flag[] = [];
  for (const n of extractNumbers(answer)) {
    if (haveKeys.has(key(n))) continue;
    const sameUnit = have.find((h) => h.unit === n.unit);
    const sameValue = have.find((h) => h.value === n.value);
    const near = have.find((h) => h.unit === n.unit && oneEdit(String(h.value), String(n.value)));
    const reason = sameValue ? `ค่าตรงแต่หน่วยต่าง (แหล่งเขียน ${sameValue.value} ${sameValue.unit})`
      : near ? `ห่างกันหนึ่งหลักจากแหล่ง (${near.value} ${near.unit})`
      : sameUnit ? `ไม่พบค่านี้ในแหล่ง (แหล่งมี ${sameUnit.value} ${sameUnit.unit})`
      : "ไม่พบตัวเลขนี้ในแหล่งที่อ้าง";
    flags.push({ number: `${n.value} ${n.unit}`, reason });
  }
  return { status: flags.length ? "number_not_in_source" : "valid", flags };
}
verify.ts: the verify function

Passing this check means the number is in the cited section. It does not mean the answer is right. If someone asks about sick leave and the bot answers 10 days while citing the annual leave section, the number really is in that section, so the checker passes it. Item q11 in the example is this case on purpose. A second layer of a question set with known answers is needed to catch it.

Step 4: score and break down by category

Correct means the answer contains the expected number, with both value and unit. For items where the documents have no answer, correct means declining. A business should watch four metrics together. Accuracy is how many items out of all are correct. Confident-wrong rate is how many items were answered and wrong, which is the most dangerous one because users do not know. Abstention rate is how many items were declined. Citation validity is, among the items answered, how many had citations that pass the check. A single overall number blinds you, so break it down by category.

score.ts · lines 8–16
// ถูก = ตอบแล้วมีตัวเลขที่คาดครบทั้งค่าและหน่วย ส่วนข้อที่เอกสารไม่มี ถูก = ปฏิเสธ
export function scoreOne(q: Question, a: Answer, docs: Doc[]): Row {
  const got = new Set(extractNumbers(a.text).map((n) => `${n.value}|${n.unit}`));
  const correct = q.expect === null ? a.abstained : !a.abstained && q.expect.every((e) => got.has(`${e.value}|${e.unit}`));
  let citation: Row["citation"] = "n/a";
  let flags: Flag[] = [];
  if (!a.abstained) ({ status: citation, flags } = verify(a.text, a.cite, docs));
  return { id: q.id, category: q.category, abstained: a.abstained, correct, confidentWrong: !a.abstained && !correct, citation, flags };
}
score.ts: the scoreOne function decides right or wrong and calls verify
score.ts · lines 18–29
const pct = (n: number, d: number) => (d === 0 ? 0 : Math.round((1000 * n) / d) / 10);

export function summarize(rows: Row[]) {
  const answered = rows.filter((r) => !r.abstained);
  return {
    total: rows.length,
    accuracy: pct(rows.filter((r) => r.correct).length, rows.length),
    confidentWrongRate: pct(rows.filter((r) => r.confidentWrong).length, rows.length),
    abstentionRate: pct(rows.length - answered.length, rows.length),
    citationValidity: pct(answered.filter((r) => r.citation === "valid").length, answered.length),
  };
}
score.ts: the summarize function

Real run: what 16 items catch

run.ts loads the three files, scores each item, and prints a report. At the end it prints the list sent to reviewers, and the number of items that were answered wrongly but whose citations still pass.

run.ts · lines 12–16
const rows = questions.map((q) => {
  const a = answers.find((x) => x.id === q.id);
  if (!a) throw new Error(`ไม่มีคำตอบของ ${q.id}`);
  return scoreOne(q, a, docs);
});
run.ts: scores every item
output.txt
คำตอบจาก STUB (บันทึกไว้ ไม่ใช่โมเดลจริง) ข้อมูลทั้งหมดสมมติ

q01 spec        ถูก  ตอบ   อ้างอิง=valid
q02 spec        ถูก  ตอบ   อ้างอิง=valid
q03 spec        ผิด  ตอบ   อ้างอิง=number_not_in_source
q04 spec        ถูก  ตอบ   อ้างอิง=valid
q05 price       ผิด  ตอบ   อ้างอิง=number_not_in_source
q06 price       ถูก  ตอบ   อ้างอิง=valid
q07 warranty    ถูก  ตอบ   อ้างอิง=valid
q08 warranty    ถูก  ตอบ   อ้างอิง=section_missing
q09 warranty    ผิด  ตอบ   อ้างอิง=section_missing
q10 policy      ถูก  ตอบ   อ้างอิง=valid
q11 policy      ผิด  ตอบ   อ้างอิง=valid
q12 spec        ผิด  ตอบ   อ้างอิง=number_not_in_source
q13 not_in_docs ผิด  ตอบ   อ้างอิง=number_not_in_source
q14 not_in_docs ถูก  ปฏิเสธ อ้างอิง=n/a
q15 not_in_docs ถูก  ปฏิเสธ อ้างอิง=n/a
q16 not_in_docs ผิด  ตอบ   อ้างอิง=no_citation

รวม 16 ข้อ: accuracy 56.3% | confident-wrong 43.8% | abstention 12.5% | citation valid 50% (ของข้อที่ตอบ)

แยกหมวด
spec         n=5 accuracy 60% confident-wrong 40% abstain 0% citation 60%
price        n=2 accuracy 50% confident-wrong 50% abstain 0% citation 50%
warranty     n=3 accuracy 66.7% confident-wrong 33.3% abstain 0% citation 33.3%
policy       n=2 accuracy 50% confident-wrong 50% abstain 0% citation 100%
not_in_docs  n=4 accuracy 50% confident-wrong 50% abstain 50% citation 0%

ส่งให้คนตรวจ (ตัวเลขหรือแหล่งอ้างอิงไม่ผ่าน)
q03 [number_not_in_source] 12.8 กิโลกรัม: ห่างกันหนึ่งหลักจากแหล่ง (12.5 กิโลกรัม)
q05 [number_not_in_source] 4850 บาท: ห่างกันหนึ่งหลักจากแหล่ง (48500 บาท)
q08 [section_missing] WR-01 ข้อ 3.5: ไม่มีข้อนี้ในเอกสาร
q09 [section_missing] WR-01 ข้อ 4.2: ไม่มีข้อนี้ในเอกสาร
q12 [number_not_in_source] 450 กิโลวัตต์: ค่าตรงแต่หน่วยต่าง (แหล่งเขียน 450 วัตต์)
q13 [number_not_in_source] 8 ชั่วโมง: ไม่พบตัวเลขนี้ในแหล่งที่อ้าง

ตอบผิดแต่อ้างอิงผ่านการตรวจตัวเลข: 1 ข้อ q11
Real output from 2026-11-21 using node run.ts (Node 24)

Reading the results one point at a time

  1. Overall accuracy is 56.3 percent and confident-wrong is 43.8 percent, meaning nearly half of the STUB's items were answered wrong without hesitation. These numbers come from answers written to be wrong from the start, not from the rate of a real model.
  2. In the not_in_docs category, 2 of 4 items were correctly declined. For the other 2 (q13 battery and q16 shipping fees) the STUB invented numbers. q16 cites nothing, so it is flagged no_citation, a signal for the system not to send an answer that has a number but no source.
  3. q03 and q05 are numbers off by one digit. The checker reports the nearby value in the source (12.5 and 48500), and a reviewer who sees it can fix it in a few seconds.
  4. q12 has the number 450 right but the unit is kilowatts. The checker catches it because it compares the value together with the unit, not just the number.
  5. q08 is answered correctly (15 working days) but cites section 3.5, which does not exist (the real section is 3.2). Accuracy counts it as correct, but citation validity fails. If the two are not measured separately, you will not see that the answer was right by coincidence.
  6. q11 is answered on the wrong subject, but the number is in the section it cites, so the checker lets it through. The last line counts it as 1 item. This is the ceiling of this method.

Test suite

verify.test.ts has 4 cases and runs with node --test verify.test.ts, giving 4 pass. It tests number extraction (commas, ranges, longer unit before shorter), catching a one-digit error and a wrong unit, three kinds of nonexistent citation, and scoring an item that should be declined. If anyone edits the regex so that kilowatt is cut down to watt, the tests fail immediately.

verify.test.ts · lines 17–25
test("ตัวเลขผิดหนึ่งหลักและหน่วยผิดถูกจับ ตัวเลขถูกผ่าน", () => {
  const ok = verify("ราคา 48500 บาท", { doc: "PL-26", section: "1" }, docs);
  assert.equal(ok.status, "valid");
  const digit = verify("ราคา 4,850 บาท", { doc: "PL-26", section: "1" }, docs);
  assert.equal(digit.status, "number_not_in_source");
  assert.match(digit.flags[0].reason, /หนึ่งหลัก/);
  const unit = verify("450 กิโลวัตต์", { doc: "PX-200", section: "1.1" }, docs);
  assert.match(unit.flags[0].reason, /หน่วยต่าง/);
});
verify.test.ts: the cases for a one-digit number error and a wrong unit

Hypothetical examples: applying it to three businesses

Machinery and spare-parts sellers

Quotations and specs are where a wrong number costs real money. Have the AI draft, then call the checker against the price list before sending. A number that does not match the source must not leave the system until a person confirms it. The question set should include a model that has just been discontinued and a model with no price yet, to measure whether the bot answers on its own or declines.

HR answering employee policy questions

Policy questions are often specific to the company, and many items are not written in the documents. Count the abstention rate as the main metric. A bot that answers every question looks useful but is more dangerous than a bot that says to ask HR.

After-sales teams and machine manuals

Units and rated values are the risk points. Build a table of units from the real manuals, such as watt, kilowatt, newton-meter and bar, and have the checker recognize those units. Safety-related answers should always go to an engineer for review, whether or not the checker passes.

Scaling to a real system

  • Real database: store every question and answer, the cited sections, and the check results (status and flags) in tables, to see weekly trends and to turn items that people corrected into new exam items.
  • Large documents: the example cites by document and section number. Real work needs stable chunk IDs that survive document edits, and the document version must be stored with the answer, or you cannot check afterward.
  • Streaming: if the bot sends the answer word by word, a number may reach the user before it is checked. Hold back sentences that contain numbers until checked, or show a pending-check status.
  • Language and encoding: normalize Unicode before comparing, and support Thai digits, numbers written as words, and unit conversion, such as 12 months versus 1 year. This example does not support them.
  • Owned data: do not send real manuals or prices to an outside service without checking rights. Use simulated test sets, or only providers whose contract allows it.

Common mistakes and a checklist

  • Using a confident tone as a sign of being right
  • Measuring only overall accuracy, without breaking down by category and without counting confident-wrong
  • A question set with no items that the documents cannot answer, so you do not know how much the bot makes things up
  • Believing that a section reference means correct, without opening that section to check
  • Having the same LLM check its own answers, which adds confidence but not correctness
  • Comparing numbers without comparing units, or without stripping commas before comparing
  • Changing the prompt or switching the model without re-running the same question set
  1. Have a question set of at least 30 items, from users' real questions, including items the documents cannot answer.
  2. Record accuracy, confident-wrong, abstention and citation validity by category every time the system changes.
  3. Every answer that contains a number must have a source and pass the number checker before it reaches the user.
  4. Numbers that fail are sent to a reviewer with the reason, not quietly corrected.
  5. High-impact work (price, safety, law) always has a named reviewer.
  6. Items that people corrected are put back into the question set to prevent the same error from recurring.

Caution: this example is for learning, not a production system. All data is fictional and the answers come from a STUB, so the percentages are not the error rate of any model. The checker catches only numbers and units in its list. It does not catch facts that are plain text, and it does not bring errors to zero. Reducing the risk needs several layers together with human reviewers.

References

  1. OWASP Top 10 for LLM Applications 2025: LLM09 Misinformation (accessed 2026-11-21)
  2. Kalai และคณะ: Why Language Models Hallucinate (arXiv 2509.04664) (accessed 2026-11-21)
  3. Lewis และคณะ: Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (arXiv 2005.11401) (accessed 2026-11-21)
  4. Gao และคณะ: Enabling Large Language Models to Generate Text with Citations (ALCE, arXiv 2305.14627) (accessed 2026-11-21)
  5. Huang และคณะ: A Survey on Hallucination in Large Language Models (arXiv 2311.05232) (accessed 2026-11-21)
  6. NIST AI Risk Management Framework (หน้าภาพรวม) (accessed 2026-11-21)

Add us on LINE

Scan with the LINE app on your phone

QR code to add LINE @Bankoos

LINE ID: @Bankoos

Open LINE on this computer