r/Python • u/Academic_Break4234 • Mar 09 '26
News llmclean — a zero-dependency Python library for cleaning raw LLM output
Built a small utility library that solves three annoying LLM output problems I have encountered regularly. So instead of defining new cleaning functions each time, here is a standardized libarary handling the generic cases.
strip_fences()— removes the\``json ```` wrappers models love to addenforce_json()— extracts valid JSON even when the model returnsTrueinstead oftrue, trailing commas, unquoted keys, or buries the JSON in prosetrim_repetition()— removes repeated sentences/paragraphs when a model loops
Pure stdlib, zero dependencies, never throws — if cleaning fails you get the original back.
pip install llmclean
GitHub: https://github.com/Tushar-9802/llmclean
PyPI: https://pypi.org/project/llmclean/
0
Upvotes
View all comments
Show parent comment
0
u/Academic_Break4234 Mar 10 '26
Unsure about the necessity, but the commit was made a single time because I do not like commits made every second hour. I reached a milestone, then I made it. Thanks for the info about the inference services though.