<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by GuideWit on Medium]]></title>
        <description><![CDATA[Stories by GuideWit on Medium]]></description>
        <link>https://medium.com/@alkupilot?source=rss-cb6569dd015a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*V9zsqV7jdem8XTbV7EDO3w.png</url>
            <title>Stories by GuideWit on Medium</title>
            <link>https://medium.com/@alkupilot?source=rss-cb6569dd015a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 02:27:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alkupilot/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A reward that likes long answers will learn to like long mistakes]]></title>
            <link>https://medium.com/guidewit/a-reward-that-likes-long-answers-will-learn-to-like-long-mistakes-1486099f573f?source=rss-cb6569dd015a------2</link>
            <guid isPermaLink="false">https://medium.com/p/1486099f573f</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[GuideWit]]></dc:creator>
            <pubDate>Wed, 18 Nov 2026 06:51:01 GMT</pubDate>
            <atom:updated>2026-11-18T06:51:01.565Z</atom:updated>
            <content:encoded><![CDATA[<p>An inventory assistant must subtract three reserved parts from twelve available parts. One candidate says nine, another says eight and a third repeats the prompt. Before training a reasoning model, test whether the reward itself ranks those answers in the desired order.</p><p><em>AI assisted the writing of this article. The worked case and diagram are original teaching examples.</em></p><h3>Before the policy update there is a grader</h3><p>The fastest way to find a reward bug is to submit answers whose merits you already know. Include a correct integer, an incorrect integer, a response with extra prose and a response containing the right numeral in an unrelated explanation. A substring search for nine accepts some of the wrong cases. A strict parser rejects explanatory text even if the arithmetic is correct. Which behavior is desired depends on what the consumer can read. Set that contract first.</p><p>The course introduces reinforcement learning for language models and GRPO, which compares several completions for the same prompt. Its practical TRL exercise demonstrates a length-based reward for summaries. Length can make a convenient training signal while remaining independent of factual correctness. <a href="https://huggingface.co/learn/llm-course/en/chapter12/2">Introduction to Reinforcement Learning and its Role in LLMs</a>.</p><p>The course’s summary exercise is especially instructive here. Its example computes distance from a target length using the length of a completion. The unit depends on the object passed to the function. In Python the length of a string counts characters, while the length of a list of token identifiers counts tokens. Print the input type and an example before interpreting a chart as evidence that outputs reached the intended token length. A rising reward can faithfully report progress toward the wrong unit.</p><h3>Center four rewards by hand</h3><p>Define a strict output format for the inventory test. A response must contain one integer and match the reference value. Score a correct answer one and all other answers zero. Keep the answer key outside the prompt that the model sees.</p><p>Try the four responses nine, eight, nine and twelve, written as digits. Their rewards are one, zero, one and zero. The group mean is one half. Subtracting the mean gives positive and negative one half. Full GRPO may also scale by a standard deviation and applies a policy objective. This hand calculation isolates the relative signal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*JoKtqG3ccmSyMQu-" /></figure><p><em>Original GuideWit diagram. Subtracting the group mean yields positive and negative half points.</em></p><p>Now give every candidate the wrong answer. Every reward is zero, so subtracting the mean yields zero for all four. That group offers no relative preference between outputs under this checker. Test the reward on deliberately misleading completions before allocating training compute.</p><ul><li><strong>Answer: </strong>“9”<strong> · Reward minus mean: </strong>1 − 0.5<strong> · Centered reward: </strong>+0.5</li><li><strong>Answer: </strong>“8”<strong> · Reward minus mean: </strong>0 − 0.5<strong> · Centered reward: </strong>−0.5</li><li><strong>Answer: </strong>“9”<strong> · Reward minus mean: </strong>1 − 0.5<strong> · Centered reward: </strong>+0.5</li><li><strong>Answer: </strong>“12”<strong> · Reward minus mean: </strong>0 − 0.5<strong> · Centered reward: </strong>−0.5</li></ul><pre>import re<br>answers = [&quot;9&quot;, &quot;8&quot;, &quot;9&quot;, &quot;12&quot;]<br>def reward(answer):<br>    return int(bool(re.fullmatch(r&quot;[0-9]+&quot;, answer)) and int(answer) == 12 - 3)<br>scores = list(map(reward, answers))<br>mean = sum(scores) / len(scores)<br>print(scores, [x - mean for x in scores])</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/0*8pvjFVGDwdASTLmh" /></figure><p><em>GuideWit local Python experiment. Subtracting the mean from rewards one, zero, one and zero gives alternating +0.5 and −0.5.</em></p><h3>Why diversity matters inside one group</h3><p>Relative rewards compare responses to the same prompt. If all four candidates return eight, the checker rejects them all, and the centered signal gives no preference among them. A training dashboard that averages over many prompts can hide this flat group. Inspect how often reward values differ within a group, and inspect actual completions for prompts that repeatedly give identical rewards.</p><p>If the operational rule accepts expressions or units, the parser needs to reflect that. Under the strict exercise contract, a sentence containing nine fails even when its arithmetic is right. Maintain separate metrics for final answer correctness, formatting and problems that the checker cannot verify.</p><p>Even a perfectly implemented checker has a boundary. The inventory test accepts the right final integer; it provides no evidence about the reasoning that produced it. A model could guess correctly or exploit a regularity in the training questions. Keep some problems with changed quantities, different wording and unseen structures outside training. Score those separately, and include tests where a plausible-looking shortcut gives the wrong answer. The question the supervisor asked was whether the system can compute remaining inventory. That question survives every improvement in the training metric.</p><h3>A verifier needs its own test set</h3><p>Write several deliberately awkward answers before training. Include the exact integer, the integer with a unit, a related but wrong number, an explanation containing both the correct result and an incorrect final answer, and an empty response. Assign the expected reward manually. If the grader disagrees with that reference on a simple fixture, work on the grader first. Reinforcement learning could otherwise amplify the discrepancy across many generations.</p><p>Consider how the exercise parser handles leading zeros. A string containing 09 consists only of digits, and converting it to an integer yields nine. Under the implemented rule it receives a point. If the interface requires a canonical decimal representation, that behavior is wrong for the deployment even though the arithmetic comparison succeeds. Tighten the parser or relax the contract consciously, then save the example as a test. This is a concrete difference between a human intention and the rule a model is actually rewarded for satisfying.</p><p>A second probe changes the problem rather than the output format. Keep the quantities familiar but change the relationship: twelve items are in stock and three more arrive. A strategy that always subtracts the smaller number now fails. A verifier derived from the inventory operation can detect that. A checker that always looks for nine cannot. Build held-out questions with different operations as well as different quantities so a fixed response cannot look like general reasoning.</p><p>When groups frequently receive uniform scores, read a few completions before changing hyperparameters. The candidates may all be right on an easy prompt, all wrong on a hard one, or indistinguishable to a faulty checker. Those explanations call for different actions. The four-response calculation earns its place in the workflow because it lets you investigate which of them actually occurred.</p><h3>Can the second response teach the model anything?</h3><p>What is the centered reward for the second completion? Minus one half, because its reward is zero and the group mean is one half.</p><p>Does a higher reward demonstrate better reasoning on new problems? No. Evaluate unseen tasks and check whether the verifier can be exploited.</p><p>Further reading in the <a href="https://huggingface.co/learn/llm-course/en/chapter12/1">Hugging Face LLM Course, chapter 12</a>.</p><p><a href="https://guidewit.com/courses/language-models-hugging-face/reasoning-models">Read the English lesson and worked example on GuideWit.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1486099f573f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidewit/a-reward-that-likes-long-answers-will-learn-to-like-long-mistakes-1486099f573f">A reward that likes long answers will learn to like long mistakes</a> was originally published in <a href="https://medium.com/guidewit">GuideWit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A valid JSON handover can still invent a repair]]></title>
            <link>https://medium.com/guidewit/a-valid-json-handover-can-still-invent-a-repair-2688edf8fb23?source=rss-cb6569dd015a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2688edf8fb23</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[structured-output]]></category>
            <dc:creator><![CDATA[GuideWit]]></dc:creator>
            <pubDate>Tue, 17 Nov 2026 16:26:01 GMT</pubDate>
            <atom:updated>2026-11-17T16:26:01.603Z</atom:updated>
            <content:encoded><![CDATA[<p>A supervisor wants each shift handover to return an asset and an action. A model emits impeccable JSON that invents a completed repair. Would lower training loss make this response acceptable? Separate formatting, grounding and deployment cost before fine-tuning.</p><p><em>AI assisted the writing of this article. The worked case and diagram are original teaching examples.</em></p><h3>The assistant turn is part of the training data</h3><p>A supervised example pairs a request with the answer you want the model to produce. If a training record contains an invented repair in a beautifully formatted response, optimizing the model to imitate that example rewards the error along with the formatting. Review the training targets against their source notes. A small collection of accurately grounded examples is easier to inspect than a large file filled with undocumented conversions.</p><p>The course formats conversations with the model’s chat template, applies supervised fine-tuning with example responses, introduces LoRA adapters and evaluates the result. A template serializes user and assistant turns in the form expected by the checkpoint. Different checkpoints can use different control tokens. <a href="https://huggingface.co/learn/llm-course/en/chapter11/2">Chat Templates</a>.</p><p>Formatting also has a lower-level meaning. The model consumes a serialized sequence of control tokens and message content. If the training pipeline uses one chat template and the deployment wrapper uses another, the apparent human conversation can look identical while the sequence received by the model changes. Render one exchange with the actual tokenizer, examine the boundary around the assistant answer and keep that fixture for inference testing. A hand-built string that resembles a chat transcript can still introduce different control tokens.</p><h3>Calculate what the adapter changes</h3><p>Write two training examples and reserve a third incident for testing. For a note that says PumpA needs inspection, the target action is inspect. A response that says repaired changes the state of the equipment and fails the factual check. Keep related notes from the same incident together when splitting.</p><p>Use the checkpoint’s own template when building the training text. Inspect one formatted conversation and its training labels before a long run. At inference, format the user turn with the generation prompt expected by the model. Avoid adding a duplicate set of special tokens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*GCPS4xqUzZXGoaGw" /></figure><p><em>Original GuideWit diagram. A rank-four update uses two factor matrices with 720 weights in total.</em></p><p>LoRA learns a low-rank update to selected weights while keeping base weights frozen. For an illustrative matrix with 100 inputs and 80 outputs, rank four needs 400 plus 320 adapter weights. The dense matrix contains 8000 weights. This calculation excludes biases, other layers and optimizer state.</p><ul><li><strong>Matrix: </strong>W<strong> · Dimensions: </strong>80 × 100<strong> · Weights: </strong>8000</li><li><strong>Matrix: </strong>A<strong> · Dimensions: </strong>4 × 100<strong> · Weights: </strong>400</li><li><strong>Matrix: </strong>B<strong> · Dimensions: </strong>80 × 4<strong> · Weights: </strong>320</li></ul><pre>import json<br>answer = &#39;{&quot;asset&quot;:&quot;PumpA&quot;,&quot;action&quot;:&quot;repaired&quot;}&#39;<br>record = json.loads(answer)<br>print(set(record) == {&quot;asset&quot;, &quot;action&quot;})<br>print(record == {&quot;asset&quot;: &quot;PumpA&quot;, &quot;action&quot;: &quot;inspect&quot;})<br>print(4 * (100 + 80), 100 * 80)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/0*DPLki40w2a6fNZKk" /></figure><p><em>GuideWit local Python experiment. The JSON has the expected keys but the action fails the factual check. The two adapter factors contain 720 weights.</em></p><h3>Two evaluation columns for one answer</h3><p>Return to the string in the exercise. A JSON parser can read it. The required keys exist. Those observations are worth recording because they establish interface compatibility. They leave a second question: can the action be justified by the source note? A repair that has merely been requested must not become a completed repair in the shift record. Record that as a factual failure even if every structural test passed.</p><p>Compare the base model and adapter on identical held-out prompts with the same decoding settings. First parse the response, then compare values with the note. Count valid formats separately from supported actions. Save the base revision and adapter together in the evaluation record.</p><p>For an adapter comparison, use the same held-out incidents and decoding settings for both the base model and the adapted model. Count the records that satisfy both conditions, and also publish the two component counts. An adapter can improve format consistency while increasing unsupported actions. The separate columns make that trade visible. The parameter arithmetic explains why trying a small adapter is feasible for a chosen layer. Only the held-out records establish whether that adapter improved the handover.</p><h3>Test an answer that satisfies half the contract</h3><p>Create a miniature review sheet with three columns: the original note, the parsed fields and the factual verdict. For “PumpA needs inspection,” a response naming PumpA and inspect satisfies both the structure and the evidence. A response naming PumpA and repaired passes the structure test but fails the evidence test. A response that merely says “inspect PumpA” may preserve the facts while failing the required interface. These three fixtures separate the two failure modes without requiring a large benchmark.</p><p>For a real evaluation, include notes that mention completed work alongside unfinished work. “The seal was replaced; inspect the bearing tomorrow” contains both a past repair and a future action. A model can copy a true phrase from the note yet attach it to the wrong asset or time. A reviewer should be able to trace each output field to the clause that supports it. Where the note supplies no evidence for an action, define the permitted response in advance instead of rewarding a confident guess.</p><p>The LoRA calculation also deserves a precise interpretation. The original dense weight matrix remains part of inference. The two factors describe a learned update. Multiplying the factors yields a matrix with compatible dimensions; it does not reconstruct the original weights themselves. Increasing rank increases the number of trainable adapter parameters in the chosen layer. It does not establish that the resulting adapter will learn a safer or more accurate handover.</p><p>Repeat the same fixtures after changing a template or merging an adapter into a base model. The transport format, generation prompt and factual assessment are all observable pieces of the deployed behavior. If a new release improves only the number of parseable answers, the review sheet will show exactly which operational question remains unresolved.</p><h3>What did the 720 weights buy?</h3><p>How many weights are in the two example adapter factors? 720. Rank four times the sum of 100 and 80.</p><p>Does this ratio describe the memory used by the whole model? No. It applies to one adapted matrix and excludes the rest of the training system.</p><p>Further reading in the <a href="https://huggingface.co/learn/llm-course/en/chapter11/1">Hugging Face LLM Course, chapter 11</a>.</p><p><a href="https://guidewit.com/courses/language-models-hugging-face/efficient-fine-tuning">Read the English lesson and worked example on GuideWit.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2688edf8fb23" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidewit/a-valid-json-handover-can-still-invent-a-repair-2688edf8fb23">A valid JSON handover can still invent a repair</a> was originally published in <a href="https://medium.com/guidewit">GuideWit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why four completed records can still leave a labeling rule unresolved]]></title>
            <link>https://medium.com/guidewit/why-four-completed-records-can-still-leave-a-labeling-rule-unresolved-3be35ec1731a?source=rss-cb6569dd015a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3be35ec1731a</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-labeling]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[GuideWit]]></dc:creator>
            <pubDate>Tue, 17 Nov 2026 06:51:01 GMT</pubDate>
            <atom:updated>2026-11-17T06:51:01.701Z</atom:updated>
            <content:encoded><![CDATA[<p>Two reviewers read “The guard looks loose, inspection requested.” One labels the note an active fault and the other labels it an inspection request. Which answer should enter the training set? Preserve the disagreement long enough to learn which instruction is missing.</p><p><em>AI assisted the writing of this article. The worked case and diagram are original teaching examples.</em></p><h3>A disagreement that improves the dataset</h3><p>Read the disputed note aloud, once as a request and once as a description of a fault. Both readings have textual support. The language “looks loose” expresses uncertainty, while “inspection requested” asks for a specific action. A policy that tells reviewers to choose the most important topic offers little help with that conflict. A policy that states how to classify an unconfirmed observation gives the next reviewer something they can apply.</p><p>The course builds an Argilla dataset from labeled news text. It configures questions for classification and entity spans, carries existing labels as suggestions, distributes records to annotators and exports reviewed responses. An imported suggestion and a submitted human response have different evidential value. <a href="https://huggingface.co/learn/llm-course/en/chapter10/2">Set up your Argilla instance</a>.</p><p>Write one additional example on each side of the boundary. “The retaining bolt has snapped” directly reports damage. “Please check whether the bolt is loose” asks for inspection. Ask both reviewers to label these examples without seeing each other’s responses. If they still disagree, the new rule may depend on technical knowledge the original task never supplied. At that point the right outcome may be escalation or a distinct uncertainty label, provided the dataset owner defines how it will be used.</p><h3>Compare the labels before adjudication</h3><p>For the maintenance exercise, use anonymous record identifiers and two allowed labels, fault and inspect. Ask two reviewers to label the same four notes independently. Keep the suggestion in its own field. Record which version of the instructions each reviewer used.</p><p>Reviewers agree on rows one, two and four. On row three one chooses fault and the other inspect. Simple observed agreement is three out of four. That number identifies the size of the disagreement but says nothing about which reviewer is right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*PwL_T-x1hd95qcNZ" /></figure><p><em>Original GuideWit diagram. Two reviewers disagree on the third of four records.</em></p><p>Add a rule for uncertain wording. For this exercise, a request to check an unconfirmed defect receives inspect. A report that directly confirms damage receives fault. Apply the rule to row three, record the decision and revisit similar records annotated under the earlier instructions.</p><ul><li><strong>Reviewers: </strong>R1 = F, R2 = F<strong> · Record IDs: </strong>1<strong> · Agreement: </strong>✓</li><li><strong>Reviewers: </strong>R1 = I, R2 = I<strong> · Record IDs: </strong>2, 4<strong> · Agreement: </strong>✓</li><li><strong>Reviewers: </strong>R1 = F, R2 = I<strong> · Record IDs: </strong>3<strong> · Agreement: </strong>×</li></ul><pre>first = [&quot;F&quot;, &quot;I&quot;, &quot;F&quot;, &quot;I&quot;]<br>second = [&quot;F&quot;, &quot;I&quot;, &quot;I&quot;, &quot;I&quot;]<br>matches = [a == b for a, b in zip(first, second)]<br>print(matches, sum(matches) / len(matches))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/0*AIGH8LRBi8B_ygLA" /></figure><p><em>GuideWit local Python experiment. The third comparison is False. The other three are True, so the agreement rate is 0.75.</em></p><h3>What survives the export</h3><p>A single exported target is convenient for training. It is a poor place to store the full history of the decision. Keep the imported suggestion, independent responses, reviewer count, final adjudication and instruction version as distinguishable fields or linked records. Then an unexpected rise in one category can be investigated without guessing whether the source data changed or the reviewers changed their interpretation.</p><p>Export a training label only after the review policy is satisfied. Retain the original responses and decision history for audit. If only one reviewer sees each record, a high completion count cannot establish agreement between reviewers.</p><p>Observed agreement is deliberately simple in the example. Three matching decisions out of four reveal one dispute. The number says little about which categories are causing trouble or how often both reviewers accept an incorrect suggestion. Inspect examples from the majority class as well as visibly disputed ones. If agreement rises after the rule change, retest it on new notes. Repeating the original four records mainly establishes that the specific disagreement was resolved.</p><h3>Rehearse the export before adding more records</h3><p>Set up a small dry run with the four examples and inspect what actually leaves the annotation system. Can you identify the original text, both independent responses and the final label? Can you tell the difference between a reviewer who has not answered and one who selected inspection? Missing information and a substantive class should remain distinguishable throughout export. Substituting a default class for every missing answer would silently turn incomplete work into training evidence.</p><p>Check how suggestions are presented. An existing label can save reviewers time, especially for easy examples, but it can also anchor them on an earlier decision. One small comparison is to ask for independent labels on a sample without showing the suggestion. Then compare those decisions with reviewed records from the usual workflow. A difference does not automatically establish that suggestions are harmful. It identifies records where the team should inspect the wording and the labeling instructions more closely.</p><p>Think about the model built from these records. If its task is to route confirmed faults, the unresolved inspection request belongs outside that class under the policy we chose. If another team intends to predict which assets might fail later, the same text could become a positive risk signal under a different target definition. Preserve the policy version so a future user knows what the training label actually means. Reusing a dataset under a new meaning without relabeling it can make a technically correct training pipeline answer the wrong question.</p><p>The reviewers now have a concrete test for the disputed note and a way to record exceptions. The final label is reproducible because the uncertainty rule travels with it. An exported column of labels alone would have lost that explanation.</p><p>For the next batch, give both reviewers two unseen borderline records. Agreement on those distinguishes a transferable instruction from a remembered answer to the original dispute.</p><h3>Would you call this 75 percent accurate?</h3><p>What is observed agreement for the four example records? Three divided by four, or 75 percent.</p><p>Does 75 percent agreement mean 75 percent accuracy? No. Accuracy needs a reference decision and both reviewers can make the same mistake.</p><p>Further reading in the <a href="https://huggingface.co/learn/llm-course/en/chapter10/1">Hugging Face LLM Course, chapter 10</a>.</p><p><a href="https://guidewit.com/courses/language-models-hugging-face/data-annotation">Read the English lesson and worked example on GuideWit.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3be35ec1731a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidewit/why-four-completed-records-can-still-leave-a-labeling-rule-unresolved-3be35ec1731a">Why four completed records can still leave a labeling rule unresolved</a> was originally published in <a href="https://medium.com/guidewit">GuideWit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Test the maintenance demo before connecting a model]]></title>
            <link>https://medium.com/guidewit/test-the-maintenance-demo-before-connecting-a-model-03d6afe77aaf?source=rss-cb6569dd015a------2</link>
            <guid isPermaLink="false">https://medium.com/p/03d6afe77aaf</guid>
            <category><![CDATA[gradio]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[GuideWit]]></dc:creator>
            <pubDate>Mon, 16 Nov 2026 16:26:01 GMT</pubDate>
            <atom:updated>2026-11-16T16:26:01.625Z</atom:updated>
            <content:encoded><![CDATA[<p>A supervisor wants to try a maintenance classifier in a browser. Before connecting a model, can a reviewer verify what happens to a blank note, a known fault and an unfamiliar description? A predictable demo makes a broken interface easier to distinguish from a bad prediction.</p><p><em>AI assisted the writing of this article. The worked case and diagram are original teaching examples.</em></p><h3>What a reviewer can discover with three inputs</h3><p>A demo removes the need to open a notebook. It also hides the boundary between the code that reads an input, the code that makes a decision and the component that displays the answer. A colleague who sees a blank result cannot tell which stage failed. Three fixtures give that colleague an independent expectation. A string of spaces exercises validation. A known word exercises the positive branch. An unfamiliar word exercises the review branch.</p><p>The Gradio chapter starts with a Python function wrapped in an Interface. It adds components, examples and ways to share a demo, including a Space backed by repository files. The chapter also explores Blocks for more complex interactions. Begin with the smallest function that captures your input and output contract. <a href="https://huggingface.co/learn/llm-course/en/chapter9/2">Building your first demo</a>.</p><p>Run the fixtures as ordinary function calls first. Then enter them into the interface and compare the strings exactly. A response returned in Python but absent in the browser suggests a wiring or output-component problem. If both report the same surprising value, the function itself is a better place to investigate. The browser has given you another way to observe a prediction without changing the definition of a correct one.</p><p><a href="https://www.youtube.com/watch?v=LS9Y2wDVI0k&amp;t=36s">Let’s Play Pictionary with Machine Learning! · Creating a Space · 00:36</a>.</p><h3>Give the demonstration four predictable responses</h3><p>Define a local stand-in for the classifier. Empty input returns an instruction, a note containing the word heat returns a candidate route and any other note goes to review. This deliberately simple rule makes the three branches reproducible without model downloads.</p><p>Call the function with each fixture in Python. Then connect the same function to a Gradio Interface with one text input and one text output. Enter the same strings in the browser and compare the displayed result with the direct function call.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*Uu_fO3BhHfU1fYBL" /></figure><p><em>Original GuideWit diagram. The simple heat rule also matches the negated input.</em></p><p>Replace the rule with model inference only after the interface passes. Preserve empty-input handling and the review path. Put a tested environment and model revision beside the demo so a reviewer can reproduce its behavior. A shared deployment also needs its backend to be available.</p><ul><li><strong>Input: </strong>“ “<strong> · Rule: </strong>strip()<strong> · Result: </strong>ENTER</li><li><strong>Input: </strong>“heat”<strong> · Rule: </strong>heat ∈ input<strong> · Result: </strong>MECH</li><li><strong>Input: </strong>“noise”<strong> · Rule: </strong>heat ∉ input<strong> · Result: </strong>REVIEW</li><li><strong>Input: </strong>“no heat”<strong> · Rule: </strong>heat ∈ input<strong> · Result: </strong>MECH</li></ul><pre>def route(note):<br>    normalized = note.strip().lower()<br>    if not normalized:<br>        return &quot;ENTER&quot;<br>    return &quot;MECH&quot; if &quot;heat&quot; in normalized else &quot;REVIEW&quot;</pre><pre>for note in [&quot;  &quot;, &quot;heat&quot;, &quot;noise&quot;, &quot;no heat&quot;]:<br>    print(repr(note), route(note))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/0*lILH_bs3elCFnwAA" /></figure><p><em>GuideWit local Python experiment. The rule sends both heat and no heat to MECH. It returns ENTER for spaces and REVIEW for noise.</em></p><h3>A hosted demo has another dependency</h3><p>In a temporary share session the interface may be reachable through a public URL while the inference code still runs in your own process. Closing that process changes what another reviewer can access. A Space puts the application in a repository-backed environment, where package requirements, files and runtime resources still matter. A successful local launch does not establish that an independent environment can load the model.</p><p>Try the counterexample “no heat.” The tiny rule still finds the word heat and returns the mechanical route. This is a limitation of the classifier. If the notebook and browser agree on that wrong answer, changing the text component will not fix it.</p><p>For a handoff, keep a short list of examples whose expected results are stable. Include the negation failure so the supervisor knows what the demo can and cannot decide. Once a real classifier replaces the rule, keep the blank-input test and revise the prediction fixtures against its intended label map. If the application begins writing to a work-order system, it has acquired a new job that the read-only demonstration never tested. Review the new action separately before letting a test field trigger operational changes.</p><h3>Give the person testing the demo a reproducible job</h3><p>Imagine a reviewer who has never opened the training notebook. Hand them the four inputs from the example and ask them to record the visible response for each. If “no heat” produces MECH, that is the known limitation of the rule. If a field containing only spaces also produces MECH, a different behavior has appeared. Distinguishing an expected failure from a regression keeps the review focused on evidence rather than on whether the demo feels impressive.</p><p>Now consider the output label ENTER. It is convenient inside a fixture because it is easy to compare exactly. For the actual supervisor, the interface might display “Enter a maintenance note.” The display text and the backend response can be tested separately. A translated interface can render the instruction in the user’s language while the response type stays stable. Otherwise a harmless wording change can break downstream code that mistook the displayed sentence for a machine-readable contract.</p><p>Keep a second record for the deployment environment. Which repository revision was running when the supervisor tested it? Were the weights loaded on startup or on the first request? A slow first response can come from model loading even when every subsequent note works correctly. Time the first call and a later call independently before diagnosing an interface freeze. Use invented inputs so the test can be repeated by someone outside the maintenance team.</p><p>Finally take the review path seriously. The interface should let a person see when the model lacks a reliable route. A demo that always returns a destination may be simple to present, but its output cannot express uncertainty that operators already encounter. That is a product decision to resolve explicitly before the classifier moves beyond a demonstration.</p><h3>What should the blank field do?</h3><p>What should a string containing only spaces return? The empty-input instruction, because surrounding whitespace is removed first.</p><p>Why test the function directly before sharing the demo? It supplies a reference result for diagnosing the interface independently.</p><p>Further reading in the <a href="https://huggingface.co/learn/llm-course/en/chapter9/1">Hugging Face LLM Course, chapter 9</a>.</p><p><a href="https://guidewit.com/courses/language-models-hugging-face/gradio-demos">Read the English lesson and worked example on GuideWit.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=03d6afe77aaf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidewit/test-the-maintenance-demo-before-connecting-a-model-03d6afe77aaf">Test the maintenance demo before connecting a model</a> was originally published in <a href="https://medium.com/guidewit">GuideWit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The service note sounds right. Which part number did the model actually check?]]></title>
            <link>https://medium.com/guidewit/the-service-note-sounds-right-which-part-number-did-the-model-actually-check-be4c65d30229?source=rss-cb6569dd015a------2</link>
            <guid isPermaLink="false">https://medium.com/p/be4c65d30229</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[large-language-models]]></category>
            <dc:creator><![CDATA[GuideWit]]></dc:creator>
            <pubDate>Mon, 16 Nov 2026 06:51:01 GMT</pubDate>
            <atom:updated>2026-11-16T06:51:01.599Z</atom:updated>
            <content:encoded><![CDATA[<p>An operator asks a language model to finish a service note: “For pump P-17, the replacement seal is …” The system supplies a familiar-looking part number and a confident explanation. A second pump uses a nearly identical number. What evidence would justify adding the proposed part to a work order?</p><p>AI helped draft this article. The pumps and invented catalog codes are a GuideWit exercise. Ava Amini’s closing core lecture at MIT examines generalization and failure modes, diffusion models and large language models. A small parts desk gives us a concrete way to separate fluent generation from a correct operational claim. <a href="https://www.youtube.com/watch?v=ev7cLSd-ySE&amp;t=2607s">Large language models, 43:27</a></p><h3>Put a boundary around the prediction</h3><p>An autoregressive language model represents the preceding text as tokens and uses the prefix to assign scores to possible next tokens. A normalization step converts scores to a probability distribution. A decoding rule chooses a token, appends it to the prefix and repeats the process. A printed part number can require several tokens. A model can therefore assemble a plausible code without storing that exact code as a single vocabulary item.</p><p>For paper arithmetic only, suppose each of two invented codes is one token. Given the prefix, the model assigns 0.6 to S42, 0.3 to S24 and 0.1 to an end token. These three numbers sum to one. Greedy decoding chooses S42. If the desk instead samples repeatedly from this unchanged distribution, roughly six out of ten draws would be S42 in the long run. A random run of ten need not contain exactly six.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DLd8wsEPBI-WCePd" /></figure><p><em>GuideWit worked example. Trace the next token. S42: 0.6 → S24: 0.3 → EOS: 0.1.</em></p><p>The value 0.6 answers a narrow question in this setup: how much probability did the model assign to this continuation among its alternatives? It does not estimate the probability that S42 fits the physical pump without further assumptions and evaluation. If yesterday’s service notes used S42 often, a familiar continuation could look good even when the catalog for this serial number says something else.</p><h3>Bring the catalog into the room</h3><p>Create a tiny approved snapshot. P-17 revision A uses S24. P-17 revision B uses S42. A ticket that names only P-17 leaves a genuine ambiguity. The model chose S42, but the evidence available to the desk does not decide between revisions. The useful next action is to obtain the revision from the nameplate or equipment record.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VFAXSq9OfO17CO4G" /></figure><p><em>GuideWit worked example. Read the catalog before the prose. P-17 → A → S24 → B → S42.</em></p><p>Now add “revision A” and supply the two approved catalog rows, including their effective date. Ask for the code and the row used. Then compare the actual returned code with that exact row before the work order is released. A citation containing P-17 but pointing to revision B is still a wrong match. The validation rule should compare equipment, revision and code, since those are the fields the technician needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SDMkIhNUfw0lVpn0" /></figure><p><em>GuideWit worked example. Check the evidence row. P-17 + A → A → S24 → S24 ✓.</em></p><p>This is a different intervention from changing the temperature of sampling. Lower temperature concentrates probability on higher-scoring continuations and can make repeated runs more similar. It does not supply the missing revision. At the limit of greedy choice the assistant could consistently return precisely the same wrong part. Record consistency and factual agreement as separate measurements.</p><h3>Check the model on the cases that look alike</h3><p>Make a paired test. Keep the surrounding text identical and change revision A to revision B. The expected codes are S24 and S42 respectively. Then remove the revision altogether and expect a request for clarification. Finally, use an unknown revision C and expect the answer to remain unresolved. Each edit changes one condition, so a failure is easier to diagnose.</p><p>Keep all notes for a given ticket together when evaluating. An assistant trained on one version of a note and tested on a nearly identical copy may appear to generalize to new assets. Also hold back some equipment families or later catalog revisions to see what changes under distribution shift. A perfect score on a collection of near duplicates says little about how the desk will handle tomorrow’s catalog change. <a href="https://www.youtube.com/watch?v=ev7cLSd-ySE&amp;t=530s">Generalization challenges, 08:50</a></p><p>If ten tickets contain a resolvable revision and the assistant answers eight, seven correctly, precision among answered tickets is 7/8. Coverage on the ten resolvable tickets is 8/10. Report the unanswered cases too. A system can achieve excellent precision by avoiding most work. Separately track ambiguous tickets on which it guessed a code, since those are exactly the cases where a fluent answer can create a purchase error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pUz3u57fb5TO2EE8" /></figure><p><em>GuideWit worked example. Test matched cases. 7 / 8 → 8 / 10 → 7 / 10.</em></p><h3>Different generators solve different prediction problems</h3><p>Earlier in the same lecture the diffusion section follows a process that adds noise and a model that learns a reverse denoising process. Sampling repeatedly refines a noisy representation. That is a different generation path from appending one text token at a time. Both can produce plausible samples from what they learned. Neither sampling procedure supplies the revision-specific catalog row. <a href="https://www.youtube.com/watch?v=ev7cLSd-ySE&amp;t=1739s">Generative diffusion, 28:59</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wFlkWTA5ESLrrAiQ" /></figure><p><em>GuideWit worked example. Distinguish the generators. x₀ → xₜ → ε → xₜ → x₀.</em></p><p>Likewise, fine-tuning a model to adopt the house style of service notes can make its prose easier to scan. It does not demonstrate that a recently superseded code has been replaced everywhere. Test the style change with formatting criteria. Test the part number with current, versioned records. Keeping those checks separate prevents a more professional-sounding paragraph from receiving credit for an engineering decision it never verified.</p><h3>Decide what the technician can use</h3><p>When revision A is known and the approved entry maps it to S24, the desk can attach S24 together with its evidence. When the revision is missing, leave the part field open and request the missing detail. The original answer S42 gets no special status from sounding familiar. It becomes acceptable for this exercise only if the case matches the revision B entry.</p><p>A final check for the release procedure: the assistant returns “S24” for revision A but cites the revision B row. The code happens to match the correct answer. Should the audit mark the response fully correct? A code-only metric would. A desk that requires traceability should record a correct code and an incorrect supporting row separately, then ask for the proper evidence before release. <a href="https://introtodeeplearning.com/2026/slides/6S191_MIT_DeepLearning_L6.pdf">MIT lecture slides</a></p><p><a href="https://guidewit.com/courses/deep-learning-mit/language-models">Read the English lesson and worked example on GuideWit.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be4c65d30229" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidewit/the-service-note-sounds-right-which-part-number-did-the-model-actually-check-be4c65d30229">The service note sounds right. Which part number did the model actually check?</a> was originally published in <a href="https://medium.com/guidewit">GuideWit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Before changing the learning rate, read one failing batch]]></title>
            <link>https://medium.com/guidewit/before-changing-the-learning-rate-read-one-failing-batch-bdddbb16b462?source=rss-cb6569dd015a------2</link>
            <guid isPermaLink="false">https://medium.com/p/bdddbb16b462</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[GuideWit]]></dc:creator>
            <pubDate>Sun, 15 Nov 2026 06:51:01 GMT</pubDate>
            <atom:updated>2026-11-15T06:51:01.367Z</atom:updated>
            <content:encoded><![CDATA[<p>A training run stops with a label bounds error after loading its first batch. Should you reduce the learning rate, rent a larger GPU or inspect the labels? Build the smallest example that can distinguish a malformed target from a numerical training problem.</p><p><em>AI assisted the writing of this article. The worked case and diagram are original teaching examples.</em></p><h3>Locate the broken boundary</h3><p>Long training programs compress several independent operations into one call. A message about an invalid target may appear inside a device kernel, far from the code that created the label map. Start by taking a single example from each relevant split and printing the label values alongside their names. Then inspect a collated batch. Do the values still describe the same classes, with the same integer encoding? A tiny batch on a CPU can be easier to inspect when the production error came from a GPU.</p><p>The course debugs a Trainer run on the three-way MNLI task. It works through the dataset, data loader, model forward pass and first optimization step. For silent failures it also recommends trying to overfit a tiny batch. Each stage gives you an observation before you start a long training job. <a href="https://huggingface.co/learn/llm-course/en/chapter8/2">What to do when you get an error</a>.</p><p>The boundary check in this exercise is deliberately cheap. It needs the number of output columns and the target integers. It does not need a scheduler, a large dataset or an optimization step. If the task genuinely contains three classes, a model configured with two output columns cannot represent one of them. If the source instead encodes two classes as one and two, adding an extra column leaves a spurious unused class. The same exception points to two different repairs.</p><p><a href="https://www.youtube.com/watch?v=L-WSwUWde1U&amp;t=68s">Debugging the Training Pipeline (PyTorch) · Inspect dataset columns · 01:08</a>.</p><h3>Two outputs and a third target</h3><p>Write down the number of output classes and the first batch of integer targets. With two output classes, the valid indices are zero and one. The example targets below include two, which refers to a third column that the logits do not contain.</p><p>Run the range check before computing loss. Inspect the source label definitions. If the task genuinely has three classes, configure three outputs with a matching label map. If the source uses one-based labels, explicitly map the entire vocabulary consistently in every split.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*emso-tB3kuZJ8PCW" /></figure><p><em>Original GuideWit diagram. Target two is invalid with two output classes and valid with three.</em></p><p>After the range check passes, inspect one forward pass, the loss and a single optimizer step. If the issue persists, report the smallest failing batch, package versions, expected result, actual exception and reproduction instructions. Use synthetic records that preserve the failing shape.</p><ul><li><strong>Outputs: </strong>K = 2<strong> · Range check: </strong>0 ≤ 2 &lt; 2<strong> · Result: </strong>False</li><li><strong>Outputs: </strong>K = 3<strong> · Range check: </strong>0 ≤ 2 &lt; 3<strong> · Result: </strong>True</li></ul><pre>target = [0, 1, 2]<br>for classes in (2, 3):<br>    invalid = [value for value in target if not 0 &lt;= value &lt; classes]<br>    print(classes, invalid)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/0*53C3z7aF_E3s1GWg" /></figure><p><em>GuideWit local Python experiment. With two classes, target two is outside the range. With three classes, the list of invalid targets is empty.</em></p><h3>A good bug report eliminates guesses</h3><p>Once you identify the smallest failing case, record the command, package versions and expected and observed results. Replace private maintenance descriptions with synthetic strings while preserving shapes, types and label values. Run the reduced example from a clean process. A reproduction that accidentally depends on a previous notebook cell may work for its author and fail to demonstrate the issue for someone else.</p><p>A one-batch overfit test addresses a different question. If a model cannot learn a tiny, consistent batch, investigate gradient flow, labels and optimizer updates. Passing that test still leaves generalization to be evaluated on separate examples.</p><p>If the exception disappears after fixing the encoding, the original diagnosis has been tested. Proceed to one update and a tiny-batch overfit check to find more subtle training problems. A model that learns a handful of examples can still rely on shortcuts and fail on unseen incidents. Keep the questions separate in the experiment log: did the pipeline run, did the parameters change, and did the resulting model generalize? Only the first two can be tested with the tiny batch alone.</p><h3>Separate three repairs that make the exception disappear</h3><p>Consider three edits to the failing script. You can add an output column, subtract one from the targets, or drop whichever row contains a two. Each change can make a particular bounds error disappear. Only one may respect the intended task. If the label definitions are normal, urgent and deferred, three output columns make sense. If the two categories are encoded as one and two, consistent remapping makes sense. Dropping the row would hide a category or a data problem, so it needs a separate reason beyond making the run finish.</p><p>Inspect examples from validation as well as training. A rare class might be absent from the first few batches yet appear later. A range check on one batch is a diagnostic, not a guarantee for the whole corpus. After understanding the failure, audit the distinct target values in each labeled split and compare them with the declared vocabulary. Keep any legitimate ignore sentinel separate from ordinary class indices and confirm that the loss is actually configured to ignore it.</p><p>Once the encoding is correct, test one optimization step with the same miniature case. Record the loss before and after several deliberate updates on that case. The point is to see whether any parameter movement reaches the supervised outputs. A large run with aggressive scheduling or many workers would introduce extra explanations if the result stayed flat.</p><p>Save a passing reproduction alongside the original failure description. If changing a data loader later reintroduces one-based labels, the fixture will identify the boundary that broke. The useful result of the debugging session is a check another maintainer can rerun, plus an explanation of why the corrected class map matches the real task.</p><h3>Would clipping the label fix the bug?</h3><p>Would clipping every target to one fix the example? It would erase the third category. Determine the intended label map first.</p><p>Why include a tiny synthetic batch in a help request? It lets another person reproduce the failure without access to the original records.</p><p>Further reading in the <a href="https://huggingface.co/learn/llm-course/en/chapter8/1">Hugging Face LLM Course, chapter 8</a>.</p><p><a href="https://guidewit.com/courses/language-models-hugging-face/debugging">Read the English lesson and worked example on GuideWit.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bdddbb16b462" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidewit/before-changing-the-learning-rate-read-one-failing-batch-bdddbb16b462">Before changing the learning rate, read one failing batch</a> was originally published in <a href="https://medium.com/guidewit">GuideWit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A five-position input with only two training labels]]></title>
            <link>https://medium.com/guidewit/a-five-position-input-with-only-two-training-labels-920a17b12c70?source=rss-cb6569dd015a------2</link>
            <guid isPermaLink="false">https://medium.com/p/920a17b12c70</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[named-entity-recognition]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[GuideWit]]></dc:creator>
            <pubDate>Sat, 14 Nov 2026 16:26:01 GMT</pubDate>
            <atom:updated>2026-11-14T16:26:01.688Z</atom:updated>
            <content:encoded><![CDATA[<p>A technician labels the word PumpA as equipment in a short report. The tokenizer splits that word into two pieces and inserts boundary symbols. Where should the training label go? Make an explicit choice before passing the example to a token classifier.</p><p><em>AI assisted the writing of this article. The worked case and diagram are original teaching examples.</em></p><h3>Count supervised decisions before you count tokens</h3><p>A maintenance engineer recognizes PumpA as one equipment name. A tokenizer can divide the same text into a familiar base and a rare suffix. Looking only at the list of pieces makes it tempting to attach the second word’s label to the suffix. Every later label can then shift one position, and the model may still train without raising a shape error if someone fills the rest of the array with defaults. The original word identifiers provide the missing correspondence.</p><p>The chapter uses CoNLL-style entity labels to explain token classification. Its worked approach uses word identifiers to align labels with pieces and turns a beginning tag into an inside tag on a continuation. Another valid policy labels only the first piece of each word. The exercise below adopts the latter policy throughout. <a href="https://huggingface.co/learn/llm-course/en/chapter7/2">Token classification</a>.</p><p>First-piece labeling and all-piece labeling each make a defensible choice about a different unit. With first-piece labeling, each original word contributes one supervised position regardless of its spelling. With all-piece labeling, the model receives a learning signal at each part and must distinguish beginnings from continuations under a BIO scheme. Compare losses or token-level scores only after checking which positions were included. The same printed percentage can describe different sets of decisions.</p><p><a href="https://www.youtube.com/watch?v=iY2AZYdZAr0&amp;t=60s">Data processing for Token Classification · Entity labels · 01:00</a>.</p><h3>A supervision mask you can inspect</h3><p>Start with two words, PumpA and stalled. Their labels are equipment and outside. Suppose the tokenizer returns five positions with word indices missing, zero, zero, one and missing. The two missing indices belong to special tokens.</p><p>Under first-piece supervision, assign the equipment class to the first zero and skip the second zero. Assign outside to index one. Use minus one hundred for skipped or special positions when using a loss configured with that ignore index. The resulting vector has five entries and two contribute to the loss.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*IGHDiEoJCrQ1wQ_w" /></figure><p><em>Original GuideWit diagram. Five token positions align with two supervised words.</em></p><p>At evaluation, remove ignored positions from both references and predictions before comparing them. When displaying a highlighted word, use offsets from the original note and recover the whole equipment span. A good score on the first piece does not highlight a full identifier by itself.</p><ul><li><strong>Piece: </strong>[CLS]<strong> · Word index: </strong>None<strong> · Target: </strong>−100</li><li><strong>Piece: </strong>Pump<strong> · Word index: </strong>0<strong> · Target: </strong>1</li><li><strong>Piece: </strong>##A<strong> · Word index: </strong>0<strong> · Target: </strong>−100</li><li><strong>Piece: </strong>stalled<strong> · Word index: </strong>1<strong> · Target: </strong>0</li><li><strong>Piece: </strong>[SEP]<strong> · Word index: </strong>None<strong> · Target: </strong>−100</li></ul><pre>word_ids = [None, 0, 0, 1, None]<br>word_labels = [1, 0]<br>labels = []<br>previous = None<br>for word in word_ids:<br>    first_piece = word is not None and word != previous<br>    labels.append(word_labels[word] if first_piece else -100)<br>    previous = word<br>print(labels)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/0*4N6auKOOitw5TWqw" /></figure><p><em>GuideWit local Python experiment. The five output positions contain just two training labels. The other three positions carry the ignore value −100.</em></p><h3>The highlighted span is a second output</h3><p>A safety reviewer looking at a work order sees characters, not model positions. Once you have a predicted label, map it back to the original note. For a split equipment identifier, a highlight that stops before the suffix can refer to an entire machine family instead of a particular asset. The offset check catches an interface problem that can survive a perfectly reasonable model evaluation.</p><p>Compare the two policies on an identifier that fragments into four pieces. Labeling every piece increases the weight of that word relative to a short word. Whichever policy you choose, use the same interpretation during training and evaluation.</p><p>Try a note with the same identifier twice, once in a historical comparison and once as the subject of a new fault. A simple search for the first occurrence of the predicted string can highlight the wrong mention. Offsets tied to the exact input avoid that ambiguity. Keep the source text, model positions, word indices and displayed character range together for a few fixtures. A reviewer can then trace a single wrong highlight through every transformation that might have caused it.</p><h3>Trace a misplaced highlight all the way back</h3><p>Take an inspector’s note containing “PumpA stalled.” Suppose the interface highlights just the letter A. Save the original string with its character positions and examine the model’s predicted positions. Was the equipment class assigned to the suffix, or did the display code choose the suffix after a correct prediction on the first piece? The first error belongs to alignment or prediction. The second belongs to reconstruction. Looking at the colored text alone cannot distinguish them.</p><p>Now add a special token at the beginning of the encoded sequence and repeat the alignment by hand. A shortcut that assigns the first word label to position zero will label the special token and shift every decision that follows. Word identifiers avoid this offset assumption. A special token carries no source word identifier, so the mapping explicitly excludes it. When a batch adds padding, the same principle applies to the extra positions. Inspect both the padded labels and the attention mask; they serve different purposes.</p><p>For a small acceptance test, include an ordinary word, a fragmented equipment identifier, two adjacent entities and a repeated name. Draw the expected character span for each entity before running the model. Compare the displayed spans with those references as well as checking the supervised labels. A model can label both beginnings correctly while the interface merges two adjacent assets into a single highlight.</p><p>The output the inspector receives is a highlighted mention in a specific report. Retaining the original input, character offsets and word-to-token mapping makes that output auditable. If the equipment naming convention later changes, add an example with the new suffix and repeat the same trace before deciding whether the classifier needs retraining.</p><h3>Which two positions count?</h3><p>How many positions carry supervised labels in this exercise? Two. Each original word contributes once.</p><p>How could a continuation be labeled under the chapter’s all-piece policy? Use an inside tag when the original label starts a multi-piece entity.</p><p>Further reading in the <a href="https://huggingface.co/learn/llm-course/en/chapter7/1">Hugging Face LLM Course, chapter 7</a>.</p><p><a href="https://guidewit.com/courses/language-models-hugging-face/token-classification">Read the English lesson and worked example on GuideWit.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=920a17b12c70" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidewit/a-five-position-input-with-only-two-training-labels-920a17b12c70">A five-position input with only two training labels</a> was originally published in <a href="https://medium.com/guidewit">GuideWit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A warehouse robot can lose a delivery by taking the fastest first step]]></title>
            <link>https://medium.com/guidewit/a-warehouse-robot-can-lose-a-delivery-by-taking-the-fastest-first-step-945e32a8b1cc?source=rss-cb6569dd015a------2</link>
            <guid isPermaLink="false">https://medium.com/p/945e32a8b1cc</guid>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <dc:creator><![CDATA[GuideWit]]></dc:creator>
            <pubDate>Sat, 14 Nov 2026 06:51:01 GMT</pubDate>
            <atom:updated>2026-11-14T06:51:01.615Z</atom:updated>
            <content:encoded><![CDATA[<p>A robot reaches a junction with a parcel onboard. One route pays a small simulated reward immediately for handing it to a local buffer. The other costs one unit now but lets the robot finish the delivery on the next step. Which action should the dispatcher teach it to take? The answer depends on when the rest of the reward arrives and how much the objective values it.</p><p>AI helped draft this article. The junction is a GuideWit simulation on paper. Alexander Amini’s MIT reinforcement learning lecture introduces states, actions, rewards and action values, then develops deep Q-networks and policy gradients. Keeping the warehouse tiny lets us see exactly which assumption changes the decision. <a href="https://www.youtube.com/watch?v=1ij3dweHu-0&amp;t=332s">RL concepts, 05:32</a></p><h3>Write down the world before choosing an algorithm</h3><p>Call the starting state J for junction. The action “buffer” gives +2 immediately and ends the episode. The action “dispatch” gives −1 and moves the robot into a delivery bay. In the bay the only available action completes delivery, gives +5, and ends the episode. For now every transition is deterministic, and the robot can tell which state it occupies. Those assumptions are part of the example, as important as any of its numbers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y5kZQg-1K1huYjYj" /></figure><p><em>GuideWit worked example. Draw the environment. J → B: +2 → J → D: −1 → D → ✓: +5.</em></p><p>A policy specifies how the robot chooses an action given the state. A reward is the signal attached to one transition. A return combines rewards over time. There is no supervisor in this setup giving the robot the correct action at the junction. It has to relate the action it takes now to rewards that may occur after the action is over.</p><h3>Compare two complete trajectories</h3><p>Use a discount factor of 0.9. The immediate reward gets full weight. A reward one step later gets 0.9 of its face value. Sending the parcel to the buffer yields a return of 2. Dispatching yields −1 + 0.9 × 5 = 3.5. A rule that picks the highest immediate reward will choose the buffer. A policy maximizing this discounted return will dispatch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8cFwjfh2cRb0qhXj" /></figure><p><em>GuideWit worked example. Compare returns. γ = 0.9 → −1 + 0.9 × 5 → 3.5 &gt; 2.</em></p><p>The reward of +5 arrives one step after −1, so it is discounted once. If the bay required another zero-reward waiting step, the return would be −1 + 0.9² × 5 = 3.05. The delivery remains attractive at this discount, but the extra wait already changes its value. In a real station, two models with different time steps can imply different effective preferences even if their numeric discount factors look identical.</p><h3>Find the point at which the decision reverses</h3><p>Leave the routes and rewards unchanged and call the discount factor g. Dispatch wins precisely when −1 + 5g &gt; 2, which simplifies to g &gt; 0.6. At 0.6 the actions tie. At 0.5 the dispatch return is 1.5, so the buffer wins. Neither the travel time nor the parcel changed. We altered the objective.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AdBXLB38Ip3cK7i5" /></figure><p><em>GuideWit worked example. Solve the boundary. γ = 0.6 → −1 + 0.6 × 5 → 2 = 2.</em></p><p>This is why evaluating a learned policy begins with writing down the reward schedule and unit of time. A team that says it values completed deliveries but rewards early handoffs more heavily than downstream completion may train an effective optimizer of the wrong business measure. A paper calculation can uncover the mismatch before anyone starts a training job.</p><h3>Give each action a value</h3><p>An action-value function Q describes the expected discounted return after choosing an action in a state and continuing according to a specified policy, or optimally when we write Q*. In the deterministic bay there is only one action and its value is 5. The target for dispatch from J is therefore −1 + 0.9 × 5. For a terminal handoff the target is just 2. There is no later state value to add once the episode has ended. <a href="https://www.youtube.com/watch?v=1ij3dweHu-0&amp;t=787s">Q-function foundations, 13:07</a></p><p>With a current estimate of zero and a learning rate of 0.2, a simple one-step Q-learning update for dispatch moves the estimate to 0 + 0.2 × (3.5 − 0) = 0.7, assuming the next-state estimate is already 5. The target and the updated estimate are different numbers. That distinction explains how an agent can experience a profitable route once without immediately behaving as if its estimate were perfect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dNy3-IXO3QhJPtDk" /></figure><p><em>GuideWit worked example. Update an estimate. Q = 0 → 0.2 × (3.5 − 0) → Q′ = 0.7.</em></p><p>A deep Q-network replaces a small lookup table with a learned function over observations. Its ability to share information across similar inputs is helpful when a camera produces more states than a table could store. But the same sharing can propagate a bad estimate to neighboring situations. Experience replay and target networks address aspects of unstable training. Neither device rescues a reward that tells the robot to do the wrong job.</p><h3>Check what the observation leaves out</h3><p>Suppose the bay closes during the last minute of a shift. A robot that sees only “junction” cannot distinguish an open bay from a closed one. If the two cases yield different outcomes, adding more examples to the same observation will mix them together. Include a relevant signal such as bay availability, then re-evaluate the policy across both conditions.</p><p>If dispatch succeeds only 60 percent of the time and failure yields zero on the second step, its expected return at 0.9 becomes −1 + 0.9 × (0.6 × 5) = 1.7. The buffer now wins even with the original discount. Reliability and patience are separate reasons to choose the other route. Logging the transition outcomes lets the dispatcher distinguish them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wk57CakS9nbskJ86" /></figure><p><em>GuideWit worked example. Change the transition. p = 0.6 → −1 + 0.9 × 3 → 1.7 &lt; 2.</em></p><p>For steering angles rather than two labeled choices, a policy can directly parameterize an action distribution, as the lecture’s policy-gradient section explains. Our junction does not require that complexity. Two routes and a terminal flag are enough to test the principle. At the desk, ask one final question: if a terminal handoff gives +2 and a buggy update also adds a future value of 5, what happens? Its target becomes 6.5 at this discount. An imaginary future now outranks a real delivery. <a href="https://introtodeeplearning.com/2026/slides/6S191_MIT_DeepLearning_L5.pdf#page=29">MIT slides on DQN training</a></p><p><a href="https://guidewit.com/courses/deep-learning-mit/reinforcement-learning">Read the English lesson and worked example on GuideWit.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=945e32a8b1cc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidewit/a-warehouse-robot-can-lose-a-delivery-by-taking-the-fastest-first-step-945e32a8b1cc">A warehouse robot can lose a delivery by taking the fastest first step</a> was originally published in <a href="https://medium.com/guidewit">GuideWit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The passenger got a timetable. The primary flight service still failed.]]></title>
            <link>https://medium.com/guidewit/the-passenger-got-a-timetable-the-primary-flight-service-still-failed-e02c0aafa836?source=rss-cb6569dd015a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e02c0aafa836</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[GuideWit]]></dc:creator>
            <pubDate>Fri, 13 Nov 2026 16:26:01 GMT</pubDate>
            <atom:updated>2026-11-13T16:26:01.810Z</atom:updated>
            <content:encoded><![CDATA[<p>A passenger asks for a flight to Barcelona. Moments later the assistant can offer departure times. From the passenger’s side of the conversation that looks like an ordinary success. From the operator’s side, the primary timetable service returned an error. If the dashboard counts only useful final answers, when will anyone notice that the primary route is broken?</p><p>This article was drafted with AI assistance from Microsoft’s lesson on deploying agents to production. Its filmed example deliberately fails a timetable lookup and provides a backup. Follow the request through both services before designing a metric for it. Our airport-mismatch and retry exercises extend the recorded case and ask whether a nominal recovery really gave the passenger the information they requested.</p><h3>Start at the point where the passenger’s words enter the system</h3><p>The instructor describes evaluating several points along the request path: access to the model or service, the interpretation of user intent, the tool chosen, the tool response and the user’s reaction to the final answer. Each point can fail while its neighbours appear healthy. A fast connection tells you little about whether the passenger’s request was interpreted correctly. A correctly chosen tool can still return an error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lLRpX7dkP8AqyqVA" /></figure><p><em>GuideWit diagram 1. A request moves through intent recognition to tool selection.</em> <a href="https://www.youtube.com/watch?v=l4TP6IyJxmQ&amp;t=50s">00:50 · Microsoft Learn</a></p><p>For this flight assistant, the wording introduces a particularly important boundary. “Book me a flight” expresses a broad goal. A function that retrieves flight times can advance that goal by producing options. A successful timetable response cannot on its own establish that a seat was reserved. Decide which intermediate result the application can legitimately promise before assigning a success label to the full interaction.</p><h3>Keep the tool call and the tool result on separate lines</h3><p>Suppose the route in the user’s request is Barcelona and the assistant calls the timetable lookup with Barcelona as the destination. So far it has selected a suitable tool and supplied a relevant argument. Now imagine several possible replies: a list of times, an empty list from a healthy source, an error, or times for another city. Each needs different treatment. Recording just “tool called” hides the difference that matters to the passenger.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9qko1zQuT_kMq4SR" /></figure><p><em>GuideWit diagram 2. Tool output enters the evaluation separately from the assistant’s final wording.</em> <a href="https://www.youtube.com/watch?v=l4TP6IyJxmQ&amp;t=115s">01:55 · Microsoft Learn</a></p><p>The course also discusses user feedback and manual or model-based assessment. A passenger’s negative rating can expose a disappointing outcome, yet it cannot locate a broken stage. A positive rating has a similar limit. The passenger may reasonably be delighted to receive options even as the primary service fails on every request. Pair user feedback with the request trace if you want to tell those stories apart.</p><h3>Read the 404 as narrowly as the evidence allows</h3><p>In the filmed code, the primary flight-times function deliberately produces an HTTP 404 error. The instructor is modelling an external dependency that fails. For this run, the trace supports a precise statement: this primary timetable lookup did not deliver the requested times. It does not establish that there are no flights to Barcelona, that an airline has cancelled a departure or that an operator has found the root cause.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TQmksEcTy07FYUPe" /></figure><p><em>GuideWit diagram 3. The primary Barcelona lookup is deliberately made to fail.</em> <a href="https://www.youtube.com/watch?v=l4TP6IyJxmQ&amp;t=212s">03:32 · Microsoft Learn</a></p><p>A simple test can expose a costly interpretation error. Replace the service response with the simulated failure, then examine the passenger message. “There are no flights” misstates the evidence and may send the traveller off to pick another destination. “I couldn’t retrieve times from the primary source” accurately describes the observation. If a suitable backup is available, the application can try it before burdening the passenger with a technical explanation.</p><h3>Make the backup answer the original question</h3><p>The assistant in the example has access to a backup function and instructions for using it when the main timetable service is down. That gives the application another way to retrieve times. It does not mean that any result from a second service is suitable. A practical backup must handle the intended destination and provide comparable information in a form that the next step can interpret.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5bE07CIANWdVUgk9" /></figure><p><em>GuideWit diagram 4. The fallback path is associated with timetable lookup.</em> <a href="https://www.youtube.com/watch?v=l4TP6IyJxmQ&amp;t=268s">04:28 · Microsoft Learn</a></p><p>For our test, ask for departures from a particular airport on a particular local date, then make the backup return a timetable from a neighbouring airport. The second call is technically successful. Its payload may even be well formed. Displaying those times without identifying the change could still cause the passenger to go to the wrong place. The acceptance check must compare the returned route and date with the request. A different airport might be a useful alternative if it is explicitly offered as one.</p><p>The same distinction applies to freshness. A timestamp tells the assistant when it received the backup response. That need not be when the underlying timetable was updated. If the passenger needs a live departure board, a day-old cached schedule is not interchangeable with live status. The question to ask the backup owner is specific: which timestamp describes the observation the passenger intends to rely on?</p><h3>Count the recovery as well as the failure</h3><p>In the video, the trace shows the original request with Barcelona, the primary error and the next call to the backup that supplies times. The passenger can receive options. Meanwhile an operator has evidence both of a failure and of a successful recovery. Keeping both means you can notice the loss of redundancy while the service still appears to work for users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LVIFMNMcXhVdqAfG" /></figure><p><em>GuideWit diagram 5. The recorded sequence reaches the backup and obtains timetable options.</em> <a href="https://www.youtube.com/watch?v=l4TP6IyJxmQ&amp;t=311s">05:11 · Microsoft Learn</a></p><ul><li><strong>Event in an illustrative test batch: </strong>Requests sent to the primary<strong> · Count: </strong>100<strong> · What the count tells an operator: </strong>Denominator for the primary failure rate</li><li><strong>Event in an illustrative test batch: </strong>Primary calls failed<strong> · Count: </strong>12<strong> · What the count tells an operator: </strong>Primary failure rate is 12 per cent</li><li><strong>Event in an illustrative test batch: </strong>Failed calls recovered with acceptable backup data<strong> · Count: </strong>10<strong> · What the count tells an operator: </strong>Ten of twelve failures were recovered</li><li><strong>Event in an illustrative test batch: </strong>Requests without usable results<strong> · Count: </strong>2<strong> · What the count tells an operator: </strong>Two passengers still lack timetable options</li></ul><p>These figures are an editorial exercise, not measurements from Microsoft. Assuming one primary call per request and no other failure paths, 98 of the 100 requests yielded usable options. A dashboard that displayed only 98 per cent would conceal the fact that twelve requests needed an alternative and two exhausted it. A dashboard that displayed only twelve failures would understate the service actually delivered.</p><p>One last boundary appears when this pattern grows from lookup to purchase. Repeating a read on a backup can retrieve another timetable. Repeating a purchase after the first service times out can create a second reservation if the first purchase succeeded before its response was lost. Verify the earlier transaction’s status before attempting that write again. The video demonstrates a read fallback, so the distinction is yours to preserve when adapting it.</p><p>The current Microsoft notebook adds related exercises on observability, evaluation and cost. <a href="https://learn.microsoft.com/en-us/shows/ai-agents-for-beginners/how-to-deploy-ai-agents-into-production">Recorded lesson</a> · <a href="https://github.com/microsoft/ai-agents-for-beginners/blob/main/10-ai-agents-production/code_samples/10-python-agent-framework.ipynb">Production notebook</a></p><p><strong>Try the release decision.</strong> Your backup returns a timetable for the right city but the wrong local date. Can this interaction count as recovered? Only if the original question has actually been answered. Keep the primary failure in the trace, reject the mismatched result and give the passenger an accurate account of what remains unavailable.</p><p><a href="https://guidewit.com/courses/ai-agents-for-beginners/production-agents">Read the English lesson and worked example on GuideWit.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e02c0aafa836" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidewit/the-passenger-got-a-timetable-the-primary-flight-service-still-failed-e02c0aafa836">The passenger got a timetable. The primary flight service still failed.</a> was originally published in <a href="https://medium.com/guidewit">GuideWit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How one BPE merge changes the spelling a model sees]]></title>
            <link>https://medium.com/guidewit/how-one-bpe-merge-changes-the-spelling-a-model-sees-578c7724c9cd?source=rss-cb6569dd015a------2</link>
            <guid isPermaLink="false">https://medium.com/p/578c7724c9cd</guid>
            <category><![CDATA[tokenization]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[GuideWit]]></dc:creator>
            <pubDate>Fri, 13 Nov 2026 06:51:01 GMT</pubDate>
            <atom:updated>2026-11-13T06:51:01.495Z</atom:updated>
            <content:encoded><![CDATA[<p>A team sees the letter sequence AB in nearly every maintenance code. Can a tokenizer learn to represent it with one token? Work one training step on three short words and then apply that frozen rule to an unfamiliar word.</p><p><em>AI assisted the writing of this article. The worked case and diagram are original teaching examples.</em></p><h3>A vocabulary begins with a counting decision</h3><p>Writing the words once in a set would hide the most important fact about this exercise. AB occurs twice. Treating both occurrences as one would change the evidence the tokenizer learns from. To make the count inspectable, place each distinct word in its own row and put its frequency beside it. Slide a window of two symbols over each row. Each adjacent pair receives the frequency of that row, even where a pair also appears in another word.</p><p>The chapter follows tokenization through normalization, splitting, a subword model and post-processing. It contrasts BPE, WordPiece and Unigram. BPE learns ordered merge rules by counting adjacent pairs in a training corpus. A fast tokenizer can also expose character offsets that connect pieces to the original string. <a href="https://huggingface.co/learn/llm-course/en/chapter6/3">Fast tokenizers’ special powers</a>.</p><p>Now consider what happens after the first merge. In ABD the original sequence of three symbols has become a sequence of two. Its available neighboring pair has changed. A second training step must count the current symbols again. Combining a list of independently frequent character pairs from the original corpus would skip this dependency. BPE learns an order, and earlier decisions alter the candidates available for later decisions.</p><p><a href="https://www.youtube.com/watch?v=HEikzVL-lZU&amp;t=70s">Byte Pair Encoding Tokenization · Counting frequencies · 01:10</a>.</p><h3>Count the first merge</h3><p>Use a training vocabulary with AB twice, AC once and ABD once. Begin with one token per character and keep each word separate. Count occurrences of adjacent symbols, weighting them by the frequency of the word. AB contributes twice from the first word and once from ABD.</p><p>The winning pair A plus B occurs three times. A plus C and B plus D each occur once. Replace A and B with the learned token AB wherever they are adjacent inside a word. The symbols in ABD now become AB followed by D.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*NbWddHt2y85VcsEL" /></figure><p><em>Original GuideWit diagram. The pair A plus B occurs three times and each alternative once.</em></p><p>Apply just this one rule to ABC. The result is AB followed by C because no rule for AB plus C has been learned. This exercise assumes all three characters are already in the alphabet and that there are no special tokens or boundary markers.</p><ul><li><strong>Pair: </strong>A + B<strong> · Contributions: </strong>2 × AB, 1 × ABD<strong> · Count: </strong>3</li><li><strong>Pair: </strong>A + C<strong> · Contributions: </strong>1 × AC<strong> · Count: </strong>1</li><li><strong>Pair: </strong>B + D<strong> · Contributions: </strong>1 × ABD<strong> · Count: </strong>1</li></ul><pre>from collections import Counter<br>words = {&quot;AB&quot;: 2, &quot;AC&quot;: 1, &quot;ABD&quot;: 1}<br>pairs = Counter()<br>for word, frequency in words.items():<br>    for pair in zip(word, word[1:]):<br>        pairs[pair] += frequency<br>print(pairs.most_common())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/0*C_Lot8HOU4TjLTSe" /></figure><p><em>GuideWit local Python experiment. The frequency counter returns three for the pair A and B, versus one for each alternative.</em></p><h3>What a shorter code costs downstream</h3><p>A single token for a common prefix can leave more of a long note inside the model’s input window. That benefit is measurable: count the pieces per identifier and inspect the retained end of the note. It comes with a separate compatibility question. A pretrained model learned an embedding for each token identifier it received during training. Replacing its tokenizer can cause the same integer to address a different symbol while the matrix shape still looks valid.</p><p>If you train a new tokenizer for a pretrained network, matching a token’s printed spelling is insufficient. Token identifiers address learned embedding rows. Changing the vocabulary can change that correspondence and requires a compatible model or additional training.</p><p>A sensible comparison keeps a small set of actual identifier patterns aside before training the vocabulary. Include common prefixes, rare suffixes, mixed case and punctuation. Run both tokenizers on those strings and print the pieces and offsets as well as the length. If an uppercase equipment code is normalized into lowercase, decide whether the distinction matters to the downstream task. Fewer tokens alone cannot establish that the new vocabulary preserves the information the user needs.</p><h3>Change the corpus and predict the result</h3><p>Take the same three words and alter a single frequency. Suppose AC occurs four times while AB remains at two and ABD stays at one. The count for adjacent A and C becomes four. The count for A and B remains three. The winning first merge changes even though the alphabet and the set of distinct words stay the same. This is a small way to see how sampling and duplicate records influence vocabulary training. The distribution matters as much as the list of spellings.</p><p>Repeat the thought experiment with two equipment plants. One plant issues many codes beginning with AB and the other uses AC. A tokenizer learned from the first plant can still tokenize strings from the second when the required base symbols exist, but it may need more pieces. Measure the difference on held-out examples from each plant and check whether it changes truncation at the end of long notes. That turns a change in representation into an observable effect on the text a downstream model receives.</p><p>How would you handle a tie? Specify a deterministic choice in your hand implementation so you can repeat the exercise. Different tie-breaking conventions can produce different merge sequences from the same small corpus. If you use a library implementation, save its configuration and learned merge table as artifacts. Trying to reconstruct the vocabulary later from a vague description such as “BPE with the same number of tokens” leaves out decisions that determine the actual identifiers.</p><p>Finally decode a few encoded examples and compare them with the normalized inputs. If the process removes case or normalizes characters, exact reconstruction of the raw source may no longer be possible. That matters especially for equipment codes that differ by case or punctuation. Identify that change at preprocessing time, before interpreting a model error as a failure to understand the note.</p><h3>Can a rule join these two words?</h3><p>Can a merge cross from the end of AB to the next word AC here? No. The toy pre-tokenization establishes word boundaries first.</p><p>What does the single rule do to AC? Nothing. A and C remain separate symbols.</p><p>Further reading in the <a href="https://huggingface.co/learn/llm-course/en/chapter6/1">Hugging Face LLM Course, chapter 6</a>.</p><p><a href="https://guidewit.com/courses/language-models-hugging-face/tokenizer-training">Read the English lesson and worked example on GuideWit.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=578c7724c9cd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidewit/how-one-bpe-merge-changes-the-spelling-a-model-sees-578c7724c9cd">How one BPE merge changes the spelling a model sees</a> was originally published in <a href="https://medium.com/guidewit">GuideWit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>