Transformer models — Which model can route a maintenance note?
Learning route
Transformer families, task pipelines, transfer learning, inference, bias and limitations.
The course runs a sentiment pipeline that takes ordinary text and returns a label and a score. The tokenizer converts text into identifiers. The model produces numerical scores and the pipeline turns them into readable labels. The labels come from the task the model learned. A confidence score only compares the available labels.
Work through the case
Write the allowed queue codes on paper. For this exercise they are
MECHandSERVICE. RecordMECHas the expected route for the loose guard. Keep the original note alongside the answer so another person can audit the choice.Consider a sentiment classifier that returns
POSITIVE. Even a score of 0.99 fails the queue contract because the returned label does not name a queue. Run the small check below to reproduce that failure without downloading model weights.Now compare two candidates. An encoder with a classification head trained on routing labels can output a queue directly. A causal decoder can generate an answer given a prompt but may add a sentence. Validate its output with the same rule. An encoder-decoder model is another option when the deliverable is a rewritten handover rather than a code.
Original GuideWit diagram. Three candidate labels checked against the queue list and expected route.
Worked example
Output | Valid queue | Correct route |
|---|---|---|
"MECH" | True | True |
"POSITIVE" | False | False |
"SERVICE" | True | False |
Try it with Python 3
queues = {"MECH", "SERVICE"}
reference = "MECH"
for output in ["MECH", "POSITIVE", "SERVICE"]:
print(output, output in queues, output == reference)Expected output
MECH True True
POSITIVE False False
SERVICE True FalseGuideWit local Python experiment. MECH passes both checks. SERVICE belongs to the list but disagrees with the expected route.
A valid queue code can still be the wrong route. After checking membership, compare the prediction with an independently assigned label. Include notes with negation and notes that mention two faults. Record ambiguous cases for a dispatcher.
Troubleshooting
Symptom | Check |
|---|---|
A sentiment label reaches the queue field. | Read the classifier's label map and reject values outside the queue vocabulary. |
The output is a valid queue but misses the loose guard. | Compare it with the dispatcher's label and examine which phrase determined the route. |
Check your understanding
- Would a high sentiment score authorize a mechanical dispatch?
- What changes when the output must be a two-sentence handover?
Answer key
- No. The score describes sentiment labels and carries no evidence about the destination queue.
- You need a generation task and a check that the handover preserves the safety detail.
Glossary
Classification head — The part of a model that transforms its text representation into a score for each class.
Sources and chapter units
The case, Python check and diagram are original teaching examples. The chapter sources are listed below.
- Hugging Face LLM Course · 1
- Transformers, what can they do?
- How do Transformers work?
- Transformer Architectures
- Deep dive into Text Generation Inference with LLMs
- Bias and limitations
- The pipeline function · 00:32
- Welcome to the Hugging Face course
- Why is language processing challenging?
- The carbon footprint of Transformers
- What is Transfer Learning?
- The Transformer architecture
- How Transformers solve tasks
- Transformer models: Encoders
- Transformer models: Decoders
- Transformer models: Encoder-Decoders
- Inference with LLMs