An open source, non-profit web search engine
Train the Combined Search model; the win is recall, not the re-ranker
Daoud Clarkece98acf212ae
diff --git a/devdata/rankeval-2026-04/learning-to-rank-llm.csv.gz b/devdata/rankeval-2026-04/learning-to-rank-llm.csv.gzindex 25b0103..7286466 100644Binary files a/devdata/rankeval-2026-04/learning-to-rank-llm.csv.gz and b/devdata/rankeval-2026-04/learning-to-rank-llm.csv.gz differdiff --git a/mwmbl/rankeval/README.md b/mwmbl/rankeval/README.mdindex 5611e8f..9771371 100644--- a/mwmbl/rankeval/README.md+++ b/mwmbl/rankeval/README.md@@ -91,17 +91,59 @@ uv run python scripts/llm_relabel_pass3_judge.py --calibration # what Staan is# 3. Rebuild learning-to-rank-llm.csv.gz with the `staan` pool in it.uv run python scripts/llm_relabel_build_dataset.py-# 4. Train and gate. Keep --split-seed fixed across arms.+# 4. Gate: the same config and split, trained WITHOUT then WITH the new source.DATABASE_URL="postgres://daoud@" uv run python -m mwmbl.rankeval.ltr.llm_experiment \- --mode baseline --model-path mwmbl/resources/model.xgb --note deployed+ --mode mixed --ext-weight 0.25 --overall-threshold 4 --scale-pos-weight 1.0 \+ --add-curation --curation-weight 0.5 --exclude-pool staan --note no-staan+DATABASE_URL="postgres://daoud@" uv run python -m mwmbl.rankeval.ltr.llm_experiment \+ --mode mixed --ext-weight 0.25 --overall-threshold 4 --scale-pos-weight 1.0 \+ --add-curation --curation-weight 0.5 --note combined++# 5. Once a config wins, retrain it on everything and install it.DATABASE_URL="postgres://daoud@" uv run python -m mwmbl.rankeval.ltr.llm_experiment \--mode mixed --ext-weight 0.25 --overall-threshold 4 --scale-pos-weight 1.0 \- --add-curation --curation-weight 0.5 --note combined \+ --add-curation --curation-weight 0.5 --test-size 0 --note combined-final \--save-model devdata/rankeval-2026-04/model-combined.xgb+cp devdata/rankeval-2026-04/model-combined.xgb mwmbl/resources/model-combined.xgb````llm_experiment` reports two axes and **both** gate a retrain: NDCG on a held-outsplit of the Haiku grades, and pair accuracy on a held-out split of the human-curation pairs. The deployed model set the precedent at NDCG@10 0.744 / human-pair-accuracy 0.818; a regression on the human axis is a blocker even when the-Haiku axis improves.+curation pairs. A regression on the human axis is a blocker even when the Haiku+axis improves.++**Do not gate against `--mode baseline` on `mwmbl/resources/model.xgb`.** That+artifact was trained on *all* 849 LLM-labelled queries (see `git log` on it), so it+has seen every query in the held-out split and scores about 0.02 NDCG@10 too high.+Gate against `--exclude-pool`, which trains both arms on the same split and differs+only in the source being measured. Once a configuration wins, retrain it with+`--test-size 0` for shipping, as the deployed model was.++### What the Staan retrain measured++Same config, same split, trained with and without the Staan rows, both scored on the+same Staan-containing test pool:++| training data | NDCG@10 | human pair-acc |+|---|---|---|+| with Staan (`model-combined.xgb`) | 0.7612 | 0.805 |+| without Staan (`--exclude-pool staan`) | 0.7583 | 0.803 |++Marginal, and expected: the 50-feature model has no source feature, so Staan's prior+reaches it only through `score`. **The endpoint's value is recall, not the re-ranker.**+On the same 2% sample of the gold test set:++| arm | NDCG | ±SEM | gold recall | latency |+|---|---|---|---|---|+| standard search (index + wiki) | 0.386 | 0.043 | 4.8% | 0.004s |+| combined search, no Staan | 0.392 | 0.043 | 4.8% | 0.005s |+| combined search (index + Staan + wiki) | 0.583 | 0.030 | 20.0% | 2.14s |++Read the NDCG gain with its caveat: the gold set is scraped **Google** SERPs, and+Staan is a commercial web-search API whose results resemble Google's, so this metric+partly rewards agreeing with Google. The independent check is the blind Haiku judge,+which never sees Google and rates Staan at relevance 2.25 / overall 6.30 against the+Mwmbl index's 0.70 / 2.53. Both point the same way.++The latency is the cold Staan call; results are cached in the external results index,+so repeat queries do not pay it.diff --git a/mwmbl/rankeval/ltr/llm_experiment.py b/mwmbl/rankeval/ltr/llm_experiment.pyindex ec54beb..268c3ee 100644--- a/mwmbl/rankeval/ltr/llm_experiment.py+++ b/mwmbl/rankeval/ltr/llm_experiment.py@@ -31,7 +31,7 @@ Training frames exclude BOTH held-out query sets, so numbers are clean on bothaxes (this makes Haiku figures a shade lower than the original single-axis runs).Usage:- uv run python -m mwmbl.rankeval.ltr.llm_experiment --mode baseline --note baseline+ DATABASE_URL=... uv run python -m mwmbl.rankeval.ltr.llm_experiment --mode baseline --note baselineuv run python -m mwmbl.rankeval.ltr.llm_experiment --mode ext-only --note "A'"uv run python -m mwmbl.rankeval.ltr.llm_experiment --mode llm-only --overall-threshold 4 --scale-pos-weight 1.0 --note Buv run python -m mwmbl.rankeval.ltr.llm_experiment --mode mixed --ext-weight 0.25 --overall-threshold 4 --scale-pos-weight 1.0 --note C@@ -39,22 +39,30 @@ Usage:import gzipimport json+import osfrom argparse import ArgumentParserfrom collections import defaultdictfrom pathlib import Path+import djangoimport numpy as npimport pandas as pdfrom scipy.stats import semfrom sklearn.metrics import ndcg_score-from mwmbl.rankeval.paths import (+# RustXGBPipeline reaches Django models through rank -> blacklist_snapshot ->+# curated_domains, so the app registry has to be up before it is imported - the same+# arrangement as compare_ltr_models.py. Importing it without this fails outright.+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mwmbl.settings_dev")+django.setup()++from mwmbl.rankeval.paths import ( # noqa: E402CURRENT_MODEL_PATH,LEARNING_TO_RANK_DATASET_PATH,LEARNING_TO_RANK_LLM_DATASET_PATH,ROOT_DIR,)-from mwmbl.tinysearchengine.ltr import RustXGBPipeline+from mwmbl.tinysearchengine.ltr import RustXGBPipeline # noqa: E402FEATURE_COLUMNS = ["query", "url", "title", "extract", "score"]RELEVANT_OVERALL = 4@@ -184,6 +192,19 @@ def pair_accuracy(model, test_pairs: list[dict]) -> tuple[float, float]:return float(correct.mean()), float((pos == neg).mean())+def drop_pool(llm: pd.DataFrame, pool: str) -> pd.DataFrame:+ """Rows that came ONLY from `pool`, removed.++ The ablation arm: train without a source's contribution while testing on the same pool+ the endpoint will serve, so the difference between the two arms is that source and+ nothing else. Rows another pool also contributed are kept - the candidate exists either+ way, and dropping it would be ablating the other source too.+ """+ membership = llm["pools"].fillna("").str.split("|")+ only_this_pool = membership.apply(lambda tags: tags == [pool])+ return llm[~only_this_pool]++def build_training_frame(mode: str,ext: pd.DataFrame,@@ -196,7 +217,12 @@ def build_training_frame(seed: int,curation: pd.DataFrame | None = None,curation_weight: float = 1.0,+ exclude_pool: str | None = None,) -> pd.DataFrame:+ if exclude_pool:+ before = len(llm)+ llm = drop_pool(llm, exclude_pool)+ print(f"Ablation: dropped {before - len(llm)} rows pooled only from {exclude_pool!r}")llm_train = llm[llm["qnorm"].isin(train_queries)].copy()llm_train["label"] = (llm_train["overall"] >= overall_threshold).astype(float)llm_train["weight"] = 1.0@@ -322,6 +348,12 @@ def run():)parser.add_argument("--test-size", type=float, default=0.3)parser.add_argument("--save-model", default=None, help="optional path to save the trained model")+ parser.add_argument(+ "--exclude-pool",+ default=None,+ help="ablation: drop training rows pooled only from this source (e.g. staan). "+ "The test split is untouched, so both arms are scored on the same pool.",+ )args = parser.parse_args()ext, llm = load_datasets()@@ -351,6 +383,7 @@ def run():args.seed,curation=curation,curation_weight=args.curation_weight,+ exclude_pool=args.exclude_pool,)print(f"Training frame: {len(train_df)} rows, "diff --git a/mwmbl/resources/model-combined.xgb b/mwmbl/resources/model-combined.xgbnew file mode 100644index 0000000..5a93b67Binary files /dev/null and b/mwmbl/resources/model-combined.xgb differ