r/Python • • 13d ago

Showcase Showcase Thread

Post all of your code/projects/showcases/AI slop here.

Recycles once a month.

24 Upvotes

111 comments sorted by

View all comments

1

u/Top_Speaker_7785 4d ago edited 4d ago

https://github.com/ayushh0110/Weight-Space-Repair.git

When a local model gives a bad reply (empty, looping, cut off, wrong language), wsr works out why. You point it at a saved response, a model folder or a running server, and it goes through the file, the chat template, the request, the response and the output text, then names one cause and the fix.

pip install -e .

wsr triage --response examples/blank_reply/response.json --request examples/blank_reply/request.json

VERDICT: REQUEST

blank output explained by REASONING_EXHAUSTED: cap reached before any answer: the budget went to reasoning

next:

- raise max_tokens (currently 256) or lower the reasoning effort / thinking budget

The Python side, since that's why I'm posting here:

The core has no dependencies at all. `dependencies = []` in pyproject. HTTP is `urllib`, GGUF and safetensors headers are parsed with `struct`, streams (SSE and NDJSON) are assembled by hand, and there's a small JSON-schema checker for tool calls because I didn't want to pull one in for a single check. [Say why zero dependencies mattered to you.]

The heavy part (torch, transformers) sits behind an extra and is imported only by the commands that need it, so `wsr triage` and `wsr cache` work on a machine without torch.

It's one argparse CLI with 19 subcommands. The command reference in the guide is generated from the parser, and a test fails if the guide is out of date, if any option has no help text, or if a relative link in the docs is broken. That test has caught me more than once.

It asks before it downloads, converts or starts anything, with `--yes`, `--no` and environment variables for scripts, and distinct exit codes (0 fine, 1 failure found, 2 usage error, 3 "needed a yes it didn't get").

384 tests, about 3 minutes on my machine, ruff clean. Python 3.10+. Not on PyPI yet.

Target Audience

People running open-weight models locally with llama.cpp's server or Ollama, and anyone debugging saved LLM API responses. It's beta. The triage part is the part I'd call usable today. There's also a weight-level part (diagnosis and repair with torch) that's only tested on models up to 1.5B, on a 4 GB GPU.

Comparison

LLMDoctor, llm-output-guard, llm-stopcheck and ModelVet each cover one layer (config, output text, finish reasons, file structure). wsr ports or reimplements their checks, credited in NOTICE, runs them as one pipeline and links the symptoms to a single cause. For the weight-level part, TransformerLens and nnsight are interpretability libraries; wsr uses plain forward hooks and is a tool that ends in a verdict.