Language Models can Exploit Cross-Task In-context Learning for Data-Scarce Novel Tasks (2024)

Abstract: Large Language Models (LLMs) have transformed NLP with their remarkable In-context Learning (ICL) capabilities. Automated assistants based on LLMs are gaining popularity; however, adapting them to novel tasks is still challenging. While colossal models excel in zero-shot performance, their computational demands limit widespread use, and smaller language models struggle without context. This paper investigates whether LLMs can generalize from labeled examples of predefined tasks to novel tasks. Drawing inspiration from biological neurons and the mechanistic interpretation of the Transformer architecture, we explore the potential for information sharing across tasks. We design a cross-task prompting setup with three LLMs and show that LLMs achieve significant performance improvements despite no examples from the target task in the context. Cross-task prompting leads to a remarkable performance boost of 107% for LLaMA-2 7B, 18.6% for LLaMA-2 13B, and 3.2% for GPT 3.5 on average over zeroshot prompting, and performs comparable to standard in-context learning. The effectiveness of generating pseudo-labels for in-task examples is demonstrated, and our analyses reveal a strong correlation between the effect of crosstask examples and model activation similarities in source and target input tokens. This paper offers a first-of-its-kind exploration of LLMs’ ability to solve novel tasks based on contextual signals from different task examples.

text: Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 11568–11587 August 11-16, 2024 ©2024 Association for Computational Linguistics
1 Introduction
Large Language Models (LLMs) have revolutionized the state of Natural Language Processing for the past few years. With the ability of In-Context Learning (ICL), one can adopt an LLM to almost any task without costly gradient updates (Brown et al., 2020). At the same time, automated assistants, built on top of foundational LLMs, are
*Equal contribution named in alphabetical order
being popularized (Pahune and Chandrasekharan, 2023). A crucial challenge with this escalating usage popularity is handling novel tasks. Humongous models like GPT-4 are able to deliver up-to-par performance even in a zero-shot regime (OpenAI, 2023). However, the computational requirements of deploying such large-scale models counteract the practicality of their usage en masse. Relatively smaller LMs, on the other hand, suffer drastically in the absence of in-context examples. The availability of labeled examples usually varies across the use cases of the language model. For example, in an NLP research setup, expert users can quickly come up with a few handwritten examples. However, when we consider mass-scale usage of average users who are not experienced prompt engineers or need quick answers, the zero-shot performance of a model becomes extremely crucial. For example, assuming the popular usage of ChatGPT, very few non-expert users would opt to write down examples while asking ChatGPT to perform some tasks.
This naturally raises the question of whether one can make an LLM generalize from labeled examples of a predefined set of tasks to an input defining a novel task. In the world of biological neurons, such abilities are commonplace: inculcating specific limb usage into an untrained limb while training the opposite limb (Ruddy and Carson, 2013), or relatively easier adoption of newer skills from the culminated experience of older skills (Qin et al., 2013; Márton et al., 2021). Drawing a blunt parallel between biological neurons and LLMs would be naive. However, one can find a supporting intuition in the mechanistic interpretation of the Transformer architecture (Elhage et al., 2021; Conmy et al., 2023; Wang et al., 2022a). One can argue that if information pathways necessary to solve a novel task are similar to those corresponding to some different task from a task library, an LLM may gather useful information across tasks. Earlier
11568
evidence found by Tanwar et al. (2023) also elicits intuitive motivation as they showed that LLMs can learn to infer from cross-lingual examples if proper alignment is provided.
In this work1, we design a cross-task prompting setup (Section 2) using three different LLMs: LLaMA-2 7B and 13B, and GPT 3.5; we select 50 different pairs of tasks where one serves as a source (i.e., context example task) and the other as target. Despite no examples from the target task presented in the context, LLMs can produce a staggering improvement over the zero-shot regime; on average, cross-task prompting improves performance by 107% for LLaMA-2 7B, 18.6% for LLaMA2 13B and 3.2% for GPT 3.5 (Section 3). With multiple source tasks, cross-task performance is even better than, if not comparable, usual in-task prompting (Contribution #1). However, learning from examples of different tasks is heavily sensitive to the choice of source task for a given target and the LLM is prone to copy the label space of the source task into the target. To circumvent this, we propose a pseudo-labeling based approach: in a data-scarce setup, cross-task prompting with majority voting is first employed to generate noisy, in-task examples; these are subsequently used for standard few-shot prompting (Contribution #2). Finally, we provide introductory analysis towards interpreting cross-task signal transfer by dissecting the model activations. We find that the cross-task signal transfer is abrupt and happens at later layers, with the effective layers widely varying for different target tasks (Contribution #3). In a nutshell, this is the first exploration of LLMs’ ability to learn to solve novel tasks based on the contextual signals of different task examples.
2 Prompting techniques
Task definition for a given task is a natural language instruction for the LM describing what is asked of it (see Figure 1). Since a cross-task setup would result in in-context examples from different tasks (with different label spaces), such a definition is necessary to discriminate.
Next, given two datasets Ds and Dt corresponding to two different tasks with task definitions ds and dt, respectively, we formalize the cross-task prompting as inferring the output ŷt for an input xt ∈ Dt conditioned upon a demonstration from
1Code available at https://github.com/C-anwoy/CrossTask-ICL
dataset Ds:
ŷt = argmax y
p(y|(ds ⊕ xs ⊕ ys ⊕ dt ⊕ xt))
In this setup, we denote Ds and Dt as source and target task datasets, respectively. Note that the formalization is equivalent to 1-shot prompting where the only provided example input-output pair comes from a different dataset. Table 14 of Appendix F presents illustrative examples of prompts in this setup. Our experiments suggest that >1-shot setup in cross-task prompting does not improve (and often deteriorates) performance.
Liu et al. (2022) showed that for a target input xt, generating context C from semantically similar examples leads to not only better results but also a more robust method of prompting. Similarly, Tanwar et al. (2023) showed that ICL could be done in a cross-lingual setup by aligning the semantic and task signals of the source and target languages.
Drawing inspiration from these works, we set up the cross-task prompting regime with sampling examples xs from the source task dataset Ds that are semantically similar to the target input xt. To extract semantically similar examples, we first utilize Sentence-BERT (Reimers and Gurevych, 2019) to extract the sentence embedding of target and source inputs 2. Following this, based on the cosine similarity between the embeddings, we select top source examples.
In-task examples combined with cross-task prompting. So far, we have assumed the unavailability of any labeled target dataset. But, if we do have a labeled target example, could prepending a source task boost its prompting performance?
To emulate such a scenario, a labeled example from the target dataset Tt is sampled. This labeled example (xlt, ylt), where xlt ∈ Tt, is then used to construct prompt. This mixed setup can be formalized as,
ŷt = argmax y
p(y|(ds⊕xs⊕ys⊕dt⊕xlt⊕ylt⊕xt))
Examples of prompts are provided in Table 15 of Appendix F.
3 Results and Analysis
Datasets and experimental setup. Our corpus of tasks consists of ten source and five target tasks.
2We also experimented with E5 and LLaMA-2 7B last layer outputs, see Appendix B.
We consider ARC-Easy (Clark et al., 2018), AGnews (Zhang et al., 2015), BoolQ (Clark et al., 2019), Commonsense-QA (Talmor et al., 2019), Conll2003-POS (Tjong Kim Sang and De Meulder, 2003), Conll2003-NER (Tjong Kim Sang and De Meulder, 2003), MNLI (Williams et al., 2018), QQP (Sharma et al., 2019), RACE (Lai et al., 2017) and SST2 (Socher et al., 2013) to be our source tasks. Our motivation remains to incorporate domain diversity and difficulty of the problems while choosing target tasks to emulate the “novel task” phenomenon as closely as possible
since learning from cross-task examples makes sense only when the target task is truly data-scarce. Our target tasks are Social-i-QA (Sap et al., 2019), SciQ (Auer et al., 2023), MedMCQA (Pal et al., 2022), Financial-Phrasebank (Malo et al., 2014), and ARC-Challenge (Clark et al., 2018); first four of these require domain expertise, while the last one is a more challenging version of the one present in the source tasks. In total, this gives us 50 unique cross-task setups (see Appendix A for dataset details. Table 16 and Table 17 of Appendix F show task definitions corresponding to source and target
tasks, respectively). The dataset size is standardised by sampling 10, 000 and 500 examples for each source and target task, i.e., |Ds| = 10, 000 and |Dt| = 500. For our experiments, we used the 7-billion and 13-billion variants of LLaMA-2 (Touvron et al., 2023), and text-davinci-003 (Brown et al., 2020) referred to as GPT3.5. We experiment with greedy and force decoding setup and selected greedy decoding as our standard for all experiments (see Appendix D for more details). We set the number of examples used to create cross-task context as one for all our experiments, unless mentioned explicitly.
Does cross-task prompting work? As evident from Table 1, cross-task prompting significantly improves performance compared to zero-shot prompting (see Table 20 in Appendix for results of significance testing). The best overall source-target pair improves performance by 162% for LLaMA-2 7B, 30% for LLaMA-2 13B and 7% for GPT3.5. We note that different models give the best performance in different source-target pairs and not all coupling of source-target tasks seem to work; e.g., Commonsense-QA as a source task decreases performance on Financial-Phrasebank, but is the best source task for ARC-Challenge and MedMCQA (for LLaMA-2 7B). Token classification tasks (POS and NER) seem to depreciate performance for LLaMA-2 13B and GPT3.5; their performance for LLaMA-2 7B is also sub-par compared to other source-target pairings. RACE and ARC-Easy are robust source tasks that improve performance for all target tasks in all models. ARC-Easy, MNLI and BoolQ can also be considered to have this robustness to some degree, as they only hurt the performance in one or two cases.
On average, cross-task prompting improves performance by 107% for LLaMA-2 7B, 18.6% for LLaMA-2 13B and 3.2% for GPT3.5. This is a strong argument for prompting in a cross-task manner when we lack labeled target data, especially using small models, which have poor zero-shot abilities (Wei et al., 2022). We also experiment with LLaMA-2 7B Chat model to analyse the performance of cross-task prompting for instructiontuned models (see Appendix C).
Performance with dissimilar source tasks. Few of the chosen source tasks have slight overlap in their broad topic or format with some of the target tasks, for example, source datasets like ARCEasy, Commonsense-QA, RACE consists of ques-
tions in multiple-choice format, similar to target datasets like ARC-Challenge, Social-i-QA, SciQ and MedMCQA. To analyse the efficacy of crosstask prompting with completely dissimilar source tasks, let us consider only the source tasks whose topic and format are absolutely disjoint from all target tasks. The following five source tasks can be considered dissimilar to the target tasks – BoolQ, Conll2003-POS, Conll2003-NER, MNLI and QQP. As reported in Table 1, even with these dissimilar source tasks, we observe a substantial performance improvement of 80.5% for LLaMA-2 7B, 11.4% for LLaMA-2 13B, and 0.5% for GPT3.5 on average over zero-shot prompting. Moreover, if we consider only BoolQ, MNLI and QQP, the average performance gains become 105.9% for LLaMA-2 7B, 22.8% for LLaMA-2 13B, and 4% for GPT3.5. This shows that cross-task prompting can especially enable the relatively smaller LMs to substantially boost their zero-shot performance even using tasks dissimilar to the target.
Importance of source task definitions. To further investigate the role of task definitions in crosstask prompting, we check the effect of removing source task definitions on performance. We note an average drop of 11% for LLaMA-2 7B and 8% for LLaMA-2 13B when we prompt without using source task definitions (see Table 13 in Appendix). Hence, definitions play a crucial role in cross-task prompting.
Increasing number of examples for cross-task prompting. Unlike in-task prompting (Brown et al., 2020), where increasing the number of examples increases prompting performance, in crosstask prompting, performance does not improve with an increase in source examples (c.f. Fig 3). For most target tasks, increasing source examples does not affect performance, while for some, the performance decreases.
Semantically similar vs random example selection. As shown in Table 2, in a cross-task setup, choosing the examples randomly leads to substantially poorer performance than when we generate the context C with semantically similar examples; concerning is the fact that, in many cases, it causes 0% accuracy. This may be caused by the model getting confused without any semantic alignment in the prompt. Furthermore, random labeling of in-context examples (Wei et al., 2023) result in nearrandom performance (see Table 12 in Appendix E).
Mixed cross-task prompting. So far, we have seen
that cross-task prompting works for single sourcetarget task pairs. Next, we experiment on using multiple source tasks to construct the prompt context. To explore such a setup, we prompt LLaMA models using three methods: 1. Best source cross-task: We select the best
source task for every target task using Table 1 and sample four semantically similar examples from that source task.
2. Random mixed cross-task: To see if a diverse set of tasks is beneficial, we randomly sample four source tasks and construct the prompt using most semantically similar examples.
3. Best mixed cross-task: This method is a combination of the first two; we use the top four best source tasks from Table 1 and sample a semantically similar source example from each task. Table 3 shows that a mixed prompting mecha-
nism does not perform better than the “best source cross-task” prompting method. On the contrary, it seems to hurt the performance of the model; in fact, single-source task prompting with only one example (Table 1) seems to do better than mixed prompting. Diversity seems to lead the model to
get more confused, thus hurting its performance. Combining in-task with cross-task prompting. Combining cross-task prompting with labeled target examples improves performance, as seen in Table 4; apart from Financial-Phrasebank in LLaMA2 13B and MedMCQA in GPT3.5, for all other instances there exist a source task that improves the performance when coupled with the in-task example. However, we see that this improvement is immensely dependent on the source-target task pair chosen and unlike Table 1, we are unable to find robust source datasets that improve the performance throughout the setup. Nevertheless, in multiple source-target instances, there is a noteworthy improvement.
To study the interaction between heterogeneous tasks in the context, we experiment by varying the number of source tasks and target task demonstrations in the context. Figure 2 shows the variation of accuracy for 8-shots, as we gradually move from an entirely in-task context to a complete cross-task context. We observe that for all target tasks, apart from Financial-Phrasebank, the accuracy with an 8- shot in-task prompt and an 8-shot cross-task prompt (with best-mixed cross-task strategy) is almost the same in all three LLMs.
4 Pseudo-label generation using cross-task prompting
Thus far we observe that cross-task prompting, though sometimes capable of even outperforming standard in-task prompting, is particularly sensitive to the choice of source task. Furthermore, the performance does not scale with the number of source task examples provided. Drawing inspiration from earlier works on pseudo-labeled examples to construct prompts (He et al., 2022; Vu et al., 2021), we propose a more practical method for potential usage of cross-task prompting.
Given a small unlabeled dataset Dpl ⊂ Dt, we assign a pseudo-label to the example using crosstask prompting. This is done using all source tasks available to us, and then a final ypl is assigned to xpl ∈ Dpl based on a majority vote from all the generated answers. Finally, this pseudo-labeled dataset Dpl is used to construct the prompt context in an in-context prompting setup. Cross task generated pseudo-examples vs gold label. To see the efficacy of our proposed method, we utilise a Dpl of size 8 and have three setups to create examples for context: 1. Gold-label: We
0 1 2 3 4 5 6 7 8 Number of cross-task demonstrations
20
40
60
80
Ac cu
ra cy
(a) 0 1 2 3 4 5 6 7 8 Number of cross-task demonstrations (b) 0 1 2 3 4 5 6 7 8 Number of cross-task demonstrations (c)
ARC-Challenge Financial-Phrasebank MedMCQA SciQ Social-i-QA
Figure 2: Variation of accuracy with the number of crosstask demonstrations in the context C for 8-shot prompt, where C consists of a mixture of cross-task and in-task examples, using (a) LLaMA2 7B, (b) LLaMA-2 13B and (c) GPT3.5. Except for Financial-Phrasebank, an increase in cross-task examples give a stable performance.
use the annotated version of Dpl in the context; 2. Pseudo-label (ZS): We use zero-shot prompting to label Dpl for the context examples; 3. Pseudo-label (CT): We use the cross-task method as proposed in Section 4.
The results of this experiment are shown in Table 5. For LLaMA models, as evident, pseudo labels generated via cross-task prompting are substantially better than zero-shot pseudo labels; they are of higher quality and lead to comparable performance as Gold-label.
In the case of GPT 3.5, the scale of improvement is much smaller though. Interestingly, with only two datasets, namely, SciQ and Social-i-QA, we observe the pseudo examples from cross-task prompting to perform worse than gold-label examples, in all three models. Given the comparable performance of cross-task prompt-generated pseudo examples, we expect this to become a viable alternative to traditional ICL in data-scarce scenarios.
Gold-label Pseudo-examples(ZS) Pseudo-examples(CT) LLaMA-2 7B
ARC-Challenge 44.40.37 7.24.52 44.40.37 Financial-Phrasebank 48.49.56 56.52.01 56.82.37 MedMCQA 30.60.84 21.014.61 30.61.03 SciQ 67.70.65 3.31.88 64.61.51 Social-i-QA 46.81.69 46.71.57 46.41.94 Average 47.62.62 26.94.91 48.51.44 LLaMA-2 13B ARC-Challenge 56.80.47 59.70.84 58.41.79 Financial-Phrasebank 67.95.03 67.95.03 67.995.03 MedMCQA 38.21.31 2.61.8 39.40.37 SciQ 84.10.75 29.339.5 84.10.75 Social-i-QA 63.62.78 43.627.7 61.43.66 Average 62.12.06 40.6214.97 62.22.32 GPT3.5 ARC-Challenge 76.70.89 77.41.13 77.460.94 Financial-Phrasebank 80.44.35 86.22.84 83.436.41 MedMCQA 43.25.65 43.43.30 47.82.97 SciQ 92.81.04 91.20.56 91.50.25 Social-i-QA 77.81.06 76.60.65 76.60.43 Average 74.22.59 74.91.69 75.32.2
Table 5: Accuracy in pseudo-label generated prompting (ZS: zero-shot, CT: cross-task). Pseudo-label (CT) performs comparably to gold-label examples.
Increasing number of pseudo-examples for intask prompting. Figure 3 shows the relation between the number of pseudo-demonstrations and
accuracy. The general trend shows a rise in performance when more demonstrations are used in creating context C, except for Financial-Phrasebank, whose performance decreases with an increase in demonstrations.
5 Interpretability analysis
In this section, we focus on the internal workings of the LLMs using the hidden states of the model and build an understanding of why and how cross-task prompting works. What is an ideal source task? Intuitively thinking of a source task that is similar to the target will result in better transfer of generalised signal from context to target inputs. To test this, we first compare the final layer outputs of the model corresponding to the source and target task definitions, ds and dt, respectively. Figure 4 shows the cosine similarity between the final layer hidden states corresponding to ds and dt. We note that for 80% of the time, the source definition that is the most semantically similar to the target definition also serves as its best suitor, leading to the best performance in Table 1. What does internal activation indicate? To get
an even more in-depth picture, we analyse the layerwise activations for the LLaMA-2 7B model. For each layer, we compute the cosine similarities between the mean activations corresponding to the source and target task definitions. For a given target task, we then compute the rank correlation (in terms of Spearman correlation coefficient, Pearson coefficient, and, Kendall’s tau) between the cosine similarities and the absolute point performance change from zero-shot prediction for each source task (see Table 19 in Appendix). Precisely, this gives us an approximate idea about the underlying mechanism of cross-task signal transfer. For all the tasks, we can see a U-shaped pattern in the correlation values (c.f. Fig 5) – at the starting layers, there is a high correlation between the cross-task activation similarity and the cross-task improvement (likely due to semantically similar example selection), that quickly drops in the middle layers, and increases again in the later layers (only exception being the MedMCQA target task). One can intuitively claim that in the initial layers of the model (Layers 2 to 5), there is more taskspecific computation going on where the cross-task transfer of information is the least. For FinancialPhrasebank, these task-specific layers cover more than 80% of the layers, with a gradual increase in correlation observable only after Layer 28. Hendel et al. (2023) provided a similar finding that the influence of the context kicks in only after a certain number of layers via task vectors. We see that the exact layer after which cross-task demonstrations will start signal to transfer is much more dependent on the target task and can vary widely.
6 Error analysis
We observe four types of error occurring in crosstask prompting (c.f. Table 6), as follows: Label space replication. In example #1, the source example is from the Conll2003-POS dataset, a POS tagging task. In contrast, the target task is to predict the financial sentiment analysis. Therefore, the generation should be either negative, positive or neutral; however, we observe that the output is a sequence of POS tags instead. Here, the LLM is replicating the label space of the source task and the definition of the target task is not able to guide it to the correct target label space. Junk prediction. In some cases, we observe that the output is neither from the label space of the source task nor from that of the target task. As
in example #2, the source task is to classify each token into one named entity category (NER), and the target task is to predict the financial sentiment. The output in this case is found to be junk — it is a sequence of N’s but N is not a pre-defined named entity category, neither is it a label for the target task. Further, we observe that the correct label in this example is ‘neutral’ – the LLM could not follow the target task definition provided and gets confused between the correct prediction label of the target task and the token classification task where the output is expected to be a sequence of labels, and instead outputs a sequence with the initial letter of the correct label.
Copying effect: We also notice the copying effect, which has been observed by Lyu et al. (2023), where the predicted label is the same as the label of the context example which is semantically very similar to the target input. In example #3, the target input is semantically very similar to the context ex-
ample from the source task provided in the prompt, and consequently, the LLM incorrectly outputs the same label as that of the context example. Definition not followed: We observe that for some instances the LLM does not adhere to the definition given in the form of task definition for the target task. In example #4, the LLM is supposed to output one among the four options A, B, C, D, instead it outputs the text corresponding to the option D – though D is the correct answer in this case, the LLM is not able to follow the definition properly.
7 Related work
In-context learning without gradient updates to the model was introduced by Brown et al. (2020) using the GPT-3 model. Multiple recent works sought robust ICL setup via different techniques: selecting the examples that are semantically most similar to the input (Liu et al., 2022), choosing low perplexity examples (Gonen et al., 2022), training a
two-stage retrieval system to select the best examples (Rubin et al., 2022), etc. However, these works primarily aim to construct better in-task prompts where the examples and the input come from the same task. Tanwar et al. (2023) showed that crosslingual ICL can be elicited with proper alignment between the source and target language examples. Raffel et al. (2020) introduced the T5 transformer model which has been trained to perform different text-processing tasks. Zhang et al. (2022) proposed a task prefix guided multi-task pre-training framework to solve this problem. More recently, a new prompting method called Meta-CoT has been proposed by Zou et al. (2023) which generalizes chain-of-thought prompting to include multi-task examples in the prompt and it has shown improvement in a number of tasks.
8 Conclusion
In this paper, we addressed LLMs’ adaptability to novel tasks. Exploiting the inherent ICL capabilities of these models, we established that LLMs can substantially enhance their performance in novel task scenarios, even when direct examples are lacking. This encouraging outcome unveils fresh possibilities for the practical integration of LLMs across a broader spectrum of applications. Furthermore, our study demonstrated the significance of generating pseudo-labels using cross-task prompting, presenting a potential solution for situations where annotated data is scarce. The observed correlation between the impact of cross-task examples and the similarity in model activations between source and target input tokens offers valuable insights into the underlying mechanisms of this phenomenon.
Limitations
Despite presenting a potential future direction towards training-free task generalization using LLMs, this study has some important limitations. It is evident that the similarity between the source and the target tasks plays an important role in the performance. Hence, in real-world scenarios where the task novelty is extreme, such a method may fail to provide suitable performance. This is directly related to the fact that ours is the first study in this direction, and we have primarily focused on the empirical viability. A deeper understanding of generalizable task information captured inside the LLM circuits would help to come up with sophisticated solutions. Task novelty in our discussion does not presuppose access to novel knowledge. Hence, one can not mitigate the gap if a novel task requires the model to access newer information not present in the pretraining data or the in-context examples.
References Sören Auer, Dante A. C. Barone, Cassiano Bartz, Ed-
uardo G. Cortes, Mohamad Yaser Jaradeh, Oliver Karras, Manolis Koubarakis, Dmitry Mouromtsev, Dmitrii Pliukhin, Daniil Radyush, Ivan Shilin, Markus Stocker, and Eleni Tsalapati. 2023. The sciqa scientific question answering benchmark for scholarly knowledge. Scientific Reports, 13(1):7240.
Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss,
Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. 2020. Language models are few-shot learners. CoRR, abs/2005.14165.
Christopher Clark, Kenton Lee, Ming-Wei Chang, Tom Kwiatkowski, Michael Collins, and Kristina Toutanova. 2019. BoolQ: Exploring the surprising difficulty of natural yes/no questions. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 2924–2936, Minneapolis, Minnesota. Association for Computational Linguistics.
Peter Clark, Isaac Cowhey, Oren Etzioni, Tushar Khot, Ashish Sabharwal, Carissa Schoenick, and Oyvind Tafjord. 2018. Think you have solved question answering? try arc, the ai2 reasoning challenge. ArXiv, abs/1803.05457.
Arthur Conmy, Augustine N Mavor-Parker, Aengus Lynch, Stefan Heimersheim, and Adrià GarrigaAlonso. 2023. Towards automated circuit discovery for mechanistic interpretability. arXiv preprint arXiv:2304.14997.
Nelson Elhage, Neel Nanda, Catherine Olsson, Tom Henighan, Nicholas Joseph, Ben Mann, Amanda Askell, Yuntao Bai, Anna Chen, Tom Conerly, et al. 2021. A mathematical framework for transformer circuits. Transformer Circuits Thread, 1.
Hila Gonen, Srini Iyer, Terra Blevins, Noah A. Smith, and Luke Zettlemoyer. 2022. Demystifying prompts in language models via perplexity estimation.
Xuanli He, Islam Nassar, Jamie Kiros, Gholamreza Haffari, and Mohammad Norouzi. 2022. Generate, Annotate, and Learn: NLP with Synthetic Text. Transactions of the Association for Computational Linguistics, 10:826–842.
Roee Hendel, Mor Geva, and Amir Globerson. 2023. In-context learning creates task vectors. In Findings of the Association for Computational Linguistics: EMNLP 2023, pages 9318–9333, Singapore. Association for Computational Linguistics.
Guokun Lai, Qizhe Xie, Hanxiao Liu, Yiming Yang, and Eduard Hovy. 2017. RACE: Large-scale ReAding comprehension dataset from examinations. In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing, pages 785– 794, Copenhagen, Denmark. Association for Computational Linguistics.
Jiachang Liu, Dinghan Shen, Yizhe Zhang, Bill Dolan, Lawrence Carin, and Weizhu Chen. 2022. What makes good in-context examples for GPT-3? In Proceedings of Deep Learning Inside Out (DeeLIO
2022): The 3rd Workshop on Knowledge Extraction and Integration for Deep Learning Architectures, pages 100–114, Dublin, Ireland and Online. Association for Computational Linguistics.
Xinxi Lyu, Sewon Min, Iz Beltagy, Luke Zettlemoyer, and Hannaneh Hajishirzi. 2023. Z-ICL: Zero-shot in-context learning with pseudo-demonstrations. In Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 2304–2317, Toronto, Canada. Association for Computational Linguistics.
P. Malo, A. Sinha, P. Korhonen, J. Wallenius, and P. Takala. 2014. Good debt or bad debt: Detecting semantic orientations in economic texts. Journal of the Association for Information Science and Technology, 65.
Christian David Márton, Léo Gagnon, Guillaume Lajoie, and Kanaka Rajan. 2021. Efficient and robust multi-task learning in the brain with modular latent primitives. arXiv preprint arXiv:2105.14108.
OpenAI. 2023. Gpt-4 technical report.
Saurabh Pahune and Manoj Chandrasekharan. 2023. Several categories of large language models (llms): A short survey. arXiv preprint arXiv:2307.10188.
Ankit Pal, Logesh Kumar Umapathi, and Malaikannan Sankarasubbu. 2022. Medmcqa: A large-scale multisubject multi-choice dataset for medical domain question answering. In Proceedings of the Conference on Health, Inference, and Learning, volume 174 of Proceedings of Machine Learning Research, pages 248–260. PMLR.
Wen Qin, Chunshui Yu, et al. 2013. Neural pathways conveying novisual information to the visual cortex. Neural plasticity, 2013.
Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. 2020. Exploring the limits of transfer learning with a unified text-to-text transformer. Journal of Machine Learning Research, 21(140):1–67.
Lance A. Ramshaw and Mitchell P. Marcus. 1995. Text chunking using transformation-based learning. ArXiv, cmp-lg/9505040.
Nils Reimers and Iryna Gurevych. 2019. Sentence-bert: Sentence embeddings using siamese bert-networks. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing. Association for Computational Linguistics.
Ohad Rubin, Jonathan Herzig, and Jonathan Berant. 2022. Learning to retrieve prompts for in-context learning. In Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 2655–2671, Seattle, United States. Association for Computational Linguistics.
Kathy Ruddy and Richard Carson. 2013. Neural pathways mediating cross education of motor function. Frontiers in Human Neuroscience, 7.
Maarten Sap, Hannah Rashkin, Derek Chen, Ronan Le Bras, and Yejin Choi. 2019. Socialiqa: Commonsense reasoning about social interactions. CoRR, abs/1904.09728.
Lakshay Sharma, Laura Graesser, Nikita Nangia, and Utku Evci. 2019. Natural language understanding with the quora question pairs dataset. CoRR, abs/1907.01041.
Richard Socher, Alex Perelygin, Jean Wu, Jason Chuang, Christopher D. Manning, Andrew Ng, and Christopher Potts. 2013. Recursive deep models for semantic compositionality over a sentiment treebank. In Proceedings of the 2013 Conference on Empirical Methods in Natural Language Processing, pages 1631–1642, Seattle, Washington, USA. Association for Computational Linguistics.
Alon Talmor, Jonathan Herzig, Nicholas Lourie, and Jonathan Berant. 2019. CommonsenseQA: A question answering challenge targeting commonsense knowledge. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 4149–4158, Minneapolis, Minnesota. Association for Computational Linguistics.
Eshaan Tanwar, Subhabrata Dutta, Manish Borthakur, and Tanmoy Chakraborty. 2023. Multilingual LLMs are better cross-lingual in-context learners with alignment. In Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 6292–6307, Toronto, Canada. Association for Computational Linguistics.
Erik F. Tjong Kim Sang and Fien De Meulder. 2003. Introduction to the CoNLL-2003 shared task: Language-independent named entity recognition. In Proceedings of the Seventh Conference on Natural Language Learning at HLT-NAACL 2003, pages 142– 147.
Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, et al. 2023. Llama 2: Open foundation and fine-tuned chat models. arXiv preprint arXiv:2307.09288.
Tu Vu, Minh-Thang Luong, Quoc V. Le, Grady Simon, and Mohit Iyyer. 2021. Strata: Self-training with task augmentation for better few-shot learning. CoRR, abs/2109.06270.
Kevin Wang, Alexandre Variengien, Arthur Conmy, Buck Shlegeris, and Jacob Steinhardt. 2022a. Interpretability in the wild: a circuit for indirect object identification in gpt-2 small. arXiv preprint arXiv:2211.00593.
Liang Wang, Nan Yang, Xiaolong Huang, Binxing Jiao, Linjun Yang, Daxin Jiang, Rangan Majumder, and Furu Wei. 2022b. Text embeddings by weakly-supervised contrastive pre-training. ArXiv, abs/2212.03533.
Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Fei Xia, Ed Chi, Quoc V Le, Denny Zhou, et al. 2022. Chain-of-thought prompting elicits reasoning in large language models. Advances in Neural Information Processing Systems, 35:24824–24837.
Jerry Wei, Le Hou, Andrew Lampinen, Xiangning Chen, Da Huang, Yi Tay, Xinyun Chen, Yifeng Lu, Denny Zhou, Tengyu Ma, and Quoc V. Le. 2023. Symbol tuning improves in-context learning in language models.
Adina Williams, Nikita Nangia, and Samuel Bowman. 2018. A broad-coverage challenge corpus for sentence understanding through inference. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pages 1112–1122. Association for Computational Linguistics.
Xiang Zhang, Junbo Jake Zhao, and Yann LeCun. 2015. Character-level convolutional networks for text classification. In NIPS.
Zhuosheng Zhang, Shuohang Wang, Yichong Xu, Yuwei Fang, Wenhao Yu, Yang Liu, Hai Zhao, Chenguang Zhu, and Michael Zeng. 2022. Task compass: Scaling multi-task pre-training with task prefix. In Findings of the Association for Computational Linguistics: EMNLP 2022, pages 5671–5685, Abu Dhabi, United Arab Emirates. Association for Computational Linguistics.
Anni Zou, Zhuosheng Zhang, Hai Zhao, and Xiangru Tang. 2023. Meta-cot: Generalizable chain-ofthought prompting in mixed-task scenarios with large language models.
A Dataset details
A.1 Source datasets We have used the following datasets as source datasets:
ARC-Easy: ARC-Easy (Clark et al., 2018) is a part of the ARC (AI2 Reasoning Challenge) dataset consisting of easy natural science questions targeted for students of 3rd to 9th grade. The questions are of multiple-choice format, where one of the four given options is correct. The training set consists of 2251 questions that we use for selecting our source examples.
AG-news: AG-news (Zhang et al., 2015) is a text classification dataset containing news
articles categorized into four classes - sports, business, technology, and world. It has a training set size of 120K, from which we have randomly sampled 10K news articles to construct the source dataset for our experiments.
BoolQ: BoolQ (Clark et al., 2019) is a reading comprehension dataset consisting of yes/no questions asked from a passage given for each question. The questions are mostly nonfactoid, and considerable inference ability is required to answer them based on the passages provided. In our usage, each question is labeled as either true or false. The training set consists of 9427 labeled question-passage pairs from which we select the source examples.
Commonsense-QA: Commonsense-QA (Talmor et al., 2019) is a commonsense questionanswering dataset that consists of multiplechoice questions where one of the five options provided is correct. To answer the questions, logical reasoning abilities and in some cases prior knowledge are required. The training set consists of 9740 labeled questions from which source examples are chosen by us.
Conll2003-POS: Conll2003-POS (Tjong Kim Sang and De Meulder, 2003) is a collection of the data which is a part of the CoNLL-2003 shared task. In this dataset, each sentence is labeled as a sequence of part-ofspeech (POS) tags (each token is assigned a POS tag). We construct our source dataset by sampling 10K sentences from the 14,041 sentences in the training set.
Conll2003-NER: Conll2003-NER (Tjong Kim Sang and De Meulder, 2003) is also a part of the CoNLL-2003 shared task. Here, each sentence is labeled as a sequence of named entity tags. The task in this case is to perform named-entity recognition (NER). IOB tagging scheme (Ramshaw and Marcus, 1995) is used for assigning the tags. Four types of entities are assumed to be present in the data – persons (PER), organizations (ORG), locations (LOC) and miscellaneous names (MISC). The training set consists of 14,041 sentences of which 10K are sampled by us as our source data.
MNLI: Multi-Genre Natural Language Inference (MNLI) (Williams et al., 2018) corpus is one of the largest available resources for natural language inference. The corpus consists of 393K labeled examples, where each example consists of a pair of sentences and the label is one among neutral, contradiction or entailment based on the relationship between their meanings. Our source dataset is constructed by sampling 10K examples from the 393K examples available.
QQP: Quora Question Pairs (QQP) (Sharma et al., 2019) dataset is curated for the task of natural language understanding. This dataset consists of question pairs collected from the popular question-answering website Quora, and the task is to determine if the questions are duplicates of each other. The training set consists of 364K question pairs, each labeled as duplicate or not duplicate. We sample 10K labeled question pairs from the training set for our source data.
RACE: RACE (Lai et al., 2017) is a reading comprehension dataset consisting of passages along with questions asked from them. The passages and questions are collected from English exams of school students aged between 12 to 18. The questions are of multiple-choice format where one of the four options is correct. Our source dataset is gathered by picking 10K passage-question pairs from 87.9K such pairs available in the training set.
SST2: SST2 (Socher et al., 2013) dataset is a part of the Stanford Sentiment Treebank corpus. It contains movie review snippets collected from the Rotten Tomatoes website. Each review is labeled as positive or negative. The 10K reviews for our source dataset are sampled from the training set consisting of 67.3K labeled reviews.
A.2 Target datasets We have used the following datasets as target datasets:
ARC-Challenge: ARC-Challenge (Clark et al., 2018) is also a part of the ARC (AI2 Reasoning Challenge) dataset and it consists of hard natural science questions targeted for students of 3rd to 9th grade. Those
questions that were answered incorrectly by both a retrieval-based algorithm and a word co-occurrence method are considered to be ‘hard’enough for inclusion in this dataset. The questions are of multiple-choice format, where one of the four options is correct. The test set consists of 1172 questions out of which 500 were randomly selected for our target dataset.
Social-i-QA: Social-i-QA (Sap et al., 2019) is a commonsense reasoning dataset focusing on social situations. This dataset contains examples consisting of a social situation or action given as context and a multiple-choice question asked based on the context aimed at testing emotional and social intelligence. Each question has three options, out of which one is correct. We select 500 examples for our target data from the 1954 examples available in the validation set.
SciQ: SciQ (Auer et al., 2023) (or, SciQA) is a scientific question-answering dataset consisting of questions from different areas of Physics, Chemistry and Biology. The questions are of multiple-choice format, where one of the four options is correct. The test set consists of 1000 questions, of which 500 are sampled to prepare our target dataset.
MedMCQA: MedMCQA (Pal et al., 2022) is a multiple-choice question-answering dataset consisting of questions from post-graduate medical entrance exams in India. Each question has four options of which one is correct. Our target dataset is constructed by selecting 500 questions from the 4183 questions in the validation set.
Financial-Phrasebank: FinancialPhrasebank (Malo et al., 2014) is a financial sentiment analysis dataset containing sentences mined from a corpus of English news on all listed companies in OMX Helsinki. Each sentence is labeled as one of the three categories – positive, negative, or neutral, based on the influence the news snippet may have on the stock price. The training set consists of 2264 labeled sentences, from which 500 are sampled for our target dataset.
In each case, for preparing our target dataset we have selected 500 examples. The selection,
though random, is done in such a way that our target datasets are balanced, i.e. the number of examples with each of the different possible labels is almost equal.
B Semantic context creation
One might assume that taking internal embeddings of the models, instead of an external model like Sentence-BERT, for extracting semantically similar examples might be better suited. However, we found that doing so for LLaMA-2 7B is computationally more expensive, with no significant gain in performance, as reported in Table 7.
We also experimented with Sentence-BERT and E5 (Wang et al., 2022b) to test which external model produces superior semantically similar context C for the LLMs to use. Table 8 shows the results for LLaMA-2 7B and GPT3.5 performance using C from the E5 model. We proceeded with Sentence-BERT instead of E5 as our external model, as the former has already been used for a similar role in prior works (Liu et al., 2022; Tanwar et al., 2023), and its performance is also comparable to that of E5.
C Cross-task prompting in instruction-tuned models
The performance gain with cross-task prompting for instruction-tuned models is lesser compared to that for the corresponding base model, due to the improvement in zero-shot performance of instruction-tuned models. For instance, Table 9 shows the performance for LLaMA-2 7B Chat model. We observe that it’s zero-shot performance is much better compared to the LLaMA-2 7B base model.
D Force decoding
Unlike greedy decoding, where the most probable token from the entire vocabulary of the model is the output, in force decoding the vocabulary is restricted to a set of tokens and the output is assigned out of these restricted tokens. Formally, for context C and a target task T , the output in the case of force decoding is:
ŷt = argmax y∈LT
p(y|C)
where, LT is the label space of target task T . The label space of all five target tasks is shown in Table 11.
Table 10 reports the performance of cross-task prompting for all source-target pairs using force decoding in LLaMA-2 7B and LLaMA-2 13B models. We noted that force decoding improves the performance of zero-shot prediction by a great margin. However, the same is not true for every sourcetarget pair.
E Random labeling
Recently, Wei et al. (2023) proposed using a random label space for pseudo-labeling examples of (target) task and utilise these to generate the context C. We experimented with this setup as it is a better alternative to zero-shot prompting, but our results (Table 12) showed that the model output is random with such C.
F Prompt details
We show a few examples of cross-task prompts in Table 14 and in-task combined with cross-task prompts in Table 15. Additionally, task definitions of source and target tasks are provided in Table 16 and Table 17 respectively.
G Error analysis
Table 18 contains detailed examples for erroneous predictions in cross-task prompting setup.
H Activation analysis on LLaMA-2 7B
Full correlation analysis is presented in Table 19.

heading: Future Work
text: Limitations
Despite presenting a potential future direction towards training-free task generalization using LLMs, this study has some important limitations. It is evident that the similarity between the source and the target tasks plays an important role in the performance. Hence, in real-world scenarios where the task novelty is extreme, such a method may fail to provide suitable performance. This is directly related to the fact that ours is the first study in this direction, and we have primarily focused on the empirical viability. A deeper understanding of generalizable task information captured inside the LLM circuits would help to come up with sophisticated solutions