liveBook · Manning

Template

As explained in Building Specialized AI Systems

A prompt template is a reusable structured text pattern containing instructions and variable content for constructing model inputs.

A prompt template is a reusable structured text pattern that combines fixed instructions with variable content to produce consistent model inputs. In financial-report summarization, it directs the model to focus on findings, metrics, and conclusions while avoiding unsupported commentary. section 2.5.2

Apply a prompt template by following these steps:

  • Write a specific instruction that defines the required output, tone, focus, and exclusions. section 2.5.2
  • Mark variable content with a placeholder such as {report_text}, then insert each report programmatically. section 2.5.2
  • For supervised fine-tuning, place the instruction, input report, and target summary in a stable prompt-target structure. section 2.5.3
  • Append an end-of-sequence token when formatting training examples, and keep the structure consistent across rows. section 2.5.3

Financial report summarization

A template can request a concise professional summary, insert an analyst report under an Input heading, and reserve a Response heading for the verified summary. The same pattern can generate synthetic labels or format training examples. section 2.5.2 section 2.5.3

Listing 2.25 Example training prompt
SUMMARY_PROMPT_TEMPLATE = """\
Given the following analyst report, generate a concise, informative summary 
in a professional tone. 
Focus on the main findings, key metrics, and conclusions. Do not add any 
commentary beyond what is in the report.
 
Report:
{report_text}
"""

Shows a concrete template with instructions, a report_text variable, and constraints on summary content. section 2.5.2

Listing 2.30 Define the prompt template
chat_prompt = """
### Instruction:
Summarize the following analyst report.
 
### Input:
{}
 
### Response:
{}"""
 
EOS_TOKEN = tokenizer.eos_token
 
def formatting_prompts_func(examples):
    inputs = examples["report"]
    outputs = examples["summary"]
    texts = []
    for input, output in zip(inputs, outputs):
        text = chat_prompt.format(input, output) + EOS_TOKEN
        texts.append(text)
    return {"text": texts}

Shows the instruction-input-response structure used to convert reports and summaries into training text. section 2.5.3

How Building Specialized AI Systems covers it

How deep it goes
Defines instructions, placeholders, output structure, and dataset transformation, but defers broader prompt-design theory.
Examples
Uses analyst reports, summary instructions, report_text placeholders, verified summaries, and instruction-input-response training records.
What it assumes
Assumes cleaned report data and initialized model access, while teaching the template structure from explicit instructions and placeholders.
What you can do after
Build consistent generation and training inputs for turning analyst reports into concise summaries.
How it connects
Connects prompt templates with synthetic data generation, supervised fine-tuning, chat templates, and dataset preparation.

Also explained in

Compare how 29 books explain template →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Specialized AI Systems. The section links point to the parts of the book it draws on.