AI

AI-assert – Constraint verification for LLM outputs (278 lines, Python)

Hacker News

AI-assert – Constraint verification for LLM outputs (278 lines, Python)

I built a tiny library that verifies LLM outputs against constraints and retries on failure. The core insight: LLMs don't reliably follow instructions, but you can catch failures cheaply and retry with targeted feedback. This is essentially a lightweight "process reward model" that requires zero training. How it works: 1. Your LLM generates output 2. ai-assert checks it against constraints (length, word count, sentence count, regex, custom predicates) 3. Each constraint returns a score in [0,1] -- composite is multiplicative (zero in any = zero overall) 4. If score < threshold, retry with feedback ("Constraint X failed because Y -- regenerate") 5. Return the best-scoring attempt On IFEval (25 instruction-following constraint types): 69.3% -> 76.2% accuracy. 278 lines. Zero dependencies. Works with any callable that takes a string and returns a string. pip install ai-assert https://github.com/kaantahti/ai-assert

Share card

Actual performance

1points
Did not reach leaderboard

Launch Intel predictions

Analyze your own launch →
Indie HackersFits the IH revenue-focused audience · Missing: supports, reddit linkedin, podcasting
64%64% predicted probability of success on Indie Hackers, based on ML models trained on real launch data.
best fitHighest predicted score across all platforms for this description.
TrustMRRLess likely to generate early MRR · Missing: mobile apps, ios, personal
40%40% predicted probability of success on TrustMRR, based on ML models trained on real launch data.
Product HuntUnlikely to reach the leaderboard · Strong signals: model, tiny · Missing: mac, agents, macos
39%39% predicted probability of success on Product Hunt, based on ML models trained on real launch data.
Hacker NewsMay not resonate with HN audience · Strong signals: io · Missing: https docs, excited, just released
36%36% predicted probability of success on Hacker News, based on ML models trained on real launch data.
nativeThis product was originally launched on this platform.
AppSumoMay struggle as an AppSumo deal · Missing: plus, platform, intuitive
33%33% predicted probability of success on AppSumo, based on ML models trained on real launch data.
Acquire.comPre-revenue stage for this audience · Strong signals: training · Missing: arr, mrr, revenue
22%22% predicted probability of success on Acquire.com, based on ML models trained on real launch data.
BetaListMay not resonate with beta-testers · Strong signals: reward · Missing: web3, chat, crypto
3%3% predicted probability of success on BetaList, based on ML models trained on real launch data.

Correct prediction on native model

Similar products

Ha
Hangman in 3 lines of Python57%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Hangman in 3 lines of Python

Hacker News58
A
A very simple Lisp interpreter in 250 lines of literate Python70%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

A very simple Lisp interpreter in 250 lines of literate Python

Hacker News5
Re
Retirement Calculator in 8 lines of Python52%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Retirement Calculator in 8 lines of Python

Hacker News1
Qu
Querying 50k Gameservers in 100 lines of Python46%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Querying 50k Gameservers in 100 lines of Python

Hacker News1
A
A Python module to steer LLM outputs43%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

A Python module to steer LLM outputs

Hacker News2
Bu
Build python ASTs in 502 lines of python without using modules65%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Build python ASTs in 502 lines of python without using modules

Hacker News2
Fu
FuzzyFinder – in 10 lines of Python53%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

FuzzyFinder – in 10 lines of Python

Hacker News10
20
2048 in ten 60-width lines of python50%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

2048 in ten 60-width lines of python

Hacker News2
Pr
Promptic – LLM superpowers for your Python functions (in ~80 lines)61%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Promptic – LLM superpowers for your Python functions (in ~80 lines)

Hacker News2
tlabel (TouchLabel AI)
tlabel (TouchLabel AI)24%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Annotate any tactile sensor in 3 lines of Python.

Product Hunt+2