Model Selection#
design_research_agents.model_selection is the stable public facade for model
catalogs, model flights, hardware snapshots, and selector decisions.
Public Facade#
- class design_research_agents.model_selection.HardwareProfile(*, total_ram_gb, available_ram_gb, cpu_count, load_average, gpu_present, gpu_vram_gb, gpu_name=None, platform_name=None)[source]#
Snapshot of system hardware capacity for model selection.
- class design_research_agents.model_selection.ModelCatalog(*, models)[source]#
Catalog of known models and their hardware hints.
- models#
Tuple of model specifications.
- class design_research_agents.model_selection.ModelCostHint(*, tier, usd_per_1k_tokens=None)[source]#
Cost hints for model selection.
- class design_research_agents.model_selection.ModelFlight(*, flight_id, description, models, tags=())[source]#
Named, reproducible set of model candidates for experiments or selection.
- models#
Tuple of model specifications included in the flight.
- class design_research_agents.model_selection.ModelFlightRegistry(*, flights)[source]#
Registry of named model flights.
- flights#
Tuple of known model flights.
- class design_research_agents.model_selection.ModelLatencyHint(*, tier, note=None)[source]#
Latency hints for model selection.
- class design_research_agents.model_selection.ModelMemoryHint(*, min_ram_gb, min_vram_gb, note=None)[source]#
Memory requirement hints for model selection.
- class design_research_agents.model_selection.ModelSafetyConstraints(*, max_cost_usd, max_latency_ms)[source]#
Safety bounds attached to a model selection decision.
- class design_research_agents.model_selection.ModelSelectionConstraints(*, require_local=False, preferred_provider=None, max_cost_usd=None, max_latency_ms=None)[source]#
Constraints that bound model selection choices.
- class design_research_agents.model_selection.ModelSelectionDecision(*, model_id, provider, rationale, safety_constraints, policy_id, catalog_signature)[source]#
Selection output describing the chosen model and rationale.
- safety_constraints#
Safety bounds applied to the selection.
- class design_research_agents.model_selection.ModelSelectionIntent(*, task, priority='balanced')[source]#
Intent descriptor used by the model selection policy.
- class design_research_agents.model_selection.ModelSelectionPolicyConfig(*, policy_id='default', prefer_local=True, ram_reserve_gb=2.0, vram_reserve_gb=0.5, max_load_ratio=0.85, remote_cost_floor_usd=0.02, default_max_latency_ms=None)[source]#
Configuration controlling model selection behavior.
- class design_research_agents.model_selection.ModelSelector(*, catalog=None, prefer_local=True, ram_reserve_gb=2.0, vram_reserve_gb=0.5, max_load_ratio=0.85, remote_cost_floor_usd=0.02, default_max_latency_ms=None, local_client_resolver=None)[source]#
Flat model selection interface with client/config resolution helpers.
Initialize model selector policy controls and optional resolver hook.
- Parameters:
catalog – Optional model catalog to use for selection.
prefer_local – Whether to prefer local models over remote ones when all else is equal.
ram_reserve_gb – Amount of RAM (in GB) to reserve when evaluating local candidates.
vram_reserve_gb – Amount of GPU VRAM (in GB) to reserve when evaluating local candidates.
max_load_ratio – Maximum system load ratio to consider a local candidate viable (0.0 to 1.0).
remote_cost_floor_usd – Minimum cost threshold (in USD) for remote models to be considered viable.
default_max_latency_ms – Default maximum latency (in milliseconds) to consider when evaluating candidates, if not specified in selection constraints.
local_client_resolver – Optional callable that takes a ModelSelectionDecision and returns a dict with ‘client_class’ and ‘kwargs’ for constructing a local client when the provider is not recognized by the built-in resolver. This allows for custom local providers to be integrated without modifying the ModelSelector code.
- select(*, task, priority='balanced', require_local=False, preferred_provider=None, max_cost_usd=None, max_latency_ms=None, hardware_profile=None, output='client')[source]#
Select a model and return a decision, config mapping, or live client.
- Parameters:
task – Description of the task or use case for which a model is being selected.
priority – Selection priority, which may influence the trade-off between quality, latency, and cost in the decision process.
require_local – If True, only consider local models as viable candidates.
preferred_provider – Optional provider name to prioritize in the selection process.
max_cost_usd – Optional maximum cost threshold (in USD) for candidate models.
max_latency_ms – Optional maximum latency threshold (in milliseconds) for candidate models.
hardware_profile – Optional mapping or HardwareProfile instance describing the current hardware state, which may be used to evaluate local candidates.
output – Determines the format of the selection result. “client” returns an instantiated LLMClient ready for use, “decision” returns the raw ModelSelectionDecision object with details of the selection rationale, and “client_config” returns a dict containing the information needed to construct an LLMClient (including ‘client_class’ and ‘kwargs’) without actually instantiating it.
- Returns:
Depending on the ‘output’ parameter –
If output is “client”: An instantiated LLMClient configured according to the selection decision, ready for use in making requests.
If output is “decision”: A ModelSelectionDecision object containing details about the selected model, provider, rationale, and policy information.
If output is “client_config”: A dict containing the resolved client configuration, including ‘client_class’, ‘kwargs’, and metadata from the selection decision, which can be used to instantiate an LLMClient at a later time or in a different context.
- Raises:
ValueError – If
outputis unsupported or selection/config coercion fails.
- class design_research_agents.model_selection.ModelSpec(*, model_id, provider, family, size_b, format, quantization, memory_hint, latency_hint, cost_hint, quality_tier, speed_tier, source='curated', repo_id=None, revision=None, artifact=None, license=None, context_window=None, capabilities=(), tags=(), source_url=None, metadata=None)[source]#
Catalog entry describing one model option.
- memory_hint#
Optional memory requirement hints.
- latency_hint#
Optional latency hints.
- cost_hint#
Optional cost hints.
- metadata#
Optional supplemental metadata.
- Type:
collections.abc.Mapping[str, object] | None
Internal Modules#
The underscored modules below are documented for contributor visibility. Public
usage should prefer design_research_agents.model_selection and the
top-level exports in design_research_agents.
Model catalog utilities and default catalog entries.
Hardware profiling helpers for model selection.
Model selection policy implementation.
Public model selection facade with flattened constructor-first ergonomics.
Shared model selection data types.