liveBook · Manning

Baseline

As explained in Building LLM Applications with DSPy

A reference performance result against which other results are compared.

A baseline model is an initial application whose performance can be evaluated as a reference for deciding whether later changes improve it. It may be sufficient on its own; otherwise, its results help guide optimization. section 1.6 section 8.3

A practical baseline workflow:

  • Build a simple application, then evaluate its performance. section 1.6
  • Use the evaluation to judge the task and decide whether to optimize the application. section 1.6

Conversation summarizer

A baseline summarizer uses a language model, a signature with dialog input and summary output, and a Predict module. Its generated summary can be compared with a ground-truth summary. section 8.3

Listing 8.4 Creating and executing a baseline program
import os

os.environ['OPENAI_API_KEY'] = OPENAI_API_KEY

class SummarySignature(dspy.Signature):  #1
    dialog: str = dspy.InputField()
    summary: str = dspy.OutputField() 

lm = dspy.LM('openai/gpt-4.1-nano', cache=False)  #2
dspy.configure(lm=lm)

prog_summarizer = dspy.Predict(SummarySignature)  #3

print(train_examples[0]['summary'])  #4
pred = prog_summarizer(dialog=summarizer_train_data[0]['dialog'])  #5
print(pred)  #6

See the Python listing that creates and runs the baseline summarizer. section 8.3

How Building LLM Applications with DSPy covers it

How deep it goes
Shows baseline construction and initial output inspection, then moves to evaluation without giving a numeric baseline result here.
Examples
Builds a conversation summarizer and compares its generated summary with a ground-truth summary.
What you can do after
Evaluate an initial application and use its performance as a reference when considering optimization.
How it connects
Connects baseline applications with evaluation, prompt optimization, and summarization.

Also explained in

Compare how 19 books explain baseline →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building LLM Applications with DSPy. The section links point to the parts of the book it draws on.