skills/llm/binary-answer-clamping/SKILL.md
Force-clamp free-form LLM output to binary yes/no with keyword matching and a fallback default for constrained environments
npx skillsauth add wenmin-wu/ds-skills llm-binary-answer-clampingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
When an LLM must produce a strictly binary response (yes/no, true/false) but generates free-form text, post-process the output by searching for target keywords and clamping to the expected format. This handles verbose responses ("Yes, I believe so"), hedged answers ("It might be"), and empty outputs. A configurable default handles cases where neither keyword appears.
def clamp_binary(response, positive="yes", negative="no", default="yes"):
if response is None or len(response.strip()) == 0:
return default
text = response.lower().strip()
if positive in text and negative not in text:
return positive
if negative in text and positive not in text:
return negative
if positive in text and negative in text:
# Both present — check which appears first
return positive if text.index(positive) < text.index(negative) else negative
return default
raw = model.generate(prompt, max_new_tokens=20)
answer = clamp_binary(raw)
data-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF