skills/nlp/yes-no-answer-type-routing/SKILL.md
Routes QA predictions through an answer-type classifier to emit boolean answers, extractive spans, or null based on type logits.
npx skillsauth add wenmin-wu/ds-skills nlp-yes-no-answer-type-routingInstall 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.
Not all questions have extractive answers — some require "yes" or "no," others are unanswerable. Answer type routing uses a classifier head (typically on the CLS token) to predict the answer type, then routes to the appropriate output: return the extracted span for SHORT/LONG types, return "YES"/"NO" for boolean types, or return empty for UNKNOWN. This prevents the model from forcing a span extraction when the answer is boolean or null.
import numpy as np
ANSWER_TYPES = {0: "UNKNOWN", 1: "YES", 2: "NO", 3: "SHORT", 4: "LONG"}
def route_answer(type_logits, short_spans, short_score_threshold=1.5):
"""Route QA output based on answer type prediction.
Args:
type_logits: (5,) logits from answer type head
short_spans: list of (start, end, score) from span extraction
short_score_threshold: minimum span score to emit
Returns:
dict with answer_type, short_answer, long_answer
"""
answer_type = ANSWER_TYPES[int(np.argmax(type_logits))]
if answer_type == "UNKNOWN":
return {"type": "UNKNOWN", "short": "", "long": ""}
elif answer_type in ("YES", "NO"):
return {"type": answer_type, "short": answer_type, "long": ""}
elif answer_type in ("SHORT", "LONG") and short_spans:
best = max(short_spans, key=lambda x: x[2])
if best[2] >= short_score_threshold:
return {
"type": answer_type,
"short": f"{best[0]}:{best[1]}",
"long": "", # derive from short via promotion
}
return {"type": "UNKNOWN", "short": "", "long": ""}
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