Prototype implementation for generating an open-weight reasoning trace and analyzing sentence-to-sentence influence with attribution patching. The repo now supports both:
- local CLI experimentation
- a minimal GPU-hosted API for Runpod-style deployment
This repository currently implements:
- a Python library for generation plus attribution analysis
- a CLI prototype for end-to-end runs
- a FastAPI service for cloud GPU execution
- unit tests for sentence splitting, token alignment, summaries, mocked analysis, and API wiring
It does not yet include the full async web/queue stack from the larger product design.
- Install dependencies.
- Run the CLI:
uv run python -m app.cli.run_prototype "Explain why the derivative of x^2 is 2x"- Inspect the emitted JSON in
outputs/.
For a dedicated Runpod pod, this repo now exposes a minimal API server:
uv run python -m app.cli.run_apiEndpoints:
GET /healthzPOST /api/warmupPOST /api/analyze
Example request:
curl -X POST http://localhost:8000/api/analyze \
-H 'content-type: application/json' \
-d '{
"question": "Explain why the derivative of x^2 is 2x",
"max_new_tokens": 256,
"max_trace_tokens": 512,
"max_sentences": 24,
"validate_top_k": 0
}'- Start with a CUDA GPU pod, not serverless.
- Use the included Dockerfile.
- Keep
deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5Bas the initial cloud model. - Set
DEVICE_PREFERENCE=cuda. - Set
PRELOAD_MODEL=trueso the first request does not pay the full model load. - Keep
max_trace_tokensconservative at first;512is the safer initial setting.
MODEL_NAMEDEVICE_PREFERENCEMAX_TRACE_TOKENSMAX_SENTENCESTAKE_LOGPRELOAD_MODELAPI_HOSTAPI_PORT
- The analysis path requires
attn_implementation="eager"andoutput_attentions=True. - The default model is
deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B. - Local development on low-memory machines is suitable for tests and static checks, not for real attribution runs.
- Cloud GPU is the intended environment for real DeepSeek attribution analysis.