自动优化少样本提示中的示例,提升模型在低数据场景下的表现
GRaSp: Automatic Example Optimization for In-Context Learning in Low-Data Tasks

- 三阶段框架:生成候选示例、聚类降维、遗传算法筛选最优示例
- 在金融命名实体识别任务中,微平均F1达45.84%,优于零样本和随机少样本
- 引入自适应变异机制,兼顾全局探索与局部优化,适合低数据领域应用
上下文学习使大语言模型能适应新任务,但其性能高度依赖示例选择。在领域特定、低数据场景下,高质量示例稀缺,难以获取。我们提出GRaSp,一种三阶段自动上下文示例优化框架:首先生成大规模合成候选池,再通过聚类与降维结构化,最后使用遗传算法寻找最优示例。在金融命名实体识别(FiNER-139)任务上评估,对比500和5000规模的合成与人工标注候选池。使用非合成数据时,GRaSp达到45.84%微平均F1,持续优于零样本和随机少样本基线。合成数据匹配随机基线但未超越,表明候选池的分布多样性对泛化至关重要。
原文摘要 · Abstract (English)
In-context learning enables large language models to adapt to new tasks, but their performance is highly sensitive to the selected examples. Finding effective demonstrations is particularly difficult in domain-specific, low-data settings where high-quality examples are scarce. We propose GRaSp, a three-stage framework for automatic in-context example optimization. By first generating a large synthetic candidate pool, then structuring it with clustering and dimensionality reduction, and finally using genetic algorithms to find the optimal in-context examples, the framework shows consistent improvements on the NER task. We also introduce a custom diversity-adaptive mutation mechanism, allowing it to transition from the initial broad inter-cluster exploration to focused intra-cluster refinement as the population converges. We evaluate GRaSp on financial named entity recognition (FiNER-139), comparing synthetic and human-annotated candidate pools across pool sizes of 500 and 5000. With non-synthetic data, GRaSp achieves 45.84% micro-F1, consistently outperforming both zero-shot and random few-shot baselines. Synthetic data matches the random baseline but does not exceed it, suggesting that distributional variety in the candidate pool is critical for generalization.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。