Sampler for reducing undesirable LLM outputs via backtracking
Top 87.8% on sourcepulse
This project provides a novel sampler for Large Language Models (LLMs) designed to prevent repetitive or undesirable phrases ("slop") in generated text. It targets LLM developers and researchers seeking to improve output quality by enforcing custom content constraints, offering a more robust alternative to per-token logit biasing.
How It Works
The AntiSlop sampler employs a backtracking mechanism. When a disallowed phrase is detected in the generated output, the sampler reverts to the point where the phrase began and adjusts token probabilities to avoid that sequence. This approach is advantageous because it operates on full phrases rather than individual tokens, preventing the unintended down-regulation of common word beginnings. It supports string and regex matching for greater flexibility in constraint definition.
Quick Start & Requirements
git clone https://github.com/sam-paech/antislop-sampler.git && cd antislop-sampler
pip install fastapi uvicorn ipywidgets IPython transformers bitsandbytes accelerate
python3 run_api.py --model unsloth/Llama-3.2-3B-Instruct --slop_adjustments_file slop_phrase_prob_adjustments.json
transformers
, fastapi
, uvicorn
, bitsandbytes
, accelerate
. GPU recommended for model inference.Highlighted Details
Maintenance & Community
Licensing & Compatibility
Limitations & Caveats
The API is minimalist, lacks concurrency support, and is geared towards local use and testing. Regex bans currently do not support streaming. The default slop list is auto-generated and not well-curated. The implementation is noted as research-grade and may contain bugs.
5 days ago
1 day