Skip to content

Model families: decoder-only, masked encoders and encoder-decoder decisions

15 min reading

Distinguish autoregressive decoders, masked encoders and encoder-decoder models, then choose an operating boundary.

Page details

GenAI · Lesson 5 of 45 · 1 / 1.2

Sources · 15 min reading · 31 min with practice

Published · Last edited:

More
20px

Progress is saved in this browser when storage is available.

View guided paths and progress

Know first: Attention: self/cross-attention, context and KV state; derive storage and compute separately. Optional help: GenAI foundations.

Optional background references

Hypothetical scenario. The attention walkthrough gives Dev a shared vocabulary for models, but it does not choose one. Northwind needs to judge candidate policy evidence and draft an answer from selected passages. Maya asks whether one attention-based model can simply replace another in both roles.

Maya: “Both accept text. Why are we comparing different families?”

Dev: “A representation for a classifier and the next token of an answer are different outputs.”

Priya: “Show the prediction task and permitted context before choosing the architecture or delivery option.”

You will compare autoregressive decoders, masked encoders and encoder-decoder models without equating architecture names with task quality. Then connect the chosen input/output contract to an operating boundary. The visibility rules from page 04 give the family comparison a mechanism rather than just a list of labels.

Which prediction problem are we asking the model to solve?

An autoregressive decoder predicts the next token from its permitted prefix. A masked encoder such as BERT learns representations using a masked-token objective and bidirectional context; it is not simply a next-token generator with a different name. An encoder-decoder such as T5 encodes a source sequence and generates a target sequence, using cross-attention to connect them. Architecture, training objective and downstream task must be considered separately.

Hypothetical scenario. Northwind's toy source has six positions and its target has four. With one head per block, the dense grids are 6² = 36 for source self-attention, 4² = 16 for target self-attention and 4 × 6 = 24 for cross-attention: 36 + 16 + 24 = 76 grid positions before accounting for masks, multiple layers or implementation choices. This count does not compare actual model speed. It makes the source/target distinction visible. For a classifier, begin with an evaluated representation-and-head baseline; for a generative task, test an appropriate generator. Neither choice guarantees quality from the architecture name alone.

The same request crosses two different boundaries

Northwind wants an assistant that drafts recommendations from supplier documents and voice notes. Dev can call a managed model endpoint or operate a selected weight release through Northwind's own serving stack. Priya needs supported recommendations, while Sam needs an understandable deployment and recovery contract. A model leaderboard cannot answer all three requirements.

Start with what the task must accept, produce and refuse. Identify the input modalities, required evidence, allowed data movement, action authority and release evaluator. Only then compare models and delivery options. A candidate that is impressive on an unrelated benchmark can still fail the actual input or operating constraints.

Select a prediction mechanism before selecting a product

Hypothetical scenario. Compare classifying a policy passage, retrieving a related passage and producing a response. A masked encoder, a causal decoder and an encoder-decoder expose different representations and prediction paths. The task contract decides which capability is needed; a family label does not certify accuracy.

Select a prediction mechanism before selecting a product
ArtifactConcrete evidenceDecision boundary
Model artifactweights, tokenizer, revisionPrediction behavior
Serving contracttemplate, decoding, limitsExecution interpretation
Application policyevidence and allowed outcomesAcceptance authority
Choose needed representation: Task contract → Selected model family.Choose needed representation: Task contract → Selected model family. Task contract to Selected model family: choose needed representation; Selected model family to Application acceptance: evaluate actual outcomes.Task contractSelected modelfamilyApplicationacceptancechoose needed representationevaluate actual outcomes
Choose needed representation: Task contract → Selected model family. Enlarge the diagram to inspect its labels; the surrounding records and explanation give the text alternative.

Record the exact model artifact separately from the service configuration and application policy. The same weights can behave differently under templates, decoding settings or tool exposure. Replacing a model family requires task-level tests and compatible request/response behavior, not merely an endpoint with the same JSON fields. Preserve refusal and unsupported-answer cases when comparing candidates, and keep disclosure authority outside the prediction mechanism.

Weights, service and application are different artifacts

A weight release provides parameters for a particular architecture and associated tooling. Operating it also requires compatible tokenization, preprocessing, a runtime and sufficient resources. A hosted service exposes an interface and an operating agreement rather than necessarily exposing those implementation details. The application wraps either choice with task state, permissions, evidence selection and accepted-output rules.

Weight availability alone does not establish that training data, complete training code or unrestricted usage rights are available. Inspect the actual release artifacts and applicable terms. Similarly, an API response does not establish a universal data-handling policy. Evaluate the specific service configuration and agreement rather than inferring behavior from a category label.

Keep these questions separate from model quality. Access to weights can help control deployment and adaptation while increasing operational responsibilities. A managed interface can reduce some serving work while leaving the application dependent on the provider's interface and availability. Neither category automatically wins on cost, confidentiality or task success.

The training objective is not the user's acceptance rule

A language model trained to predict text receives an optimization signal about its selected training examples. Later adaptation can change that signal through demonstrations or preferences. The resulting model can still produce unsupported statements or unsuitable actions. Improving an objective and satisfying an application contract are different claims.

The loss-and-gradients foundation explains how a chosen loss drives a parameter update. The post-training chapter works through a preference objective and its limitations. Use those mechanisms to ask what behavior an intervention rewards, then evaluate whether the changed behavior improves Northwind's supported recommendations.

Likewise, more generated deliberation is not an independent correctness test. A task can allocate inference work to candidate generation, search or critique, but its acceptance still needs the appropriate external checks. The planning and workflows chapter separates a proposed route from verified applicability and authority.

Choose representations that retain the required information

A text-only representation can be sufficient for an ordinary prose document. A table's meaning may also depend on row alignment, headers and footnotes. A voice note has acoustic content before it becomes a transcript. Selecting a model therefore includes choosing which transformations happen before the model sees the task.

Multimodal systems do not all process inputs in the same way. An image encoder can create visual representations, a text encoder can create language representations, and a learned alignment can relate them. A speech system can transform audio into time-frequency features and decode text from the encoded signal. Those representations support different operations and failure modes.

The CLIP paper studies learning related image and text representations from paired supervision. It illustrates representation alignment rather than a universal image-understanding guarantee. The Whisper paper studies speech recognition using an encoder-decoder approach trained on audio and text supervision. Transcription and image-text matching are different tasks, even when both use learned representations.

Keep the original evidence beside its representation

Input representations meet an application acceptance boundaryDocument and image evidence follow a visual or text path. Voice evidence follows an audio path. Their representations feed a candidate decision, while source identity and validation remain separate.Document / imageVoice evidenceText / visual featuresAudio featuresCandidate resultverify task contract

A representation can discard information that a later model cannot recover reliably. Preserve source identity and the relevant page, region or audio interval. The existing document-pipeline case develops that provenance requirement for text and page images. Audio adds a different measurement problem: inspect transcription errors, speaker or timing requirements and their effect on the downstream task.

Do not equate pixels, samples and model tokens

Hypothetical scenario. Consider a selected image representation that divides a 224-by-224-pixel image into non-overlapping 16-by-16-pixel patches. Each side contains 224 / 16 = 14 patches. The grid contains 14 × 14 = 196 patches. This is illustrative architecture accounting, not a claim that every image model uses those dimensions or that its final context contains exactly 196 tokens.

For a separate audio example, a chosen 30-second recording sampled at 16,000 samples per second contains 30 × 16,000 = 480,000 samples. If a selected frontend forms time positions at a ten-millisecond hop, the nominal count is 30 / 0.01 = 3,000 positions before accounting for its precise windowing and subsequent transformations. Neither raw samples nor frontend positions can be substituted directly for the language tokenizer's token count.

The accounting matters because changing resolution, duration or preprocessing can change resource use and retained information. A smaller image may lose a table footnote; a poor transcript may change an identifier. Evaluate the source-to-representation stage independently before blaming a final recommendation on the language model alone.

Compare deployment cost under declared assumptions

For a toy monthly workload, choose 10,000 tasks. Suppose a managed option costs an assumed $0.02 per task, giving 10,000 × $0.02 = $200. Suppose an operated-weight option has an assumed $150 fixed serving cost and $0.005 variable cost per task. Its selected serving subtotal is $150 + 10,000 × $0.005 = $200. These values are chosen examples, not provider prices.

Now assign the operated option an additional $100 of monthly operational effort. Its accounted total becomes $300. Under the selected linear model, equality occurs when $0.02 × N = $250 + $0.005 × N. Subtracting the variable term gives $0.015 × N = $250, so N = $250 / $0.015 ≈ 16,666.67 tasks. This threshold changes if utilization, staffing, retries or price assumptions change.

Cost equality is not task equality. If the managed option produces 9,000 accepted results from the 10,000 tasks, its selected cost per accepted result is $200 / 9,000 ≈ $0.02222. If the operated option produces 8,000 accepted results, its corresponding value is $300 / 8,000 = $0.0375. Acceptance must use the same task contract, and serious failure categories can disqualify an option even when its average cost looks attractive.

Version the complete deployed combination

Record the selected model artifact or service version, tokenizer and preprocessing, prompt, tool interfaces, evidence policy and serving configuration. A comparison between two names without those details can hide several simultaneous changes. Updating an image processor or transcript normalizer can change the task even when the nominal language model stays fixed.

For operated weights, define who owns packaging, capacity, patches, rollback and incident response. For a managed interface, define how the application handles rejected requests, changed limits, uncertain attempts and provider-side changes. Both need a task-level evaluation and a way to inspect accepted outputs after release.

Choose an exit plan that matches the actual dependencies. Storing a provider-neutral prompt does not make a multimodal payload, tool schema or tokenizer portable automatically. Likewise, downloading weights does not eliminate a dependency on an accelerator runtime or a particular preprocessing implementation.

In the wild: model documentation describes a scope

Hugging Face's model-card documentation describes structured information about a model, including intended use, limitations and evaluation context. A card provides a useful starting record for a selection review. It is not independent proof that every statement is correct or that Northwind's task matches the reported evaluation.

CLIP and Whisper supply concrete examples of different representation and training choices. Their relevance here is mechanistic, not a comparison of current commercial services. Check the particular release and evaluate the actual input distribution before turning a paper's result into an application promise.

Run a comparison that can reject your preferred option

Construct cases from the application contract: ordinary requests, unavailable evidence, ambiguous identifiers, difficult tables, noisy audio and unauthorized actions. Keep the evaluation population fixed when comparing candidate combinations. Record which stage failed so that a transcription error is not silently counted as a reasoning error.

Use a deployment option only when the required data handling, task quality and operational controls can be established. A managed endpoint can be a reasonable starting point when its contract fits the task and local operation adds little value. Operating weights can be justified when the needed control and workload support that responsibility. A mixed design needs its own routing, consistency and fallback evaluation.

Preserve abstention and escalation as supported outcomes. The best combination for a task may be the one that identifies an uncertain audio span and requests clarification rather than confidently drafting a policy change. A higher rate of fluent responses does not establish more accepted work.

Category labels that hide a decision

Available weights mean a complete reproducible system. Inspect architecture, tokenizer, data disclosures, dependencies and terms separately.

A lower loss proves better customer recommendations. The objective describes its training signal; the application needs its own held-out evaluation.

Multimodal input removes extraction errors. Learned representations can lose or misinterpret information. Preserve the original and test the transformation.

What this comparison does not establish

The cost model uses selected linear assumptions and excludes many possible operational charges. Patch and audio counts are frontend examples, not universal model budgets. Model documentation and research results need independent application validation, and deployment rights or data obligations depend on actual release terms and service agreements. This chapter chooses no vendor or current model winner and provides no legal conclusion about a particular release.

Test the model artifact boundary

A decoder can generate a class label. Does that make it interchangeable with the current classifier?

Reveal the design reasoning

Not without comparable task evidence, calibration and cost/latency behavior. Test malformed or unsupported outcomes and preserve the same decision consequences.

Decision: Choose by task evidence and operating envelope, with a versioned replacement trigger.

Choose the boundary before the model name

At 10,000 tasks, are the two deployment options equally expensive in the complete toy model?

The serving subtotals are both $200, but the selected operational allowance raises the operated option to $300. Quality also differs in the example, so cost per accepted result is about $0.02222 versus $0.0375. Neither comparison establishes that a real provider or deployment has those prices or outcomes.

Can the 480,000 audio samples be entered as a language-token context budget?

No. Samples, frontend positions and model tokens are different representations. Inspect the particular preprocessing and model interface, then account for the actual sequence it accepts. Preserve audio provenance so a downstream error can be traced to the relevant source interval.

A candidate has better training loss but misses a table qualifier. What should be inspected first?

Check whether the representation retained the table relation and qualifier, then whether the application supplied and used that evidence. The training metric cannot establish that this transformation succeeded. Repair the failing boundary and compare complete task outcomes against the existing baseline.

Northwind decision log

  1. Choose a task and input contract before comparing model delivery categories.
  2. Keep source identity through text, visual and audio transformations.
  3. Compare accepted outcomes and operating responsibilities under explicit cost assumptions.

Go deeper: model boundaries and operating patterns

Check the mechanism in this lesson

Can Northwind replace a next-token generator with a masked encoder merely because both use attention?

Compare the explanation

No. Their visibility masks, training objectives and output interfaces differ. Evaluate a representation-and-head model for a classification task and an appropriate generator for generation rather than inferring substitutability from the shared mechanism.

Carry the decision forward

Northwind has separated the prediction task, architecture and delivery boundary for text. Page 06 introduces scans and speech: readable text extracted from another modality is a derived representation, so the design must preserve what the original evidence actually supports.