skills/llm/binary-search-entity-narrowing/SKILL.md
Hierarchical binary search over entity space by asking category, region, then first-letter questions to narrow candidates before guessing
npx skillsauth add wenmin-wu/ds-skills llm-binary-search-entity-narrowingInstall 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 agent must identify an unknown entity from a large candidate set using yes/no questions, a hierarchical binary search strategy is far more efficient than open-ended questioning. Ask about broad categories first (person/place/thing), then sub-categories (continent/country), then discriminating features (first letter). Each answer halves the remaining candidate space.
CATEGORIES = ["place", "person", "thing"]
CONTINENTS = ["Europe", "Asia", "Africa", "North America", "South America", "Oceania"]
def ask_question(obs, candidates, cat_guess, con_guess, let_guess,
category_yes, continent_yes):
if cat_guess < len(CATEGORIES) and not category_yes:
q = f"Is the keyword the name of a {CATEGORIES[cat_guess]}?"
return q, cat_guess + 1, con_guess, let_guess
if con_guess < len(CONTINENTS) and not continent_yes:
cat = category_yes[0] if category_yes else "thing"
q = f"Is the {cat} located in {CONTINENTS[con_guess]}?"
return q, cat_guess, con_guess + 1, let_guess
filtered = apply_filters(candidates, category_yes, continent_yes)
letters = filtered['first_letter'].value_counts().index.tolist()
if let_guess < len(letters):
q = f"Does the keyword begin with the letter {letters[let_guess]}?"
return q, cat_guess, con_guess, let_guess + 1
return filtered.sample(1).iloc[0]['keyword'], cat_guess, con_guess, let_guess
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