Robust Integration of Contextual Information for Cross-Target Stance Detection
Year: 2023

Abstract:
Stance detection deals with identifying an author’s stance towards a target. Most existing stance detection models are limited because they do not consider relevant contextual information which allows for inferring the stance correctly. Complementary context can be found in knowledge bases but integrating the context into pretrained language models is non-trivial due to the graph structure of standard knowledge bases. To overcome this, we explore an approach to integrate contextual information as text which allows for integrating contextual information from heterogeneous sources, such as structured knowledge sources and by prompting large language models. Our approach can outperform competitive baselines on a large and diverse stance detection benchmark in a cross-target setup, i.e. for targets unseen during training. We demonstrate that it is more robust to noisy context and can regularize for unwanted correlations between labels and targetspecific vocabulary. Finally, it is independent of the pretrained language model in use.1

heading: 1 Introduction
text: Given a text and a target the text is directed at, stance detection (SD) aims to predict whether the text contains a positive or negative stance towards the target or is unrelated. We provide an example in Figure 1. In contrast to formal polls, stance detection (SD) provides a scalable alternative to assess opinions expressed in unstructured texts. However, in contrast to predicting the polarity of a text (i.e., sentiment analysis), SD is more challenging because it requires establishing the relation towards a target which is rarely mentioned in the text (Augenstein et al., 2016).
Further, to infer the correct stance, often the text alone is not sufficient and contextual information
∗* Equal contribution. 1Data and code at https://github.com/UKPLab/
arxiv2022-context-injection-stance
needs to be taken into account (Du Bois, 2007). In contrast, most stance classification models are expected to make a correct prediction given the text and target only. This can lead to overly relying on label correlations with target-specific vocabulary (Reuver et al., 2021; Thorn Jakobsen et al., 2021). In our example (Figure 1), it is challenging to follow the reasoning of the text if the meaning of school spirit is left unclear.
Consequently, providing external knowledge as an additional signal to stance classification has been proposed as a remedy. However, lacking a general solution, previous work applies knowledge integration only for a specific text domain like social media (Allaway et al., 2021; Clark et al., 2021). Nevertheless, SD algorithms are applied on a multitude of different text sources like social media (ALD), news (Hanselowski et al., 2019) or debating fora (Hasan and Ng, 2013; Chen et al., 2019) and on diverse targets such as persons (Sobhani et al., 2017; Li et al., 2021), products (Somasundaran and Wiebe, 2010), or controversial topics (Stab et al., 2018; Jo et al., 2021a), among other things. In addition, existing approaches (Zhang et al., 2020; Paul et al., 2020) often depend on the structure of the external knowledge source used. However, a single source of knowledge will likely not suffice for all different scenarios and adapting
494
the model architecture to the structure of a specific knowledge source (e.g. graph-based) limits its applicability.
This work proposes a flexible and robust approach to integrate contextual information by encoding it as text. It is better aligned to the encoding schema of a pre-trained language model (PLM) and circumvents any dependency on the structure of a particular knowledge source. It also allows for using any context source that best fits the data’s text domain or mixing contextual information from multiple sources. In detail, we propose a dual-encoder architecture (INJECT), which encodes the input text and context information separately while facilitating information exchange between both via attention. We investigate extracting contextual information from various sources using different extraction strategies. We evaluate our approach across a benchmark of 16 stance detection datasets exhibiting different characteristics concerning text source, size, and label imbalance.
First, we demonstrate that existing state-of-theart approaches outperform standard baselines only on the domains they have been tuned for - but perform worse on average. When integrating context via INJECT, we observe improvements on average and provide an analysis demonstrating the robustness of our approach. In summary, we make the following contributions:
• We show that the performance of existing state-of-the-art approaches does not transfer across a large and diverse benchmark of 16 SD datasets compared to a standard baseline.
• We propose the INJECT architecture to integrate contextual information for cross-target stance detection. Our approach leads to performance improvements across the benchmark and is independent of the underlying pretrained language model.
• We compare different sources for extracting contextual information and their effectiveness for stance detection. We extract context from structured knowledge bases by prompting a large pre-trained language model.
• An analysis highlights our approach’s benefits compared to a more direct integration via appending the context to the input. Our approach regularizes the influence of correlations of target-specific vocabulary and is robust to noisy contexts.

heading: 2 Related Work
text: Many tasks in NLP benefit from access to external knowledge such as natural language inference (Chen et al., 2018), machine translation (Shi et al., 2016) or argument mining (Lauscher et al., 2022). Within the era of PLMs, many approaches rely on extensive pretraining using data from knowledge bases (Peters et al., 2019; Zhang et al., 2019) (KB) or supervision from knowledge completion tasks (Wang et al., 2021; Rozen et al., 2021).
Early works leveraged sentiment lexicons (BarHaim et al., 2017b) or combinations thereof (Zhang et al., 2020) to improve SD classification performance. Other contextual components like author information (Li et al., 2018; Sasaki et al., 2018; Lukasik et al., 2019), dissemination features of social media (Lai et al., 2018; Veyseh et al., 2017) such as retweets or structural discourse elements (Nguyen and Litman, 2016; Opitz and Frank, 2019) have been shown to play an important role for stance detection. Similarly to the aforementioned approaches, the focus in SD has shifted towards combining structural KBs and PLMs. Kawintiranon and Singh (2021) identify label-relevant tokens and prioritize those during masked language modeling. This approach risks overfitting on targetspecific tokens because stance is often expressed using target-specific terminology - an issue which is particularly problematic for argumentative sentences (Thorn Jakobsen et al., 2021). Clark et al. (2021) apply a knowledge infusion method for PLMs by filtering Wikipedia triplets for contextual knowledge. Popat et al. (2019) extend BERT by introducing a consistency constraint to learn agreement between the text and its target. Jo et al. (2021b) presents a variant of BERT pre-trained using a variety of supervised tasks resembling logical mechanisms. Paul et al. (2020) extract relevant concepts from ConceptNet using graph-based ranking methods to improve argument relation classification. Likewise, Liu et al. (2021) uses ConceptNet to identify relevant concept-edge pairs and integrate them via a graph neural network during training. Finally, Hardalov et al. (2021) used label embeddings to improve SD multi-dataset learning and recently showed (Hardalov et al., 2022) that sentiment-based pretraining improves multi-lingual stance detection.
In summary, most existing approaches integrate knowledge through extensive pretraining on knowledge-rich data. This does not guarantee im-
provement of the downstream task they are intended for and requires additional experiments. Another line of work introduces architectural dependencies on the structure of the knowledge source, thereby limiting their usage to tasks and domains for which the knowledge source is applicable. In contrast, our approach does not require further pretraining but directly learns to integrate contextual information during supervised training. The usefulness of the context is, therefore, directly measurable. Further, our proposed approach integrates context in natural language, thereby decoupling it from the structure of the context source. It is better aligned with the encoding mechanism of pre-trained language models and enables the integration of contextual information from various sources.

heading: 3 Methodology
text: Our goal is twofold: (1) we aim to integrate contextual information independent of the context source and (2) in a way that is robust to noisy and irrelevant content in the context. We propose INJECT, a dual encoder approach to integrate contextual sentences using the cross-attention mechanism introduced by Vaswani et al. (2017). The general intuition is that information can flow from input to context and vice versa, thereby regularizing the attention in both encoders. Thus, the context provides further information to reweigh the prediction importance of individual tokens in the input.

heading: 3.1 Contextual information
text: With regards to stance detection, we define contextual information (or short context) as the sum of all information which, given the text and its target, renders the conclusion of the stance plausible. The context for each dataset instance is retrieved beforehand and is provided as text to the model. Formally, we describe context c ∈ C where c is a list containing m texts which provide contextual information on the input text x. See Figure 1 for an example (m = 2). The length of these texts is upper bounded by the maximum sequence length of the encoder model.

heading: 3.2 Context integration via INJECT
text: Figure 2 provides a high-level visualization of our proposed INJECT architecture. It consists of two modules: input- and context-encoder. The input encoder processes input and target I = (X,T )
while the context encoder processes the context sentences C. The encoders exchange information using inject blocks (IB(j)) which are injected on layer j of both encoders. j is a hyperparameter tuned using the dataset’s development set. All other layers are standard transformer blocks. An IB block is technically similar to a self-attention block but receives different inputs for key K, value V , and query Q. In detail, the inject block of the context-encoder (on layer j) receives the output from the self-attention e(j)(I,s) on layer j of the inputencoder as key and value and the output of its own self-attention e(j)(C,s) on layer j as query:
IB(j)(K=e (j) (I,s), V=e (j) (I,s), Q=e (j) (C,s))
Afterward, it is forwarded to get the new hidden state h(i)C of the context. Next, we back-inject the context into the input-encoder by feeding h(i)C as key and value in its inject block:
IB(j)(K=h (j) C , V=h (j) C , Q=e (j) (I,s))
Next, the hidden state h(i)I at layer j of the input encoder is produced by processing the cross-attention output e(j)(I,c). Finally, we add a classification head to the input encoder, which consists of a pooling layer, a dropout, and a linear classification layer. The parameters of both modules are optimized using the standard cross-entropy loss.
Our architecture is flexible regarding the number of context sentences that can be encoded (parameter m). In the case of multiple sentences, we average the cross-attention for all of them. Due to the
dual encoders, INJECT is computationally more efficient than context integration via concatenation, as we explain in the Appendix A.7.

heading: 3.3 Context integration via concatenation
text: An alternative approach would be to append contextual information to the input text such that the model can exploit context directly using the selfattention mechanism. Technically, this is implemented by separating the input and context using the model-specific separation token (e.g., text + [SEP] + context for BERT)2.
We see two major drawbacks of this approach. First, integrating irrelevant context will hurt downstream performance due to its direct influence on attention. Second, it is limited by the maximum sequence length of the model in use.

heading: 4 Context integration for stance detection
text: Task In stance detection, given an input text x ∈ X and its corresponding target t ∈ T, the goal is to identify the correct label y ∈ Y from a predefined set of stance descriptions. We further provide a set of contextual sentences C. The retrieval of C is explained in the next section.

heading: 4.1 Context retrieval
text: The INJECT model expects the context in natural language form and is therefore flexible with regard to the source of contextual information. To showcase, we evaluate different context sources that we deem relevant for inferring stance relations: (1) a structured knowledge base which stores knowledge as entity-relationship triplets, (2) a set of causal relations extracted from an encyclopedia, and (3) prompting a large pretrained language model using predefined question templates. The latter provides an intuitive interface to prompt for relevant sample-specific context, especially without suitable knowledge bases.
We neither expect these sources always to provide perfect contextual information nor to be suitable for all of the heterogeneous stance detection applications (see §5.1). However, our proposed architecture is designed to be robust, i.e., it utilizes beneficial context and ignores irrelevant information. In the following, we describe each approach in detail.
2In case of two input texts, the context is concatenated to the second input text.
ConceptNet Oftentimes, commonsense knowledge is beneficial to infer the stance towards a target correctly and has been shown to complement stance classification (Liu et al., 2021). Therefore, we use ConceptNet (Speer et al., 2017), a directed graph whose nodes are concepts and whose edges are assertions of commonsense about these concepts. For every edge, ConceptNet provides a textual description of the type of node relationship. Further, ConceptNet provides a weight factor for every edge computed based on the edge frequency within the ConceptNet training corpus.
Our approach uses the English subset of ConceptNet to get context sentences. We filter out concepts that are part of English stopwords 3 and ignore relations without descriptions. In total, we consider 400k nodes connected through approximately 600k edges. To retrieve the context, we use all tokens of the input text to search for string matches within the ConceptNet concepts. We consider only paths of length one where the startand/or end-concept are contained in the input text. Finally, we sort the paths based on their weight (provided by ConceptNet) and convert every path into a context candidate by joining the descriptions of all its edges, as done in previous work (Lauscher et al., 2020).
CauseNet Causal relations, as a more specific example of commonsense knowledge, are often beneficial for understanding opinionated expressions (Sasaki et al., 2016) but rarely formulated in the text. To explain such relations, we investigate CauseNet (Heindorf et al., 2020), a KB of claimed causal relations extracted from the ClueWeb12 corpus and Wikipedia. We use the causal relations contained in the high-precision subset4 of CauseNet, consisting of 80,223 concepts and 199,806 relations. We ignore concepts shorter than three characters or consisting of a modal verb (see Appendix A.6.1). We encode all relations using a sentence encoder (Reimers and Gurevych, 2019) using BERT-base-uncased weights. For each sample in a dataset, we retrieve the most relevant relations by ranking based on the cosine similarity between the encoded sample and all relations.
Pretrained language model Large PLMs can be queried as KBs using natural language prompts (Petroni et al., 2019; Heinzerling and Inui,
3As in NLTK (Bird, 2006) 4see https://causenet.org/
2021). We adopt this paradigm and generate context candidates by prompting a PLM to provide more information on either the target, parts of the input, or a combination of both. Precisely, we extract noun-phrases from the input sentence of a length of up to three words using the Stanford CoreNLP tool (Manning et al., 2014), ignoring stopwords and filtering noun-phrases that are equal to the target. Then, we create prompts using the following templates for single inputs a (e.g., target or noun-phrase)
P1(a) = define a
P2(a) = what is the definition of a
P3(a) = explain a
and combination of inputs (a, b).
P4(a, b) = relation between a and b
P5(a, b) = how is a related to b
P6(a, b) = explain a in terms of b
The single-input approach is referred to as T0pp-NP, and the second approach as T0pp-NP-T. We found those prompts to generate the most meaningful contexts across different targets and noun-phrases (see Appendix A.6.2 for more details). The prompts can then generate outputs using any pre-trained sequence-to-sequence model.
We make use of T0pp5 (Sanh et al., 2022), which is based on a pre-trained encoder-decoder (Raffel et al., 2020) and was fine-tuned using multiple diverse prompts generated using a large set of supervised datasets. We set the output sequence length to 40 words and sort the generated outputs by the length in descending order because we sometimes observe T0pp degenerate into producing single words. We filter those candidates where more than half of the generated words are repetitions. Finally, we remove all special tokens from the candidates. We found using two context sentences (m = 2) most beneficial in preliminary experiments.

heading: 5 Experiments

heading: 5.1 Datasets
text: We use a SD benchmark (Schiller et al., 2021; Hardalov et al., 2021), which covers 16 English
5See https://huggingface.co/bigscience/ T0pp. We also did experiments using T5 directly but found the outputs to be inferior to T0pp.
datasets for research on (cross-domain) stance detection. We use this benchmark (Table 1) because it shows a large diversity regarding text sources, the number of targets, the number of annotated instances, and label imbalance. Thus, it provides a suitable testbed to evaluate the effectiveness of our context injection approach. More information about the details of each dataset can be found in the Appendix A.2.

heading: 5.2 Experimental details
text: Evaluation Our results are evaluated in a crosstarget fashion (Augenstein et al., 2016; Xu et al., 2018), i.e., the setup is organized such that instances of a specific target are only contained in the training, development, or test split. We point out that our results are not directly comparable to Hardalov et al. (2021) as they perform experiments in a cross-domain fashion, i.e., their goal is to evaluate transfer learning effects by training on all but one dataset, which is used for testing. In contrast, we use one dataset per experiment to study the usefulness of context integration.
Baselines We compare INJECT to the following baselines. BERT is provided only the input, whereas BERT+Target is provided with both input and target using the model-specific separator token. (BERT⊕X) refers to BERT+Target with the retrieved context being appended, where X refers to context sources used (ConceptNet, CauseNet, T0pp-NP and T0pp-NP-T). We also test a combination of all context sources (All) and integration of random context (Random). To the best of our knowledge, no prior work has evaluated context integration for cross-target SD on the full benchmark. Thus, we compare with TGA-Net (Allaway and McKeown, 2020), STANCY (Popat et al., 2019), and JointCL (Liang et al., 2022) three state-of-the-art methods for SD which have been proposed for subsets of the benchmark. TGA-Net uses clustering to identify generalized topic representations. STANCY applies contrastive learning to learn embeddings where texts supporting a target are closer and opposing texts are more distant to their targets. JointCL use a prototypical graph for target-aware token representations. All of them require target information, which is not available for semeval19. In addition, we found JointCL is not working on fnc1 due to its long input texts. In these cases, we use the corresponding BERT-Target score for macro-F1 avg. calcula-
tion for a fair comparison.
Training setup We make use of the standard splits given in the benchmark (Hardalov et al., 2021) where possible or create our own (see Appendix A.1). We use macro-F1 as evaluation metric and average across ten runs with different seeds. Performance is measured after the best-performing epoch based on the development set. We use MannWhitney U-Test (Mann and Whitney, 1947) with p < 0.05 to test statistical significance. We use the uncased BERT base model (Devlin et al., 2019) for all experiments. We use the same set of hyperparameters for all model setups. For INJECT, we use the same model architecture for the input and context encoder. We tune the layer j for context integration (see §3.2). We tested layers 3, 6, 9, and 12 on the development set of the benchmark. Layer 12 performed the best and was used for all reported
results. More details are in the Appendix A.1.

heading: 6 Results
text: This section shows the effectiveness of INJECT by providing constant improvements using noisy context on the heterogeneous benchmark (Table 2).
First, we note a large performance boost (+8.5pp) when including information about the target when comparing BERT and BERT+Target. While target information improved the performance for individual datasetes (Stab et al., 2018), we generalize this finding for 14 out of 16 SD datasets.
The baselines STANCY, TGA-Net, and JointCL mostly show the best performance for the datasets they have been proposed for. However, on average, they do not perform on par with the strong BERT+Target baseline. STANCY
performs slightly worse, probably due to the binary contrastive loss and thereby ignoring multi-label information. TGA-Net underperforms all other approaches except for vast. Using generalized topic representations transfers to a scenario where the number of targets is relatively high (5634) and only a few examples per target exist (mean 2.4), as for vast. JointCL performs best on datasets from social media (semeval16, wtwt, or mtsd), but is outperformed by standard baselines for the rest of the tasks. Thus, this approach can not generalize to datasets with longer text inputs. We conclude that existing state-of-the-art approaches for cross-target stance detection work well for the datasets they have been designed for but do not generalize across the diverse set of datasets that exist in SD.
INJECT outperforms BERT+Target in 13 of 16 cases, while for three datasets (perspectrum, poldeb, snopes) none of the extracted contexts provides benefits, independently of the integration. On average, all context sources lead to performance improvements in combination with INJECT, with T0pp-NP-T being the best. Combining all context sources underperforms the integration of individual context, most probably due to the average function leading to a perturbation of the context. Surprisingly, integration of random context slightly outperforms the strong BERT+Target baseline in ten datasets while degrading the direct integration performance, as expected. We investigate the reasons in our subsequent analysis (§6.3).

heading: 6.1 Quality of context
text: To evaluate the quality of each context source, we looked at the aggregated performance differences with the baseline across each source (Figure 3b). While CauseNet leads to performance improvements for a maximum number of tasks (12), T0pp-NP-T leads the board concerning the total sum of absolute improvements across all datasets. The context quality extracted by prompting a PLM also becomes evident when looking at the performance of BERT⊕. ConceptNet and CauseNet lead to large performance degradation both in number of tasks and absolute numbers.

heading: 6.2 Generalization across PLMs
text: We investigate if the benefits of INJECT transfer to other PLM architectures by evaluating it in combination with RoBERTa (Liu et al., 2019) and ELECTRA (Clark et al., 2020). We follow the same experimental protocol as for BERT A.1,
but chose only the best-performing context source (T0pp-NP-T) due to the large number of experiments. The results (Table 3) confirm the previously observed findings that INJECT improves the performance on average across this diverse set of stance detection tasks. We observe similar improvements as with BERT for both models, with the strongest increase (+1.1pp on average) and the best overall performance for ELECTRA.

heading: 6.3 Further analysis
text: As integration with INJECT outperforms direct integration and even performs more robustly when provided with random context, we analyze the regularization provided by the INJECT architecture.
Regularization via INJECT We analyze how INJECT regularizes inputs by examining how models rely on target-specific vocabulary. Such vocabulary is often used to express a stance (Wei and Mao, 2019), but can lead to spurious correlations (Thorn Jakobsen et al., 2021). Therefore, we identify the top 5% label-indicative and target-specific tokens and correlate them with the model attributions using vector-norms (Kobayashi et al., 2020) (see Appendix A.4 for details). Table 4 shows these correlations for six benchmark datasets. For arc, argmin, and rumor we note a general low to negative correlation of BERT+Target. Further, we see BERT⊕T0pp-NP-T and BERT⊗T0pp-NP-T increasing the correlation - giving more attribution to target and label indicative tokens. This behavior is one reason for the bad performance of BERT+Target for these tasks. For rumor, we note a correlation increase of 45.5 for INJECT+T0pp-NP-T, which leads to a clear performance improvement of 11.7pp (Table 2). Thus, INJECT adjusts the low attribution to relevant tokens compared to BERT+Target. On the other hand, we see INJECT+T0pp-NP-T reducing the attribution for ibmcs, mtsd, and wtwt. Given the better performance of INJECT+T0pp-NP-T on ibmcs and mtsd, we conclude that INJECT can reduce potential spurious correlations in this case. For wtwt, INJECT+T0pp-NP-T reduces the correlation but has a performance loss of 0.8pp. Given the niche domain of wtwt (financial mergers and acquisitions on Twitter), identifying relevant context is more challenging using standard context sources.
Dataset characteristics We investigate which dataset characteristics are indicative of perfor-
mance improvements using INJECT. Thus, we compute the Pearson correlation of various dataset characteristics and the performance differences between the baseline and the average of the INJECT variants. Details about how we calculate dataset characteristics are provided in the Appendix A.5. The results are visualized in Figure 4. Independent of the context source, we observe beneficial improvements using INJECT if datasets
exhibit characteristics leading to performance instabilities. This is indicated by positive correlations with an increasing number of labels and label imbalance. Further, we measure text understanding difficulty using the Flesch reading-ease score (FRES) by Flesch (1948). Interestingly, INJECT can better deal with datasets exposing a high variability of FRES within their instances (meanflesch, std-flesch). These factors generally contribute to training instabilities where INJECT is more robust. This observation is confirmed by the strong positive correlation of the variance across random initializations and INJECT performance.
Robustness We investigate robustness across all benchmark datasets for the T0pp-NP-T context by visualizing the performance differences to the baseline (BERT+Target) in Figure 3a. In the case of performance improvements, INJECT consistently outperforms direct context integration. If there is no improvement for both integration ap-
proaches, the performance loss is less pronounced for INJECT with only one exception (snopes). To substantiate this finding, we contrast both context integration approaches in a scenario with both ideal context, i.e., the contextual information is guaranteed to be beneficial in predicting the correct class and random context. Our results demonstrate INJECT successfully leveraging the contextual information while not outperforming direct integration in the case of ideal context. However, when given irrelevant context, INJECT is closer to contextfree baseline performance. Details about the experiments are provided in the Appendix §A.3. In summary, we conclude that context integration is more robust regarding noisy context.

heading: 7 Conclusion
text: We propose INJECT, a dual-encoder approach to integrate contextual information for stance detection based on cross-attention. While state-of-the-art approaches perform mostly well on the datasets they have been proposed for, we evaluate our approach across a large and diverse benchmark in a crosstarget setting and observe improvements compared using three different sources for extracting contextual information. We show that the context integrated via INJECT improves stance detection and is beneficial for generalization on targets not seen during training. In future, we plan to explore more sophisticated ways of prompting large pre-trained language models for helpful context.
Ethical Considerations and Limitations
Quality of the context The performance improvement for contextual information injection is
bounded by the quality of the context source. Independently of the source in use, it is possible to introduce additional noise into the training procedure. While this is a rather generic problem, our proposed architecture seems to be better at filtering noisy context than a direct integration via appending to the input.
Quality of context source Most of the existing knowledge bases provide high-quality and curated knowledge. In contrast, when prompting a large language model for knowledge, we are also exposed to the risk that we extract the biases (e.g. false facts or stereotypical biases) that the model has learned during pretraining. In our experiments, we use the T0pp language model where biases have been reported to exist6. These biases can potentially influence the prediction performance unintendedly, especially as in many SD datasets, the annotated targets are often controversial. While investigating such effects is out of scope for this work, we consider such an evaluation inevitable before deploying our proposed model to any data outside (academic) research context.
Limitations As described in §3, our proposed approach uses two parallel encoder models (input and context). It thus requires twice as many parameters as the baseline model we compare to, thereby enforcing additional hardware demands. We consider our approach as a proof-of-concept on how to integrate contextual knowledge without amplifying a model’s exploitation of spurious correlations. We plan to make our architecture more parameter-efficient by investigating more recent approaches for parameter sharing, e.g. with the use of adapters (Houlsby et al., 2019).
Moreover, we acknowledge the strong influence of wording in prompts on the output of a language model, as has been reported in the literature (Jiang et al., 2020; Schick and Schütze, 2021). We experienced similar effects during preliminary experiments and pointed out that we did not find a one-size-fits-all solution which works equally well across the diverse set of SD benchmark datasets. Therefore, special care must be taken when extracting contextual information from large language models using prompting.
6More details at https://huggingface.co/ bigscience/T0pp?

heading: Acknowledgements
text: We thank Leonardo F. R. Ribeiro, Haritz Puerto, Nico Daheim and the anonymous ARR reviewers for their valuable feedback. This work has been funded by the German Research Foundation (DFG) as part of the Research Training Group KRITIS No. GRK 2222 and by the German Federal Ministry of Education and Research (BMBF) under the promotional reference 01UP2229B (KoPoCoV) as well as by the Hasler Foundation Grant No. 21024.

heading: A Appendix
text: A.1 Experimental Details
• All models are trained using five epochs, batch size of 16, a learning rate of 0.00002, a warmup-up ratio of 0.2 with linear scheduling, and AdamW (Loshchilov and Hutter, 2019) as optimizer. The hyperparameters tuned during training are described in the main paper (see §5.2).
• We use CUDA 11.6, Python v3.8.10, torch v1.10.0, and transformers v4.13.0 as software environment and a mixture of NVIDIA P100, V100, A100, A6000 as GPU hardware.
• We load all pretrained language models from HuggingFace model hub. In detail, we use the following model tags: bert-base-uncased for BERT, google/electra-basediscriminator for ELECTRA, and roberta-base for RoBERTa.
• We use the captum library (v0.5.0) to calculate the vector-norms for approximating tokenattributions (Kobayashi et al., 2020) in §6.3.
• We use the statsmodel library (v0.13.2) to calculate statistical significant differences using the Bhapkar test (Bhapkar, 1966) with p < 0.05.
• We use sklearn (Pedregosa et al., 2011) for computing evaluation metrics (e.g. macroF1).
• We measured the average training runtime of models on the argmin dataset as a reference. BERT+Target and BERT+ConceptNet needed 618 seconds whereas INJECT needed 400 seconds.
• We use the seeds [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].
A.2 Datasets
We provide details about the individual split proportions for the cross-target evaluation setup in Table 5. For more information on each individual dataset, we refer to Schiller et al. (2021) and Hardalov et al. (2021).
A.3 Evaluation with ideal context
To evaluate our goal of robust integration of contextual information using INJECT, we contrast both context integration approaches in a scenario with both ideal context, i.e. the contextual information is guaranteed to be beneficial in predicting the correct class, and random context. To showcase, we use the e-SNLI (Camburu et al., 2018) corpus for natural language inference and the Snopes (Hanselowski et al., 2019) corpus for claim verification. We use the provided explanations (e-SNLI, m=1) and evidences (Snopes, m=10) as ideal context, respectively. As random (but syntactically correct) context, we randomly extract sentences from the Gutenberg corpus7 included in NLTK (Bird, 2006). Table 6 compares a BERT baseline without context, BERT with context integration via concatenation (BERT⊕), and integration via INJECT (BERT⊗).
The results demonstrate INJECT successfully leveraging the contextual information while not outperforming direct integration in the case of ideal context. However, when provided with irrelevant context, INJECT is closer to the context-free baseline performance.
A.4 Identification of target-specific label correlations
We examine internal processes in the model architecture by analyzing how relevant a token is compared to how much a model attributes to the token. In detail, we calculate for the 5% most relevant tokens for target and label the correlation of this relevance and the model attribution on them.
Token Relevance We consider the probability of a token to appear in combination with a label l and target t. A higher probability indicates that a token is more likely to occur within a label-target combination.
In detail, we first calculate the relevance as the maximum log-odds-ratio r(w,(li,tj)) (Kawintiranon and Singh, 2021) over all possible combinations of labels L = {l1, ..., ln} and targets T = {t1, ..., tk} for a given token w. We define o(w,(l,t)) (Equation 1) as the probability of token t appearing in combination with label l and target t, with c(w, (l, t)) denoting the counts of w in texts with label l and target t. Next, we calculate the maximum log odds-ratio r(t,(L,T )) as in Equation 2. This tells us how specific a token w is at max. for a label-target combination.
7http://www.gutenberg.org/
o(w,(li,tj)) = c(w, (li, tj))
c(¬w, (li, tj)) (1)
r(w,(L,T )) = max (li,tj)∈L×T
log( o(w,(li,tj))
o(w,¬(li,tj)) ) (2)
Token Attributions To approximate a token’s attribution, we calculate the vector-norms (Kobayashi et al., 2020) for the output of the 12th layer.
We provide anecdotal examples in Figure 5 along with their token-level attribution of the 12th layer from (BERT, BERT+Target, BERT+CauseNet) and INJECT+CauseNet. For the first three, we use the self-attention and for the latter one the cross-attention. In the first example, INJECT+CauseNet made the right prediction while all BERT-based models failed and vice-versa for the second one. In both examples, we see lower attribution for target-specific terms like firearms or arms and higher attribution for terms with general use like besides, cause, or to. INJECT+CauseNet makes the correct prediction while BERT+Target failed due to its high attribution to firearms - an example of a spurious correlation. However, in some cases this can also lead to erroneous predictions as in the second example where INJECT+CauseNet gives less importance to the specific - and in this case important - tokens of the sentences (right to bear arms).
A.5 Dataset Characteristics In Table 7, we provide relevant dataset characteristics for each dataset in the stance detection benchmark. To compute label imbalance, we first calculate the mean and standard deviation of the number of instances per label. The label imbalance is then
defined as the division of the standard deviation by the mean.
A.6 Knowledge The information about the average length of the retrieved contextual knowledge is given in Table 8. We observe substantially longer paragraphs extracted from CauseNet which is not surprising as CauseNet consists of passages extracted from Wikipedia.
A.6.1 CauseNet We ignore concepts which are shorter than 3 characters or consist of one of the following modal verbs ("must", "shall", "will", "should", "would", "can", "could", "may", "might").
A.6.2 Prompts We manually evaluated the following prompts for both single and combination inputs. As reported in related work (Jiang et al., 2020; Schick and Schütze, 2021), the generated text is sensible to wording and punctuation in the prompt. We made similar experiences and removed all punctuation at the end of the prompt to prevent the model from generating outputs of short length.
A.7 On Efficiency of INJECT From an efficiency point-of-view, INJECTprocesses a text and corresponding contexts more efficiently than via SEP integration. This is because there is no self-attention over input and context jointly where the attention dimension is dsep = (len(input) + len(context)) × (len(input) + len(context)). For INJECT, in contrast, input and context are processed in separate encoders with attention dimensions dinput = len(input) × len(input) and dcontext = len(context) × len(context) on every layer. Just in the INJECTlayer, there are two additional attention blocks with dimensions dcross context = len(input) × len(context) and dcross input = len(context) × len(input).

heading: Future Work
text: In future, we plan to explore more sophisticated ways of prompting large pre-trained language models for helpful context. Ethical Considerations and Limitations
Quality of the context The performance improvement for contextual information injection is
bounded by the quality of the context source. Independently of the source in use, it is possible to introduce additional noise into the training procedure. While this is a rather generic problem, our proposed architecture seems to be better at filtering noisy context than a direct integration via appending to the input. Quality of context source Most of the existing knowledge bases provide high-quality and curated knowledge. In contrast, when prompting a large language model for knowledge, we are also exposed to the risk that we extract the biases (e. g. false facts or stereotypical biases) that the model has learned during pretraining. In our experiments, we use the T0pp language model where biases have been reported to exist6. These biases can potentially influence the prediction performance unintendedly, especially as in many SD datasets, the annotated targets are often controversial. While investigating such effects is out of scope for this work, we consider such an evaluation inevitable before deploying our proposed model to any data outside (academic) research context. Limitations As described in §3, our proposed approach uses two parallel encoder models (input and context). It thus requires twice as many parameters as the baseline model we compare to, thereby enforcing additional hardware demands. We consider our approach as a proof-of-concept on how to integrate contextual knowledge without amplifying a model’s exploitation of spurious correlations. We plan to make our architecture more parameter-efficient by investigating more recent approaches for parameter sharing, e. g. with the use of adapters (Houlsby et al. , 2019). Moreover, we acknowledge the strong influence of wording in prompts on the output of a language model, as has been reported in the literature (Jiang et al. , 2020; Schick and Schütze, 2021). We experienced similar effects during preliminary experiments and pointed out that we did not find a one-size-fits-all solution which works equally well across the diverse set of SD benchmark datasets. Therefore, special care must be taken when extracting contextual information from large language models using prompting. 6More details at https://huggingface. co/ bigscience/T0pp?