reflex-search / README.md
EdwardIrby's picture
docs: document full RLCD base training, open-source datasets, local pilot hillclimb, and v0.4.1/v0.4.2 co-design
0467707 verified
|
Raw History Blame Contribute Delete
10.6 kB
---
license: apache-2.0
base_model: google/embeddinggemma-2
library_name: safetensors
pipeline_tag: text-classification
datasets:
- google/deepsearchqa
- AIM-Harvard/MedBrowseComp
- perplexity-ai/draco
- youdotcom/reflex-search-eval
tags:
- search
- reranking
- calibration
- rlcd
- system-1
- weight-space-programming
- cpu-inference
- embeddinggemma-2
- mcp
---
# `youdotcom/reflex-search` (`v0.4.1`)
`youdotcom/reflex-search` (`v0.4.1`) is a compact, CPU-native **System 1 search decision and source-ranking model** built on the 24-layer text encoder of [`google/embeddinggemma-2`](https://huggingface.co/google/embeddinggemma-2) (`d = 768`, hybrid 512-token sliding-window and global full attention). Vision and audio towers are removed so the text-only `bf16` checkpoint occupies **517 MB on disk** (`58 MB` calibrated heads) and runs in **~196 MB RSS (`int8`) / ~315 MB RSS (`bf16`)** on commodity CPUs via our SIMD/SME/AMX Rust engine (`s1_eg2cpu`, zero GPU sidecars, zero external filter-LLM calls).
It powers the **`reflex-search`** and **`reflex-extract`** Model Context Protocol (MCP) tools on **`https://api.you.com/mcp/reflex`** and in the standalone pure-Rust `rmcp` `stdio` reference server ([`youdotcom-oss/reflex-search-eval`](https://github.com/youdotcom-oss/reflex-search-eval)):
1. **Gate 1 (Sub-Query Preflight):** Scores parallel candidate sub-queries (`noul_query_matches_intent`, `choice_best_query_for_intent`) to fast-path valid decompositions in `0 ms`, prune off-topic hallucinations, and rank over-ceiling queries before spending Search API calls.
2. **Gate 2 (Unified SERP + Knowledge Ranking & Turn-Adaptive Routing):** Scores web highlights and licensed knowledge cards (`attribution` + `as_of`) on one unified relevance scale (`choice_best_search_hit` across up to 12 candidates + `score_return_relevance`), estimates counterfactual full-page read utility (`noul_hit_worth_reading`), and emits `evidence_coverage_score` + typed `next_step` (`{answer, read, revise, stop}`).
3. **Parallel Extract Intent Scoring:** Scores BM25-windowed webpage and PDF passages against each caller-supplied `document_intent` (`score_extract_relevance` on `doc_kind = "extracted_doc"`).
---
## How `reflex-search` Was Built: Two-Phase Training & MCP Co-Design
`reflex-search` was developed in **two distinct phases** — first training calibrated decision heads and zero-drift LoRA adapters via **Reinforcement Learning for Calibrated Decisions (RLCD)** alongside a `7,404`-trial local MCP evaluation hillclimb (`v0.1 -> v0.3.3`), and only then applying **Activation-Guided Weight-Space Programming (WSP)** informed by a `46,573`-rollout cloud sandbox benchmark (`v0.3.3 -> v0.4.0 -> v0.4.1`, plus `v0.4.2` MCP runtime refinement).
### Phase I — System 1 RLCD Base Training & Local Pilot Hillclimb (`v0.1 -> v0.3.3`)
Autoregressive cross-entropy and binary RLVR post-training push ambiguous posteriors toward `0` or `1` (*mode-dropping overconfidence*) while incurring `O(T)` decode latency. **System 1 RLCD** removes generative token decoding (`T = 1` forward pass, `lm_head` stripped), normalizes post-projection token states onto the unit hypersphere (`h_hat = F.normalize(out.last_hidden_state, dim=-1)`), and trains three lightweight (`float32`) projection heads plus upper-layer **Rank-16 LoRA** (`layers [17, 20, 21, 22, 23]` + `embedding_projection`) exclusively under **strictly proper scoring rules** (Gneiting & Raftery, 2007) plus `0.1 * JS(p(S) || p(S'))` perturbation invariance:
- **`ChoiceHead` (`1-of-K` Setwise Cross-Attention + Abstention):** Cross-attends `[z, e_q, c_k]` over `h_hat` with an explicit `(z · w_abstain) + b_abstain` margin on `"none_of_the_above"`, trained with **Multiclass Brier** + `0.15` intra-query sibling pairwise margin loss (`[#rank] host/path | title — snippet` hard negatives).
- **`NoulHead` (Calibrated Bernoulli Predicates):** Query-guided token read trained on balanced `50/50` **Binary Brier** across query-validity predicates and **`12,590` counterfactual URL read-vs-skip pairs** (`noul_hit_worth_reading`).
- **`ScoreHead` (Two-Part Hurdle + Heteroscedastic Ordinal Probit):** Combines a Bernoulli applicability hurdle with a 5-rank monotone-cutpoint ordinal probit trained under **Hurdle Brier + Ranked Probability Score (RPS)** and calibrated post-hoc in categorical log-space (`softmax((log p_rank + b_rank) / T_rank)`, `mean(b_rank) = 0`) so interior ranks `2..4` never collapse.
- **Zero-Drift LoRA Routing:** Static query templates (`"task: ... | query: ..."`) and candidate strings (`"title: candidate | text: ..."`) **bypass LoRA**, guaranteeing **`0.0` Matryoshka embedding drift** on `model.safetensors`.
**Open-Source Datasets & Zero-Leakage `bar_locked` Gate:**
- Base RLCD supervision and the `210`-task local pilot benchmark (`7,404` graded multi-model trials) built on open-source multi-hop research and QA benchmarks — including **[`google/deepsearchqa`](https://huggingface.co/datasets/google/deepsearchqa)** (`5,400+` multi-rollout trajectories yielding `12,590` counterfactual URL pairs and `12,259` fused multi-branch highlight states, with `40` `bar_locked` tasks held out exclusively for agent evaluation), **`LiveQA`**, and structured **`OR` / exact-phrase / `site:` operator retrieval suites** paired with synthetic operator corruptions. *(Proprietary search logs are not redistributed.)*
- Every task root was partitioned via `sha256` into disjoint **`fit` (`64%`)**, **`cal` (`11%`)**, and **`bar_locked` (`25%`, `6,155` text rows)** splits (`0` overlap with downstream evaluation tasks).
- Co-designing the model and MCP tools across `v0.1 -> v0.3.3` established key architectural invariants: retiring neural span pointers (`v0.1`) in favor of `40x` faster batched S1 + BM25 windowing (`v0.2.1`), introducing request-shape-keyed gating and per-branch `#1` non-mirror hit protection (`v0.2.2`), decoupling `evidence[]` relevance sorting from `recommended_extract_urls` counterfactual read utility (`v0.3.2`, `0.582` pooled 4-model QA F1), and bounding parallel extract batches to `<= 16,000` chars with `score_extract_relevance` (`v0.3.3`).
---
### Phase II — Counterfactual Weight-Space Programming & Cloud Sandbox Co-Design (`v0.3.3 -> v0.4.1` / `v0.4.2`)
Using our `107`-task public agentic benchmark ([`youdotcom/reflex-search-eval`](https://huggingface.co/datasets/youdotcom/reflex-search-eval): `FabV2` SEC filings from `vals-ai/finance-agent-v2`, `AIM-Harvard/MedBrowseComp`, and `perplexity-ai/draco`, `46,573` total graded rollouts across 17 models in `networkBlockAll: true` sandboxes), we executed two zero-leakage Weight-Space Programming rounds (`57` declarative ops, `824` parameters in `heads.safetensors` + `heads.json`; `model.safetensors` untouched) strictly on the **54-task Discovery Split** (`0` overlap with `bar_locked` or the **53-task Sealed Holdout Split**):
1. **`v0.4.0` (Round-1 Empirical-Bayes Moderated-$t$ WSP + 12-Way CPU `ChoiceHead`):** Refined top discriminative post-SiLU units across `ChoiceHead` ($t = +6.94$), `NoulHead` ($t = +2.44$), and `ScoreHead` (`T_rank = 2.02`), lifting Sealed Holdout-53 `ndcg@6` from **`0.8574 -> 0.8841` (`+2.67 pp`)**, Arena-30 `pass@5` (`67.07% -> 68.70%`), and interactive streaming score (`0.5867 -> 0.6195`).
2. **`v0.4.1` (Round-2 `google/gemini-4-carbon` Anti-Overextraction WSP + Turn-Adaptive Extract):** Mined `676` clean-pass vs. `440` over-extracting turn-exhausted `v0.4.0` Discovery-Split rollouts to suppress distractor `worth_reading` traps while sharpening `ChoiceHead` recall:
- **Untouched `bar_locked` (`6,155` rows):** Best overall Quantile ECE (**`0.0242 <= 0.040`**) and lowest Perturbation JS (**`0.00105 <= 0.005`**) of all releases, with `49.60%` 5-way `Choice:text` accuracy.
- **Sealed Holdout-53 (`int8` `s1_eg2cpu`):** Lifts out-of-distribution `winningRecall@6` to **`55.46%` (`+6.37 pp` over `v0.3.3`)** and `worthReadingAlignment` to **`0.8768`**.
- **Live Cloud Impact (`v0.4.1` & `v0.4.2` Hard-Conditional BM25 Runtime):** Cuts bulk `13+` extract over-reading (`21.85% -> 20.28%`) and heavy-reader turn exhaustion (`62.62% -> 59.58%`), sets a record **`1,687.5 ms` streaming `TTFT`** (`4.6x-8.2x` faster than server-side web loops), and — paired with `perceived_difficulty === "hard"` conditional dual-window BM25 (`v0.4.2`) — achieves **all-time Reflex highs** on All-17-Model Arena-30 score (**`0.5947`**), `FabV2` `pass^5` (**`36.56%`**), Arena `MedBrowseComp` `pass@5` (**`70.06%`**), and Full-50 `MedBrowseComp` accuracy (**`39.15%`**).
---
## Untouched Holdout Calibration (`bar_locked`, `6,155` Rows)
| Cell | Holdout Rows | Proper Loss (vs. Base Rate) | Accuracy / Conditional RPS | Quantile ECE (Gate `<= 0.045`) | Perturbation JS (Gate `<= 0.005`) |
| :--- | ---: | :--- | :--- | :--- | :--- |
| **`Choice:text`** | `2,024` | `0.1249 < 0.1599` | `49.60%` (`5`-way) | `0.0252` (`-17.9%` vs `v0.3.3`) | `0.00067` (`-15.5%` vs `v0.3.3`) |
| **`Noul:text`** | `2,040` | `0.1587 < 0.2500` | `77.25%` | `0.0302` (`-18.8%` vs `v0.4.0`) | `0.00120` (`-7.3%` vs `v0.3.3`) |
| **`Score:text`** | `2,091` | `0.1188 < 0.3340` | `RPS 0.1559 < 0.2004` | `0.0175` | `0.00128` |
| **Combined** | **`6,155`** | **All `3/3` Heads Admitted** | — | **`0.0242 <= 0.040`** | **`0.00105 <= 0.005`** |
---
## References & Companion Artifacts
- **Technical Report, Co-Design Lineage (`MODEL_AND_RUNTIME_CODESIGN.md`), & Pure-Rust `rmcp` `stdio` Server:** [`youdotcom-oss/reflex-search-eval`](https://github.com/youdotcom-oss/reflex-search-eval)
- **Full `46,573`-Rollout Benchmark Dataset Archive:** [`youdotcom/reflex-search-eval`](https://huggingface.co/datasets/youdotcom/reflex-search-eval)
- **You.com Search & Contents Integration Runbook:** <https://you.com/search-contents-integration-runbook>
- **Research Foundations:** Gneiting & Raftery (2007) *Strictly Proper Scoring Rules*; [Chroma `Context-1`](https://www.trychroma.com/research/context-1); [SID `SID-2`](https://www.sid.ai/research/sid-2-technical-report); [Takehi et al., MIT CSAIL (2026) *Sparks of Weight-Space Programming*](https://rikiyat.github.io/blog/weight-space-programming/).
---
## License & Attribution
- Base weights (`model.safetensors`, `tokenizer.json`, `config.json`) derive from [`google/embeddinggemma-2`](https://huggingface.co/google/embeddinggemma-2) under the **Apache-2.0** license.
- LoRA adapters, calibrated RLCD projection heads, weight-space edits, and configuration metadata are released under **Apache-2.0**.