Per-Instance Program Synthesis (PIPS) is an adaptive reasoning baseline that decides, for every problem instance, whether to run deliberate chain-of-thought reasoning or synthesize executable Python code.
- [10/26/2025] Code for PIPS as well as a Gradio demo are released.
- [09/18/2025] PIPS accepted to NeurIPS 2025!
- Adaptive per-instance strategy selection that balances executable program synthesis with fast chain-of-thought reasoning.
- Iterative code refinement with automatic execution, error recovery, and optional interactive callbacks.
- Works out-of-the-box as a Python library and ships with a lightweight Gradio UI for quick exploration.
- Drop-in baseline: import a single class to embed Per-Instance Program Synthesis inside your stack.
git clone <repository-url>
cd PIPS
uv venv
source .venv/bin/activate
uv sync --editable .To include optional dependencies:
uv sync --group gradioenables the browser UI.uv sync --group devinstalls linting and test tooling.
Install multiple groups at once with uv sync --group gradio --group dev.
Export whichever API keys you plan to use:
export OPENAI_API_KEY="..."
export ANTHROPIC_API_KEY="..."
export GOOGLE_API_KEY="..."Only one key is required to get started.
from pips import PIPSSolver, get_model
from pips.utils import RawInput
model = get_model("gpt-4o", api_key="your-openai-api-key")
solver = PIPSSolver(model=model, max_iterations=8, temperature=0.0)
problem = RawInput(text_input="What is the sum of the first 10 prime numbers?")
answer, telemetry, mode_decision = solver.solve(problem, stream=False)
print("Answer:", answer)
# Inspect the selected mode
print("Mode:", "code" if mode_decision["use_code"] else "chain-of-thought")Set stream=True and pass callbacks such as on_llm_streaming_token or
on_step_update to receive incremental updates. For complete control you can
call solve_with_code or solve_chain_of_thought directly, and the same
callbacks work for both.
Install the Gradio extra and launch the browser experience:
uv sync --group gradio
uv run python -m pips.gradio_appPIPS supports any OpenAI, Anthropic, or Google model through their API endpoints. Models hosted with VLLM are also supported.
Install dev tooling and run the test suite:
uv sync --group dev
uv run pytestMIT
