liveBook · Manning

Task language model

As explained in Building LLM Applications with DSPy

The language model assigned to perform an application's task, including when evaluating candidate prompts.

A task language model (task LM) runs the application’s task. During prompt optimization, it evaluates candidate prompts on validation data; in production, it remains the model configured for the program. A separate prompt LM can generate candidate instructions, allowing a more capable model to assist optimization while a less costly task LM handles frequent production calls. section 6.1.4 section 6.2

Separate prompt generation from task execution

A COPRO setup uses GPT-5 as the prompt LM and gpt-4o-mini as the task LM. MIPROv2 also uses the task LM to score candidate instruction-and-demonstration combinations. section 6.1.4 section 6.2

Figure 6.2 The MIPROv2 algorithm step 3. In steps 1 and 2, we create the candidate sets of demos and candidate instructions. In step 3, we try various ways to combine them until we find the combination that performs best. Because there are often many combinations, this step uses a Bayesian optimization method to determine which combinations to try. In this example, we try set of demos #5 and instructions #3, creating a prompt that is tested on all or part of the validation set with the task LM. The score is recorded, allowing us to track which sets of demos work well, which instructions work well, and which work well together. This helps us determine which other combinations to test in subsequent iterations.
figure

Shows how MIPROv2 tests instruction and demonstration combinations with the task LM, then uses their scores to guide later trials. section 6.2

How Building LLM Applications with DSPy covers it

How deep it goes
Explains the task LM’s operational role in prompt evaluation and production, without detailing model internals.
Examples
Uses gpt-4o-mini as COPRO’s task model and scores MIPROv2 intent-classification candidates on validation data.
What you can do after
Evaluate candidate prompts by running them with the configured task model against validation data.
How it connects
Connects prompt language models with prompt optimization, validation sets, and Bayesian optimization.

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.