Contexting as Recommendation: Evolutionary Collaborative Filtering for Context Engineering

Jiachen Zhu, Zhuoying Ou, Congmin Zheng, Yuxiang Chen, Zeyu Zheng, Rong Shan, Lingyu Yang, Lionel Z. Wang, Weiwen Liu, Yong Yu, Weinan Zhang, Jianghao LinarXiv 2026

TL;DR

Large Language Models (LLMs) are notoriously sensitive to their input prompts, yet most automated prompt engineering methods search for a single "best" prompt to use for every input. This paper introduces Neural Collaborative Context Engineering (NCCE), which treats prompt selection as a recommendation problem, dynamically routing each individual input to its own optimal context strategy to unlock significant performance gains.

What Problem Does This Paper Address?

LLMs exhibit extreme sensitivity to "context engineering"—the specific combination of instructions, few-shot examples, and reasoning formats provided at inference time. Current state-of-the-art methods (like DSPy or OPRO) treat this as a global optimization problem, seeking one prompt that maximizes average performance across a whole dataset.

However, the authors argue that this "one-size-fits-all" approach is fundamentally flawed. A complex multi-hop reasoning task might require a detailed Chain-of-Thought prompt, while a simple verification task might perform better with a concise, grounded instruction. By forcing a single global prompt, researchers leave substantial "instance-level" performance on the table. The challenge is how to efficiently discover and assign the right prompt to the right input without exhaustively testing every possibility.

Methods

The authors propose a paradigm shift: Context Engineering as Recommendation. In this framework, input instances are treated as "users," context strategies (prompts) are "items," and task accuracy serves as the "interaction signal."

The shift from global optimization to instance-wise recommendation.

To operationalize this, they developed the NCCE framework, which consists of three main stages:

  1. Cluster-based Initialization: Training instances are clustered by semantic similarity. A global optimizer (like MIPROv2) is used to generate specialized "anchor" contexts for each cluster, creating a high-quality initial "item catalog."
  2. Context-CF Co-Evolution: This is the core innovation. A lightweight Neural Collaborative Filtering (NCF) model is trained on sparse interaction data to learn latent preferences between inputs and prompts. NCCE then uses the NCF model's gradients to identify "blind spots"—instances where current prompts fail. An LLM "reflector" then evolves new, specialized context variants to target these failures, which in turn provides new data to further refine the NCF model.
  3. Instance-wise Routing: At inference time, the trained NCF model acts as a router. For any new, unseen input, it scores the entire catalog of prompts and selects the one predicted to yield the highest accuracy.
The overall architecture of the NCCE framework and its co-evolutionary loop.

Datasets

The framework was evaluated on three reasoning benchmarks known for instance heterogeneity:

  • HoVer: A multi-hop fact verification benchmark.
  • SCONE: A context-dependent semantic parsing and state-tracking task.
  • HotpotQA: A multi-hop question-answering dataset requiring reasoning over multiple documents.

The experiments used GPT-4o-mini as the target LLM and all-MiniLM-L6-v2 for semantic embeddings.

Key Insights and Ideas

  • Personalization Matters: The authors demonstrate a massive gap between the best global prompt and the "Oracle" performance (the result if you perfectly chose the best known prompt for every instance). NCCE aims to close this gap.
  • Beyond Surface Similarity: While clustering helps, the NCF model captures "latent" compatibility. Visualization shows that the final router doesn't just pick prompts based on simple semantic neighborhoods; it learns nuanced requirements for different reasoning types.
  • Sample Efficiency: The recommendation approach is highly efficient. Experiments showed that populating only 30% of the instance-context interaction matrix was enough to trigger a massive performance leap, avoiding the need for exhaustive (and expensive) LLM evaluations.
t-SNE visualization showing how NCCE produces a more nuanced, interwoven distribution of context assignments compared to simple cluster-based routing.

Key Results

NCCE consistently outperformed all global optimization baselines across all datasets:

  • Average Accuracy: NCCE achieved a test accuracy of 74.8%, outperforming the strongest global baselines like MIPROv2 (68.8%) and GEPA-Merge (68.7%) by roughly 6% absolute margin.
  • Dataset Specifics: It reached 74.7% on HoVer, 89.7% on SCONE, and 60.1% on HotpotQA, setting new high-water marks for automated context engineering on these tasks.
  • Theoretical Backing: The paper includes PAC-style proofs showing that the routing regret is bounded by the quality of the initial catalog and the generalization ability of the NCF router.

Limitations and Future Work

  • Training Cost: The "Co-Evolution" phase requires an LLM to reflect on and generate new prompts. While this is a one-time offline cost, it can be expensive and slow for very large datasets. The authors suggest exploring smaller, local models for the reflection step.
  • Cross-Model Transferability: The current study focuses on a single base LLM. It remains an open question whether a prompt catalog evolved for a frontier model (like GPT-4o) can be effectively routed to smaller, open-weight models.
  • Search Space: While the catalog evolves, it is still limited by the initial "anchor" strategies. Future work could explore more radical prompt mutations during the co-evolution phase.

Summary updated

BibTeX
@misc{zhu2026contexting,
  author = {Jiachen Zhu and Zhuoying Ou and Congmin Zheng and Yuxiang Chen and Zeyu Zheng and Rong Shan and Lingyu Yang and Lionel Z. Wang and Weiwen Liu and Yong Yu and Weinan Zhang and Jianghao Lin},
  title = {{Contexting as Recommendation: Evolutionary Collaborative Filtering for Context Engineering}},
  year = {2026},
  eprint = {2605.15721},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.15721},
}

Loading related content...

Figure