LLM中的few-shot是什么意思

我上篇博客写了我做的测试Baichuan2-13B模型的一些工作,测试过程免不了要修改代码,在代码中接触了下所谓的few-shot。

比如,所谓2-shot,就是在提示词里提供两个问题和答案,让大模型以为自己回答过问题,后面生成文本会参考前面的内容。2-shot的提示词如下:
在这里插入图片描述
而0-shot,或者zero-shot在正式的问题前面就没有追加的例子。0-shot的提示词如下:
在这里插入图片描述
经过我的测试,2-shot的情况下,Baichuan2-13B-Base的C-Eval准确率是0.587,同样的方法,0-shot的情况下则只有0.579。
所以few-shot其实能增加大语言模型的能力的。

参考资料

baichuan2-13b-base的C-Eval得分简析

### Few-Shot Learning Examples in Large Language Models (LLM) In the context of large language models, few-shot learning allows these models to perform tasks effectively even when provided with a limited number of training examples. This capability is particularly valuable as it reduces the need for extensive labeled data and demonstrates robust generalization abilities. #### Example 1: Tabular Data Reasoning For reasoning over tabular data, LLMs like GPT-3 can be prompted using only a handful of examples within the input prompt itself[^2]. For instance: ```plaintext Table: | Name | Age | Occupation | |------|-----|------------| | John | 30 | Engineer | | Jane | 25 | Doctor | Question: Who is older between John and Jane? Answer: John. ``` The model learns from this small set of structured inputs and applies similar logic to new questions about different tables without requiring additional specific training on each table format or content type. #### Example 2: Guided Active Learning for Debiasing Another application involves guided active learning strategies aimed at reducing biases present in pre-trained LLMs by identifying biased samples through counterfactual in-context learning methods[^3]: ```python def identify_biased_samples(model_output): # Analyze output patterns that indicate potential bias pass biased_examples = [] for sample in dataset: prediction = model(sample) if identify_biased_samples(prediction): biased_examples.append((sample, "Biased")) # Use identified biased examples to refine model behavior further via targeted retraining ``` This approach leverages few-shot capabilities not just for task execution but also for improving model fairness across various applications. #### Example 3: One-Shot Selection of High-Quality SFT Data When selecting high-quality instruction-following instances for fine-tuning purposes, one-shot learning techniques help evaluate individual command demonstrations based on their effectiveness in enhancing overall performance across diverse downstream tasks[^4]. ```json { "instruction": "Summarize the following article...", "input_text": "...", "output_summary": "..." } ``` By assessing how well single examples contribute towards better outcomes during evaluation phases, researchers can strategically choose optimal datasets for specialized tuning processes.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值