Large Language Models cannot reliably acquire new knowledge post-deployment -- even when relevant text resources exist, models fail to transform them into actionable knowledge without retraining. Retrieval-Augmented Generation attempts to bridge this gap by surfacing relevant documents at inference time, yet similarity-based retrieval often fails to identify context that actually improves task performance. We introduce Evolutionary Context Search (ECS), an evolutionary method that searches context combinations using accuracy on a small development set, requiring only inference calls without weight updates. ECS moves beyond semantic similarity to discover non-obvious context pairings that significantly boost performance. Our empirical results show that ECS improves BackendBench by 27% and τ-bench airline by 7%. The evolved contexts are model-agnostic, as those evolved with Gemini-3-Flash transfer effectively to Claude Sonnet and DeepSeek. This suggests that ECS opens a path toward automated context discovery for skill acquisition -- an efficient alternative to manual prompt engineering or costly fine-tuning.
Figures & tables
Figure 1: Evolutionary Context Search. Our method takes a population of text resources and evolves optimized contexts that confer the knowledge required to perform tasks in unseen domains. Each successive generation accumulates task-dependent, knowledge-rich information, effectively searching the corpora to obtain token-efficient contexts that enable novel skill acquisition in LLMs.
Figure 2: Performance comparison on Backend Bench. Our method (ECS) achieves a 27% relative improvement over AST + Hybrid. Detailed result are in Appendix A.2 .
Figure 3: Fitness score during the evolutionary search process.
Method
Pass 1
Pass 2
Pass 3
Plain LLM
0.622
0.489
0.400
Random
0.650
0.556
0.500
BM25
0.641
0.550
0.483
Full
0.717
0.628
0.550
ECS (Ours)
0.767
0.710
0.683
Table 1: Comparison on τ2 -Bench. ECS significantly outperforms baselines across all Pass metrics.
Figure 4: Transferability to Unseen Models (BackendBench). Contexts evolved by ECS transfer effectively to models not used during evolution. On DeepSeek-V3.2, where standard retrieval (AST+Dense) fails to provide meaningful gains, ECS unlocks significant capability, yielding a significant improvement.
Claude-4.5-Sonnet
DeepSeek-V3.2
Metric
Plain
Full
ECS
Plain
Full
ECS
Pass 1
0.600
0.678
0.678
0.583
0.633
0.600
Pass 2
0.506
0.561
0.617
0.478
0.500
0.472
Pass 3
0.450
0.500
0.583
0.417
0.417
0.417
# Tokens
0
5491
848
0
5491
848
Table 2: Transferability on τ2 -Bench. With Claude-4.5-Sonnet, ECS matches the Full baseline on Pass 1 and significantly outperforms it on stricter metrics (Pass 2 , Pass 3 ). Notably, ECS achieves comparable performance to the Full baselines with substantially fewer tokens, reducing usage from 5491 to 848, a 6 × reduction.
(a) Evolved Context
(b) RAG Baseline
(c) With Evolved Context
hopper/fmha.py (lines 1372–1384)
DeepSeek generates wrong API
DeepSeek generalizes correctly
⬇ 1 for j in range_constexpr (...): 2 acc_qk_mn [ i , j ] = cute.math.exp2 ( 3 scale_softmax_log2 4 * acc_qk_mn [ i , j ]
⬇ 1 input_val = gA [ tidx ] 2 # WRONG: ArithValue is symbolic! 3 result = math.atan ( input_val )
⬇ 1 input_val = gA [ tidx ] 2 # CORRECT: DSL intrinsic 3 result = cute.math.atan ( input_val )
cute.math.* pattern
× Fails: stdlib on symbolic value
✓ Works: DSL intrinsic
Figure 6: Cross-model context transfer from Gemini Flash to DeepSeek V3.2 on BackendBench. Top: (a) Evolved context demonstrates the cute.math.* pattern. (b) Without this context, DeepSeek incorrectly uses Python’s math.atan() on symbolic values, causing JIT compilation failures. (c) With evolved context, DeepSeek correctly generalizes to DSL intrinsics. Bottom: Quantitative results show evolved context improves pass rate from 6.5% to 22.3% ( 3.4× ); e.g., div.Tensor passes 16 out of 18 test cases.
Figure 7: Ablation study. We evaluate variants by removing components. Fitness , Mutation are universally critical. Refinement is domain-dependent: it is essential for resolving conflicting agentic policies ( τ2 -Bench) but has negligible impact on BackendBench.
Appendix figures & tables4 assets
Supplementary material from the paper’s appendix.
Appendix
Category
Operator
Signature
Description
Trigonometric Functions
acos
f:[−1,1]→[0,π]
Computes element-wise inverse cosine (arccosine) of the input tensor.
Computes element-wise inverse tangent (arctangent) of the input tensor.
Appendix
Table 3: PyTorch operators used in BackendBench evaluation. We evaluate 20 operators across three categories: trigonometric functions (8 ops), arithmetic operations (4 ops), and linear algebra primitives (8 ops).
Operator
Plain
Random
Chunk
AST
AST
AST
ECS
LLM
+Dense
+Dense
+BM25
+Hybrid
(Ours)
acos.default
0.333
0.444
0.444
0.778
0.667
0.222
0.778
acosh.default
0.333
0.444
0.778
0.667
0.667
0.667
0.778
addmm.default
0.333
0.000
0.000
0.000
0.000
0.000
0.000
addmv.default
0.167
0.000
0.167
0.000
0.000
0.000
0.222
addbmm.default
0.000
0.000
0.000
0.000
0.000
0.000
0.000
Appendix
Table 4: Comparison between ECS and various RAG baselines in BackendBench
Most existing large language models (LLMs) are expensive to adapt after deployment, especially when a task requires newly produced information or niche domain knowledge. Recent work has shown that, by manipulating and optimizing their context, LLMs can be tailored to downstream tasks without updating their weights. However, most existing methods remain closed-loop, relying solely on the model's intrinsic knowledge. In this paper, we equip these context optimizers with Wikipedia search and browser tools for active information seeking. We show that naively adding these tools to a standard sequential context optimization pipeline can actually degrade performance compared to baselines. However, when paired with a search-based training procedure that maintains and prunes multiple candidate contexts, active information seeking delivers consistent and substantial gains. We demonstrate these improvements across diverse domains, including low-resource translation (Flores+), health scenarios (HealthBench), and reasoning-heavy tasks (LiveCodeBench and Humanity's Last Exam). Furthermore, our method proves to be data-efficient, robust across different hyperparameters, and capable of generating effective textual contexts that generalize well across different models.
Teaching language models to use search tools is not only a question of whether they search, but also of whether they issue good queries. This is especially important in open-domain question answering, where broad or copied queries often waste retrieval budget and derail later reasoning. We propose \Ours, a framework that makes query planning explicit through reusable search skills. At each step, the model first selects a skill, then generates a search or answer action conditioned on the selected skill card. The skill inventory itself is not fixed: SearchSkill maintains an evolving SkillBank, expands or refines it from recurrent failure patterns, and reconstructs affected trajectories before supervised training. The resulting two-stage SFT recipe aligns training with the inference-time protocol of skill selection followed by skill-grounded execution. Across open-source and closed-source models, SearchSkill improves exact match on knowledge-intensive QA benchmarks and yields better retrieval behavior, including fewer copied first queries, more atomic hop-focused queries, and more correct answers within a small search budget. These results suggest that explicit skill-conditioned query planning is a lightweight alternative to treating search as an undifferentiated action.
Jinchao Hu, Meizhi Zhong, Kehai Chen +1
School of Computer Science and Technology, Harbin Institute of Technology, Shenzhen · Independent Researcher Shenzhen / Beijing, China
Many real-world tasks require language models (LMs) to reason over complex contexts that exceed their parametric knowledge. This calls for context learning, where LMs directly learn relevant knowledge from the given context. An intuitive solution is inference-time skill augmentation: extracting the rules and procedures from context into natural-language skills. However, constructing such skills for context learning scenarios faces two challenges: the prohibitive cost of manual skill annotation for long, technically dense contexts, and the lack of external feedback for automated skill construction. In this paper, we propose Ctx2Skill, a self-evolving framework that autonomously discovers, refines, and selects context-specific skills without human supervision or external feedback. At its core, a multi-agent self-play loop has a Challenger that generates probing tasks and rubrics, a Reasoner that attempts to solve them guided by an evolving skill set, and a neutral Judge that provides binary feedback. Crucially, both the Challenger and the Reasoner evolve through accumulated skills: dedicated Proposer and Generator agents analyze failure cases and synthesize them into targeted skill updates for both sides, enabling automated skill discovery and refinement. To prevent adversarial collapse caused by increasingly extreme task generation and over-specialized skill accumulation, we further introduce a Cross-time Replay mechanism that identifies the skill set achieving the best balance across representative cases for the Reasoner side, ensuring robust and generalizable skill evolution. The resulting skills can be plugged into any language model to obtain better context learning capability. Evaluated on four context learning tasks from CL-bench, Ctx2Skill consistently improves solving rates across backbone models.