13 min read · May 28, 2024
When we ask a language model a question, we often assume that the answer comes directly from the knowledge inside the model. We stay in a simple frame: if the model knows it, it answers; if it does not, it makes a mistake. But in practice, things do not work that cleanly. Because what shapes the answer the model produces is not only the training process, but also the context it can read and take as input at that moment. The same model, the same task, and even the same question can produce a completely different output under a different context. [1][2][3]
That is why, when we look at language models, it is often not enough to ask only “what does the model know?” There is another question that matters just as much: how did we explain this task to the model? The way we frame the question, the format we use, whether we show examples beforehand, and if we do, which examples we choose, all directly affect the result. That is exactly what we focused on in this research. In other words, how the knowledge inside the model and the context given to it at that moment work together.
At the simplest level, language models read the text in front of them and generate a continuation that fits. But what we mean by “fits” is not limited to predicting the next word. The model reads the tone, the task definition, the format, and, if there are any, the examples we provide together. The answer that comes out is not only a reflection of the knowledge inside the model; it is also a result of the frame we build around it. [1][2]
That is why the same model sometimes gives a very strong answer and sometimes gives a more scattered or weaker one. Because the model reads not only what is being asked, but also how it is being asked. This is exactly where context becomes important. That was also the focus of this research: how do the examples we give right before answer generation, in other words question-answer pairs, affect model behavior? More specifically: how much do the selection, order, and correctness of those examples change the result? [1][2][3]
The short answer: it does.
Of course, the model’s capacity, the data it was trained on, and its architecture matter. But in real use, what determines the result does not stop there. The context we provide becomes just as decisive. The same question can be interpreted differently by the model under a different context, and that naturally produces different outputs. [1][2][3]
That was the critical point for us. Because the effect does not stay only at the level of “did we give examples or not?” The examples we give, their order, and how correct they are all change the result. As we moved forward, what we saw was that context was far more decisive than we first assumed. [2][3]
One of the most basic distinctions when working with language models is the difference between zero-shot and few-shot. From the outside, the two can look the same: you give the model a task and expect an answer. But that difference changes quite seriously how the model reads the task. [1][2][3]
In the zero-shot case, we give the task directly to the model. That means there is only the question or request itself; there is no extra question-answer pair beforehand that the model can look at as an example. The model produces an answer based on the knowledge it carries from training and on how it interprets the question at that moment. [1][7]
In few-shot, the flow changes a little. This time, we do not leave the model alone with the question; we first show it a few examples. So in practice, we are not only saying “solve this,” but also, “look, this is how this task is solved here.” [1][2][3]
At first glance, that difference may look small. After all, the same model still runs, and the same task is still asked. But in practice, that small difference changes the model’s answer in a serious way. Because in a few-shot setup, the model does not only read the question; it also starts reading the format, logic, and relational structure of the examples we give before it. This means that part of the task definition comes not directly from the instruction, but from the examples themselves. [1][2][3]
At that point, the issue for us was no longer just using few-shot. What we were really curious about was how much, and in which ways, the examples we gave as few-shot changed model behavior. If giving the model a few examples really made a difference, where did that difference come from? From the examples themselves, their order, or how correct and how relevant they were?
So what we were chasing was not simply the question “is few-shot good?” More than that, we were trying to understand how the choices inside few-shot shape model output.
We built the experimental setup around two languages and two main models. On the English side, we used Llama2-7B-HF from the Llama family; on the Turkish side, we used mGPT because of its multilingual structure. On the evaluation side, we selected multiple-choice benchmark datasets so we could observe the model across different tasks. On the main axis were HellaSwag, ARC, and MMLU; in the first trials we also used TruthfulQA. That allowed us to observe different behaviors such as commonsense inference, reasoning, and multi-domain knowledge use within the same frame. [4][5][6][7][8][9][10]
Since the Turkish side did not come directly as a ready benchmark, we also built a dataset preparation process. We examined the benchmark content, then translated those datasets for Turkish testing. In the first stage, we used Cloud Translation API, but we did not leave the translations as they were. We manually corrected the parts where meaning had shifted or the phrasing had weakened. In the end, we created Turkish datasets of 250 examples each in a form that could run on mGPT. So the Turkish side of the experiment was shaped not only by model selection, but also by rebuilding and cleaning the dataset. [10]
In the first step, we ran these datasets in zero-shot form. The goal there was to see how the model behaved without giving it any examples at all. Because in order to understand the difference that emerged on the few-shot side, we first had to see the example-free baseline. On the Turkish datasets, we got the first baseline results with mGPT and gpt2-turkish-cased; on the English datasets, with mGPT and Llama-2-7b. That stage became the reference point for all later few-shot experiments. [4][9][10]
After that, we tested the same tasks again, this time in a few-shot structure. In other words, before the actual question reached the model, we gave it a certain number of question-answer examples and expected it to answer the new question by reading it through that context. But we did not leave few-shot as a single fixed setup. The core of the experiment relied on changing that example structure in a controlled way. [4]
Once we moved to the few-shot side, the first thing we saw was this: what is happening there is not just adding a few examples to the model. From the outside, it looks like you are putting a few question-answer pairs at the beginning of the prompt. But on the model side, the effect is much more sensitive. Because those examples do not only provide extra information; they also shape how the task will be read, what kind of relation will be built, and under which frame the new question will be interpreted. [2][3]
That is why even small changes inside few-shot can change the result. In other words, even when the same model, the same task, and the same test setup are kept fixed, changing only the examples themselves, their order, or their correctness changes the behavior that comes out. That showed us something important: few-shot is not a single, fixed technique. Every choice inside it reshapes the context the model builds. [2][3]
The first thing we looked at was the most basic one: what happens when we change the few-shot examples we give the model?
To see that, we kept the number of examples fixed but changed the examples themselves. So the model was still seeing the same kind of few-shot context, but the question-answer pairs in front of it were different this time. The expectation here was this: if few-shot really meant only “seeing a few examples beforehand,” then which examples those were should not have made too much of a difference. But what we saw was the exact opposite.
When the examples changed, the results changed too. In other words, few-shot context was not working for the model like empty boxes that could be filled at random. The content of the examples we gave really mattered. Some sets of examples helped the model read the task better, while others did not create the same effect. The first thing that became clear for us was this: if few-shot has an effect, a significant part of that effect comes directly from example selection itself. [2][3]
From there, we moved to a more interesting question: what happens if we do not change the examples themselves at all, and only change their order?
At first glance, you might expect that not to make much of a difference. After all, if the content is the same, the arrangement might seem like a small detail. But once again, on the model side, the situation turned out not to be that simple. When the same examples were given in a different order, the results changed again.
This finding mattered because it showed that the model reads few-shot context not only as a pool of examples, but also as a flow. In other words, it was not only asking “which examples did I see?” but also “in what order did these examples arrive?” When the order changes, the emphasis of the context changes, the pattern the model pays attention to changes, and that is reflected differently in the output. [2]
In the third stage, we made a stronger intervention. This time, we corrupted the answer side of the few-shot examples. In other words, in the question-answer pairs shown to the model, the answers were not the correct ones they were supposed to be.
The expectation here was straightforward: if we give wrong examples, performance should directly drop. Intuitively, those examples should pull the model in the wrong direction. But the picture that came out here was more interesting. Yes, wrong examples were not risk-free. But the effect was not always one-directional or entirely predictable either. [2]
In some cases, examples with wrong answers did not create as clear a negative effect as we expected. In fact, under certain conditions, they seemed to behave differently. That suggested to us that the model was not mechanically copying the few-shot context, but was sometimes interpreting the structure inside the example in another way. In other words, context mattered for the model, but the effect of that context was not always linear. [2]
Once these three observations came together, the picture became much clearer. The examples themselves mattered. Their order mattered. Their correctness mattered too. In other words, the real power of what we call few-shot lay not in giving a few examples, but in the kind of context we built with them. [2][3]
What became clear for us here was this: the result in language models cannot be explained only by the model’s capacity. The same model, the same task, and the same question can still behave differently under different contexts. And that is exactly where the difference between zero-shot and few-shot grows. Because the moment we give examples to the model, we are not only adding information; we are also shaping how the task will be read. [1][2][3]
That naturally took us to the next question:
if not every few-shot example has the same value, then is it possible to choose these examples more deliberately?
In the next piece, we look at which few-shot examples work better and how more deliberate example selection changes the result. To continue reading: https://ottomind.ai/blogs/how-to-choose-the-right-examples-in-few-shot
[1] T. Brown, B. Mann, N. Ryder, M. Subbiah, J. Kaplan, P. Dhariwal, A. Neelakantan, P. Shyam, G. Sastry, A. Askell, S. Agarwal, A. Herbert-Voss, G. Krueger, T. Henighan, R. Child, A. Ramesh, D. M. Ziegler, J. Wu, C. Winter, C. Hesse, M. Chen, E. Sigler, M. Litwin, S. Gray, B. Chess, J. Clark, C. Berner, S. McCandlish, A. Radford, I. Sutskever, and D. Amodei, Language Models are Few-Shot Learners, in Advances in Neural Information Processing Systems 33 (NeurIPS 2020), 2020, pp. 1877–1901.
https://arxiv.org/abs/2005.14165
[2] S. Min, X. Lyu, A. Holtzman, M. Artetxe, M. Lewis, H. Hajishirzi, and L. Zettlemoyer, Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?, in Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing (EMNLP 2022), 2022.
https://aclanthology.org/2022.emnlp-main.759/
[3] T. Gao, A. Fisch, and D. Chen, Making Pre-trained Language Models Better Few-shot Learners, in Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (ACL-IJCNLP 2021), 2021, pp. 3816–3830.
https://aclanthology.org/2021.acl-long.295/
[4] L. Gao, J. Tow, S. Biderman, S. Black, A. DiPofi, C. Foster, C. O’Brien, B. Schoelkopf, E. Skowron, and T. Sutawika, A framework for few-shot language model evaluation, version v0.0.1, Zenodo, 2021.
https://zenodo.org/records/5371629
[5] P. Clark, I. Cowhey, O. Etzioni, T. Khot, A. Sabharwal, C. Schoenick, and O. Tafjord, Think you have Solved Question Answering? Try ARC, the AI2 Reasoning Challenge, 2018. arXiv:1803.05457 [cs.AI].
https://arxiv.org/abs/1803.05457
[6] R. Zellers, A. Holtzman, H. Bisk, A. Farhadi, and Y. Choi, HellaSwag: Can a Machine Really Finish Your Sentence?, in Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics (ACL 2019), 2019, pp. 4791–4800.
https://arxiv.org/abs/1905.07830
[7] D. Hendrycks, C. Burns, S. Basart, A. Zou, M. Mazeika, D. Song, and J. Steinhardt, Measuring Massive Multitask Language Understanding, 2020. arXiv:2009.03300 [cs.CY].
https://arxiv.org/abs/2009.03300
[8] S. Lin, J. Hilton, and O. Evans, TruthfulQA: Measuring How Models Mimic Human Falsehoods, in Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (ACL 2022), 2022, pp. 3214–3252.
https://arxiv.org/abs/2109.07958
[9] H. Touvron, T. Lavril, G. Izacard, X. Martinet, M.-A. Lachaux, T. Lacroix, B. Rozière, N. Goyal, E. Hambro, F. Azhar, A. Rodriguez, A. Joulin, E. Grave, and G. Lample, LLaMA: Open and Efficient Foundation Language Models, 2023. arXiv:2302.13971 [cs.CL].
https://arxiv.org/abs/2302.13971
[10] O. Shliazhko, A. Fenogenova, M. Tikhonova, A. Kozlova, V. Mikhailov, and T. Shavrina, mGPT: Few-Shot Learners Go Multilingual, Transactions of the Association for Computational Linguistics, vol. 12, pp. 58–79, 2024.
https://aclanthology.org/2024.tacl-1.4/