Lesson 4 of 4 Text Analysis with Language Models and Foundry Tools

Customizing Outputs for Domain Tasks

This lesson explains the options, in increasing order of effort, for making outputs follow an organization's terminology, structure and rules in domain tasks such as compliance summarization or clinical note extraction.

Learning outcomes

After completing this lesson, you will be able to:

  • Write a domain prompt with audience, structure and terminology.
  • Ground domain outputs in reference material.
  • Decide when fine-tuning is justified.

Prompt-level customization

A general model produces general output. Asked to summarize a regulatory notice, it writes a fluent paragraph for a general reader, which may omit the deadline that matters most to the compliance team, use the regulator's terms instead of the bank's, and give no clause references. Customization closes the gap between that general output and what the domain requires, and most of it is achieved in the prompt.

Each element of a domain prompt removes a particular kind of variation. Stating the audience and purpose tells the model what to prioritize. A required structure ensures that every summary covers the same points in the same order, so readers know where to look. A glossary replaces the model's general vocabulary with the organization's. Examples show the expected depth and tone more precisely than a description can. A schema makes fields machine-readable, and explicit rules such as "cite the clause for every obligation" make the output verifiable. The following list shows these elements for a compliance summary.

  • Audience and purpose: "Summaries for the compliance team deciding which controls are affected."
  • Required structure: obligations, deadlines, penalties, affected business units, open questions.
  • Glossary: the organization's terms and definitions.
  • Examples: one or two annotated input-output pairs.
  • Schema: structured output for fields that feed other systems.
  • Rules: cite the clause for every obligation; mark uncertain interpretations.

Grounding and retrieval

Domain outputs often depend on reference material: regulations, internal policies, product specifications. Retrieving the relevant passages and including them in the prompt lets the model apply current rules and cite them, and keeps outputs correct when the rules change. Combining retrieval with structured outputs produces summaries whose every field links to a source.

Fine-tuning

When prompting and grounding do not achieve consistent quality, or a smaller model must perform a narrow task as well as a larger one, fine-tuning trains the model on examples. Supervised fine-tuning uses inputs with approved outputs, typically hundreds to thousands of high-quality examples. Fine-tuning improves format, style and domain phrasing; it does not reliably add knowledge, and it requires retraining when requirements change. Customized outputs are measured with a domain evaluation set and custom evaluators that check required sections and citations.

Choosing the approach

The three approaches change different things, and they are usually applied in order of effort. Prompt customization changes the instructions and examples, grounding changes the information available for each request, and fine-tuning changes the model's learned behaviour. The following table compares them.

ApproachChangesBest forEffort when requirements change
Prompt customizationInstructions, structure, examplesFormat, terminology and rules that can be statedEdit the prompt
Grounding with retrievalInformation supplied per requestFacts and rules that change or must be citedUpdate the indexed sources
Fine-tuningModel behaviourConsistent style or a narrow task on a smaller modelPrepare data and retrain

A common outcome is a combination: a prompt that defines structure and rules, retrieval that supplies current reference material, and, only if evaluation shows it is still needed, a fine-tuned smaller model to reduce cost or improve consistency.

The following diagram orders the approaches by the effort they take when requirements change.

Customization approaches in order of effort. Prompt customization changes the instructions and examples and is updated by editing the prompt. Grounding with retrieval changes the information supplied per request and is updated by changing the indexed sources. Fine-tuning changes the model's behaviour and needs new data and retraining.
Each step up changes something deeper and costs more to update, so the next step is taken only when evaluation shows the current one is not enough.
Sort into groups

Prompt, grounding or fine-tuning?

Exam skills 4.1.4

Choose the customization approach for each requirement.

Log in to try this activity Interactive activities are free with an account.
Worked example

Compliance summarization

A bank summarizes new regulatory notices for its compliance team. Current summaries are fluent but omit deadlines, use inconsistent terms and do not reference clauses.

Add a structured output with required fields (obligations with clause references, deadlines, penalties, affected units), a glossary of the bank's terms and one annotated example, and retrieve related internal policies so the summary can say which policies are affected. Evaluate with a custom evaluator that checks every obligation has a clause reference. Fine-tuning would be a later step only if these measures fall short.

Check yourself

What should be tried before fine-tuning a model for a domain task?

Show answer

Customizing with instructions, a glossary, examples, a schema and grounding. Fine-tuning comes later, for a consistent format or style on a narrow task.

Exam Tips

Remember for the exam

  • Customize first with instructions, glossary, examples, schema and grounding.
  • Domain outputs should cite their sources.
  • Fine-tune for consistent format or style on a narrow task, measured on a domain evaluation set.