Skip to content

Class: BaseLM

Abstract base class for DSPy language models (dspy.BaseLM).

  • NOTE: this is an abstract class and should not be instantiated directly

URI: dspy:BaseLM

 classDiagram
    class BaseLM
    click BaseLM href "../BaseLM/"
      NamedThing <|-- BaseLM
        click NamedThing href "../NamedThing/"


      BaseLM <|-- LM
        click LM href "../LM/"


      BaseLM : cache

      BaseLM : callbacks

      BaseLM : description

      BaseLM : forward_contract





        BaseLM --> "0..1" ForwardContract : forward_contract
        click ForwardContract href "../ForwardContract/"



      BaseLM : history





        BaseLM --> "*" LMHistoryEntry : history
        click LMHistoryEntry href "../LMHistoryEntry/"



      BaseLM : id

      BaseLM : max_tokens

      BaseLM : model

      BaseLM : model_type





        BaseLM --> "0..1" ModelType : model_type
        click ModelType href "../ModelType/"



      BaseLM : name

      BaseLM : num_retries

      BaseLM : temperature

      BaseLM : use_developer_role

Inheritance

Slots

Name Cardinality and Range Description Inheritance
model 0..1
ModelName
LiteLLM-style provider/model identifier direct
model_type 0..1
ModelType
Which LiteLLM API contract to use (chat / text / responses) direct
temperature 0..1
Float
direct
max_tokens 0..1
Integer
direct
cache 0..1
Boolean
Whether responses for this LM should be cached direct
num_retries 0..1
Integer
direct
callbacks *
String
Dotted import paths of callbacks registered on the module direct
use_developer_role 0..1
Boolean
direct
forward_contract 0..1
ForwardContract
direct
history *
LMHistoryEntry
Per-module call history of LM requests / responses direct
id 1
Identifier
Stable opaque identifier for an instance NamedThing
name 0..1
String
Short human-readable name NamedThing
description 0..1
String
Free-form description NamedThing

Usages

used by used in type used
TwoStepAdapter extraction_model range BaseLM
Predictor lm range BaseLM
Predict lm range BaseLM
ChainOfThought lm range BaseLM
MultiChainComparison lm range BaseLM
ReAct lm range BaseLM
ReActV2 lm range BaseLM
ProgramOfThought lm range BaseLM
CodeAct lm range BaseLM
RLM lm range BaseLM
COPRO prompt_model range BaseLM
MIPROv2 prompt_model range BaseLM
MIPROv2 task_model range BaseLM
Settings lm range BaseLM

In Subsets

Identifier and Mapping Information

Annotations

property value
dspy_source_paths ['dspy/clients/base_lm.py']
dspy_source_urls ['https://github.com/stanfordnlp/dspy/blob/main/dspy/clients/base_lm.py']

Schema Source

Mappings

Mapping Type Mapped Value
self dspy:BaseLM
native dspy:BaseLM
broad ai:MachineLearningModel, nexus:AiModel
close mellea:BackendSpec

LinkML Source

Direct

name: BaseLM
annotations:
  dspy_source_paths:
    tag: dspy_source_paths
    value:
    - dspy/clients/base_lm.py
  dspy_source_urls:
    tag: dspy_source_urls
    value:
    - https://github.com/stanfordnlp/dspy/blob/main/dspy/clients/base_lm.py
description: Abstract base class for DSPy language models (``dspy.BaseLM``).
in_subset:
- clients
from_schema: https://w3id.org/lmodel/dspy
close_mappings:
- mellea:BackendSpec
broad_mappings:
- ai:MachineLearningModel
- nexus:AiModel
is_a: NamedThing
abstract: true
slots:
- model
- model_type
- temperature
- max_tokens
- cache
- num_retries
- callbacks
- use_developer_role
- forward_contract
- history

Induced

name: BaseLM
annotations:
  dspy_source_paths:
    tag: dspy_source_paths
    value:
    - dspy/clients/base_lm.py
  dspy_source_urls:
    tag: dspy_source_urls
    value:
    - https://github.com/stanfordnlp/dspy/blob/main/dspy/clients/base_lm.py
description: Abstract base class for DSPy language models (``dspy.BaseLM``).
in_subset:
- clients
from_schema: https://w3id.org/lmodel/dspy
close_mappings:
- mellea:BackendSpec
broad_mappings:
- ai:MachineLearningModel
- nexus:AiModel
is_a: NamedThing
abstract: true
attributes:
  model:
    name: model
    description: LiteLLM-style ``provider/model`` identifier.
    from_schema: https://w3id.org/lmodel/dspy
    rank: 1000
    owner: BaseLM
    domain_of:
    - LMRequest
    - LMResponse
    - BaseLM
    - TrainingJob
    range: ModelName
  model_type:
    name: model_type
    description: Which LiteLLM API contract to use (chat / text / responses).
    from_schema: https://w3id.org/lmodel/dspy
    rank: 1000
    owner: BaseLM
    domain_of:
    - BaseLM
    range: ModelType
  temperature:
    name: temperature
    from_schema: https://w3id.org/lmodel/dspy
    rank: 1000
    owner: BaseLM
    domain_of:
    - LMConfig
    - BaseLM
    range: float
    minimum_value: 0.0
    maximum_value: 2.0
  max_tokens:
    name: max_tokens
    from_schema: https://w3id.org/lmodel/dspy
    rank: 1000
    owner: BaseLM
    domain_of:
    - LMReasoningConfig
    - LMConfig
    - BaseLM
    range: integer
    minimum_value: 0
  cache:
    name: cache
    description: Whether responses for this LM should be cached.
    from_schema: https://w3id.org/lmodel/dspy
    rank: 1000
    ifabsent: boolean(True)
    owner: BaseLM
    domain_of:
    - BaseLM
    range: boolean
  num_retries:
    name: num_retries
    from_schema: https://w3id.org/lmodel/dspy
    rank: 1000
    ifabsent: int(3)
    owner: BaseLM
    domain_of:
    - BaseLM
    range: integer
    minimum_value: 0
  callbacks:
    name: callbacks
    description: Dotted import paths of callbacks registered on the module.
    from_schema: https://w3id.org/lmodel/dspy
    rank: 1000
    owner: BaseLM
    domain_of:
    - BaseLM
    - Adapter
    - Module
    - Settings
    range: string
    multivalued: true
  use_developer_role:
    name: use_developer_role
    from_schema: https://w3id.org/lmodel/dspy
    rank: 1000
    ifabsent: boolean(False)
    owner: BaseLM
    domain_of:
    - BaseLM
    range: boolean
  forward_contract:
    name: forward_contract
    from_schema: https://w3id.org/lmodel/dspy
    rank: 1000
    ifabsent: string(legacy)
    owner: BaseLM
    domain_of:
    - BaseLM
    range: ForwardContract
  history:
    name: history
    description: Per-module call history of LM requests / responses.
    from_schema: https://w3id.org/lmodel/dspy
    rank: 1000
    owner: BaseLM
    domain_of:
    - BaseLM
    - Module
    range: LMHistoryEntry
    multivalued: true
    inlined: true
    inlined_as_list: true
  id:
    name: id
    description: Stable opaque identifier for an instance.
    from_schema: https://w3id.org/lmodel/dspy
    rank: 1000
    slot_uri: schema:identifier
    identifier: true
    owner: BaseLM
    domain_of:
    - NamedThing
    range: Identifier
    required: true
  name:
    name: name
    description: Short human-readable name.
    from_schema: https://w3id.org/lmodel/dspy
    rank: 1000
    slot_uri: rdfs:label
    owner: BaseLM
    domain_of:
    - NamedThing
    - LMToolCallPart
    - LMMessage
    - LMToolSpec
    range: string
  description:
    name: description
    description: Free-form description.
    from_schema: https://w3id.org/lmodel/dspy
    rank: 1000
    slot_uri: dct:description
    owner: BaseLM
    domain_of:
    - NamedThing
    - LMToolSpec
    range: string