---
title: "impact of sample selection on in-context learning for entity"
description: "How the choice of in-context examples affects scientific entity extraction with GPT-3.5, and when it holds up against supervised training."
canonical: "https://research.elamur.ai/free/en/papers/bolucu-2023-impact-sample-selection-context-learning/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/) · [Constitution](https://md.constitution.elamur.ai/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/bolucu-2023-impact-sample-selection-context-learning/)

[Elamur Research](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2023](https://md.research.elamur.ai/free/en/papers/2023/) / impact of sample selection on in-context learning for entity extraction from scientific writing

# impact of sample selection on in-context learning for entity extraction from scientific writing

Paper · 2023 · Necva Bölücü, Maciej Rybinski and Stephen Wan

**Authors:** [Necva Bölücü](https://md.research.elamur.ai/free/en/authors/necva-bolucu/), Maciej Rybinski and [Stephen Wan](https://md.research.elamur.ai/free/en/authors/stephen-wan/) · **Year:** 2023 · **Venue:** Findings of the Association for Computational Linguistics: EMNLP 2023 · **Licence:** [CC BY 4.0 (ACL Anthology)](https://creativecommons.org/licenses/by/4.0/)

[Cited by **4** papers in our library of more than 163,000 papers whose bibliographies we read](https://md.research.elamur.ai/free/en/papers/bolucu-2023-impact-sample-selection-context-learning/cited-by/) · Findings of the Association for Computational Linguistics: EMNLP 2023 · [licence](https://creativecommons.org/licenses/by/4.0/)

- [Publisher's page](https://aclanthology.org/2023.findings-emnlp.338/)
- [PDF](https://aclanthology.org/2023.findings-emnlp.338.pdf)
- [DOI 10.18653/v1/2023.findings-emnlp.338](https://doi.org/10.18653/v1/2023.findings-emnlp.338)

## Summary

A system that extracts information from scientific writing has to decide which words belong together and what those words refer to. In a medical case report, for example, it must distinguish the name of a drug from a phrase describing an adverse effect. Training a system to make those distinctions usually requires expert annotation. This paper asks how much can be achieved with fewer annotations by giving GPT-3.5 a handful of labeled sentences alongside each new sentence. The authors compare ways to choose those demonstrations and test when this approach can compete with a system trained directly for the task. [Information extraction](https://md.research.elamur.ai/free/en/concepts/information-extraction/)

In-context learning gives the system examples inside the prompt while keeping its parameters fixed. The authors draw all demonstrations from existing annotations and compare random sampling with several selection rules. KATE retrieves sentences that are close to the input in a numerical representation of sentence meaning. BM25 retrieves by word overlap and term weights. Perplexity favors sentences that a language model finds relatively predictable, reusing the same examples across test inputs. Influence ranks examples by their estimated effect on the loss of a supervised extractor. That last method uses the correct labels for the test sentence during selection, so it serves as an oracle comparison for studying the potential value of better choices. [Few-shot learning](https://md.research.elamur.ai/free/en/concepts/few-shot-learning/) · [Language model](https://md.research.elamur.ai/free/en/concepts/language-model/)

The authors evaluate entity-level macro F1 across medical case reports, measurement annotations, scientific abstracts, and wet-lab protocols. On the sampled test sentences with the full training pools available, supervised RoBERTa has the highest score on 4 of 5 datasets. The exception is WLPC, the protocol dataset. There, supervised RoBERTa scores 28.36, random demonstrations score 32.20, KATE reaches 45.02, and Influence reaches 45.41. Across the main experiments, the authors report an average improvement over random selection of 5.26% for KATE and 7.56% for Influence. The gains vary by dataset, and the practical selector with the highest score changes across tasks. [RoBERTa](https://md.research.elamur.ai/free/en/papers/liu-2019-roberta-robustly-optimized-bert-pretraining/)

When the authors restrict the labeled training pool to 1%, supervised RoBERTa loses much more ground than the prompted approaches. On SciERC, for example, the supervised score falls to 10.16 on the sampled test set, while BM25 with demonstrations drawn from the reduced pool scores 31.33. The error analysis helps explain what these comparisons leave unresolved. A demonstration can help the system recognize a relevant phrase while leaving it uncertain about where the phrase ends or which label applies. The study establishes that example selection can improve extraction with scarce annotations, while showing how much the result depends on the dataset, the available examples, and the choice of supervised comparison.

## Deep dive: impact of sample selection on in-context learning for entity extraction from scientific writing

How the choice of in-context examples affects scientific entity extraction with GPT-3.5, and when it holds up against supervised training. · about 33 minutes to read

**In this deep dive**

1. [The problem and its context](#dd-the-problem-and-its-context)
2. [The method, step by step](#dd-the-method-step-by-step)
3. [Experiments and results](#dd-experiments-and-results)
4. [What the ablations show](#dd-what-the-ablations-show)
5. [Limitations](#dd-limitations)
6. [What came after](#dd-what-came-after)

### The problem and its context

#### What an extractor needs to learn

Scientific articles and reports contain details that could help readers locate relevant work, organize evidence, and search collections of papers. To support those uses, an information extraction system needs to turn parts of a sentence into structured records. Entity extraction supplies the spans and their categories. A span is the stretch of text that the system selects. The category describes its role under the dataset’s annotation rules. Those rules determine which phrases count as entities and how much of each phrase to include. [Named entity recognition](https://md.research.elamur.ai/free/en/concepts/named-entity-recognition/)

Knowing the subject matter helps, but a benchmark also demands knowledge of its labeling conventions. A measurement can be written beside a unit, a symbol, or a description of what was measured. An extractor may recognize the measurement and still choose a span that extends beyond the annotated quantity. A phrase in an abstract can likewise be recognizable as a scientific term while sitting near the boundary between categories such as Method and Process. Correct extraction requires both the agreed span and its assigned type. That is one reason developing annotation guidelines and recruiting expert annotators can be demanding. [Linguistic annotation](https://md.research.elamur.ai/free/en/concepts/annotation/)

The conventional supervised comparison in the paper uses many labeled sentences to fit an extractor for each dataset. In-context learning offers a different use for an annotated sentence. It presents the sentence and its accepted answer as a worked example for the current request. The authors ask whether a small set of these examples can convey enough about the categories, boundaries, and response format to make scientific extraction effective. This is especially relevant when a collection comes from a specialized area where annotated text is scarce. [Fine-tuning](https://md.research.elamur.ai/free/en/concepts/fine-tuning/)

The paper distinguishes the size of the available collection from the number of examples shown in any prompt. A researcher may have a fairly large training set and still display only a handful of examples for a particular sentence. In that situation, the selector has a broad choice even though the prompt is short. If the training collection itself is small, the selector may have few suitable examples to choose from. The paper studies both situations so that a compact prompt can be judged separately from the supply of labeled data behind it.

#### Why choosing examples became a research problem

The paper places its work in the line of research that demonstrated how a pretrained system can perform a new task using a textual prompt. A task description, some answered inputs, and an unanswered input can establish a pattern for prediction without a parameter update. The authors describe earlier applications to tasks including translation, question answering, and semantic parsing, where in-context learning had sometimes been competitive with supervised methods. They also note that earlier work did not consistently find an advantage over fine-tuning. [Language Models are Few-Shot Learners](https://md.research.elamur.ai/free/en/papers/brown-2020-language-models-few-shot-learners/)

Choosing demonstrations matters because a prompt supplies only a small view of the task. A random draw may contain sentences that exemplify the relevant category, or it may largely illustrate categories and constructions that have little bearing on the new input. Earlier studies had already reported sensitivity to the examples supplied. The paper also draws on work showing that the order of examples can affect performance. Selection asks which examples appear in the prompt. Ordering asks how those examples should be arranged once chosen. The authors concentrate on selection. [Fantastically Ordered Prompts and Where to Find Them](https://md.research.elamur.ai/free/en/papers/lu-2022-fantastically-ordered-prompts-where-find/)

The authors distinguish approaches that retrieve existing examples from ones that generate material or search among rewritten prompts. KATE is an example of the retrieval approach. It searches the training set for neighbors of a new input. The prior work on perplexity used predictability to choose among generated prompt alternatives, including rewrites created through paraphrasing and back-translation. Bölücü and colleagues take that scoring idea and apply it to a different object. They rank labeled training sentences that already exist. This keeps the candidate pool tied to the same annotations used by the other selectors. [What Makes Good In-Context Examples for GPT-3?](https://md.research.elamur.ai/free/en/papers/liu-2022-what-makes-good-context-examples/) · [Demystifying Prompts in Language Models via Perplexity Estimation](https://md.research.elamur.ai/free/en/papers/gonen-2022-demystifying-prompts-language-models-perplexity/)

Earlier work on scientific and biomedical extraction gave the authors a more specific comparison. The biomedical study they cite evaluated prompting on entity recognition and relation extraction, with supervised training providing an important point of reference. Another study used nearest-neighbor retrieval for relation extraction, incorporating information about the entities into the demonstrations. In the present paper, predicting entities is itself the task. The selector has to choose what examples to show before the correct spans and types for the new sentence are known. [Thinking about GPT-3 In-Context Learning for Biomedical IE? Think Again](https://md.research.elamur.ai/free/en/papers/gutierrez-2022-thinking-about-gpt-3-context/) · [GPT-RE](https://md.research.elamur.ai/free/en/papers/wan-2023-gpt-re-context-learning-relation/)

That background leads to two questions that can be answered with different comparisons. To isolate the value of selection within prompting, the authors compare chosen examples with a random draw from the same training data. To see how prompting competes as a way to use annotations, they compare it with a supervised extractor. A zero-shot prompt supplies another reference point by showing what GPT-3.5 can do with the task format and the test input alone. Together these comparisons allow an improvement in demonstration choice to be interpreted separately from the performance of the extraction system as a whole.

### The method, step by step

#### From a labeled sentence to a demonstration

The starting material is a collection of sentences with reference annotations. Each training sentence can be presented together with its labeled entities. Those entities are called gold annotations because they provide the reference used by the experiment. The new input is another sentence from the same dataset. Its gold annotations are used to evaluate the answer and, in the special Influence condition, to rank the demonstrations. The practical selection methods operate without those answers.

For each test input, the authors give GPT-3.5 a prompt with the task format and the sentence to analyze. In few-shot conditions, they also include the selected demonstrations. A demonstration supplies both the input text and the answer expected for that text. Its answer provides evidence about what to extract, how closely to follow a span boundary, and what labels to use. The task remains entity extraction regardless of how the examples reach the prompt.

The authors use EasyInstruct’s entity extraction prompt format and supply the labels of the dataset being evaluated. Zero-shot prompting uses the format with the test input. Random sampling and the selection methods add worked examples from the training partition. The system then predicts the entities for the new sentence. GPT-3.5 is held fixed throughout these comparisons. Any fine-tuning used by a selector is on the RoBERTa side of the experiment.

Selecting demonstrations and extracting entities The steps in order.

Random sampling replaces the scoring step with a draw from the training pool. Perplexity performs its scoring independently of the test sentence, so a given demonstration count yields the same selections throughout a dataset. KATE and BM25 score candidates against the particular test input. Influence also produces an input-specific ranking, but it requires a supervised loss calculated using that input’s reference annotations. The flow therefore describes a common prompt construction procedure with materially different sources of evidence upstream.

#### The paper’s notation

The authors regard entity extraction as predicting the annotated entities associated with a set of sentences. Their notation separates the inputs from the corresponding answers.

```
D = (X, Y)
```

`D` is the dataset. `X` is the collection of input sentences, and `Y` is the collection of entity annotations associated with those sentences. The parentheses group the inputs and their references into a pair. The equals sign defines `D` as that pair. An entity annotation tells the system which text the dataset identifies as an entity and what type it assigns.

```
s = (w₁, …, wₙ)
```

`s` denotes a sentence. Each `w` is a word in that sentence. The subscript `₁` identifies the first word, and `ₙ` identifies the last. `n` is the number of words in the sentence. The ellipsis represents the intervening positions in order, and the parentheses enclose the sequence. The equals sign expresses the sentence as that sequence.

```
T(sₗᵗʳᵃⁱⁿ, eₗᵗʳᵃⁱⁿ)
```

`T` denotes the demonstrations in the paper’s prompt notation. In this expression it is used to describe a demonstration whose input is `sₗᵗʳᵃⁱⁿ` and whose gold entities are `eₗᵗʳᵃⁱⁿ`. The superscript `train` indicates the training partition. The subscript `l` identifies the demonstration within the selection. The comma separates its input sentence from its annotated answer, and the enclosing parentheses group those components. The paper calls the total number of demonstrations `k`.

```
P = I + T + sᵢᵗᵉˢᵗ
```

`P` is the complete prompt. `I` is the format that specifies the entity extraction task. `T` is the selected set of demonstrations rendered in the prompt. `sᵢᵗᵉˢᵗ` is the input sentence at test index `i`, with the superscript `test` marking its partition. The plus signs indicate that these pieces are put together as text. The equals sign defines the resulting prompt. With zero-shot prompting, the demonstration component is absent. According to the authors, predicting for a test sentence means picking the entities with the greatest predicted likelihood.

#### KATE retrieves by sentence representation

KATE uses nearest-neighbor retrieval. It converts each candidate sentence and the test sentence into an embedding, a vector that lets the selector compare sentences numerically. It then takes the requested number of training sentences closest to the test sentence according to its chosen comparison. The attached gold labels travel with the selected sentences into the prompt. The selector therefore compares inputs by their embeddings, while the extraction system sees complete worked examples. [Word embeddings](https://md.research.elamur.ai/free/en/concepts/word-embeddings/) · [Semantic similarity](https://md.research.elamur.ai/free/en/concepts/semantic-similarity/)

The paper considers Euclidean distance and cosine similarity. Euclidean distance compares the positions of vectors directly, so shorter distance means greater proximity. Cosine similarity compares their directions, so greater alignment means greater similarity. The choice matters because candidate sentences can be ranked differently depending on whether their vector magnitudes affect the comparison. Each measure supplies a ranking over the training sentences for the current input.

There are also two sources of embeddings. One uses the representation of the special `[CLS]` token from RoBERTa, with the discussion identifying strong settings that use a version fine-tuned on the dataset. The other uses OpenAI’s `text-embedding-ada-002` embedding endpoint. The authors treat the source of the embedding as a hyper-parameter alongside the number of demonstrations. In either case, GPT-3.5 receives the retrieved examples as text. The vector representation serves the selector.

The distinction between embedding and extraction is important in the low-resource experiment. A RoBERTa system trained on very little data may be poor at assigning labels directly, yet its representations can still organize the available sentences well enough to help choose examples. These are separate tests of what the same trained system can contribute. One uses its final predictions as the answer. The other uses an internal representation to decide which annotated sentences GPT-3.5 should see.

#### Perplexity ranks sentences independently of the input

Perplexity is a measure of how surprising a sequence is under a language model. A low score indicates that the sequence looks relatively predictable to the scorer. The authors use RoBERTa to score the training sentences, following a method for scoring with masked language models. Such scoring uses the surrounding text to assess words that are hidden from the scorer. The paper also discusses using pretrained and fine-tuned versions of RoBERTa for this purpose. [Masked Language Model Scoring](https://md.research.elamur.ai/free/en/papers/salazar-2020-masked-language-model-scoring/)

The selector sorts the training sentences by perplexity and takes those with the lowest scores. The test sentence contributes no information to that ranking. A fixed selection size and scorer therefore yield a fixed demonstration set for that dataset. Where KATE tries to match the input with nearby examples, perplexity asks whether a training sentence is predictable under the selected scorer. It can favor sentences that fit familiar patterns even if they are about a different subject from the current input.

This adaptation also changes what a low score is meant to buy. In the earlier prompt-selection work, the score was applied to alternative prompt formulations. The present experiment uses the score to select annotated examples. A predictable sentence can still contain few relevant labels or illustrate a different span boundary from the one needed at test time. The extraction results show how far predictability alone can carry this particular selection rule.

#### BM25 retrieves by words

BM25 treats sentences as bags of words for retrieval. It uses the test sentence as a query and scores each training sentence for relevance. The rank reflects shared terms and the weighting of those terms. The method can distinguish a match on a relatively informative word from a match on a word common throughout the collection. The authors take the highest-scoring training sentences and attach their annotations in the same prompt format used for the other selectors. [Information retrieval](https://md.research.elamur.ai/free/en/topics/information-retrieval/)

The implementation uses `rank-bm25` with its defaults. The term-frequency saturation parameter, `k1`, is 1.5. It controls how the contribution of repeated occurrences levels off. The length-normalization parameter, `b`, is 0.75. It governs the adjustment for the length of a candidate sentence. The constant `ϵ` is 0.25 and is used in handling negative inverse document frequency, the collection-frequency part of the term weighting. These settings are held at their defaults across the experiments.

BM25 and KATE both select examples in response to the current input, but their evidence differs. A training example can rank well under BM25 because it shares distinctive vocabulary, even if its overall subject differs. KATE can bring together sentences whose vector representations are close despite different wording. Both approaches can be applied before the entities in the test input are known. BM25 also avoids fitting a task-specific scorer, which makes its performance particularly relevant in the experiment with a restricted annotation pool.

#### Influence ranks by estimated training utility

Influence functions ask how a training observation affects a prediction made by a fitted system. In this paper, the quantity of interest is the estimated change in the loss on a particular test sentence if a particular training sentence were removed from training. Loss measures how poorly the supervised prediction agrees with the annotated answer. Ranking training sentences by influence gives the experiment a way to select examples according to their estimated contribution to that supervised prediction. The authors use their fine-tuned RoBERTa extractor and follow earlier work on influence functions for sequence tagging.

The ranking is then used outside the system that produced it. A training sentence judged influential for RoBERTa becomes a worked example in GPT-3.5’s prompt. The score therefore indicates estimated usefulness to the supervised extractor. Its usefulness as a demonstration for GPT-3.5 is a separate question answered by the experiment. A ranking could be informative across the two systems even when their errors differ.

The correct annotation of the test sentence is needed to evaluate the loss. In ordinary use that annotation is the answer the extractor is meant to produce, so the authors describe Influence as an oracle. Its role is to test whether a ranking informed by training utility can identify stronger demonstrations than rankings based on surface relevance or embeddings. The oracle label describes its access to the answer during ranking. It does not define the score as the best possible prompt that could be assembled from the training pool.

#### Training the supervised comparison

The supervised baseline is built from RoBERTa-base and trained as a token labeler. It uses BIO labels to distinguish a token at the beginning of an entity, a token inside an entity, and a token outside all entities. The labeler can reconstruct spans from these token predictions and attach an entity category to each span. It is then evaluated against the same kind of reference spans as GPT-3.5, even though the two extraction procedures produce those spans differently. [Tokenization](https://md.research.elamur.ai/free/en/concepts/tokenization/)

The authors fine-tune RoBERTa using the Hugging Face Transformers library. They use a batch size of 32, a maximum length of 128, a learning rate of 1e-5, and 15 epochs of training. The experiments use a single NVIDIA Quadro RTX 5000 GPU. After training the model five times with a distinct random seed for each run, the authors report the resulting mean and standard deviation. That spread captures variation in the supervised training procedure under the chosen setup. [Transformers](https://md.research.elamur.ai/free/en/papers/wolf-2020-transformers-state-art-natural-language/)

The prompting experiments use `gpt-3.5-turbo-0301`. The token limit restricts each prompt to 20 demonstrations, while usage costs restrict evaluation to 100 sentences per test set. For the random baseline, they repeat the experiment five times and report both average performance and standard deviation. The authors make the experimental code publicly available as `ICL_EE`. The code accompanies a design in which the input, task format, and reference annotations are kept comparable while the source and number of demonstrations vary.

### Experiments and results

#### What the datasets ask the extractor to find

ADE consists of medical case reports drawn from MEDLINE. The extraction task uses 2 entity types, Drug and Adverse-Effect. The training partition contains 3,076 sentences and 7,768 entity annotations. The full test partition contains 427 sentences and 1,069 annotations. Recognizing a drug name and locating the full expression for an adverse effect are different demands even when both occur in the same sentence. The paper’s analysis later compares their scores separately.

MeasEval comes from scientific documents across 10 subjects. Its original annotation scheme includes 4 entity types, but the experiment evaluates only Quantity. The authors leave the other types out because they depend on quantity annotations, including cases where one annotation triggers or nests within another. The training partition contains 542 sentences with 882 entities, and the full test partition contains 294 sentences with 499 entities. A single target category still leaves open questions about where a quantity begins and ends and whether nearby wording belongs inside it.

[SciERC](https://md.research.elamur.ai/free/en/papers/luan-2018-multi-task-identification-entities-relations/) comprises 500 artificial intelligence abstracts and extends earlier shared-task datasets on extracting scientific information. The paper evaluates 6 entity types, including Method, Metric, and Task, and shortens OtherScientificTerm to Other. There are 1,861 training sentences and 5,568 training annotations. The full test partition has 551 sentences and 1,681 annotations. The extractor must distinguish several roles that technical phrases can play in an abstract. [ScienceIE](https://md.research.elamur.ai/free/en/papers/augenstein-2017-semeval-2017-task-10-scienceie/)

STEM-ECR also uses abstracts and draws from the same range of scientific subjects as MeasEval. It has 7 entity types in the original resource. Following the dataset’s baseline study, the authors keep 4 types for the experiment. These are Data, Material, Method, and Process. The omitted types are typically nested within the retained ones. STEM-ECR has 942 training sentences with 4,560 annotations. Its full test set has 118 sentences with 559 annotations. The restricted label inventory defines a specific extraction task within a resource designed for additional purposes.

WLPC consists of wet-lab protocols from biology and chemistry. The underlying corpus supplies entity, relation, and event annotations, while this paper studies the entity spans and their types. WLPC has 18 types in the experiment. Its training partition contains 8,581 sentences with 25,229 annotations. The full test partition has 2,861 sentences and 9,707 annotations. These are instructions, so a label such as Action often refers to a verb. This gives the benchmark a different writing style and set of annotation cues from scientific abstracts and case reports.

These datasets vary simultaneously in genre, number of labels, training-set size, and the relationship between training and test vocabulary. A result on one dataset consequently describes a particular combination of conditions. The comparison can show whether a selection method works across multiple forms of scientific writing. It cannot isolate the number of labels from the other features that distinguish those datasets. [Evaluation and benchmarks](https://md.research.elamur.ai/free/en/topics/evaluation-benchmarks/)

#### How scores and uncertainty are reported

The main metric is entity-level macro F1. At the entity level, identifying part of the right phrase or assigning the wrong type to the right span can lose credit for that prediction. Precision concerns how much of the predicted output is correct, and recall concerns how much of the annotated output the system recovers. F1 combines these two quantities. Macro averaging brings the scores for different entity types into the overall measure so that frequent types cannot by themselves account for the entire result. The authors also report type-specific scores to show where the aggregate hides large differences.

The main comparison uses the same sampled set of 100 test sentences per dataset for the extraction conditions reported together. In that comparison, “full training pool” means that the full training partition is available for fine-tuning or for drawing demonstrations. It describes the training side of the experiment. The supervised results for the full test partitions are reported separately. Keeping the two meanings of “full” distinct is essential when interpreting the WLPC comparison, because the sampled and full test results differ appreciably.

For significance, the authors use an approximate randomisation test with 99, 999 iterations and a threshold of 0.05. They compare each selection method with random sampling and with supervised RoBERTa. For those two baselines, the test uses the run with the median entity-level macro F1, while the result tables report their mean scores and standard deviations. A significance mark therefore refers to the indicated comparison against a representative run. Its direction comes from the scores. A method can differ significantly from the supervised baseline while scoring below it.

#### Results with the full training pools

On ADE’s sampled test set, supervised RoBERTa records entity-level macro F1 of 90.42, with standard deviation 0.13. The zero-shot result is 71.29 and random sampling reaches 74.56, with standard deviation 0.33. KATE reaches 83.11, perplexity 79.13, and BM25 77.28. Influence scores 86.35. All of the directed selectors outperform random selection numerically, and the paper marks each of those comparisons as significant. The oracle is closest to supervised RoBERTa, while the embedding-based selector is strongest among the methods that can choose examples without access to the test labels.

On MeasEval’s sampled test set, supervised RoBERTa scores 50.68, with standard deviation 3.93. Zero-shot prompting scores 19.65, and random examples lift the score to 22.49, with standard deviation 1.45. KATE reaches 22.75 and perplexity 21.43. BM25 scores 24.72, the highest practical selection result, and Influence scores 27.13. The significant gains over random sampling are BM25’s and Influence’s. The remaining gap to supervised training shows that retrieval helps with some Quantity predictions while leaving much of the task unresolved.

On SciERC’s sampled test set, supervised RoBERTa scores 68.52, with standard deviation 1.30. The zero-shot result is 17.86, while random selection scores 29.27, with standard deviation 0.73. KATE reaches 29.97, and perplexity reaches 31.31. The main comparison reports BM25 at 35.96 and Influence at 36.47, with both marked significant against random selection. The separate sweep over demonstration counts reports BM25 at 35.99 in one setting and 35.96 in another. The latter is the number used in the main comparison. Under either report, word-based retrieval is close to the oracle on this dataset.

On STEM-ECR’s sampled test set, supervised RoBERTa records 69.70, with standard deviation 3.46. Zero-shot prompting reaches 28.89. Random sampling is lower at 26.85, with standard deviation 1.26. Perplexity scores 26.57, BM25 scores 25.61, and Influence scores 27.81. KATE is the highest-scoring prompted condition at 30.78. The main table thus gives a concrete exception to the authors’ general statement that Influence leads the selection methods across datasets. KATE has the higher reported score here, and Influence’s significant difference from supervised RoBERTa is in the downward direction.

WLPC gives the strongest result for selection. On the sampled test set, KATE, BM25, and Influence all score above the supervised baseline and random sampling, with those differences marked as significant. Perplexity scores below both zero-shot prompting and random sampling. Its significant difference from RoBERTa corresponds to a score above that baseline.

Entity-level macro F1 on the sampled WLPC test set with the full training pool Influence leads, with embedding and word-based retrieval close behind.

**The numbers**

| System or setting | Macro F1 |
| --- | --- |
| Supervised RoBERTa | 28.36 |
| Zero-shot | 31.64 |
| Random sampling | 32.20 |
| Perplexity | 30.46 |
| BM25 | 44.14 |
| KATE | 45.02 |
| Influence (oracle) (this paper) | 45.41 |

The authors report average improvements over random sampling of 7.56% for Influence and 5.26% for KATE across the main experiments. These are the paper’s reported gains, while the individual dataset values are its entity-level macro F1 scores. ADE and WLPC show that the gains can be substantial on particular datasets. MeasEval, SciERC, and STEM-ECR show how even the highest prompted scores in their comparisons can leave a sizeable advantage for supervised RoBERTa.

The full test partitions give another view of the supervised comparison. The paper reports entity-level macro F1 of 89.00 with standard deviation 0.07 on ADE, and 65.62 with standard deviation 5.54 on MeasEval. On SciERC it reports 62.59 with standard deviation 0.11, and on STEM-ECR it reports 66.43 with standard deviation 0.42. On WLPC, the full-test score is 40.51 with standard deviation 0.32. The prompting results in the main comparison are based on the smaller samples, so these full-partition scores establish how supervised performance changes with the evaluation set rather than a new direct ranking against GPT-3.5.

#### Results with a restricted training pool

The authors simulate annotation scarcity by making 1% of the training partition available for both supervised training and demonstration selection. The test comparison continues to use the sampled sentences, with zero-shot still requiring no training examples. The restriction changes the amount of information available to each approach in a different way. Supervised RoBERTa has far fewer labeled positions from which to learn its prediction rule. A selector has fewer candidates, while GPT-3.5 can still interpret the examples through its existing capabilities.

Entity-level macro F1 on the sampled SciERC test set with the reduced training pool Influence leads the reduced-pool comparison, with BM25 close behind.

**The numbers**

| System or setting | Macro F1 |
| --- | --- |
| Supervised RoBERTa | 10.16 |
| Zero-shot | 17.86 |
| Random sampling | 25.31 |
| KATE | 26.78 |
| Perplexity | 26.42 |
| BM25 | 31.33 |
| Influence (oracle) (this paper) | 32.49 |

On ADE with the reduced pool, supervised RoBERTa scores 14.32, with standard deviation 71.09 as reported. Random prompting scores 66.53, with standard deviation 0.19. BM25 reaches 72.66 and Influence reaches 73.68. Those two selectors also exceed the zero-shot score of 71.29. KATE at 69.06 and perplexity at 68.83 improve on reduced-pool random sampling but remain below zero-shot prompting. This comparison shows why both baselines matter. A ranking can improve the examples available in a small pool even when those examples have yet to beat a prompt that omits them.

On MeasEval with the reduced pool, supervised RoBERTa scores 19.20, with standard deviation 12.90, while zero-shot scores 19.65. Random selection reaches 21.32, with standard deviation 0.88. KATE leads at 24.48, followed by Influence at 24.21 and BM25 at 23.39. Perplexity scores 22.23. KATE’s reduced-pool result exceeds its full-pool result for this test sample. The method rankings and individual scores therefore need to be read alongside the general conclusion that restricting the training data tends to degrade performance.

STEM-ECR provides another case where a selected prompt has to clear a competitive zero-shot baseline. With reduced training data, RoBERTa scores 15.42, with standard deviation 5.78, and random demonstrations score 21.38, with standard deviation 1.89. KATE scores 26.49, perplexity 25.84, Influence 25.01, and BM25 24.24. Each of these selectors beats reduced-pool random sampling, while zero-shot remains higher at 28.89. The labeled examples help within the few-shot comparison, but the best reported extraction score for this restricted condition comes from the prompt without demonstrations.

On WLPC with the reduced pool, supervised RoBERTa scores 10.37, with standard deviation 0.50. Random selection scores 28.46, with standard deviation 1.77, below zero-shot’s 31.64. KATE scores 28.97 and perplexity 26.05. BM25 reaches 36.73 and Influence reaches 34.24, both above zero-shot and both marked as significantly better than random selection. BM25 leads the reduced-pool comparison, whereas KATE is the leading practical selector with the full pool. Changing the pool changes which kind of retrieval is most effective.

The most consistent difference in the reduced-pool experiment is the comparatively large loss of performance for supervised RoBERTa. Selection still makes a difference when only a small collection of labeled sentences is available. Its usefulness depends on which examples survive the restriction and on what the system can already infer from the task format. The comparison also explains why a smaller drop from the full training condition and a higher score than zero-shot are separate observations.

### What the ablations show

#### More demonstrations can help or hurt

The demonstration-count sweep changes how many examples the selector can place in the prompt. It tests 1, 3, 5, 10, and 20 demonstrations. For a ranked selector, increasing the count admits examples farther down its ranking along with adding more annotated evidence. A higher count is thus a change to the prompt’s composition as well as its length. The sweep tests whether the extra material helps under each selection rule.

On the sampled ADE test set, KATE climbs from 71.44 with the 1-shot setting to 83.11 with 10-shot and then falls to 77.31 with 20-shot. Influence reaches 86.35 with 5-shot, followed by 83.36 with 10-shot and 78.23 with 20-shot. The same pool therefore supports different preferred counts for different rankings. Adding examples after the strongest setting can lower performance even when the selector had already found examples that worked well.

KATE entity-level macro F1 by demonstration count on the sampled ADE test set The score peaks before the largest demonstration set.

**The numbers**

| System or setting | Macro F1 |
| --- | --- |
| 1-shot | 71.44 |
| 3-shot | 77.76 |
| 5-shot | 81.45 |
| 10-shot (this paper) | 83.11 |
| 20-shot | 77.31 |

Other combinations benefit from carrying more examples into the prompt. On the sampled WLPC test set, BM25 goes from 35.01 with 1-shot to 44.14 with 20-shot. KATE also has its strongest reported WLPC result at 20-shot, with 45.02, although the intermediate scores do not rise steadily. On MeasEval, Influence scores 24.45 at 1-shot, drops to 15.52 at 3-shot, and reaches its highest reported score of 27.13 at 5-shot. The result with more examples therefore depends on exactly which inputs and annotations are added. The experiments demonstrate that the count matters, but they do not separate the influence of example content from that of its position in the longer prompt.

Random sampling provides a corresponding check without a ranking. On the sampled SciERC set, its mean climbs from 21.10 at 1-shot to 29.27 at 20-shot. On ADE, random sampling’s strongest mean is 74.56 at 5-shot. The ADE mean at 20-shot is 72.52, with standard deviation 7.30, whereas the standard deviation at 5-shot is 0.33. In this case, larger randomly assembled prompts also yield more variation across runs. A benchmark that reported a single count would miss both the change in average performance and the change in variability.

#### The representation can matter independently of the extractor

KATE lets the authors compare what happens when the same type of retrieval uses a different representation of the sentences. The strongest KATE configurations for ADE and WLPC use representations from fine-tuned RoBERTa. The strongest configurations for MeasEval and the two abstract datasets use the OpenAI embeddings. These observations concern the best settings found in the paper’s comparisons. The authors suggest that some of the training sets may be too small to give the task-tuned representations a reliable advantage.

The perplexity experiments likewise compare scores obtained with pretrained and fine-tuned RoBERTa. The authors report better selection with the fine-tuned scorer. That finding indicates that adaptation to a dataset can make predictability more useful as a ranking signal. It also changes the data requirements of the method. A prompt using only a few examples can still depend on annotated data used earlier to fit the scorer that decided which examples to include.

The restricted-pool experiment distinguishes using a trained system for its internal representations from using it to extract the entities directly. The authors observe that RoBERTa fine-tuned on 1% of the training set can be used for KATE selection even when its direct supervised predictions are poor. They propose that embeddings can retain useful information about the input text while the classifier responsible for label predictions is undertrained. They also suggest that high training variance with very little data can weaken the loss signal on which Influence depends. The experiment compares outcomes under scarcity, so that explanation remains an account of the pattern rather than a separate test of the mechanism.

#### Resampling the test sentences changes the comparison

The authors repeat the evaluation on 3 randomly sampled test sets for ADE and WLPC. These are the datasets on which in-context extraction comes closest to or exceeds supervised RoBERTa in the main results. Holding the dataset and methods fixed while changing the evaluated sentences tests whether the findings depend on a particular sample. The samples themselves vary in how many entities they contain and in the reported length statistics.

For ADE, the main ordering remains broadly similar. Supervised RoBERTa scores 90.42 on Set 1, 92.15 on Set 2, and 88.68 on Set 3. Influence scores 86.35, 85.43, and 84.21 on those sets. KATE scores 83.11, 84.47, and 82.65. The supervised system leads on each sample, while both directed selectors remain substantially ahead of the zero-shot prompt. The improvement associated with choosing examples therefore appears across more than the original draw of test sentences.

WLPC gives a more sensitive baseline comparison. Supervised RoBERTa scores 28.36 on Set 1 with standard deviation 11.25, then 35.93 on Set 2 with standard deviation 4.18 and 26.42 on Set 3 with standard deviation 1.79. KATE leads the selection methods on Set 2 at 46.86. BM25 has the highest score on Set 3 at 43.20, alongside Influence at 43.18. On Set 3 KATE scores 42.47. KATE, BM25, and Influence remain competitive across the draws, while their places in the ranking change.

Perplexity is more sensitive to the WLPC sample composition in this comparison. It scores 30.46 on Set 1, 34.96 on Set 2, and 38.38 on Set 3. That variation can occur even though perplexity chooses the same demonstrations for every sentence under a fixed setup. The examples stay constant, while their suitability changes across the sentences being evaluated. The repeated samples also put the high supervised standard deviation for Set 1 in context. A finding about this particular evaluation draw deserves a different level of confidence from one observed across the sampled sets.

#### Dataset diagnostics suggest different sources of difficulty

The paper describes each dataset using Entity Ambiguity Degree and Text Complexity. Entity Ambiguity Degree summarizes how ambiguous the entity information is under the benchmark’s annotations. The authors use Text Complexity as a separate measure of difficulty in the input. SciERC and STEM-ECR have the highest reported Entity Ambiguity Degree values, 2.26 and 2.07. Their Text Complexity values are also the highest, at 41.09 for SciERC and 61.06 for STEM-ECR. Both datasets leave relatively large gaps between supervised scores and the prompted extraction results.

For training-to-test similarity, the paper uses Target Vocabulary Covered. MeasEval has the lowest value, 53.68, whereas ADE’s is 81.51. The authors interpret the MeasEval value as evidence that its test vocabulary has less coverage in its training set than the other benchmarks have. This provides one explanation for why access to just a few training sentences may be of limited help even when there is only one target category. Examples can convey the labeling rule and still fail to show how that rule applies to unfamiliar forms in the test data.

The diagnostics support different interpretations for different tasks. High ambiguity offers a reason to investigate category confusions in the abstract datasets. Low vocabulary coverage offers a reason to examine generalization in MeasEval. Because the authors measure these properties on datasets that also differ in genre, label inventories, and annotation density, the diagnostics cannot assign a causal share of the performance gap to any one property.

#### Span errors and label errors tell different stories

The authors inspect GPT-3.5’s predictions using Influence-selected demonstrations and present examples alongside the gold annotations. The comparisons show errors in the selected span, the assigned type, or both. A span can be meaningful in its sentence and still be absent from the benchmark’s reference annotations. Likewise, the exact words can be located correctly while the type is wrong. The paper uses the type-specific results to place these examples in the context of overall performance.

In ADE, Drug scores higher than Adverse-Effect across the reported systems. With Influence, the type-level entity F1 scores are 88.54 for Drug and 84.16 for Adverse-Effect. The authors point to shorter spans and a smaller vocabulary for Drug. The reported average length is 10.27 for Drug and 18.85 for Adverse-Effect. The vocabulary counts are 1,290 for Drug and 2,786 for Adverse-Effect. Adverse-Effect occurs more often in the training set and in the examples drawn by the selectors, which makes frequency alone an incomplete explanation for the difference. The inspection also finds labels outside ADE’s inventory, including Disease and Route. These predictions reveal a failure to follow the task’s label set even when the terms are meaningful in a medical report.

In MeasEval, nearby information can be marked as Quantity even when it belongs to a category excluded from this experiment. The authors describe qualifiers being treated as quantities, and they also find instances where the predicted span extends past the answer. One example pairs a gold span of `11%` with a prediction that also takes in the axis notation. These errors illustrate why recognizing that a sentence contains a measurement provides only part of the answer. The category boundary determines which nearby wording can be selected. The span boundary determines which characters belong to the measurement itself.

In SciERC, the authors report that GPT-3.5 struggles with less frequent types such as Generic, Material, Metric, and Task. A phrase that has been located correctly is sometimes assigned the prevalent Other category. In the per-type comparison for Influence, Method has F1 of 63.08 and Metric has F1 of 17.37. The inspection also finds a tendency to extract phrases that the references leave unmarked. The authors observe that Influence can retrieve examples with more annotations than are typical for the dataset, and they suggest that this may encourage more extraction from the test sentence.

In STEM-ECR, the authors see cases where the correct words are found but the predicted type differs from the reference. Their inspection includes a phrase annotated as Process that is instead labeled Method. The paper links recurring errors towards Material and Process to their frequency in the dataset and in the retrieved demonstrations. Under Influence, the per-type scores are 37.12 for Material and 31.11 for Process. The analysis suggests that examples can convey a useful idea of which phrases to select while giving uneven evidence about the distinctions among labels.

In WLPC, the written instructions are dense with annotated entities, and several common labels account for many of the examples retrieved by Influence. An explicit action verb can be easier to recognize than a less common category with a more specialized boundary. Under KATE, the reported type-level F1 is 72.67 for Action and 92.10 for Temperature, while Generic-Measure and Measure-Type each score 0.00. This spread helps explain why a relatively high aggregate score can coexist with unreliable extraction for individual types. The authors suggest that some of WLPC’s prompting advantage could involve choosing demonstrations from the relevant minority classes. Their inspection also shows frequent labels dominating some selected examples. The analyses identify plausible contributors to the aggregate result without isolating the effect of minority-class coverage.

### Limitations

#### Boundaries the authors identify

The authors restrict the GPT-3.5 evaluation to samples of the test partitions because of cost. The additional draws for ADE and WLPC help establish how some results vary with the evaluation sample. They leave the other datasets with less evidence about that variation. The token budget also limits the number of demonstrations. The experiment shows how selection behaves within the evaluated prompt sizes, for the particular GPT-3.5 version used. The authors propose comparing other pretrained systems, including systems whose training may align more closely with scientific writing.

Several of the stronger selection settings rely on fine-tuning RoBERTa. Influence uses the supervised extractor to calculate the test loss, and some of the strongest KATE and perplexity settings use adapted representations or scores. This matters when the purpose of prompting is to work with minimal annotation. The KATE variant using OpenAI embeddings offers a way to generate vectors without first training a task-specific extractor, with an additional usage cost. BM25 uses the training sentences as a searchable collection and leaves the relevance parameters at their defaults.

The authors also identify the instruction as a factor they leave untested. They use a common task format in the extraction experiments, so the results are conditional on that format. They leave demonstration order for future work. Earlier research indicates that order can affect few-shot performance, and a selector determines which examples are available to be ordered. A ranking that supplies the highest-scoring demonstration set in these experiments might behave differently under a different arrangement.

The number of examples is a hyper-parameter that varies by dataset and selector. To choose among the settings they evaluated, the authors rely directly on the test set and skip validation-set selection. The reported best scores consequently describe settings selected with knowledge of their test performance. A reader can use the sweep to understand sensitivity, while an estimate of how well a chosen configuration would generalize would require evaluating it on data that did not guide the choice.

The authors did not apply contextual calibration. They cite prior research showing that calibration can improve few-shot performance on other tasks and leave its application to this extraction setup open. The study therefore estimates the effects of the tested selectors within the chosen prompt and inference procedure. It supplies no estimate of how those effects would interact with a calibration step. [Calibrate Before Use](https://md.research.elamur.ai/free/en/papers/zhao-2021-calibrate-before-use-improving-few/)

#### Boundaries that follow from the design

Influence benefits from access to the answer key during selection. Its score helps quantify what a loss-informed demonstration ranking can achieve in the comparison, but it cannot establish that the same gain is available at inference time. Its use of supervised loss also means that it estimates usefulness for a particular RoBERTa extractor. GPT-3.5 may benefit from demonstrations that Influence ranks lower, as the stronger practical results in some settings suggest. The oracle is an informative benchmark for this ranking procedure, with no guarantee that it exhausts the potential of selection.

The low-resource experiment simulates scarcity by drawing on 1% of datasets that already have established label schemes and annotations. A genuinely new subdomain may require defining its labels at the same time as collecting examples. Its first labeled sentences may be gathered under a different process from the one that produced the benchmark’s training partition. The results demonstrate resilience when the annotation pool in an existing benchmark is restricted. They do not establish performance under changes to the annotation guidelines or under a transfer to a new source of scientific text.

The dataset comparisons also leave the role of label count unresolved. WLPC has 18 entity types, more than any other dataset in the study, and some retrieval methods produce especially strong gains there. It is also written as instructions and contains many densely annotated sentences. Several of its frequent entities have cues that differ from those in abstracts or case reports. Because the authors do not vary only the number of types within a common dataset, the results cannot establish that adding categories itself makes selection more valuable. The finding is a pattern across benchmarks whose tasks differ in several respects.

Reported significance concerns differences against the specified baselines on the evaluated sentences. It does not remove the effects of choosing a demonstration count on the test set or establish the ranking for a fresh sample. The full-test and sampled WLPC scores for RoBERTa make that distinction concrete. The repeated samples make the prompting advantage more informative for WLPC, while the particular size of the advantage still depends on the sample and the selected configuration.

Finally, the outcome is an extraction score. The paper motivates scientific extraction by pointing to uses such as organizing and searching literature, but the experiments do not measure effects on those downstream tasks. An improvement in macro F1 demonstrates better agreement with a benchmark’s entity annotations. Whether the remaining errors matter for an application depends on which entities that application needs and what it does with them. The per-type results help identify such differences without measuring their downstream consequences.

### What came after

[*Large Language Models for Generative Information Extraction*](https://md.research.elamur.ai/free/en/papers/xu-2023-large-language-models-generative-information/) (2023) cites this study in a survey of generative information extraction. That broader subject encompasses the design choice examined here. Even with the extraction system fixed, researchers must decide what annotated material to supply and how to choose it. Bölücü and colleagues provide comparisons for that decision on scientific entity extraction, including a case where a label-informed oracle and a practical retrieval rule achieve similar results. The citation gives the study a place in the subsequent survey literature. It does not by itself establish that the survey reproduced the experiments or adopted a particular selector.

[*In-Context Learning with Long-Context Models*](https://md.research.elamur.ai/free/en/papers/bertsch-2025-context-learning-long-context-models/) (2025) cites the study from the perspective of longer input contexts. The connection is the relationship between the number of examples and their selection. The scientific extraction experiments had a ceiling of 20 demonstrations and showed that the largest tested count could help one dataset and hurt another. A longer input context makes room for a different range of demonstration counts. That broadens the question raised by the earlier work about which examples earn a place in the prompt. The citation establishes that connection in topic, while the long-context study’s particular treatment of the scientific benchmarks or selection rules is unspecified.

The later works thus place the paper alongside research on two dimensions of prompting. The extraction survey concerns the task for which demonstrations are supplied. The long-context study concerns how much material the system can receive. The paper’s own comparison falls where those dimensions meet. Under a fixed scientific labeling scheme and a limited prompt budget, the quality of a demonstration set depends on the information its examples convey about the sentence being analyzed.

## Cite

Cite as Necva Bölücü, Maciej Rybinski and Stephen Wan. 2023. impact of sample selection on in-context learning for entity extraction from scientific writing. Findings of the Association for Computational Linguistics: EMNLP 2023.

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.18653/v1/2023.findings-emnlp.338](https://doi.org/10.18653/v1/2023.findings-emnlp.338)

```bibtex
@inproceedings{bolucu2023impact,
  title = {{impact of sample selection on in-context learning for entity extraction from scientific writing}},
  author = {Necva Bölücü, Maciej Rybinski and Stephen Wan},
  booktitle = {Findings of the Association for Computational Linguistics: EMNLP 2023},
  year = {2023},
  doi = {10.18653/v1/2023.findings-emnlp.338},
  url = {https://doi.org/10.18653/v1/2023.findings-emnlp.338}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
