diff --git a/docs/service/running_locally.md b/docs/service/running_locally.md new file mode 100644 index 00000000..01a7140a --- /dev/null +++ b/docs/service/running_locally.md @@ -0,0 +1,275 @@ +# Running the ThinkBooster service locally + +Stand up the ThinkBooster service on your own machine and call it as an +OpenAI-compatible API endpoint. The scaling **strategy** and **scorer** live in the URL, +so any OpenAI client can drive test-time scaling by pointing `base_url` at the service — +no other code change. This guide covers building, running, and calling the service. For +the full request/response reference, see [`api_guide.md`](api_guide.md). + +## What you get + +The service exposes the OpenAI `/v1/chat/completions` schema, with the strategy and +scorer as URL path segments: + +``` +/v1///chat/completions +``` + +| Path segment | Valid values | +|---|---| +| `` | `self_consistency`, `offline_bon`, `online_bon`, `beam_search` | +| `` (optional) | `entropy`, `perplexity`, `sequence_prob`, `prm` | + +`self_consistency` runs against a remote model (OpenRouter or any OpenAI-compatible API) +and needs no GPU. The other strategies score reasoning steps: the uncertainty scorers +(`entropy`, `perplexity`, `sequence_prob`) are read from the generator's +log-probabilities at near-zero cost, while `prm` runs a separate reward model that needs +a GPU. + +## 1. Prerequisites + +| Need | When | +|---|---| +| Python 3.10+ and `git` | always | +| An OpenRouter (or other OpenAI-compatible) API key | for remote generation, including `self_consistency` | +| 1× NVIDIA GPU (≥24 GB) + driver | only for local generation or the `prm` scorer | +| Docker + `nvidia-container-toolkit` | only for the Docker path with a GPU | + +## 2. Get the code and install + +```bash +git clone https://github.com/IINemo/thinkbooster.git +cd thinkbooster + +pip install -e ".[service]" + +# lm-polygraph powers the uncertainty scorers and is a separate, gitignored repo. +# Clone it into the repo root (needed for the scorers and the Docker build): +git clone https://github.com/IINemo/lm-polygraph.git + +# Service config; set your keys here (each request can also carry its own key). +cp service_app/.env.example .env +``` + +## 3. Run the service + +### Bare metal (simplest) + +```bash +# API-only: self_consistency / remote generation, no GPU needed +export OPENROUTER_API_KEY=sk-or-... # fallback key, used when a request omits its own +export PORT=8001 +python service_app/main.py +# -> http://localhost:8001 (interactive docs at /docs) +``` + +Keep it alive across disconnects with `tmux` (`tmux new -t thinkbooster`, detach with +`Ctrl-b d`). Logs are written under `logs//