skills/llm/sentence-truncation-fallback/SKILL.md
Truncate LLM output to exactly N sentences and fall back to a known-good baseline string when output is empty or too short
npx skillsauth add wenmin-wu/ds-skills llm-sentence-truncation-fallbackInstall 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.
LLM outputs for structured tasks (prompt recovery, classification rationale, single-line answers) often include unwanted preamble, repetition, or rambling. Truncate to the first N sentences, then check length — if the result is too short or empty, substitute a well-scoring baseline string. This two-step post-processing ensures consistent submission quality.
import re
BASELINE = "Improve the following text using a more formal and academic tone while maintaining the original meaning"
def truncate_sentences(text, max_sentences=1):
sentences = re.split(r'(?<=[.!?])\s+', text.strip())
result = ' '.join(sentences[:max_sentences])
return result
def postprocess(raw_output, min_length=15):
cleaned = truncate_sentences(raw_output, max_sentences=1)
cleaned = cleaned.strip().strip('"').strip("'")
if len(cleaned) < min_length:
return BASELINE
return cleaned
predictions = [postprocess(output) for output in raw_outputs]
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