一键导入
llm-sentence-truncation-fallback
Truncate LLM output to exactly N sentences and fall back to a known-good baseline string when output is empty or too short
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Truncate LLM output to exactly N sentences and fall back to a known-good baseline string when output is empty or too short
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Memory-efficient Keras generator that streams sharded CSV files in chunks, renders strokes to images on-the-fly, and yields batches for training on datasets too large for memory
Stack 1D convolutions for local feature extraction before bidirectional LSTMs to classify variable-length stroke sequences into hundreds of doodle categories
Partition a large dataset into N balanced shards using integer key modulo arithmetic for reproducible, class-interleaved splits across CSV files
Normalize raw stroke coordinates to 0-255 range, resample at uniform arc-length spacing, then apply Ramer-Douglas-Peucker simplification
Render stroke sequences to grayscale images with temporal intensity encoding where earlier strokes are brighter and later strokes fade to encode drawing order
Score each face in a video as anomalous by computing L2 distance from the embedding centroid of all faces, then convert to probability via logistic function
| name | llm-sentence-truncation-fallback |
| description | Truncate LLM output to exactly N sentences and fall back to a known-good baseline string when output is empty or too short |
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]