# Dr.ICL: Demonstration-Retrieved In-context Learning

Dr.ICL: 시연 검색 기반 인컨텍스트 학습

Man Luo, Xin Xu, Zhuyun Dai, Panupong Pasupat, Mehran Kazemi, Chitta Baral 외 2명 · arXiv · 2023년 5월 23일

- **연구 문제** 기존 ICL은 고정되거나 무작위인 데모를 주로 사용해, 질의마다 유용한 데모를 고르는 효과가 충분히 검증되지 않았습니다.
- **연구 방법** BM25와 GTR로 질의별 데모를 검색하고, PaLM-62B 점수로 재순위화한 후보로 과제 맞춤형 데모 검색기를 학습합니다.
- **주요 결과** PaLM에서 BM25와 GTR 데모는 무작위 데모보다 나은 것으로 보고되며, 학습된 검색기는 one-shot 평균에서 GTR보다 높은 값을 보입니다.

## 질의별 데모를 고르는 문제

In-context learning(ICL)은 파라미터를 바꾸지 않고 몇 개의 데모를 입력에 넣어 과제를 수행하게 하는 방식입니다. 기존 연구는 고정된 데모나 무작위 데모를 주로 사용해 왔지만, 이 논문은 테스트 질의마다 데모를 고르는 Demonstration-Retrieved In-context Learning(Dr. ICL)을 다룹니다. 검색은 학습 데이터 풀에서 질의와 가까운 데모를 찾는 방식으로 이루어집니다.

논문은 단순한 단어 중첩 기반 검색기인 BM25도 무작위 데모보다 나은 데모를 찾을 수 있는지 묻습니다. 또한 검색 기반 ICL을 지시 학습된 모델과 Chain-of-Thought(CoT) 프롬프팅에까지 확장할 수 있는지 확인합니다.

## off-the-shelf 검색기와 학습된 데모 검색기

BM25는 단어 빈도와 역문서 빈도 등을 이용하는 희소 검색기이고, GTR은 T5 기반 듀얼 인코더로 의미적으로 가까운 데모를 찾는 밀집 검색기입니다. 두 검색기 모두 학습 데이터의 질문-정답 쌍을 검색 코퍼스로 사용합니다.

논문은 여기에 더해 과제 맞춤형 데모 검색기를 학습합니다. 먼저 GTR로 질의마다 후보 100개를 검색하고, PaLM-62B로 각 후보가 정답 확률을 얼마나 높이는지 점수화합니다. 이후 상위 후보를 양성 데모, 하위 후보를 어려운 음성 데모로 사용하며, 검색기 점수 s(q,d)=v\_q^⊤v\_d를 대조 손실로 GTR에서 미세조정합니다.

![Figure 2: Pipeline for training demonstration retriever and inference (R for a neural retriever). Figure on the left shows the procedure of obtaining data to t…](https://refivu.com/papers/996dd357-1e54-4c56-bfef-88bcdef0091c/figures/figure-48159c66986a464811a4c11964c8fac8.png?thumb=512)

**Figure 2** : Pipeline for training demonstration retriever and inference (R for a neural retriever). Figure on the left shows the procedure of obtaining data to train a demonstration retriever: an off-the-shelf retriever takes an input query xq and retrieves top-k (e.g., 100) demonstrations candidates from the training corpus. Then an LLM is used to output the score of the ground truth of yq with each retrieved demonstration and xq. Figure on the right shows the inference pipeline for in-context learning with the trained demonstration retriever.

[원문](https://arxiv.org/abs/2305.14128v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Man Luo, Xin Xu, Zhuyun Dai, Panupong Pasupat, Mehran Kazemi, Chitta Baral, Vaiva Imbrasaite, Vincent Y Zhao · Dr.ICL: Demonstration-Retrieved In-context Learning · 원문 그림 인용 · 원본 PDF 4쪽에서 그림 영역을 추출했습니다.

## PaLM과 Flan-PaLM에서의 검색 데모 비교

PaLM-540B에서 BM25와 GTR로 검색한 데모는 one-shot과 few-shot 설정 모두에서 무작위 데모보다 나은 것으로 보고됩니다. 이 비교는 NQ, ANLI(r3), GSM8k, StrategyQA, AQuA 같은 데이터셋에서 정확 일치 정확도로 측정되었습니다.

![Figure 1: The average performance of PaLM and Flan- PaLM on five datasets, with one and few-shot ICL. Re- trieved demonstrations given by either BM25 or GTR yi…](https://refivu.com/papers/996dd357-1e54-4c56-bfef-88bcdef0091c/figures/figure-d7c9922e92838d0e6c0092b6e03352df.png?thumb=512)

**Figure 1** : The average performance of PaLM and Flan- PaLM on five datasets, with one and few-shot ICL. Re- trieved demonstrations given by either BM25 or GTR yield better performance than random demonstrations.

[원문](https://arxiv.org/abs/2305.14128v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Man Luo, Xin Xu, Zhuyun Dai, Panupong Pasupat, Mehran Kazemi, Chitta Baral, Vaiva Imbrasaite, Vincent Y Zhao · Dr.ICL: Demonstration-Retrieved In-context Learning · 원문 그림 인용 · 원본 PDF 1쪽에서 그림 영역을 추출했습니다.

![Figure 3: PaLM: One-shot and few-shot inference with three types of demonstrations, random, BM25, and GTR](https://refivu.com/papers/996dd357-1e54-4c56-bfef-88bcdef0091c/figures/figure-cc353364804e9a663eab36b0589b4542.png?thumb=512)

**Figure 3** : PaLM: One-shot and few-shot inference with three types of demonstrations, random, BM25, and GTR.

[원문](https://arxiv.org/abs/2305.14128v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Man Luo, Xin Xu, Zhuyun Dai, Panupong Pasupat, Mehran Kazemi, Chitta Baral, Vaiva Imbrasaite, Vincent Y Zhao · Dr.ICL: Demonstration-Retrieved In-context Learning · 원문 그림 인용 · 원본 PDF 5쪽에서 그림 영역을 추출했습니다.

Flan-PaLM은 PaLM과 같은 구조를 가지지만 수천 개의 과제로 지시 학습된 모델입니다. 저자들은 이 모델에서도 학습 데이터에서 검색한 데모가 데모가 없거나 무작위 데모를 사용하는 경우보다 나은 결과를 낸다고 보고합니다. 저자들은 이를 학습 데이터가 추론 시점의 검색 자원으로도 쓰일 수 있다는 해석으로 제시하며, 검색 데모가 모델의 지식 위치를 드러내는 효과인지는 추가 증명하지 않습니다.

![Figure 4: Flan-PaLM: One-shot and few-shot inference with three types of demonstrations, random, BM25, and GTR](https://refivu.com/papers/996dd357-1e54-4c56-bfef-88bcdef0091c/figures/figure-8c73ef42490229e89fb4067e54b9194c.png?thumb=512)

**Figure 4** : Flan-PaLM: One-shot and few-shot inference with three types of demonstrations, random, BM25, and GTR.

[원문](https://arxiv.org/abs/2305.14128v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Man Luo, Xin Xu, Zhuyun Dai, Panupong Pasupat, Mehran Kazemi, Chitta Baral, Vaiva Imbrasaite, Vincent Y Zhao · Dr.ICL: Demonstration-Retrieved In-context Learning · 원문 그림 인용 · 원본 PDF 5쪽에서 그림 영역을 추출했습니다.

## 학습된 데모 검색기의 결과

표 2에서 PaLM 기준 Demo-GTR은 GTR보다 평균 성능이 높습니다. one-shot 평균은 Demo-GTR 51.1이고 GTR 49.8입니다. few-shot 평균은 Demo-GTR 54.8, GTR 54.6입니다. 이 결과는 one-shot 설정에서 개선 폭이 더 뚜렷하다는 점을 보여 줍니다.

![Table 2: Performance of PaLM using GTR and Demo- GTR retrieved demonstrations. Demo-GTR consistently achieves better performance than GTR in one-shot case](https://refivu.com/papers/996dd357-1e54-4c56-bfef-88bcdef0091c/figures/figure-4a5525aa4b70fb7d864a378a726ed452.png?thumb=512)

**Table 2** : Performance of PaLM using GTR and Demo- GTR retrieved demonstrations. Demo-GTR consistently achieves better performance than GTR in one-shot case.

[원문](https://arxiv.org/abs/2305.14128v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Man Luo, Xin Xu, Zhuyun Dai, Panupong Pasupat, Mehran Kazemi, Chitta Baral, Vaiva Imbrasaite, Vincent Y Zhao · Dr.ICL: Demonstration-Retrieved In-context Learning · 원문 그림 인용 · 원본 PDF 6쪽에서 그림 영역을 추출했습니다.

이 표의 비교는 NQ, ANLI(r3), GSM8k에 대한 PaLM 결과입니다. 따라서 이 결과를 모든 데이터셋이나 모든 모델로 일반화하기는 어렵습니다.

## 검색 방식의 한계와 해석 범위

BM25는 키워드 매칭에 크게 의존하고 문맥 이해가 부족하여 결과의 정확성이 떨어질 수 있다고 서술됩니다. GTR은 의미 이해에 강점이 있지만 메모리와 계산 효율이 낮고 해석 가능성이 부족하다고 설명됩니다.

겹침 분석에서 데모 답과 정답의 겹침 비율은 여러 데이터셋에서 무작위 기준과 비슷하거나 낮게 나타나 검색 이득이 단순한 라벨 식별 때문이라는 설명은 약하게 보입니다. 다만 NQ에서는 겹침이 크게 나타났으며, 저자들은 이 경우 질문이 데모 질문과 의미적으로 같은 경우가 많았다고 보고합니다.

![Table 3: Overlapped Ratio of Demonstrations Answers with Targets: Random represents the probability of selecting the correct label if we select randomly from t…](https://refivu.com/papers/996dd357-1e54-4c56-bfef-88bcdef0091c/figures/figure-04265e6080ed41bc1728eb8ac23466e6.png?thumb=512)

**Table 3** : Overlapped Ratio of Demonstrations Answers with Targets: Random represents the probability of selecting the correct label if we select randomly from the space of possible labels.

[원문](https://arxiv.org/abs/2305.14128v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Man Luo, Xin Xu, Zhuyun Dai, Panupong Pasupat, Mehran Kazemi, Chitta Baral, Vaiva Imbrasaite, Vincent Y Zhao · Dr.ICL: Demonstration-Retrieved In-context Learning · 원문 그림 인용 · 원본 PDF 6쪽에서 그림 영역을 추출했습니다.

## 논문 정보

- **저자**: Man Luo, Xin Xu, Zhuyun Dai, Panupong Pasupat, Mehran Kazemi, Chitta Baral, Vaiva Imbrasaite, Vincent Y Zhao
- **학회·저널**: arXiv · 프리프린트
- **최초 공개일**: 2023년 5월 23일
- **등록일**: 2026년 11월 6일
- **수정일**: 2023년 5월 23일
- **버전**: v1
- **arXiv**: 2305.14128
- **분류**: cs.CL · cs.AI
- **원문 이용 조건**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **제공 범위**: 논문 정보, 해설, 허용된 원문 그림

[논문 원문 ↗](https://arxiv.org/abs/2305.14128v1) · [원문 PDF ↗](https://arxiv.org/pdf/2305.14128v1)

AI 해설은 논문 원문과 별개의 설명이며 오류가 있을 수 있습니다. 원문과 그림은 각 출처의 이용 조건과 따로 표시된 권리를 따릅니다.

## 초록

In-context learning (ICL), teaching a large language model (LLM) to perform a task with few-shot demonstrations rather than adjusting the model parameters, has emerged as a strong paradigm for using LLMs. While early studies primarily used a fixed or random set of demonstrations for all test queries, recent research suggests that retrieving semantically similar demonstrations to the input from a pool of available demonstrations results in better performance. This work expands the applicability of retrieval-based ICL approaches by demonstrating that even simple word-overlap similarity measures such as BM25 outperform randomly selected demonstrations. Furthermore, we extend the success of retrieval-based ICL to instruction-finetuned LLMs as well as Chain-of-Thought (CoT) prompting. For instruction-finetuned LLMs, we find that although a model has already seen the training data at training time, retrieving demonstrations from the training data at test time yields better results compared to using no demonstrations or random demonstrations. Last but not least, we train a task-specific demonstration retriever that outperforms off-the-shelf retrievers.

## 원문 인용

Man Luo, Xin Xu, Zhuyun Dai, Panupong Pasupat, Mehran Kazemi, Chitta Baral, Vaiva Imbrasaite, Vincent Y Zhao (2023). Dr.ICL: Demonstration-Retrieved In-context Learning. arXiv:2305.14128v1. https://arxiv.org/abs/2305.14128v1

**BibTeX**

```
@misc{luo2023demonstration,
  title = {{Dr.ICL: Demonstration-Retrieved In-context Learning}},
  author = {Man Luo and Xin Xu and Zhuyun Dai and Panupong Pasupat and Mehran Kazemi and Chitta Baral and Vaiva Imbrasaite and Vincent Y Zhao},
  year = {2023},
  eprint = {2305.14128},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2305.14128v1}
}
```

## 이 논문의 용어

- [GSM8K](https://refivu.com/terms/e48f0e01064d-gsm8k)
- [BM25](https://refivu.com/terms/64437f95755a-bm25)
- [in-context learning](https://refivu.com/terms/d53d2af6b551-in-context-learning)
- [Contrastive loss](https://refivu.com/terms/53c787c4cf0e-contrastive-loss)
- [majority voting](https://refivu.com/terms/20e954015dfd-majority-voting)
- [StrategyQA](https://refivu.com/terms/da46e388b92b-strategyqa)
- [NQ](https://refivu.com/terms/355505a22c59-nq)
- [PaLM-540B](https://refivu.com/terms/6b399672c9de-palm-540b)
- [AQuA](https://refivu.com/terms/4527d93761bb-aqua)
- [Flan-PaLM](https://refivu.com/terms/86490c3d3ccc-flan-palm)
- [GTR](https://refivu.com/terms/3c4e306560c1-gtr)

## 다른 논문 해설

- [Large Language Model-Based Uncertainty-Adjusted Label Extraction for Artificial Intelligence Model Development in Upper Extremity Radiography](https://refivu.com/papers/9b222a13-ea6f-4ce3-a329-e7ff28964ff8-large-language-model-based-uncertainty-adjusted-label.md)
- [Unlocking the Archives: Using Large Language Models to Transcribe Handwritten Historical Documents](https://refivu.com/papers/c3f9b9b5-8145-4837-9b3e-abaf5cbfb22c-unlocking-the-archives-using-large-language-models-to.md)
- [Can Large Language Models Transform Natural Language Intent into Formal Method Postconditions?](https://refivu.com/papers/cfece4bb-1558-4163-9369-9dfea374f585-can-large-language-models-transform-natural-language-intent.md)
- [Evaluating the Ripple Effects of Knowledge Editing in Language Models](https://refivu.com/papers/b5a70e67-045a-47b7-96d8-dbc886057a9e-evaluating-the-ripple-effects-of-knowledge-editing-in.md)
- [Does the Magic of BERT Apply to Medical Code Assignment? A Quantitative Study](https://refivu.com/papers/9db22439-ebb1-4274-82e5-98c07b5b5366-does-the-magic-of-bert-apply-to-medical.md)
- [Knowledge Graphs, Large Language Models, and Hallucinations: An NLP Perspective](https://refivu.com/papers/bfd02873-c02f-410b-8245-d4b6a31c8a37-knowledge-graphs-large-language-models-and-hallucinations-an.md)
- [Artificial Spacetimes for Reactive Control of Resource-Limited Robots](https://refivu.com/papers/7fee5e47-2718-467d-a41c-11442f8a8f2e-artificial-spacetimes-for-reactive-control-of-resource.md)
- [TCCT: Tightly-Coupled Convolutional Transformer on Time Series Forecasting](https://refivu.com/papers/32df64eb-3c3e-409d-bee5-f6799998f841-tcct-tightly-coupled-convolutional-transformer-on-time.md)
- [Classification of Shoulder X-Ray Images with Deep Learning Ensemble Models](https://refivu.com/papers/8a08d6bc-7fca-4507-8e73-873f94dea956-classification-of-shoulder-x-ray-images-with-deep.md)
- [Reinforcement Learning for Mixed-Integer Problems Based on MPC](https://refivu.com/papers/1533cfc4-31a0-4046-a18a-83ecb1069c71-reinforcement-learning-for-mixed-integer-problems-based-on.md)
- [Adaptive Prototypical Networks with Label Words and Joint Representation Learning for Few-Shot Relation Classification](https://refivu.com/papers/f1f70772-4d0a-4d7a-aba9-54dbce52a865-adaptive-prototypical-networks-with-label-words-and-joint.md)
- [The Power of Combined Modalities in Interactive Robot Learning](https://refivu.com/papers/0fce9a4a-5764-433b-8f6c-a19ace5c9d5d-the-power-of-combined-modalities-in-interactive-robot.md)

---

AI 해설에는 오류가 있을 수 있습니다. [Refivu](https://refivu.com/papers/996dd357-1e54-4c56-bfef-88bcdef0091c-dr-icl-demonstration-retrieved-in-context-learning)
