Skip to content

policy_model

diapason.learning.intelligence.orchestrator.policy_model

Policy model wrapper for orchestrator training.

Adapted from IPW's policy.py. Wraps a HuggingFace causal LM (e.g. Qwen3-1.7B) to predict structured actions in the orchestrator environment. All torch/transformers imports are guarded so the module can be imported without GPU dependencies.

OrchestratorPolicyModel

Wrapper around a causal LM for orchestrator policy prediction.

Input format (prompt)::

Task: {initial_prompt}

Available tools: calculator, think, ...

History:
Turn 1:
  Thought: ...
  Tool: ...
  Observation: ...

What should you do next?
Format your response as:
THOUGHT: [your reasoning]
TOOL: [tool_name]
INPUT: [input for tool]

Output format (from model)::

THOUGHT: [reasoning]
TOOL: [tool_name]
INPUT: [input]
--- or ---
FINAL_ANSWER: [answer]

from_checkpoint(checkpoint_path, **kwargs) classmethod

Load from a previously saved checkpoint directory.

from_pretrained(model_name='Qwen/Qwen3-1.7B', gradient_checkpointing=False, load_in_8bit=False, device=None, **kwargs) classmethod

Load model from a HuggingFace checkpoint.

Raises ImportError if transformers is not installed.

predict_action(state, available_tools)

Predict the next action given current state.

save(path)

Save model and tokenizer to path.