liveBook · Manning

Language model

As explained in Building LLM Applications with DSPy

A language model is a machine-learning model that generates or evaluates language based on textual context.

A language model (LM) generates or evaluates language from textual context. In DSPy, an LM is represented by an object that selects a model and can be configured for subsequent calls. section 2.4

Configure a model in DSPy

Create an LM object with a model name and API key, then pass it to dspy.configure(). The selected LM is used for subsequent calls until configuration changes. section 2.4

lm = dspy.LM(model='gpt-4o-mini', api_key=OPENAI_API_KEY)
dspy.configure(lm=lm)

Shows the two-line setup for selecting and configuring an LM. section 2.4

How Building LLM Applications with DSPy covers it

How deep it goes
Defines the LM object and explains model selection and configuration, without detailing model internals.
Examples
Configures gpt-4o-mini and describes trial-and-error prompt testing for article summaries.
What you can do after
Apply it via DSPy by creating an LM object and configuring it for subsequent calls.
How it connects
Connects language models with DSPy signatures, modules, predictions, and prompt optimization.

Also explained in

Compare how 67 books explain language model →

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.