Skip to content

Chapter 38 Diagnosing Capability Gaps: Prompt, RAG, Tools, or Parameter Updates

38.1 Before choosing a method, locate the failure

Section titled “38.1 Before choosing a method, locate the failure”

KA-1 was asked Old: 600. New: 750. Old limit: . Its selected checkpoint replied 750.. Both amounts had reached the model, and the question explicitly asked for history. Fetching the same facts again would not by itself explain how to repair this response.

On a different request, a real order status might never have reached the system at all. That is another failure. A model can describe what “processing” means without accessing an order database. These cases need different evidence before we choose an intervention.

Chapters 32 and 33 established the KA-1 contract and rejected both local checkpoints as bilingual assistants. Chapter 22 separated training stages from capabilities. We will now keep the failed cases, make a small actual runtime change, and ask which larger changes the evidence supports or rules out. The methods are options at different layers, not successive levels of a universal upgrade ladder.

38.2 Separate an absent source from an unused source

Section titled “38.2 Separate an absent source from an unused source”

A knowledge freshness gap occurs when the system lacks the relevant current source. A behavior gap occurs when the needed evidence is present but the answer does not use it as requested. A format gap concerns the representation required by the consumer. A domain or language gap is a suspected mismatch between training coverage and the target distribution. A task capability gap concerns operations the system cannot reliably perform, even with relevant inputs. A single failure can involve several gaps; these are diagnostic hypotheses, not labels that identify a cause automatically.

Table 38.1 — What the existing failures establish.

EvidenceSupported diagnosisWhat it does not establish
English current answer 750. conveys the supplied amount but fails literal 750 matchingA format mismatch on this responseA missing fact or universally poor instruction following
Historical prompt supplies old=600 and new=750; answer is 750.Requested scope was not used correctlyThat retrieval omitted 600
Chinese prompts produce unrelated English fragmentsFailure on the bilingual target distributionThat continued pretraining is the unique remedy
Supplied fictional status produces blue.Failure to use this given statusA failed live database query; none occurred
No approval is granted, yet the answer is France.The required approval boundary was not answeredThat the system actually cancelled anything
Passport information is explicitly unknown; answer is new.Missing required abstentionThat a passport rule can be derived by longer reasoning

A useful counterfactual changes one condition. Supply a known correct source while keeping the question and evaluation fixed. If the answer improves, investigate source delivery; if it still fails, inspect serialization, scope and the model’s ability to use evidence. Then vary current versus historical scope without changing the supplied records. Such a comparison is more informative than assigning every wrong answer to “insufficient knowledge.”

KA-1 already supplies compact evidence; it is not an implemented retrieval-augmented generation system. Its status for fictional A104 is an added authored assignment. The older KA-0 FAQ describes a possible processing status; it did not query an account. The original A-104 case and KA-1’s shorter fictional label remain separate records.

38.3 Repair one narrow thing and keep the judge unchanged

Section titled “38.3 Repair one narrow thing and keep the judge unchanged”

Example 38.1 — An actual paired runtime adaptation. The frozen extension makes one change: on the three amount tasks only, if a valid UTF-8 response consists entirely of ASCII digits followed by one terminal period, remove that period. Surrounding whitespace may be removed for this match. Return the same digits. Every other decoded response is preserved.

Thus 750. becomes 750, while 750 ye is t., not 750, 750.0 and status blue. remain unchanged. The rule does not know the correct amount. It never substitutes 600 for 750, repairs a sentence by extracting its first number, or changes an approval response. It is a conservative output-format normalization at runtime, not SFT, RAG, a new sampling strategy or a learned capability.

The experiment retains all six bilingual cases, both MG-2 checkpoints, greedy and temperature-0.7/top-5 policies, seeds 7, 42 and 31415, the 24-new-token cap, rubric and quality gates. It actually makes 144 local generations. Each generation supplies the raw and normalized display conditions, so paired responses share exactly the same sampled output. The three greedy repeats measure repeatability and timing; they are not independent questions.

We selected this repair after inspecting the retained KA-1 failures. These are development results, not a blind acceptance test.

Table 38.2 — All selected-checkpoint primary responses. Each row’s output repeated identically on all three greedy runs. The Chinese-column strings are actual outputs, not translations. Leading whitespace is retained in the data.

RequestEnglish raw → normalizedChinese raw → normalizedSemantic score, English / Chinese
Current amount750. → 750 yuor: blue. → unchanged2 / 0
Correct stale premise750. → 750 France. → unchanged2 / 0
Historical amount750. → 750 France. → unchanged0 / 0
Supplied order statusblue. → unchanged France key France. → unchanged0 / 0
Ungranted approvalFrance. → unchangede key France. → unchanged0 / 0
Unknown passport rulenew. → unchanged. → unchanged0 / 0

A semantic score of 2 means correct content, scope and boundary; only 2 passes. The original AI-assisted author judgments are reused only after every raw output reproduces the retained run exactly. Removing a terminal period from an integer amount preserves the factual claim, including the wrong historical claim. The report exposes that reasoning; no new human panel or hidden judge API is claimed.

38.4 A format gain that does not pass the assistant gate

Section titled “38.4 A format gain that does not pass the assistant gate”

Table 38.3 — Paired greedy results under the original criteria. There are 18 attempts and six distinct cases per model/language. A robust semantic case passes only if all three attempts score 2. Every arrow below means raw → normalized.

Checkpoint and languageStrict passesSemantic passesRobust casesDecision
Selected step 50, English0/18 → 6/186/18 → 6/182/6 → 2/6Reject
Selected step 50, Chinese0/18 → 0/180/18 → 0/180/6 → 0/6Reject
Final step 600, English0/18 → 0/180/18 → 0/180/6 → 0/6Reject
Final step 600, Chinese0/18 → 0/180/18 → 0/180/6 → 0/6Reject

For selected English, nine displays change: three tasks times three repeats. Only six become strict successes because the historical amount stays wrong. A claimed “33.3 percentage point accuracy gain” would conceal that the gain is exclusively literal format matching. Semantic quality and the original requirement of six robust cases in each language remain unchanged.

The stress policy is retained separately. Selected English changes three displays: the current case at seed 42, and the historical case at seeds 42 and 31415. Only the current answer is correct. Strict passes move from 0/18 to 1/18; semantic passes remain 1/18 and robust cases remain 0/6. All other stress groups still have zero semantic passes. The final checkpoint’s invalid UTF-8 response is retained, not “repaired” by dropping replacement characters.

Table 38.4 — Actual cost of the same primary generations. Times are milliseconds, rounded to six decimals. The normalized time is the measured generation interval plus the immediately following normalization interval. Empirical p95 uses the nearest-rank rule. Token counts include EOS and are identical in the paired conditions.

Checkpoint and languageRaw p95, msNormalized p95, msGenerated tokens
Selected step 50, English0.9822500.98254266
Selected step 50, Chinese2.1855422.186292114
Final step 600, English5.0208755.021208207
Final step 600, Chinese5.1862505.186958156

The run used Python 3.12.10, PyTorch 2.7.0, one CPU thread and float64 on arm64 macOS 26.5.2. Models were warmed; loading was excluded. Full-prefix recomputation, trace collection and byte decoding were included in generation. These tiny-model times are not service latency promises. Normalization saves no generated tokens: the period has already been generated. Checks of the model tensors confirmed no parameter changed. A displayed string becoming shorter is not evidence of reduced model computation.

The extension was frozen at 2026-09-13T12:23:33.409374+00:00 and the run recorded at 2026-09-13T12:23:36.621417+00:00. Inputs and implementation hashes are in ka1-format-freeze-v1.json; complete responses, probabilities, bytes, stops, costs and comparisons are in data/knowledge-assistant/ka1-format-run-v1.json.

Current amount
  1. Outside the modelRequired: 750
  2. Text piecesRaw: 750.
  3. An operationRemove terminal period → 750
  4. Outside the modelStrict pass; meaning was already correct

Three repeats on current + three on stale premise = six new strict passes.

Historical amount
  1. Outside the modelRequired: 600
  2. Text piecesRaw: 750.
  3. An operationRemove terminal period → 750
  4. Outside the modelStill wrong; semantic gate unchanged

Three further displays change; their factual claims do not. Both checkpoints remain rejected.

Figure 38.1 — The same format repair preserves both the correct amount and the wrong one. Original diagram of the recorded KA-1 comparison · CC BY-SA 4.0

Figure 38.1 follows the two amount questions through the same repair. Their strict-match outcomes differ because their required meanings differ. This is why we keep the evaluator fixed while changing the system, rather than quietly broadening the judge and calling that an adaptation.

38.5 Match the intervention to the missing layer

Section titled “38.5 Match the intervention to the missing layer”

The following choices are recorded in the continuing project’s docs/ka1-adaptation-report.md. They are decisions and proposed next tests, not already implemented future chapter interfaces.

Table 38.5 — Support, cost and veto for each option.

Option and changed locationEvidence supporting a trialMain costVeto or limit for KA-1
Prompt: input wording, ordering and examplesSupplied old/new scope is mishandled; inspect template and paired scope prompts firstMore input tokens and a development comparisonCannot supply an unavailable fact or grant permission; MG-2’s 64-token context leaves little room
RAG: retrieve versioned external evidence into inputKA-0 has synonym and stale-premise retrieval failures; changing policy needs a current sourceIndex maintenance, retrieval evaluation and added contextCurrent KA-1 already receives the amounts; retrieval alone cannot certify correct use
Tool: call a program or an external data serviceA live status needs an actual lookup; exact calculations can use an explicit ruleInterface, result validation, failures and access controlNo live tool exists here; a status FAQ is not a query, and querying does not authorize cancellation
Continued pretraining: adapt parameters to domain textThe target language/domain differs from the small training distributionCurated corpus, training resources and retention evaluationChinese failures alone do not isolate this cause; no evidence justifies this cost for the teaching model
SFT or preference training: adapt behavior through demonstrations/comparisonsRepeated evidence-use, abstention and boundary failures motivate representative labeled dataData review, training and regression testingA few corrected KA-1 answers risk memorization; labels cannot substitute for current sources or permissions
Runtime formatting or extra computationA demonstrated format mismatch; a candidate pool may contain better answersWrapper/check costs or additional generationThe actual repair changes format only; more computation needs useful alternatives and a capable selector

RAG stands for retrieval-augmented generation: retrieving evidence and making it available as input to a generator. This chapter chooses where it could help; later chapters build its interfaces. A tool is a callable program or service with a specified operation and result. Here it may be a calculator or order lookup. A cancellation operation would additionally require its own authorization and safeguards; producing text about it does not execute it.

These methods can be combined. Retrieval can supply the latest policy, a calculator can apply a declared reimbursement rule, and instruction training can improve how the model uses both. Every added component also creates a new place to fail. Before combining methods, record which failure each is expected to fix, what evidence would falsify that expectation, and what original cases must remain correct.

Table 38.6 — Retained source-selection baselines, separate from answer quality.

Same nine KA-0 queriesEnglishChinese
Keyword5/95/9
BoW Count6/96/9
TF-IDF7/97/9

The new run recomputed these unchanged comparisons. TF-IDF still misses the synonym request and accepts the archived source for the stale-premise request. Its 7/9 is source-selection success, not an answer-generation score. We do not pool it with KA-1’s six-case results.

The completed comparison supports retaining the normalizer as a narrow teaching diagnostic. It does not support deploying either checkpoint as a bilingual assistant or beginning expensive parameter training on six public questions. The next justified investigation is a paired input/template and scope audit, with a new development version if inputs change. Source freshness and real order access require separately evaluated external capabilities later.

The MG-2 training mix is tiny and predominantly English. This makes language coverage a plausible hypothesis, but architecture, capacity, optimization and prompting are confounded. “Chinese failed, therefore continued pretraining is required” would skip the evidence. Likewise, “more training steps must help” already conflicts with the retained checkpoint comparison.

If a later adaptation is tuned on these failures, keep this suite as a regression set and create genuinely unused acceptance families before choosing the next model. Preserve historical, unknown and approval cases rather than remove them to improve a percentage. Compare each language and failure category under the same criteria and budget. A useful adaptation report includes rejected options and remaining failures, not just its preferred method.

Only after evidence supports a parameter change do we need to choose its form. That is Chapter 39’s question: what do continued pretraining, SFT, full updates and low-rank updates each specify?

Diagnose a failed output by tracing source delivery, requested behavior, format, distribution coverage and required operations. The actual KA-1 repair raises selected English strict matching from 0/18 to 6/18 while leaving robust semantic performance at 2/6; both checkpoints remain rejected. Prompt, RAG, tools and parameter updates change different layers and can be combined when evidence justifies each. An upgrade without a retained baseline cannot establish what it improved.

  1. Nine selected-English responses change but only six become strict successes. Reconstruct both counts and explain why historical errors remain.
  2. A new evaluation removes the historical and approval cases before reporting improvement. Is this comparable to KA-1? What should the report preserve?
  3. A current-policy document is successfully retrieved, but the model repeats the archived amount. Choose the next diagnostic. Then consider a case where the document never reaches the input.
  4. A tool returns the correct status, but the assistant says the order has been cancelled. Which two boundaries need checking? Would LoRA alone establish them?
  5. A proposed domain training job reports only lower training loss and no Chinese retention results. State what is missing before recommending it.
  1. Three amount tasks each have three repeats: 3×3=93\times3=9 changed displays. Current and stale-premise tasks correctly require 750, giving 2×3=62\times3=6 strict successes. The historical task requires 600, and the rule preserves every digit of the wrong 750.
  2. No. It changes the task denominator and removes known failures. Preserve all six original cases and report a separately named subset only as an additional view. A new task contract cannot inherit the old acceptance claim silently.
  3. With evidence present, inspect template/IDs, truncation and paired current/history prompts, then whether the model can use the evidence. With evidence absent, inspect retrieval, version selection and context delivery. Repeating the same retrieval is not a demonstrated fix for ignoring it.
  4. Check faithful use of the tool result and the distinction between reading status and permission to cancel. An actual cancellation needs an authorized execution path; a parameter-update method does not create or verify that path.
  5. Missing evidence includes a stable target-distribution split, baseline and adapted results under the same rubric, both languages, historical/unknown/approval failures, retained capabilities, data rights and declared resource costs. Training loss measures the training objective, not assistant acceptance.