Add Batch 40c78fcd-0e75-40b3-b669-8e77a92a3b88
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- adaptivecontrastivedecodinginretrievalaugmentedgenerationforhandlingnoisycontexts/4d23fc91-6425-4cb3-afbc-002263991b88_content_list.json +3 -0
- adaptivecontrastivedecodinginretrievalaugmentedgenerationforhandlingnoisycontexts/4d23fc91-6425-4cb3-afbc-002263991b88_model.json +3 -0
- adaptivecontrastivedecodinginretrievalaugmentedgenerationforhandlingnoisycontexts/4d23fc91-6425-4cb3-afbc-002263991b88_origin.pdf +3 -0
- adaptivecontrastivedecodinginretrievalaugmentedgenerationforhandlingnoisycontexts/full.md +317 -0
- adaptivecontrastivedecodinginretrievalaugmentedgenerationforhandlingnoisycontexts/images.zip +3 -0
- adaptivecontrastivedecodinginretrievalaugmentedgenerationforhandlingnoisycontexts/layout.json +3 -0
- adaptivecontrastivesearchuncertaintyguideddecodingforopenendedtextgeneration/f2ecb4be-4356-4109-a5e6-9f8b0077d9ae_content_list.json +3 -0
- adaptivecontrastivesearchuncertaintyguideddecodingforopenendedtextgeneration/f2ecb4be-4356-4109-a5e6-9f8b0077d9ae_model.json +3 -0
- adaptivecontrastivesearchuncertaintyguideddecodingforopenendedtextgeneration/f2ecb4be-4356-4109-a5e6-9f8b0077d9ae_origin.pdf +3 -0
- adaptivecontrastivesearchuncertaintyguideddecodingforopenendedtextgeneration/full.md +523 -0
- adaptivecontrastivesearchuncertaintyguideddecodingforopenendedtextgeneration/images.zip +3 -0
- adaptivecontrastivesearchuncertaintyguideddecodingforopenendedtextgeneration/layout.json +3 -0
- adaptivefeaturebasedlowrankcompressionoflargelanguagemodelsviabayesianoptimization/570c3a02-efbf-4dc1-9d53-e5c7ead5e45e_content_list.json +3 -0
- adaptivefeaturebasedlowrankcompressionoflargelanguagemodelsviabayesianoptimization/570c3a02-efbf-4dc1-9d53-e5c7ead5e45e_model.json +3 -0
- adaptivefeaturebasedlowrankcompressionoflargelanguagemodelsviabayesianoptimization/570c3a02-efbf-4dc1-9d53-e5c7ead5e45e_origin.pdf +3 -0
- adaptivefeaturebasedlowrankcompressionoflargelanguagemodelsviabayesianoptimization/full.md +408 -0
- adaptivefeaturebasedlowrankcompressionoflargelanguagemodelsviabayesianoptimization/images.zip +3 -0
- adaptivefeaturebasedlowrankcompressionoflargelanguagemodelsviabayesianoptimization/layout.json +3 -0
- adaptivetokenbiaserknowledgeeditingviabiasingkeyentities/bc7526ab-04d4-4e76-9a80-6dbe78c201f6_content_list.json +3 -0
- adaptivetokenbiaserknowledgeeditingviabiasingkeyentities/bc7526ab-04d4-4e76-9a80-6dbe78c201f6_model.json +3 -0
- adaptivetokenbiaserknowledgeeditingviabiasingkeyentities/bc7526ab-04d4-4e76-9a80-6dbe78c201f6_origin.pdf +3 -0
- adaptivetokenbiaserknowledgeeditingviabiasingkeyentities/full.md +450 -0
- adaptivetokenbiaserknowledgeeditingviabiasingkeyentities/images.zip +3 -0
- adaptivetokenbiaserknowledgeeditingviabiasingkeyentities/layout.json +3 -0
- advancingcrosslingualentityalignmentwithlargelanguagemodelstailoredsamplesegmentationandzeroshotprompts/d5aecb5d-ab41-4934-b11d-ae5260ca4dac_content_list.json +3 -0
- advancingcrosslingualentityalignmentwithlargelanguagemodelstailoredsamplesegmentationandzeroshotprompts/d5aecb5d-ab41-4934-b11d-ae5260ca4dac_model.json +3 -0
- advancingcrosslingualentityalignmentwithlargelanguagemodelstailoredsamplesegmentationandzeroshotprompts/d5aecb5d-ab41-4934-b11d-ae5260ca4dac_origin.pdf +3 -0
- advancingcrosslingualentityalignmentwithlargelanguagemodelstailoredsamplesegmentationandzeroshotprompts/full.md +453 -0
- advancingcrosslingualentityalignmentwithlargelanguagemodelstailoredsamplesegmentationandzeroshotprompts/images.zip +3 -0
- advancingcrosslingualentityalignmentwithlargelanguagemodelstailoredsamplesegmentationandzeroshotprompts/layout.json +3 -0
- advancingvisionlanguagemodelswithadapterensemblestrategies/49626621-2725-4d15-81d2-2840f458f976_content_list.json +3 -0
- advancingvisionlanguagemodelswithadapterensemblestrategies/49626621-2725-4d15-81d2-2840f458f976_model.json +3 -0
- advancingvisionlanguagemodelswithadapterensemblestrategies/49626621-2725-4d15-81d2-2840f458f976_origin.pdf +3 -0
- advancingvisionlanguagemodelswithadapterensemblestrategies/full.md +628 -0
- advancingvisionlanguagemodelswithadapterensemblestrategies/images.zip +3 -0
- advancingvisionlanguagemodelswithadapterensemblestrategies/layout.json +3 -0
- adversarialattacksonpartsofspeechanempiricalstudyintexttoimagegeneration/00d22e0d-0a6f-42b1-9bb4-f9d6cea5a1f9_content_list.json +3 -0
- adversarialattacksonpartsofspeechanempiricalstudyintexttoimagegeneration/00d22e0d-0a6f-42b1-9bb4-f9d6cea5a1f9_model.json +3 -0
- adversarialattacksonpartsofspeechanempiricalstudyintexttoimagegeneration/00d22e0d-0a6f-42b1-9bb4-f9d6cea5a1f9_origin.pdf +3 -0
- adversarialattacksonpartsofspeechanempiricalstudyintexttoimagegeneration/full.md +462 -0
- adversarialattacksonpartsofspeechanempiricalstudyintexttoimagegeneration/images.zip +3 -0
- adversarialattacksonpartsofspeechanempiricalstudyintexttoimagegeneration/layout.json +3 -0
- adversarialmathwordproblemgeneration/d968ab76-b420-4619-93ae-b6a1e4ac5f39_content_list.json +3 -0
- adversarialmathwordproblemgeneration/d968ab76-b420-4619-93ae-b6a1e4ac5f39_model.json +3 -0
- adversarialmathwordproblemgeneration/d968ab76-b420-4619-93ae-b6a1e4ac5f39_origin.pdf +3 -0
- adversarialmathwordproblemgeneration/full.md +427 -0
- adversarialmathwordproblemgeneration/images.zip +3 -0
- adversarialmathwordproblemgeneration/layout.json +3 -0
- afriinstructinstructiontuningofafricanlanguagesfordiversetasks/b5c2b468-50bb-4ce9-8d25-3b475d651c30_content_list.json +3 -0
- afriinstructinstructiontuningofafricanlanguagesfordiversetasks/b5c2b468-50bb-4ce9-8d25-3b475d651c30_model.json +3 -0
adaptivecontrastivedecodinginretrievalaugmentedgenerationforhandlingnoisycontexts/4d23fc91-6425-4cb3-afbc-002263991b88_content_list.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cbfd26fcbcf9bbba371608b565bde9e0617de23e0b551f282ab1849de86fce6c
|
| 3 |
+
size 80791
|
adaptivecontrastivedecodinginretrievalaugmentedgenerationforhandlingnoisycontexts/4d23fc91-6425-4cb3-afbc-002263991b88_model.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:aa0b3eeaea442cf5aa5a0d4517a8291b20d071026d7983157596a8c01e7621d3
|
| 3 |
+
size 94190
|
adaptivecontrastivedecodinginretrievalaugmentedgenerationforhandlingnoisycontexts/4d23fc91-6425-4cb3-afbc-002263991b88_origin.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7696b33d16917e5d3fc2666bd049158895aba2a8f6edb587512d4575f2d3b7a1
|
| 3 |
+
size 420697
|
adaptivecontrastivedecodinginretrievalaugmentedgenerationforhandlingnoisycontexts/full.md
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Adaptive Contrastive Decoding in Retrieval-Augmented Generation for Handling Noisy Contexts
|
| 2 |
+
|
| 3 |
+
Youna Kim $^{1}$ , Hyuhng Joon Kim $^{1}$ , Cheonbok Park $^{2,3}$ , Choonghyun Park $^{1}$ , Hyunsoo Cho $^{4}$ , Junyeob Kim $^{1}$ , Kang Min Yoo $^{1,2,5}$ , Sang-goo Lee $^{1,6}$ , Taeuk Kim $^{7*}$
|
| 4 |
+
|
| 5 |
+
$^{1}$ Seoul National University, $^{2}$ NAVER Cloud, $^{3}$ KAIST AI, $^{4}$ Ewha Womans University,
|
| 6 |
+
|
| 7 |
+
$^{5}$ NAVER AI LAB, $^{6}$ IntelliSys, Korea, $^{7}$ Hanyang University
|
| 8 |
+
|
| 9 |
+
{anna9812, heyjoonkim, pch330, juny116, sglee} @europa.snu.ac.kr
|
| 10 |
+
|
| 11 |
+
{cbok.park, kangmin.yoo} @navercorp.com, chohyunsoo@ewha.ac.kr
|
| 12 |
+
|
| 13 |
+
kimtaeuk@hanyang.ac.kr
|
| 14 |
+
|
| 15 |
+
# Abstract
|
| 16 |
+
|
| 17 |
+
When using large language models (LLMs) in knowledge-intensive tasks, such as open-domain question answering, external context can bridge the gap between external knowledge and the LLMs' parametric knowledge. Recent research has been developed to amplify contextual knowledge over the parametric knowledge of LLMs with contrastive decoding approaches. While these approaches could yield truthful responses when relevant context is provided, they are prone to vulnerabilities when faced with noisy contexts. We extend the scope of previous studies to encompass noisy contexts and propose adaptive contrastive decoding (ACD) to leverage contextual influence effectively. ACD demonstrates improvements in open-domain question answering tasks compared to baselines, especially in robustness by remaining undistracted by noisy contexts in retrieval-augmented generation.
|
| 18 |
+
|
| 19 |
+
# 1 Introduction
|
| 20 |
+
|
| 21 |
+
While large language models (LLMs) (Touvron et al., 2023; Achiam et al., 2023) achieve remarkable performance levels across diverse benchmarks, they sometimes struggle to generalize to knowledge-intensive tasks, such as open-domain question-answering (QA; Chen et al., 2017), and may also fail to capture long-tail knowledge, leading to unfaithful output generation (Mallen et al., 2023; Kandpal et al., 2023). One common approach to address these limitations is fine-tuning the model, but this results in a quadratic rise in computational demands as the size of the LLMs increases exponentially (Longpre et al., 2023). To overcome this, researchers have been investigating strategies to combine non-parametric knowledge with LLMs during response generation without explicit re-training (Asai et al., 2023a). This approach leverages external information from knowledge
|
| 22 |
+
|
| 23 |
+

|
| 24 |
+
Figure 1: An illustration of adaptive contrastive decoding (ACD). Entropy $(H)$ changes depending on context relevance, affecting the adaptive weight $(\alpha_{\mathrm{ACD}})$ . Noisy context leads the model to incorrectly answer "Diede De Groot" when employing regular greedy decoding. ACD applies context-based adjustments, enabling the correct answer, "Sloane Stephens," despite the noise.
|
| 25 |
+
|
| 26 |
+
bases and enhances the capability of the LLMs dynamically, ensuring that the information is both current and accurate.
|
| 27 |
+
|
| 28 |
+
Early studies in this field attempt to append query-relevant context to generate more accurate responses. Especially, contrastive decoding (Li et al., 2023; Malkin et al., 2022; Liu et al., 2021) yields significant enhancement in various tasks by amplifying the influence of the given context at decoding step (Shi et al., 2023; Zhao et al., 2024). While such methods work well when context information is correct and faithful, in real-world scenarios, context information is not always correct and may contain some noisy and unfaithful information. For instance, if the retrieval system pulls in irrelevant or contradictory information, it could lead to incorrect responses (Wang et al., 2024; Wu et al., 2024; Yu et al., 2024). This highlights the necessity for a generation model that can gauge the appropriateness of the context by itself, being robust to noise
|
| 29 |
+
|
| 30 |
+
and unfaithful data to ensure the output remains reliable (Yoran et al., 2024).
|
| 31 |
+
|
| 32 |
+
To assess whether the existing contrastive decoding approaches can be utilized in practice, we extend the setting to situations where the gold-standard context is not guaranteed, specifically in the retrieval-augmented generation (RAG) framework (Yao et al., 2022; Shi et al., 2024; Izacard et al., 2023). In this paper, we demonstrate that existing context-aware contrastive decoding approaches experience performance drops in open-domain question answering, especially when the retrieved context is noisy. To address this issue, we propose adaptive contrastive decoding (ACD), adaptively weighting the contrastive contextual influence on the parametric knowledge, making it suitable for noisy context settings (Figure 1).
|
| 33 |
+
|
| 34 |
+
Incorporating the distinction between contextual and parametric knowledge, our approach aims to mitigate the dominance of potentially noisy contextual information in model output. We control contrastive contextual influence based on context's contribution to the LLM's uncertainty reduction, thereby minimizing its disruptive effect during decoding. Through in-depth experiments with three open-domain QA datasets, we demonstrate the potential of the proposed approach with increased overall performance. Moreover, ACD enhances the performance significantly on the noisy context scenario while minimizing performance degradation on the gold context scenario compared to the baselines.
|
| 35 |
+
|
| 36 |
+
# 2 Related Works
|
| 37 |
+
|
| 38 |
+
Context-Augmented Generation Approaches for context-augmented generation have been developed to enhance the model's limited parametric knowledge by providing external knowledge, enabling more factual and contextually accurate responses during inference (Zhou et al., 2023; He et al., 2024). To sufficiently incorporate the information from the context in model generation, contrastive decoding approaches are applied to overwrite the model's parametric knowledge with external knowledge (Shi et al., 2023; Zhao et al., 2024). These context-aware contrastive decoding methods to generate responses faithful to the given context show effective performance in summarization (See et al., 2017; Narayan et al., 2018), knowledge conflict (Longpre et al., 2022), and question answering with gold-standard contexts.
|
| 39 |
+
|
| 40 |
+
Robustness in RAG Frameworks While retrieval-augmented generation enables LLMs to become factual and reliable with the retrieved external knowledge, there are still concerns about incorrectly retrieved irrelevant contexts (Yoran et al., 2024). To address hallucination errors posed by irrelevant contexts, some researchers take an approach to train LLMs that can adaptively retrieve relevant context (Asai et al., 2023b; Wang et al., 2024). Another approach aims to selectively use retrieved contexts after assessing their truthfulness or relevance through context verification with prompting strategies or training untruthful context detectors (Yu et al., 2024; Zhang et al., 2024). These approaches highlight the ongoing efforts to advance the robustness and accuracy of LLMs in multiple directions to manage potentially misleading information.
|
| 41 |
+
|
| 42 |
+
# 3 Methodology
|
| 43 |
+
|
| 44 |
+
# 3.1 Problem Formulation
|
| 45 |
+
|
| 46 |
+
At decoding time step $t$ , given the input $x$ and preceding sequences $y_{< t}$ , a pretrained auto-regressive LLM $\theta$ computes the logit $\mathbf{z}_t \in \mathbb{R}^{|V|}$ , where $V$ is the vocabulary, for the $t$ -th token. In the open-domain QA task, a question $q$ serves as the input $x$ , and $\mathbf{z}_t$ relies solely on the LLM's parametric knowledge. When both $q$ and the retrieved context $c$ are provided as $x$ , the logit is denoted as $\mathbf{z}_t^c \in \mathbb{R}^{|V|}$ .
|
| 47 |
+
|
| 48 |
+
# 3.2 Contrastive Decoding
|
| 49 |
+
|
| 50 |
+
In cases where context cannot be blindly trusted, directly following the context-augmented distribution can increase the risk of being misled. Thus, we adopt the approach of adding the contextual influence, which contrasts with the LLM's parametric knowledge, to the parametric distribution $\mathbf{z}_t$ . With the contrastive decoding objective, $\mathbf{z}_t^c$ and $\mathbf{z}_t$ are ensembled to reflect the influence of external context on the LLM's parametric knowledge at each decoding step $t$ . The probability distribution $P_{\theta}(Y_t|x,y_{< t})$ is modified by weighted adjustment based on the difference between $\mathbf{z}_t^c$ and $\mathbf{z}_t$ , as represented in the following equation.
|
| 51 |
+
|
| 52 |
+
$$
|
| 53 |
+
P _ {\theta} \left(Y _ {t} \mid x, y _ {< t}\right) = \operatorname {s o f t m a x} \left(\mathbf {z} _ {t} + \alpha \left(\mathbf {z} _ {t} ^ {c} - \mathbf {z} _ {t}\right)\right) \tag {1}
|
| 54 |
+
$$
|
| 55 |
+
|
| 56 |
+
The contrastive adjustment enables the LLM to integrate external context $c$ into its prediction, leveraging the weight $\alpha$ to control the impact of $c$ on the final probability distribution.
|
| 57 |
+
|
| 58 |
+
# 3.3 Adaptive Weight on Contextual Influence
|
| 59 |
+
|
| 60 |
+
The degree to which contextual influence is incorporated into $\mathbf{z}_t$ needs to be controlled based on the provided context's informativeness. In practice, however, it is often unknown whether the context is gold or noisy. To address this, we investigate whether the model could adjust accordingly with a simple entropy-based approach.
|
| 61 |
+
|
| 62 |
+
The LLM's uncertainty is expressed with the entropy $H(Y_{t})$ of its probability distribution $P_{\theta}(Y_t|x,y_{< t})$ (Huang et al., 2023; Kuhn et al., 2023). While $H(Y_{t})$ reflects how much uncertainty the model has based on its parametric knowledge under the given question, $H(Y_{t}^{c})$ is influenced by the external knowledge within the retrieved context $c$ . Generally, when the context is added, the entropy decreases (Kendall and Gal, 2017). However, if the context is noisy, irrelevant, or provides no information to answer the given question, it may contribute to increased uncertainty instead.
|
| 63 |
+
|
| 64 |
+
Intuitively, if the retrieved context provides informative cues for answering the question, then $H(Y_{t}^{c})$ is expected to be lowered compared to $H(Y_{t})$ . Conversely, if the context is non-helpful or even confusing the model prediction, $H(Y_{t}^{c})$ in predicting the next token is likely to be higher. This scenario would be particularly evident when the model knows the answer with low $H(Y_{t})$ .
|
| 65 |
+
|
| 66 |
+
Considering the above scenarios, the motivation behind the adaptive weight $\alpha_{ACD}$ is to assign a relatively smaller weight in cases where the context increases uncertainty by being uninformative or confusing for the model in answering the given question. Thus, the value of $\alpha_{ACD}$ is set as the proportion of uncertainty contributed by $H(Y_{t})$ relative to the total uncertainty when considering both $H(Y_{t})$ and $H(Y_{t}^{c})$ :
|
| 67 |
+
|
| 68 |
+
$$
|
| 69 |
+
\alpha_ {A C D} = \frac {H \left(Y _ {t}\right)}{H \left(Y _ {t}\right) + H \left(Y _ {t} ^ {c}\right)} \tag {2}
|
| 70 |
+
$$
|
| 71 |
+
|
| 72 |
+
Under the condition where $H(Y_{t}) > H(Y_{t}^{c})$ , $\alpha_{ACD}$ value approaches to 1, indicating that when the context $c$ is provided, the uncertainty associated with predicting the next token decreases. Conversely, when $H(Y_{t}) < H(Y_{t}^{c})$ , $\alpha_{ACD}$ value approaches to 0, reflecting minimal influence from $c$ . Note that when $H(Y_{t}) = H(Y_{t}^{c})$ , $\alpha_{ACD}$ becomes 0.5, resulting in an ensemble of two distributions, $\mathbf{z}_{t}$ and $\mathbf{z}_{t}^{c}$ , with equal weighting.
|
| 73 |
+
|
| 74 |
+
With $\alpha_{ACD}$ , the vocab $v$ with maximum probability is selected as the next token under the follow
|
| 75 |
+
|
| 76 |
+
ing distribution:
|
| 77 |
+
|
| 78 |
+
$$
|
| 79 |
+
\hat {P} _ {\theta} \left(Y _ {t} \mid x, y _ {< t}\right) = \operatorname {s o f t m a x} \left(\mathbf {z} _ {t} + \alpha_ {A C D} \left(\mathbf {z} _ {t} ^ {c} - \mathbf {z} _ {t}\right)\right) \tag {3}
|
| 80 |
+
$$
|
| 81 |
+
|
| 82 |
+
Informed by $\alpha_{ACD}$ and contextual contrast, the adjustment process determines the degree to which the model's parametric knowledge is superseded, thus optimizing the assimilation of contextual information throughout decoding.
|
| 83 |
+
|
| 84 |
+
# 4 Experimental Results
|
| 85 |
+
|
| 86 |
+
# 4.1 Experimental Settings
|
| 87 |
+
|
| 88 |
+
Datasets and Models We conduct experiments on open-domain QA datasets, TriviaQA (Joshi et al., 2017), Natural Questions (NQ; Kwiatkowski et al., 2019), and PopQA (Mallen et al., 2022) with Wikipedia contexts.
|
| 89 |
+
|
| 90 |
+
We use auto-regressive language models, LLAMA2 (7B & 13B, Touvron et al., 2023), LLAMA3 $8\mathrm{B},^3$ and MISTRAL 7B (Jiang et al., 2023). Utilizing CONTRIEVER-MSMARCO (Izacard et al., 2022) as a retriever, the top-1 retrieved context is appended to each question.
|
| 91 |
+
|
| 92 |
+
Evaluation Metric Following Zhao et al. (2024), we use few-shot prompts with 5 examples. We report Exact Match (EM) as an evaluation metric, which verifies whether the generated sequences precisely match one of the candidate answers.
|
| 93 |
+
|
| 94 |
+
Baselines As fundamental baselines, regular greedy decoding has been employed in open-book $(\mathrm{Reg}_{Opn})$ and closed-book $(\mathrm{Reg}_{Cls})$ settings. We compare our method against existing context-aware contrastive decoding methods, including Context-Aware Decoding (CAD; Shi et al., 2023) and Multi-Input Contrastive Decoding (MICD; Zhao et al., 2024). MICD uses inputs with and without context, along with an additional input with adversarial context, to generate the output distribution. MICD presents two methods, referred to as $\mathrm{MICD}_F$ and $\mathrm{MICD}_D$ , which offer fixed and dynamic $\alpha$ , respectively. Similar to our approach, to leverage the burden of hyperparameter search and dependency on fixed $\alpha$ , $\mathrm{MICD}_D$ also determines $\alpha$ dynamically. In $\mathrm{MICD}_D$ , $\alpha$ is assigned as the maximum token probability with context $(\max P_{wc})$ if $\max P_{wc}$ exceeds the maximum token probability without context $(\max P_{woc})$ ; otherwise, it is calculated as $1 - \max P_{woc}$ .
|
| 95 |
+
|
| 96 |
+
<table><tr><td></td><td>Dataset (→)</td><td colspan="3">TriviaQA</td><td colspan="3">NQ</td><td colspan="3">PopQA</td></tr><tr><td>Model</td><td>Method (↓)</td><td>All</td><td>SubsetGold</td><td>SubsetNoisy</td><td>All</td><td>SubsetGold</td><td>SubsetNoisy</td><td>All</td><td>SubsetGold</td><td>SubsetNoisy</td></tr><tr><td rowspan="6">LLAMA2 7B</td><td>RegCls</td><td>59.00</td><td>-</td><td>-</td><td>25.48</td><td>-</td><td>-</td><td>28.36</td><td>-</td><td>-</td></tr><tr><td>RegOpn</td><td>60.23</td><td>87.40</td><td>33.50</td><td>31.39</td><td>61.31</td><td>12.40</td><td>38.49</td><td>81.21</td><td>7.77</td></tr><tr><td>CAD</td><td>49.02</td><td>73.69</td><td>24.75</td><td>25.57</td><td>51.61</td><td>9.05</td><td>33.70</td><td>72.18</td><td>6.03</td></tr><tr><td>MICDF</td><td>60.36</td><td>85.72</td><td>35.39</td><td>29.45</td><td>56.10</td><td>12.54</td><td>35.73</td><td>74.25</td><td>8.03</td></tr><tr><td>MICD</td><td>63.23</td><td>86.03</td><td>40.79</td><td>30.36</td><td>52.18</td><td>16.52</td><td>39.01</td><td>77.39</td><td>11.42</td></tr><tr><td>ACD</td><td>64.85</td><td>88.01</td><td>42.06</td><td>32.91</td><td>56.60</td><td>17.88</td><td>41.29</td><td>82.77</td><td>11.46</td></tr><tr><td rowspan="6">LLAMA2 13B</td><td>RegCls</td><td>63.77</td><td>-</td><td>-</td><td>30.80</td><td>-</td><td>-</td><td>32.70</td><td>-</td><td>-</td></tr><tr><td>RegOpn</td><td>62.81</td><td>88.52</td><td>37.51</td><td>33.35</td><td>62.96</td><td>14.58</td><td>40.03</td><td>83.20</td><td>8.98</td></tr><tr><td>CAD</td><td>52.62</td><td>76.78</td><td>28.85</td><td>27.87</td><td>55.96</td><td>10.05</td><td>35.86</td><td>76.38</td><td>6.71</td></tr><tr><td>MICDF</td><td>63.53</td><td>87.40</td><td>40.04</td><td>32.63</td><td>59.67</td><td>15.48</td><td>38.16</td><td>77.04</td><td>10.21</td></tr><tr><td>MICD</td><td>66.52</td><td>87.68</td><td>45.69</td><td>34.38</td><td>57.32</td><td>19.83</td><td>41.65</td><td>79.27</td><td>14.60</td></tr><tr><td>ACD</td><td>67.37</td><td>89.36</td><td>45.74</td><td>36.12</td><td>61.17</td><td>20.24</td><td>43.35</td><td>83.98</td><td>14.14</td></tr><tr><td rowspan="6">LLAMA3 8B</td><td>RegCls</td><td>61.67</td><td>-</td><td>-</td><td>28.34</td><td>-</td><td>-</td><td>32.65</td><td>-</td><td>-</td></tr><tr><td>RegOpn</td><td>61.27</td><td>86.94</td><td>36.02</td><td>33.30</td><td>63.10</td><td>14.40</td><td>39.73</td><td>82.95</td><td>8.64</td></tr><tr><td>CAD</td><td>49.70</td><td>72.45</td><td>27.31</td><td>29.17</td><td>58.39</td><td>10.64</td><td>35.86</td><td>76.82</td><td>6.40</td></tr><tr><td>MICDF</td><td>61.01</td><td>85.40</td><td>37.00</td><td>27.62</td><td>51.89</td><td>12.22</td><td>37.99</td><td>77.12</td><td>9.85</td></tr><tr><td>MICD</td><td>64.01</td><td>86.08</td><td>42.28</td><td>30.72</td><td>53.96</td><td>15.98</td><td>41.35</td><td>79.32</td><td>14.04</td></tr><tr><td>ACD</td><td>66.32</td><td>89.20</td><td>43.81</td><td>35.48</td><td>62.03</td><td>18.65</td><td>43.25</td><td>84.48</td><td>13.60</td></tr><tr><td rowspan="6">MISTRAL 8B</td><td>RegCls</td><td>63.72</td><td>-</td><td>-</td><td>29.64</td><td>-</td><td>-</td><td>29.04</td><td>-</td><td>-</td></tr><tr><td>RegOpn</td><td>60.45</td><td>86.85</td><td>34.48</td><td>32.55</td><td>64.67</td><td>12.18</td><td>38.28</td><td>81.26</td><td>7.36</td></tr><tr><td>CAD</td><td>44.69</td><td>66.89</td><td>22.85</td><td>24.10</td><td>52.25</td><td>6.25</td><td>33.93</td><td>73.95</td><td>5.15</td></tr><tr><td>MICDF</td><td>63.33</td><td>88.43</td><td>38.62</td><td>31.80</td><td>61.10</td><td>13.22</td><td>36.58</td><td>76.00</td><td>8.23</td></tr><tr><td>MICD</td><td>66.97</td><td>89.24</td><td>45.05</td><td>33.24</td><td>57.89</td><td>17.61</td><td>39.87</td><td>78.46</td><td>12.11</td></tr><tr><td>ACD</td><td>67.82</td><td>90.16</td><td>45.83</td><td>35.37</td><td>62.17</td><td>18.38</td><td>41.47</td><td>82.90</td><td>11.68</td></tr></table>
|
| 97 |
+
|
| 98 |
+
Table 1: EM accuracy of full data (All) and subsets with gold (SubsetGold) and noisy contexts (SubsetNoisy). The highest score is in **bold**, and the second-best is **underlined**.
|
| 99 |
+
|
| 100 |
+

|
| 101 |
+
Figure 2: EM accuracy of each method in LLAMA2-7B. EM of three datasets used are averaged for each subset, Unknown-gold and Known-noisy.
|
| 102 |
+
|
| 103 |
+
# 4.2 Main Results
|
| 104 |
+
|
| 105 |
+
Performance on RAG As shown in Table 1, ACD outperforms the baselines across all datasets and models within the RAG framework, particularly when considering the full test data (All). When analyzing the performance by dividing the data into two subsets based on whether the retrieved context is gold (SubsetGold) or not (SubsetNoisy), ACD achieves either the best or second-best performance. $\mathrm{MICD}_D$ demonstrates performance comparable to ACD on SubsetNoisy. However, it shows a significant drop on SubsetGold, indicating a tendency to ignore gold context while handling noisy context. It is notable that both CAD and $\mathrm{MICD}_F$ exhibit a significant drop in their performance under noisy conditions.
|
| 106 |
+
|
| 107 |
+
Performance under Parametric Knowledge We aim to analyze the model's performance across various aspects, focusing specifically on its parametric knowledge. We estimate whether the model possesses relevant parametric knowledge for a given question based on its accuracy in a closed-book setting $(\mathrm{Reg}_{Cls})$ . We consider two subsets under the following conditions: (1) Known-noisy: the model has parametric knowledge of the given question and noisy context is retrieved. (2) Unknown: the model does not have parametric knowledge of the given question and gold context is retrieved.
|
| 108 |
+
|
| 109 |
+
From Figure 2, we observe that ACD outperforms the baselines in Known-noisy. Notably, two approaches with adaptively adjusted weight, ACD and $\mathrm{MICD}_D$ , perform well in Known-noisy, while other baselines show a relative strength in Unknown-gold. However, these baselines also experience significant performance drops in Known-noisy, indicating distraction by noisy context despite correctly answering when only the question is provided. In both cases, ACD demonstrates better performance compared to $\mathrm{MICD}_D$ , overall showing a tendency towards reliability.
|
| 110 |
+
|
| 111 |
+
# 4.3 Analysis
|
| 112 |
+
|
| 113 |
+
Correlation between Adaptive Weight and Context Noisiness While other baselines rely on the fixed hyperparameter of weight $\alpha$ , ACD and
|
| 114 |
+
|
| 115 |
+
<table><tr><td></td><td>α</td><td>NQ</td><td>TriviaQA</td><td>PopQA</td></tr><tr><td rowspan="2">Max</td><td>MICD D</td><td>51.53</td><td>59.76</td><td>65.49</td></tr><tr><td>ACD</td><td>65.78</td><td>73.37</td><td>74.84</td></tr><tr><td rowspan="2">Avg.</td><td>MICD D</td><td>54.18</td><td>63.78</td><td>72.64</td></tr><tr><td>ACD</td><td>68.80</td><td>72.32</td><td>78.90</td></tr><tr><td rowspan="2">First</td><td>MICD D</td><td>53.92</td><td>62.95</td><td>68.81</td></tr><tr><td>ACD</td><td>73.27</td><td>80.45</td><td>80.08</td></tr></table>
|
| 116 |
+
|
| 117 |
+
Table 2: AUROC between $\alpha$ used in each method and the noisiness of the retrieved context.
|
| 118 |
+
|
| 119 |
+

|
| 120 |
+
Figure 3: EM accuracy on NQ-swap with contexts replacing the gold answer with a random entity span.
|
| 121 |
+
|
| 122 |
+
$\mathrm{MICD}_D$ adjust $\alpha$ during the decoding step. It depends not only on the noisiness of the retrieved context but also on whether the model's parametric knowledge contains an answer to the given question. To exclude cases that are not directly related to the analysis of how weight is adjusted based on context quality and the model's parametric knowledge, we use the same subsets, Known-noisy and Unknown-gold.
|
| 123 |
+
|
| 124 |
+
Adaptive weights $\alpha_{\mathrm{ACD}}$ and $\alpha_{\mathrm{MICD}}$ are extracted at each decoding step and analyzed across three metrics: maximum, average, and the first within the generated sequence. As an evaluation metric, the area under the receiver operator characteristic curve (AUROC) between $\alpha$ and the noisiness of the retrieved context is measured. AUROC of each $\alpha$ for LLAMA 2-7B is reported in Table 2. Under every metric and dataset, ACD demonstrates a higher AUROC compared to $\mathrm{MICD_D}$ . Aligned with our motivation, when the model is knowledgeable and presented with noisy context, $\alpha_{\mathrm{ACD}}$ tends to be lower, emphasizing greater reliance on parametric knowledge. Conversely, when the model lacks knowledge and is provided with gold context, $\alpha_{\mathrm{ACD}}$ is adjusted to prioritize reliance on the provided context.
|
| 125 |
+
|
| 126 |
+
Handling Knowledge Conflict With a knowledge conflict QA dataset, NQ-swap (Longpre et al., 2022), we verify whether the two decoding methods with dynamic weight, ACD and $\mathrm{MICD}_D$ , can
|
| 127 |
+
|
| 128 |
+

|
| 129 |
+
Figure 4: EM across alpha values ranges from 0.0 to 1.0. The dashed line indicates EM score with $\alpha_{ACD}$ .
|
| 130 |
+
|
| 131 |
+

|
| 132 |
+
|
| 133 |
+

|
| 134 |
+
|
| 135 |
+
generate context-based responses without considering a conflicting context as a noisy context. The conflicting context in the NQ-swap dataset is constructed by replacing the answer entity span in the original gold context with a random entity of the same type. Figure 3 illustrates that ACD consistently exceeds the performance of $\mathrm{MICD}_D$ across all models and achieves results comparable to open-book regular decoding. The results indicate that the ACD's approach remains effective even in settings where the context is relevant to the question but contradicts the model's parametric knowledge.
|
| 136 |
+
|
| 137 |
+
Ablation on $\alpha_{\mathrm{ACD}}$ To assess the impact of $\alpha_{\mathrm{ACD}}$ on performance, we fix the value of $\alpha$ within a range [0, 1] and examine whether employing ACD is more effective than optimizing a fixed weight. In Figure 4, it can be observed that using a fixed $\alpha$ results in degraded performance compared to ACD. Increasing the alpha value, which enhances the contextual influence on the output distribution, initially leads to a rise in the EM score. However, beyond a certain point, further increasing $\alpha$ results in a decline in the EM score. In scenarios with potential noisy context, a fixed $\alpha$ value may not ensure optimal performance. Therefore, employing an adaptive weight, $\alpha_{\mathrm{ACD}}$ , to adjust the impact of contextual knowledge based on entropy is crucial for improving overall performance.
|
| 138 |
+
|
| 139 |
+
# 5 Conclusion
|
| 140 |
+
|
| 141 |
+
In this work, we mainly tackle handling noisy contexts in open-domain QA on the RAG framework. Our proposed method, ACD, dynamically adjusts contextual influence during decoding by quantifying the model's uncertainty that is either reduced or increased by the retrieved context. Our results show that ACD improves performances across various dimensions by considering the LLM's parametric knowledge and context noisiness. These findings highlight ACD's potential to enhance the reliability of retrieval-augmented generation.
|
| 142 |
+
|
| 143 |
+
# Limitations
|
| 144 |
+
|
| 145 |
+
Similar to other contrastive decoding approaches, the inference cost of our approach is higher than the conventional greedy decoding. Specifically, while CAD incurs twice the inference cost and MICD incurs three times the cost, ACD also incurs twice the inference cost of conventional greedy decoding.
|
| 146 |
+
|
| 147 |
+
Our research is limited the base models and does not encompass chat or instruction-following models trained with reinforcement learning from human feedback (RLHF) or instruction fine-tuning (Ouyang et al., 2022; Chung et al., 2022). These aligned models often generate token distributions that vary significantly based on the presence or absence of contextual instruction or templates. For instance, an instruction-following model might start its generation with "According to the given context ..." when context is provided, while directly generating the answer in absence of context. This alignment with the provided instructions poses another challenge to be tackled when the contrastive decoding approach is utilized.
|
| 148 |
+
|
| 149 |
+
Our current focus is primarily on short-form QA tasks. Expanding to QA tasks with long-form generation will enable a wider range of applications. Under long-form QA tasks, our approach can be further developed to investigate scenarios where the context is only partially relevant to the question.
|
| 150 |
+
|
| 151 |
+
# Acknowledgement
|
| 152 |
+
|
| 153 |
+
This work was partly supported by SNU-NAVER Hyperscale AI Center and Institute of Information & communications Technology Planning & Evaluation (IITP) grant funded by the Korea government (MSIT) [NO.RS-2021-II211343, Artificial Intelligence Graduate School Program (Seoul National University), No.RS-2020-II201373, Artificial Intelligence Graduate School Program (Hanyang University), NO.RS-2021-II212068, Artificial Intelligence Innovation Hub (Artificial Intelligence Institute, Seoul National University)]
|
| 154 |
+
|
| 155 |
+
# References
|
| 156 |
+
|
| 157 |
+
Josh Achiam, Steven Adler, Sandhini Agarwal, Lama Ahmad, Ilge Akkaya, Florencia Leoni Aleman, Diogo Almeida, Janko Altenschmidt, Sam Altman, Shyamal Anadkat, et al. 2023. Gpt-4 technical report. arXiv preprint arXiv:2303.08774.
|
| 158 |
+
Akari Asai, Sewon Min, Zexuan Zhong, and Danqi Chen. 2023a. Retrieval-based language models and
|
| 159 |
+
|
| 160 |
+
applications. In Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 6: Tutorial Abstracts), pages 41-46, Toronto, Canada. Association for Computational Linguistics.
|
| 161 |
+
Akari Asai, Zeqiu Wu, Yizhong Wang, Avirup Sil, and Hannaneh Hajishirzi. 2023b. Self-rag: Learning to retrieve, generate, and critique through self-reflection. Preprint, arXiv:2310.11511.
|
| 162 |
+
Danqi Chen, Adam Fisch, Jason Weston, and Antoine Bordes. 2017. Reading Wikipedia to answer open-domain questions. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1870-1879, Vancouver, Canada. Association for Computational Linguistics.
|
| 163 |
+
Hyung Won Chung, Le Hou, Shayne Longpre, Barret Zoph, Yi Tay, William Fedus, Yunxuan Li, Xuezhi Wang, Mostafa Dehghani, Siddhartha Brahma, Albert Webson, Shixiang Shane Gu, Zhuyun Dai, Mirac Suzgun, Xinyun Chen, Aakanksha Chowdhery, Alex Castro-Ros, Marie Pellat, Kevin Robinson, Dasha Valter, Sharan Narang, Gaurav Mishra, Adams Yu, Vincent Zhao, Yanping Huang, Andrew Dai, Hongkun Yu, Slav Petrov, Ed H. Chi, Jeff Dean, Jacob Devlin, Adam Roberts, Denny Zhou, Quoc V. Le, and Jason Wei. 2022. Scaling instruction-finetuned language models. Preprint, arXiv:2210.11416.
|
| 164 |
+
Zhenyu He, Zexuan Zhong, Tianle Cai, Jason D. Lee, and Di He. 2024. Rest: Retrieval-based speculative decoding. Preprint, arXiv:2311.08252.
|
| 165 |
+
Giwon Hong, Aryo Pradipta Gema, Rohit Saxena, Xiaotang Du, Ping Nie, Yu Zhao, Laura Perez-Beltrachini, Max Ryabinin, Xuanli He, Clémentine Fourrier, and Pasquale Minervini. 2024. The hallucinations leaderboard – an open effort to measure hallucinations in large language models. Preprint, arXiv:2404.05904.
|
| 166 |
+
Yuheng Huang, Jiayang Song, Zhijie Wang, Shengming Zhao, Huaming Chen, Felix Juefei-Xu, and Lei Ma. 2023. Look before you leap: An exploratory study of uncertainty measurement for large language models. Preprint, arXiv:2307.10236.
|
| 167 |
+
Gautier Izacard, Mathilde Caron, Lucas Hosseini, Sebastian Riedel, Piotr Bojanowski, Armand Joulin, and Edouard Grave. 2022. Unsupervised dense information retrieval with contrastive learning. Preprint, arXiv:2112.09118.
|
| 168 |
+
Gautier Izacard, Patrick Lewis, Maria Lomeli, Lucas Hosseini, Fabio Petroni, Timo Schick, Jane Dwivedi-Yu, Armand Joulin, Sebastian Riedel, and Edouard Grave. 2023. Atlas: Few-shot learning with retrieval augmented language models. Journal of Machine Learning Research, 24(251):1-43.
|
| 169 |
+
Albert Q. Jiang, Alexandre Sablayrolles, Arthur Mensch, Chris Bamford, Devendra Singh Chaplot, Diego de las Casas, Florian Bressand, Gianna Lengyel, Guillaume Lample, Lucile Saulnier, Lélio Renard Lavaud,
|
| 170 |
+
|
| 171 |
+
Marie-Anne Lachaux, Pierre Stock, Teven Le Scao, Thibaut Lavril, Thomas Wang, Timothée Lacroix, and William El Sayed. 2023. Mistral 7b. Preprint, arXiv:2310.06825.
|
| 172 |
+
Mandar Joshi, Eunsol Choi, Daniel S. Weld, and Luke Zettlemoyer. 2017. Triviaqa: A large scale distantly supervised challenge dataset for reading comprehension. Preprint, arXiv:1705.03551.
|
| 173 |
+
Nikhil Kandpal, Haikang Deng, Adam Roberts, Eric Wallace, and Colin Raffel. 2023. Large language models struggle to learn long-tail knowledge. In Proceedings of the 40th International Conference on Machine Learning, volume 202 of Proceedings of Machine Learning Research, pages 15696-15707. PMLR.
|
| 174 |
+
Alex Kendall and Yarin Gal. 2017. What uncertainties do we need in bayesian deep learning for computer vision? In Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc.
|
| 175 |
+
Lorenz Kuhn, Yarin Gal, and Sebastian Farquhar. 2023. Semantic uncertainty: Linguistic invariances for uncertainty estimation in natural language generation. Preprint, arXiv:2302.09664.
|
| 176 |
+
Tom Kwiatkowski, Jennimaria Palomaki, Olivia Redfield, Michael Collins, Ankur Parikh, Chris Alberti, Danielle Epstein, Illia Polosukhin, Jacob Devlin, Kenton Lee, et al. 2019. Natural questions: a benchmark for question answering research. Transactions of the Association for Computational Linguistics, 7:453-466.
|
| 177 |
+
Xiang Lisa Li, Ari Holtzman, Daniel Fried, Percy Liang, Jason Eisner, Tatsunori Hashimoto, Luke Zettlemoyer, and Mike Lewis. 2023. Contrastive decoding: Open-ended text generation as optimization. In Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 12286-12312, Toronto, Canada. Association for Computational Linguistics.
|
| 178 |
+
Alisa Liu, Maarten Sap, Ximing Lu, Swabha Swayamdipta, Chandra Bhagavatula, Noah A. Smith, and Yejin Choi. 2021. DExperts: Decoding-time controlled text generation with experts and anti-experts. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pages 6691-6706, Online. Association for Computational Linguistics.
|
| 179 |
+
Shayne Longpre, Kartik Perisetla, Anthony Chen, Nikhil Ramesh, Chris DuBois, and Sameer Singh. 2022. Entity-based knowledge conflicts in question answering. Preprint, arXiv:2109.05052.
|
| 180 |
+
Shayne Longpre, Gregory Yauney, Emily Reif, Katherine Lee, Adam Roberts, Barret Zoph, Denny Zhou, Jason Wei, Kevin Robinson, David Mimno, and Daphne Ippolito. 2023. A pretrainer's guide to training data: Measuring the effects of data age,
|
| 181 |
+
|
| 182 |
+
domain coverage, quality, & toxicity. Preprint, arXiv:2305.13169.
|
| 183 |
+
Nikolay Malkin, Zhen Wang, and Nebojsa Jojic. 2022. Coherence boosting: When your pretrained language model is not paying enough attention. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 8214-8236, Dublin, Ireland. Association for Computational Linguistics.
|
| 184 |
+
Alex Mallen, Akari Asai, Victor Zhong, Rajarshi Das, Daniel Khashabi, and Hannaneh Hajishirzi. 2022. When not to trust language models: Investigating effectiveness of parametric and non-parametric memories. arXiv preprint arXiv:2212.10511.
|
| 185 |
+
Alex Mallen, Akari Asai, Victor Zhong, Rajarshi Das, Daniel Khashabi, and Hannaneh Hajishirzi. 2023. When not to trust language models: Investigating effectiveness of parametric and non-parametric memories. In Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 9802-9822, Toronto, Canada. Association for Computational Linguistics.
|
| 186 |
+
Shashi Narayan, Shay B. Cohen, and Mirella Lapata. 2018. Don't give me the details, just the summary! topic-aware convolutional neural networks for extreme summarization. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pages 1797-1807, Brussels, Belgium. Association for Computational Linguistics.
|
| 187 |
+
Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll L. Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, John Schulman, Jacob Hilton, Fraser Kelton, Luke Miller, Maddie Simens, Amanda Askell, Peter Welinder, Paul Christiano, Jan Leike, and Ryan Lowe. 2022. Training language models to follow instructions with human feedback. Preprint, arXiv:2203.02155.
|
| 188 |
+
Abigail See, Peter J. Liu, and Christopher D. Manning. 2017. Get to the point: Summarization with pointer-generator networks. Preprint, arXiv:1704.04368.
|
| 189 |
+
Weijia Shi, Xiaochuang Han, Mike Lewis, Yulia Tsvetkov, Luke Zettlemoyer, and Scott Wen tau Yih. 2023. Trusting your evidence: Hallucinate less with context-aware decoding. Preprint, arXiv:2305.14739.
|
| 190 |
+
Weijia Shi, Sewon Min, Maria Lomeli, Chunting Zhou, Margaret Li, Gergely Szilvasy, Rich James, Xi Victoria Lin, Noah A. Smith, Luke Zettlemoyer, Scott Yih, and Mike Lewis. 2024. In-context pretraining: Language modeling beyond document boundaries. Preprint, arXiv:2310.10638.
|
| 191 |
+
Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, Dan Bikel, Lukas Blecher, Cristian Canton Ferrer, Moya Chen, Guillem Cucurull, David Esiobu, Jude Fernandes, Jeremy Fu, Wenyin Fu, Brian Fuller,
|
| 192 |
+
|
| 193 |
+
Cynthia Gao, Vedanuj Goswami, Naman Goyal, Anthony Hartshorn, Saghar Hosseini, Rui Hou, Hakan Inan, Marcin Kardas, Viktor Kerkez, Madian Khabsa, Isabel Kloumann, Artem Korenev, Punit Singh Koura, Marie-Anne Lachaux, Thibaut Lavril, Jenya Lee, Diana Liskovich, Yinghai Lu, Yuning Mao, Xavier Martinet, Todor Mihaylov, Pushkar Mishra, Igor Molybog, Yixin Nie, Andrew Poulton, Jeremy Reizenstein, Rashi Rungta, Kalyan Saladi, Alan Schelten, Ruan Silva, Eric Michael Smith, Ranjan Subramanian, Xiaoqing Ellen Tan, Binh Tang, Ross Taylor, Adina Williams, Jian Xiang Kuan, Puxin Xu, Zheng Yan, Iliyan Zarov, Yuchen Zhang, Angela Fan, Melanie Kambadur, Sharan Narang, Aurelien Rodriguez, Robert Stojnic, Sergey Edunov, and Thomas Scialom. 2023. Llama 2: Open foundation and finetuned chat models. Preprint, arXiv:2307.09288.
|
| 194 |
+
|
| 195 |
+
Yuhao Wang, Ruiyang Ren, Junyi Li, Wayne Xin Zhao, Jing Liu, and Ji-Rong Wen. 2024. Rear: A relevance-aware retrieval-augmented framework for open-domain question answering. Preprint, arXiv:2402.17497.
|
| 196 |
+
|
| 197 |
+
Siye Wu, Jian Xie, Jiangjie Chen, Tinghui Zhu, Kai Zhang, and Yanghua Xiao. 2024. How easily do irrelevant inputs skew the responses of large language models? Preprint, arXiv:2404.03302.
|
| 198 |
+
|
| 199 |
+
Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, and Yuan Cao. 2022. React: Synergizing reasoning and acting in language models. arXiv preprint arXiv:2210.03629.
|
| 200 |
+
|
| 201 |
+
Ori Yoran, Tomer Wolfson, Ori Ram, and Jonathan Berant. 2024. Making retrieval-augmented language models robust to irrelevant context. Preprint, arXiv:2310.01558.
|
| 202 |
+
|
| 203 |
+
Tian Yu, Shaolei Zhang, and Yang Feng. 2024. Truth-aware context selection: Mitigating hallucinations of large language models being misled by untruthful contexts. Preprint, arXiv:2403.07556.
|
| 204 |
+
|
| 205 |
+
Zihan Zhang, Meng Fang, and Ling Chen. 2024. Retrievalqa: Assessing adaptive retrieval-augmented generation for short-form open-domain question answering. Preprint, arXiv:2402.16457.
|
| 206 |
+
|
| 207 |
+
Zheng Zhao, Emilio Monti, Jens Lehmann, and Haytham Assem. 2024. Enhancing contextual understanding in large language models through contrastive decoding. Preprint, arXiv:2405.02750.
|
| 208 |
+
|
| 209 |
+
Wenxuan Zhou, Sheng Zhang, Hoifung Poon, and Muhao Chen. 2023. Context-faithful prompting for large language models. In *Findings of the Association for Computational Linguistics: EMNLP* 2023, pages 14544–14556, Singapore. Association for Computational Linguistics.
|
| 210 |
+
|
| 211 |
+
Answer the following questions:
|
| 212 |
+
|
| 213 |
+
<few-shots>
|
| 214 |
+
|
| 215 |
+
Question: <question>
|
| 216 |
+
|
| 217 |
+
Answer:
|
| 218 |
+
|
| 219 |
+
Table 3: Template used in closed-book generation.
|
| 220 |
+
|
| 221 |
+
Answer the following questions:
|
| 222 |
+
|
| 223 |
+
<few-shots>
|
| 224 |
+
|
| 225 |
+
Context: <context>
|
| 226 |
+
|
| 227 |
+
Question: <question>
|
| 228 |
+
|
| 229 |
+
Answer:
|
| 230 |
+
|
| 231 |
+
Table 4: Template used in open-book generation.
|
| 232 |
+
|
| 233 |
+
# Appendix
|
| 234 |
+
|
| 235 |
+
# A Implementation Details
|
| 236 |
+
|
| 237 |
+
# A.1 Instructions
|
| 238 |
+
|
| 239 |
+
The templates we use throughout the experiment are in Table 3 and Table 4. The template used in open-book generation (Table 4) is applied to get context-augmented distribution $\mathbf{z}_t^c$ . Also, to obtain $\mathbf{z}_t$ , the template in Table 3 is used.
|
| 240 |
+
|
| 241 |
+
# A.2 Datasets
|
| 242 |
+
|
| 243 |
+
For NQ and TriviaQA, general world knowledge is required to answer the given question. In PopQA, tackling long-tailed information, less popular factual knowledge is asked. For NQ and TriviaQA, few-shot examples are adopted from train data. For PopQA, we randomly sample 5 examples with different relationship types for sample diversity. The number of test data in used is 3,610 for NQ, 11,313 for TriviaQA, and 14,262 for PopQA.
|
| 244 |
+
|
| 245 |
+
# A.3 Baselines
|
| 246 |
+
|
| 247 |
+
Baselines using regular greedy decoding are evaluated under two different settings. In the closed-book setting, only the question is provided. In the open-book setting, the retrieved context is employed. The same top-1 retrieved context is utilized for every baseline and ACD.
|
| 248 |
+
|
| 249 |
+
CAD introduces a context-aware contrastive decoding approach that employs a contrastive output distribution to accentuate discrepancies in model predictions with and without context. This
|
| 250 |
+
|
| 251 |
+
<table><tr><td></td><td>R@1</td><td>R@5</td><td>R@10</td><td>R@20</td><td>R@100</td></tr><tr><td>NQ</td><td>38.81</td><td>65.65</td><td>73.91</td><td>79.56</td><td>88.01</td></tr><tr><td>TriviaQA</td><td>49.60</td><td>71.32</td><td>76.72</td><td>80.39</td><td>85.71</td></tr><tr><td>PopQA</td><td>41.83</td><td>61.54</td><td>68.63</td><td>74.55</td><td>83.95</td></tr></table>
|
| 252 |
+
|
| 253 |
+
method effectively overrides model priors conflicting with provided context, offering significant performance enhancements in tasks requiring resolution of knowledge conflicts. MICD further enhances context grounded generation by integrating contrastive decoding with adversarial irrelevant passages. From a computational time perspective, MICD requires three times more than conventional greedy decoding, while CAD and ACD require twice as much.
|
| 254 |
+
|
| 255 |
+
MICD proposes two usage directions, referred to as $\mathrm{MICD}_F$ and $\mathrm{MICD}_D$ , which offer fixed and dynamic $\alpha$ , respectively. $\mathrm{MICD}_D$ determines $\alpha$ in use by comparing the highest token probabilities with and without given context. Throughout the experiments, fixed value of $\alpha$ is set to the value used in Zhao et al. (2024), 0.5 and 1.0 for CAD and $\mathrm{MICD}_F$ , respectively.
|
| 256 |
+
|
| 257 |
+
# A.4 Retriever Performance
|
| 258 |
+
|
| 259 |
+
To assess performance in the RAG framework, the top-1 context from top-100 contexts retrieved by CONTRIEVER-MSMARCO (Izacard et al., 2022) is utilized. Recall@100 is reported for each dataset in Table 5.
|
| 260 |
+
|
| 261 |
+
# A.5 Knowledge Conflict
|
| 262 |
+
|
| 263 |
+
For the NQ-swap dataset, we utilize the questions and entity-swapped contexts provided in Hong et al. (2024), which includes 3,650 samples. This total excludes 5 few-shot samples and those with contexts presented in a tabular format due to the limited context length. In the case of NQ-swap, each data point has a given context. Since it is a task that does not use a retriever, for MICD, we use the fixed negative context taken from the MICD as an adversarial context. MICD reports that the performance difference between fixed negative and the most distant context is negligible.
|
| 264 |
+
|
| 265 |
+
Table 5: Recall@100 performance for CONTRIEVER-MSMARCO
|
| 266 |
+
|
| 267 |
+
<table><tr><td></td><td>NQ</td><td>TriviaQA</td><td>PopQA</td></tr><tr><td colspan="4">LLAMA2-7B</td></tr><tr><td>αACD</td><td>32.91</td><td>64.85</td><td>41.29</td></tr><tr><td>αoracle</td><td>35.35 (+2.44)</td><td>65.31 (+0.46)</td><td>44.10 (+2.81)</td></tr><tr><td colspan="4">LLAMA2-13B</td></tr><tr><td>αACD</td><td>36.12</td><td>67.37</td><td>43.35</td></tr><tr><td>αoracle</td><td>38.75 (+2.63)</td><td>68.19 (+0.82)</td><td>47.01 (+3.66)</td></tr><tr><td colspan="4">LLAMA3 8B</td></tr><tr><td>αACD</td><td>35.48</td><td>66.32</td><td>43.25</td></tr><tr><td>αoracle</td><td>36.98 (+1.50)</td><td>66.10 (-0.22)</td><td>46.47 (+3.22)</td></tr><tr><td colspan="4">MISTRAL 7B</td></tr><tr><td>αACD</td><td>35.37</td><td>67.82</td><td>41.47</td></tr><tr><td>αoracle</td><td>38.37 (+3.00)</td><td>67.29 (-0.53)</td><td>44.53 (+3.06)</td></tr></table>
|
| 268 |
+
|
| 269 |
+
Table 6: EM score comparison between ACD $(\alpha_{ACD})$ and ACD with oracle alpha value $(\alpha_{oracle})$ .
|
| 270 |
+
|
| 271 |
+
# B Results
|
| 272 |
+
|
| 273 |
+
# B.1 Results on Known-noisy and Unknown-gold
|
| 274 |
+
|
| 275 |
+
For Known-noisy and Unknown-gold, the exact values of EM accuracy on each case are reported in Table 8 and Table 9, respectively.
|
| 276 |
+
|
| 277 |
+
# B.2 AUROC between Adaptive Weight and Context Noisiness
|
| 278 |
+
|
| 279 |
+
AUROC of ACD and $\mathrm{MICD}_D$ for three models not reported in Table 2 is reported in Table 10.
|
| 280 |
+
|
| 281 |
+
# C Additional Analysis
|
| 282 |
+
|
| 283 |
+
# C.1 Upper-bound of Alpha
|
| 284 |
+
|
| 285 |
+
In our approach, the parameter $\alpha$ is expected to be close to 1 when the retrieved context contains information that helps answer the given question, and close to 0 otherwise. To evaluate the upper-bound performance of ACD, we assume that we have prior knowledge of whether the context in use is gold or noisy. Under this assumption, we fix the $\alpha$ value to 1.0 if the context is gold and to 0.0 if the context is noisy.
|
| 286 |
+
|
| 287 |
+
For TriviaQA dataset, the performance of ACD is comparable to $\alpha_{oracle}$ , with less than 1 point difference (Table 6). NQ and PopQA show a difference of approximately 2-3 points, indicating that the method for calculating the $\alpha$ weight could be further enhanced in future research.
|
| 288 |
+
|
| 289 |
+
# C.2 Case Study
|
| 290 |
+
|
| 291 |
+
We conduct the case study on $\alpha_{ACD}$ , examining its value in cases of Known-noisy and Unknown-gold. Table 7 shows the generations from LLAMA2
|
| 292 |
+
|
| 293 |
+
<table><tr><td></td><td>Sample</td><td colspan="2">RegCls</td><td colspan="2">RegOpn</td><td colspan="2">ACD</td></tr><tr><td>Case</td><td></td><td>Generation</td><td>H(Yt)</td><td>Generation</td><td>H(Yct)</td><td>Generation</td><td>αACD</td></tr><tr><td rowspan="2">Known-noisy</td><td>Question: who does the voice of nala in the lion king?</td><td rowspan="2">Moira Kelly</td><td rowspan="2">2.9160</td><td rowspan="2">Whoopi Goldberg</td><td rowspan="2">5.4562</td><td rowspan="2">Moira Kelly</td><td rowspan="2">0.3483</td></tr><tr><td>Gold answer: Moira Kelly</td></tr><tr><td rowspan="2">Unknown-gold</td><td>Question: who was the actor that played ben stone on law and order?</td><td rowspan="2">Michael Tucker</td><td rowspan="2">6.6748</td><td rowspan="2">Michael Moriarty</td><td rowspan="2">1.5628</td><td rowspan="2">Michael Moriarty</td><td rowspan="2">0.8103</td></tr><tr><td>Gold answer: Michael Moriarty</td></tr></table>
|
| 294 |
+
|
| 295 |
+
7B and how the values of entropy from closed-book generation $(\mathrm{Reg}_{Cls})$ and open-book generation $(\mathrm{Reg}_{Opn})$ affect $\alpha_{ACD}$ at the first decoding time step.
|
| 296 |
+
|
| 297 |
+
In the case of Known-noisy, when the model generates the answer correctly even without the given context, the retrieved noisy context yields relatively higher entropy, resulting in $\alpha_{ACD}$ value of 0.3483. Conversely, in the case of Unknown-gold, the model's generated answer is incorrect, aligning with a relatively high entropy value of 6.6748. In this scenario, the retrieved gold context guides the model to correctly answer the question, which is reflected in a relatively lower entropy value of 1.5628. Thus, the value of $\alpha_{ACD}$ , adjusted with these entropy values, yields a relatively higher weight on the context at 0.8103.
|
| 298 |
+
|
| 299 |
+
Table 7: Case study on the value of $\alpha_{ACD}$ for Known-noisy and Unknown-gold cases in LLAMA2 7B. Each value of entropy without context $(H(Y_t))$ , entropy with context $(H(Y_t^c))$ , and $\alpha_{ACD}$ is extracted at the first decoding step $(t = 0)$ .
|
| 300 |
+
|
| 301 |
+
<table><tr><td></td><td>NQ</td><td>TriviaQA</td><td>PopQA</td></tr><tr><td colspan="4">LLAMA2-7B</td></tr><tr><td>RegOpn</td><td>45.13</td><td>68.12</td><td>33.47</td></tr><tr><td>CAD</td><td>29.22</td><td>48.91</td><td>25.97</td></tr><tr><td>MICDf</td><td>51.07</td><td>72.37</td><td>36.81</td></tr><tr><td>MICDd</td><td>72.92</td><td>86.33</td><td>56.04</td></tr><tr><td>ACD</td><td>76.72</td><td>88.79</td><td>54.58</td></tr></table>
|
| 302 |
+
|
| 303 |
+
<table><tr><td colspan="4">LLAMA2-13B</td></tr><tr><td>RegOpn</td><td>47.18</td><td>69.77</td><td>32.53</td></tr><tr><td>CAD</td><td>32.04</td><td>52.48</td><td>22.66</td></tr><tr><td>MICDF</td><td>54.17</td><td>75.05</td><td>38.55</td></tr><tr><td>MICDD</td><td>76.31</td><td>88.24</td><td>59.38</td></tr><tr><td>ACD</td><td>75.15</td><td>88.78</td><td>56.11</td></tr></table>
|
| 304 |
+
|
| 305 |
+
<table><tr><td colspan="4">LLAMA3-8B</td></tr><tr><td>RegOpn</td><td>46.20</td><td>68.50</td><td>33.39</td></tr><tr><td>CAD</td><td>32.91</td><td>50.51</td><td>23.00</td></tr><tr><td>MICDF</td><td>43.25</td><td>70.67</td><td>39.07</td></tr><tr><td>MICDD</td><td>61.18</td><td>83.70</td><td>59.80</td></tr><tr><td>ACD</td><td>64.14</td><td>86.59</td><td>56.87</td></tr></table>
|
| 306 |
+
|
| 307 |
+
<table><tr><td colspan="4">MISTRAL-7B</td></tr><tr><td>RegOpn</td><td>41.04</td><td>64.57</td><td>31.03</td></tr><tr><td>CAD</td><td>19.17</td><td>42.63</td><td>20.80</td></tr><tr><td>MICDF</td><td>48.12</td><td>71.99</td><td>36.48</td></tr><tr><td>MICDD</td><td>69.58</td><td>86.84</td><td>57.14</td></tr><tr><td>ACD</td><td>70.62</td><td>89.36</td><td>53.55</td></tr></table>
|
| 308 |
+
|
| 309 |
+
Table 8: EM accuracy of Known-noisy case.
|
| 310 |
+
|
| 311 |
+
<table><tr><td></td><td>NQ</td><td>TriviaQA</td><td>PopQA</td></tr><tr><td colspan="4">LLAMA2-7B</td></tr><tr><td>RegOpn</td><td>47.78</td><td>68.18</td><td>74.42</td></tr><tr><td>CAD</td><td>43.90</td><td>62.22</td><td>66.12</td></tr><tr><td>MICDF</td><td>40.47</td><td>61.51</td><td>64.63</td></tr><tr><td>MICD</td><td>29.82</td><td>50.43</td><td>65.17</td></tr><tr><td>ACD</td><td>36.03</td><td>57.10</td><td>73.41</td></tr><tr><td colspan="4">LLAMA2-13B</td></tr><tr><td>RegOpn</td><td>46.52</td><td>65.09</td><td>75.04</td></tr><tr><td>CAD</td><td>45.77</td><td>61.07</td><td>69.43</td></tr><tr><td>MICDF</td><td>41.79</td><td>62.03</td><td>65.85</td></tr><tr><td>MICD</td><td>30.72</td><td>47.77</td><td>64.70</td></tr><tr><td>ACD</td><td>36.19</td><td>53.98</td><td>72.38</td></tr><tr><td colspan="4">LLAMA3-8B</td></tr><tr><td>RegOpn</td><td>48.12</td><td>68.47</td><td>74.10</td></tr><tr><td>CAD</td><td>48.00</td><td>60.52</td><td>70.41</td></tr><tr><td>MICDF</td><td>38.15</td><td>61.40</td><td>65.55</td></tr><tr><td>MICD</td><td>33.33</td><td>48.45</td><td>64.81</td></tr><tr><td>ACD</td><td>41.67</td><td>61.24</td><td>72.52</td></tr><tr><td colspan="4">MISTRAL-7B</td></tr><tr><td>RegOpn</td><td>49.57</td><td>64.82</td><td>73.09</td></tr><tr><td>CAD</td><td>45.38</td><td>56.02</td><td>67.81</td></tr><tr><td>MICDF</td><td>43.28</td><td>63.59</td><td>66.58</td></tr><tr><td>MICD</td><td>32.06</td><td>54.97</td><td>66.37</td></tr><tr><td>ACD</td><td>37.73</td><td>57.70</td><td>73.03</td></tr></table>
|
| 312 |
+
|
| 313 |
+
Table 9: EM accuracy of Unknown-gold case.
|
| 314 |
+
|
| 315 |
+
<table><tr><td></td><td>α</td><td>NQ</td><td>TriviaQA</td><td>PopQA</td></tr><tr><td colspan="5">LLAMA2 13B</td></tr><tr><td>Max</td><td>MICDDACD</td><td>52.7769.24</td><td>60.0975.31</td><td>61.8474.12</td></tr><tr><td>Avg.</td><td>MICDDACD</td><td>57.8671.61</td><td>62.0073.41</td><td>71.7977.92</td></tr><tr><td>First</td><td>MICDDACD</td><td>54.8073.07</td><td>46.1377.96</td><td>68.4480.51</td></tr><tr><td colspan="5">LLAMA3 8B</td></tr><tr><td>Max</td><td>MICDDACD</td><td>50.7563.12</td><td>52.5957.82</td><td>63.7275.00</td></tr><tr><td>Avg.</td><td>MICDDACD</td><td>51.8064.08</td><td>52.8359.67</td><td>67.9975.90</td></tr><tr><td>First</td><td>MICDDACD</td><td>45.7067.48</td><td>39.0775.45</td><td>69.2180.31</td></tr><tr><td colspan="5">MISTRAL 7B</td></tr><tr><td>Max</td><td>MICDDACD</td><td>56.9871.27</td><td>64.9577.46</td><td>61.9374.11</td></tr><tr><td>Avg.</td><td>MICDDACD</td><td>63.6676.02</td><td>69.2778.20</td><td>73.8279.08</td></tr><tr><td>First</td><td>MICDDACD</td><td>56.8475.75</td><td>68.9884.11</td><td>71.7382.07</td></tr></table>
|
| 316 |
+
|
| 317 |
+
Table 10: AUROC between $\alpha$ used in each method and the noisiness of the retrieved context. The best AUROC is in bold.
|
adaptivecontrastivedecodinginretrievalaugmentedgenerationforhandlingnoisycontexts/images.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:58ee66a7db01694e343d933888aa6d5e576477dcf82754fb802edd2e17f39216
|
| 3 |
+
size 591072
|
adaptivecontrastivedecodinginretrievalaugmentedgenerationforhandlingnoisycontexts/layout.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6871e7185f955db650a5e286c9eefa8d0de69cfb427fd228a38d11fb2239a6cf
|
| 3 |
+
size 410046
|
adaptivecontrastivesearchuncertaintyguideddecodingforopenendedtextgeneration/f2ecb4be-4356-4109-a5e6-9f8b0077d9ae_content_list.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9bfac1efa18acb98ac4e8e59b680b383347ae7601492fc53e0dcdc04c3c25476
|
| 3 |
+
size 127530
|
adaptivecontrastivesearchuncertaintyguideddecodingforopenendedtextgeneration/f2ecb4be-4356-4109-a5e6-9f8b0077d9ae_model.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:74b5d38550c3235db7d0ac9a316f2f32e53e038b03838c52d94b32f1895b2d4f
|
| 3 |
+
size 149372
|
adaptivecontrastivesearchuncertaintyguideddecodingforopenendedtextgeneration/f2ecb4be-4356-4109-a5e6-9f8b0077d9ae_origin.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:63a156059e1df297beca6ccf71939174814a16658721b362b0b9dad1ba712bf6
|
| 3 |
+
size 1483488
|
adaptivecontrastivesearchuncertaintyguideddecodingforopenendedtextgeneration/full.md
ADDED
|
@@ -0,0 +1,523 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Adaptive Contrastive Search: Uncertainty-Guided Decoding for Open-Ended Text Generation
|
| 2 |
+
|
| 3 |
+
Esteban Garces Arias $^{1,2}$ , Julian Rodemann $^{1}$ , Meimingwei Li $^{1}$ , Christian Heumann $^{1}$ , Matthias Aßenmacher $^{1,2}$
|
| 4 |
+
|
| 5 |
+
$^{1}$ Department of Statistics, LMU Munich, $^{2}$ Munich Center for Machine Learning (MCML)
|
| 6 |
+
|
| 7 |
+
Correspondence: esteban.garcesarias@stat.uni-muenchen.de
|
| 8 |
+
|
| 9 |
+
# Abstract
|
| 10 |
+
|
| 11 |
+
Despite the remarkable capabilities of large language models, generating high-quality text remains a challenging task. Numerous decoding strategies—such as beam search, sampling with temperature, top- $k$ sampling, nucleus (top- $p$ ) sampling, typical decoding, contrastive decoding, and contrastive search—have been proposed to address these challenges by improving coherence, diversity, and resemblance to human-generated text. In this study, we introduce Adaptive Contrastive Search (ACS), a novel decoding strategy that extends contrastive search (CS) by incorporating an adaptive degeneration penalty informed by the model's estimated uncertainty at each generation step. ACS aims to enhance creativity and diversity while maintaining coherence to produce high-quality outputs. Extensive experiments across various model architectures, languages, and datasets demonstrate that our approach improves both creativity and coherence, underscoring its effectiveness in text-generation tasks. We release our code, datasets, and models to facilitate further research.
|
| 12 |
+
|
| 13 |
+
# 1 Introduction
|
| 14 |
+
|
| 15 |
+
The Transformer (Vaswani et al., 2017) plays a key role in various generative natural language processing (NLP) tasks, such as generating stories, completing contextual text, and dialogue systems. However, the conventional method of training these models using maximum likelihood estimation (MLE) and decoding to the most probable sequence often results in substantial shortcomings. This can lead to repetitive and uncreative outputs, also known as degenerate text.
|
| 16 |
+
|
| 17 |
+
To address this issue, previous approaches have aimed to adjust the decoding strategy by incorporating sampling from less probable vocabularies. While this helps reduce repetitiveness, it introduces the problem of semantic inconsistency (Welleck et al., 2020). The sampled text may stray from or
|
| 18 |
+
|
| 19 |
+

|
| 20 |
+
Figure 1: Visualization of the Adaptive Contrastive Search (ACS) process: A three-step procedure that uses entropy as a proxy for model uncertainty to automatically adjust contrastive search parameters.
|
| 21 |
+
|
| 22 |
+
even contradict the original context provided by a human-written prompt.
|
| 23 |
+
|
| 24 |
+
In response, contrastive search (CS, Su et al., 2022) has been introduced. It employs a fixed balance between model confidence and degeneration penalty throughout the generation process, maintaining a blend of likelihood and diversity. However, it is important to note that this fixed weighting requires hyperparameter tuning and overlooks the unique demands of each generation step, where a different balance between model confidence and degeneration penalty might be desirable and even more effective.
|
| 25 |
+
|
| 26 |
+
We address this limitation by proposing adaptive contrastive search (ACS), an adaptive approach that automatically adjusts the hyperparameters of conventional CS. This method evaluates the model's uncertainty at each generation step and adjusts the weighting of both components without the need for manual intervention. The experimental outcomes demonstrate the effectiveness of our method, as it performs well in the task of open-ended text generation across different architectures, languages, and datasets.
|
| 27 |
+
|
| 28 |
+
Contributions Our contributions can be summarized as follows:
|
| 29 |
+
|
| 30 |
+
1. We introduce an adaptive CS method based on the work by Su et al. (2022) that measures the uncertainty of the model at each time step to automatically adjust the number of candidate tokens and the degeneration penalty.
|
| 31 |
+
2. We conduct comprehensive experiments to compare our approach to various established decoding methods, such as nucleus sampling (Holtzman et al., 2019), contrastive decoding (CD, Li et al., 2023), and CS (Su et al., 2022), for open-ended text generation.
|
| 32 |
+
3. We offer new insights into MAUVE and its correlation with human judgments, highlighting the need for a more robust metric that better aligns with human preferences when evaluating decoding strategies for open-ended text generation.
|
| 33 |
+
4. Our code and datasets and results are publicly available under this link.
|
| 34 |
+
|
| 35 |
+
# 2 Related work
|
| 36 |
+
|
| 37 |
+
Decoding methods are generally categorized into two types: deterministic and stochastic.
|
| 38 |
+
|
| 39 |
+
Deterministic Methods. These approaches focus on choosing the text continuation with the highest probability according to the model's probability distribution. Prominent examples are beam search and greedy search. Recently, studies by Shao et al. (2017); Vijayakumar et al. (2018); Paulus et al. (2017); Klein et al. (2017) have demonstrated that solely maximizing the output probability frequently leads to degenerated or repetitive text sequences, a problem that has been addressed by stochastic, sampling-based methods.
|
| 40 |
+
|
| 41 |
+
Stochastic Methods. Top- $k$ , proposed by Fan et al. (2018), samples from a subset of tokens $V^{(k)}$ that represent the tokens with the higher scores in the output distribution. Alternatively, nucleus $p$ sampling (Holtzman et al., 2019) samples from the smallest subset $S$ with a total probability mass above a threshold $p$ ; specifically, $S$ is the smallest subset such that the cumulative probability for tokens in $S$ surpasses $p$ . While these methods reduce model degeneration, the inherent stochasticity can lead to semantic divergence or disconnection from the human-written prompt.
|
| 42 |
+
|
| 43 |
+
To tackle the imbalance between coherence and diversity, methods such as typical sampling (Meister et al., 2023) and CD have been developed to
|
| 44 |
+
|
| 45 |
+
produce more diverse and interesting text in open-ended settings. Typical sampling aims at generating based on the information content, which should be close to the expected information content, i.e., the conditional entropy of the model. CD, on the other hand, employs an expert language model (LM) and an amateur LM in parallel and searches for text that maximizes the difference between the expert's and the amateur's log probabilities, subject to plausibility constraints.
|
| 46 |
+
|
| 47 |
+
Our study, however, focuses on the work of Su et al. (2022), where they introduce Contrastive Search. In CS, given the prompt text $x_{<t}$ , the selection of the output token $x_{t}$ follows:
|
| 48 |
+
|
| 49 |
+
$$
|
| 50 |
+
\begin{array}{l} x_{t} = \operatorname *{arg max}_{v\in V^{(k)}}\Bigg\{(1 - \alpha)\times \underbrace{p_{\theta}(v\mid\boldsymbol{x}_{< t})}_{\text{model confidence}} - \\ \left. \alpha \times \underbrace {\left(\max \left\{s \left(h _ {v} , h _ {x _ {j}}\right) : 1 \leq j \leq t - 1 \right\}\right)} _ {\text {d e g e n e r a t i o n p e n a l t y}} \right\} \tag {1} \\ \end{array}
|
| 51 |
+
$$
|
| 52 |
+
|
| 53 |
+
where $V^{(k)}$ is the set of top- $k$ predictions from the LM's probability distribution $p_{\theta}(\cdot \mid x_{< t})$ . In Eq. (1), the first term, model confidence, is the probability of the candidate $v$ predicted by the LM. The second term, degeneration penalty, measures how discriminative is the candidate $v$ with respect to the previous context $x_{< t}$ and $s(\cdot ,\cdot)$ computes the cosine similarity between token representations. Intuitively, a larger degeneration penalty of $v$ means it is more similar to the context, therefore more likely leading to undesirable repetitions in the generated output. The hyperparameter $k\in \mathbb{N}_{>0}$ determines the number of candidate tokens to be considered, while $\alpha \in [0,1]$ regulates the importance of these two components.
|
| 54 |
+
|
| 55 |
+
Empirical results suggest different values for $\alpha$ and $k$ , depending on the task, the datasets, and the language of interest, respectively (Su et al., 2022; Su and Xu, 2022; Su and Collier, 2023). An empirical study comparing CS and CD (Su and Collier, 2023) highlights the strengths and weaknesses of both approaches. The automatic evaluation results suggest that CD performs better on MAUVE Pillutla et al. (2021), while CS excels in diversity and coherence. Additionally, through extensive human evaluations, they demonstrate that human annotators universally prefer CS over CD by substantial margins. Given the contradictory results between MAUVE and human evaluations, their analysis reveals that balancing diversity and coherence metrics better correlates with human judgments.
|
| 56 |
+
|
| 57 |
+
Further studies have extended the concept of CS to incorporate additional criteria in scoring candidates for the next token. Chen et al. (2023) investigate the effect of adding a third criterion, fidelity, beyond model confidence and degeneration penalty to enhance the coherence of the generated text. This third criterion is again weighed by a hyperparameter $\beta$ that is determined from empirical results. To the best of our knowledge, adaptive approaches based on the concept of CS have not been thoroughly explored.
|
| 58 |
+
|
| 59 |
+
# 3 Methodology
|
| 60 |
+
|
| 61 |
+
# 3.1 Incorporating Model Uncertainty
|
| 62 |
+
|
| 63 |
+
In this work, we propose an adaptive method that considers the estimated uncertainty of the model at time step $t$ to automatically control $k$ and $\alpha$ . In other words, our adaptive approach consists in modifying Eq. (1) as follows:
|
| 64 |
+
|
| 65 |
+
$$
|
| 66 |
+
\begin{array}{l} x _ {t} = \underset {v \in V ^ {(k _ {t})}} {\arg \max } \left\{(1 - \alpha_ {t}) \times \underbrace {p _ {\theta} (v \mid \boldsymbol {x} _ {< t})} _ {\text {m o d e l c o n f i d e n c e}} - \right. \\ \left. \alpha_ {t} \times \underbrace {\left(\max \left\{s \left(h _ {v} , h _ {x _ {j}}\right) : 1 \leq j \leq t - 1 \right\}\right)} _ {\text {d e g e n e r a t i o n p e n a l t y}} \right\} \tag {2} \\ \end{array}
|
| 67 |
+
$$
|
| 68 |
+
|
| 69 |
+
where
|
| 70 |
+
|
| 71 |
+
$$
|
| 72 |
+
k _ {t} = 1 0 * \frac {\exp (\delta_ {t})}{\exp (\delta_ {t}) + 1} + 5 \tag {3}
|
| 73 |
+
$$
|
| 74 |
+
|
| 75 |
+
with
|
| 76 |
+
|
| 77 |
+
$$
|
| 78 |
+
\delta_ {t} = q * \operatorname {a r c t a n h} \left(\frac {H (X) ^ {(t)} - \operatorname {m e d i a n} \left(H (X) ^ {(< t)}\right)}{\text {m a x i m u m e n t r o p y}}\right) \tag {4}
|
| 79 |
+
$$
|
| 80 |
+
|
| 81 |
+
and
|
| 82 |
+
|
| 83 |
+
$$
|
| 84 |
+
\mathrm {H} (X) ^ {(t)} = - \sum_ {x \in \mathcal {V}} p (x \mid x _ {< t}) \ln p (x \mid x _ {< t}). \tag {5}
|
| 85 |
+
$$
|
| 86 |
+
|
| 87 |
+
Once $k$ is selected, a similar procedure is followed to determine $\alpha_{t}$ :
|
| 88 |
+
|
| 89 |
+
$$
|
| 90 |
+
\alpha_ {t} = \frac {\exp (\delta_ {t , k})}{\exp (\delta_ {t , k}) + 1} \tag {6}
|
| 91 |
+
$$
|
| 92 |
+
|
| 93 |
+
$$
|
| 94 |
+
\delta_ {t, k} = q * \operatorname {a r c t a n h} \left(\frac {H (X) ^ {(t , k)} - \operatorname {m e d i a n} \left(H (X) ^ {(< t , k)}\right)}{\operatorname {m a x i m u m} \text {e n t r o p y} ^ {(k)}}\right) \tag {7}
|
| 95 |
+
$$
|
| 96 |
+
|
| 97 |
+
In other words, we follow a sequential procedure for $k_{t}$ and $\alpha_{t}$ that involves these steps:
|
| 98 |
+
|
| 99 |
+
i) Measuring uncertainty: Compute the entropy of the output distribution denoted as $H(X)^{(t)}$ .
|
| 100 |
+
ii) Centering: Subtract the median entropy of the previous prediction steps.
|
| 101 |
+
iii) Scaling: Divide by the maximum entropy. This step aims to obtain a relative measure, ensuring comparability across different vocabulary sizes.
|
| 102 |
+
iv) Computation: Pass the centered and rescaled entropy term through a sigmoid function, yielding the value of $\alpha_{t} \in (0,1)$ - or for the case of $k$ - through a rescaled sigmoid function that yields positive integer values.
|
| 103 |
+
|
| 104 |
+
The scaling term maximum entropy refers to the entropy of a uniform distribution over a finite set $x_{1},\ldots ,x_{|\mathcal{V}|}$ , where each token has an equal probability of $\frac{1}{|\mathcal{V}|}$ . Consequently, this entropy remains constant over time. For a vocabulary of size $|\mathcal{V}|$ , the maximum entropy is given by $\ln (|\mathcal{V}|)$ , analogously, the maximum entropy for the distribution of the top- $k$ tokens is given by $\ln (k)$ .
|
| 105 |
+
|
| 106 |
+
Additionally, the parameter $q$ serves as a temperature factor, influencing the range of $k$ and $\alpha$ values at each time step. Adjusting $q$ can either broaden or narrow this range: a lower temperature reduces variability, while a higher value allows for larger changes. This impact is demonstrated in Appendix A, Figures 3, 4, 5, 6, 7 and 8. However, it is important to note that our evaluation is based on a setup with no temperature (i.e., $q = 1$ ).
|
| 107 |
+
|
| 108 |
+
# 3.2 Theoretical Motivation
|
| 109 |
+
|
| 110 |
+
The general question that might arise is to why $k_{t}$ and $\alpha_{t}$ should be chosen adaptively, i.e., why there is no global $\alpha$ nor a global $k$ that is optimal at all time steps. Taking on a more statistical perspective on the problem offers an explanation: The degeneration penalty in constrastive search can be understood as a regularization term, see also (Chen et al., 2023). More precisely, we have:
|
| 111 |
+
|
| 112 |
+
Proposition 1 The degeneration penalty $\max_j\{s(h_v,h_{x_j})\}$ is a function of the penalty $||h_v - h_{x_j}||_2$ in statistical Tikhonov-regularization, if the representations $h$ are normalized.
|
| 113 |
+
|
| 114 |
+
The proof can be found in Appendix B. Classical statistical regularization aims at preventing overfitting by smoothing out the effect of the training data on the model fit. In CS, the degeneration
|
| 115 |
+
|
| 116 |
+
penalty plays a similar role: It attenuates the effect of the model on the chosen output token. Recall that we do not want to select tokens solely based on the model to prevent repetitive text generation. It is a well-known fact that optimal regularization parameters (corresponding to $k_{t}$ and $\alpha_{t}$ here) for many statistical models correspond to the signal-to-noise ratio in the data, see e.g. the work by Kimeldorf and Wahba (1970); Rao et al. (2008); Hastie et al. (2009); Fahrmeir et al. (2022). The intuition is straightforward: For a given signal, the more noise in the data, the higher the optimal regularization parameter should be chosen to prevent overfitting to the latter. This motivates our adaptive approach to CS. Instead of choosing fixed $k$ and $\alpha$ in the beginning, we choose it based on the observed variation of the object on which we want to prevent overfitting. In contrast to statistical modeling, however, this object is the model output, not the training data. We thus choose the optimal $k_{t}$ and $\alpha_{t}$ based on the variation of the model output, i.e., its estimated uncertainty measured by $\delta_{t}$ and $\delta_{(t,k)}$ , the standardized Shannon entropy. While several approaches to quantifying uncertainty exist, see Abdar et al. (2021) for an overview, we rely on the classical Shannon entropy since it is computationally efficient and tailored to measuring epistemic (reducible) predictive uncertainty, see (Hüllermeier and Waegeman, 2021, section 3.3), as required here.
|
| 117 |
+
|
| 118 |
+
# 4 Experimental Setup
|
| 119 |
+
|
| 120 |
+
In this section, we describe the metrics, datasets, baseline models, and human evaluation settings.
|
| 121 |
+
|
| 122 |
+
# 4.1 Evaluation Metrics
|
| 123 |
+
|
| 124 |
+
We follow Su and Xu (2022) and use three metrics to automatically measure the quality the generations: Diversity, MAUVE, and Coherence.
|
| 125 |
+
|
| 126 |
+
Diversity. This metric aggregates n-gram repetition rates:
|
| 127 |
+
|
| 128 |
+
$$
|
| 129 |
+
\mathrm {D I V} = \prod_ {n = 2} ^ {4} \frac {\mid \text {u n i q u e n - g r a m s} \left(\mathrm {x} _ {\text {c o n t}}\right) \mid}{\text {t o t a l n - g r a m s} \left(\mathrm {x} _ {\text {c o n t}}\right) \mid}.
|
| 130 |
+
$$
|
| 131 |
+
|
| 132 |
+
A low diversity score suggests the model suffers from repetition, and a high diversity score means the model-generated text is lexically diverse.
|
| 133 |
+
|
| 134 |
+
MAUVE. MAUVE (Pillutla et al., 2021) score measures the distribution similarity between the set of generated text and the set of gold references.
|
| 135 |
+
|
| 136 |
+
Coherence. Proposed by Su et al. (2022), the coherence metric is defined as the averaged log-likelihood of the generated text conditioned on the prompt as
|
| 137 |
+
|
| 138 |
+
$$
|
| 139 |
+
\operatorname {C O H} (\hat {\boldsymbol {x}}, \boldsymbol {x}) = \frac {1}{| \hat {\boldsymbol {x}} |} \sum_ {i = 1} ^ {| \hat {\boldsymbol {x}} |} \log p _ {\mathcal {M}} \left(\hat {\boldsymbol {x}} _ {i} \mid [ \boldsymbol {x}: \hat {\boldsymbol {x}} _ {< i} ]\right)
|
| 140 |
+
$$
|
| 141 |
+
|
| 142 |
+
where $\pmb{x}$ and $\hat{\pmb{x}}$ are the prompt and the generated text, respectively; [:] is the concatenation operation and $\mathcal{M}$ is the OPT model (2.7B) (Zhang et al., 2022).
|
| 143 |
+
|
| 144 |
+
Human Eval. In order to evaluate the quality of the generated text, we consider two critical aspects: fluency and coherence. A fluent piece of text is written in grammatical English and has a natural flow (e.g. excluding unnatural repetition or web formatting). A coherent piece of text should stay on topic with the prompt and avoid unnatural topic drift. We provide five native English speakers with 240 competing continuations (A and B) of the same prompt and ask them to rate their coherence and fluency. Definitions and instructions for the rating process are shown in Appendix C, Figure 9.
|
| 145 |
+
|
| 146 |
+
# 4.2 Datasets
|
| 147 |
+
|
| 148 |
+
Following previous studies, we evaluate our proposed method on three domains for open-ended text generation: news, Wikipedia articles, and stories. For the news domain, we use articles from Wikinews (2000 examples); for the Wikipedia domain, we use the WikiText-103 dataset (1314 examples; Merity et al., 2016); and for the story domain, we use the BookCorpus (Project Gutenberg split, 1947 examples; Zhu et al., 2015). Each of the examples contains a prompt and a gold reference i.e. human-generated continuation for evaluation purposes. We extract the prompts and decode 256 tokens for the continuations. Finally, we evaluate the generated text based on both the set of metrics (as described in Sec. 4.1) and human preferences.
|
| 149 |
+
|
| 150 |
+
# 4.3 Baselines
|
| 151 |
+
|
| 152 |
+
We compare ACS to widely used decoding methods (including deterministic and stochastic approaches): greedy search, beam search, top- $k$ sampling, nucleus sampling, typical decoding, CD, and CS with constant $\alpha = 0.6$ and two versions of $k$ : 5 and 10. We include the latter for a fair comparison: The CS generations with $k = 10$ achieve better automatic evaluation scores than those generated with
|
| 153 |
+
|
| 154 |
+

|
| 155 |
+
|
| 156 |
+

|
| 157 |
+
|
| 158 |
+

|
| 159 |
+
Figure 2: Visualization of uncertainty over time, measured by the Shannon entropy of the output distribution (first row, left). It is used to determine the value of $k$ over time (right). The second row illustrates the entropy of the top- $k$ tokens distribution, which is used to compute the value of $\alpha$ (right).
|
| 160 |
+
|
| 161 |
+

|
| 162 |
+
|
| 163 |
+
Prompt: Knowing that she would be staying in, she started by choosing a pair of fitted, soft, black slippers, the type that barely covered her feet but gave
|
| 164 |
+
|
| 165 |
+
Generated story: her a sense of comfort. As she walked to the dining room, she took a moment to admire the decor and thought about what she would do for dinner. Her family was going to be here for a few days, and she wanted to make the most of the time they had before they left.
|
| 166 |
+
|
| 167 |
+
<table><tr><td rowspan="2">Method</td><td colspan="3">Wikinews</td><td colspan="3">Wikitext</td><td colspan="3">Story</td></tr><tr><td>div.(%)↑</td><td>MAUVE(%)↑</td><td>coh.↑</td><td>div.(%)↑</td><td>MAUVE(%)↑</td><td>coh.↑</td><td>div.(%)↑</td><td>MAUVE(%)↑</td><td>coh.↑</td></tr><tr><td>Greedy Search*</td><td>3.55</td><td>13.96</td><td>-0.47</td><td>1.77</td><td>4.91</td><td>-0.41</td><td>0.86</td><td>2.65</td><td>-0.34</td></tr><tr><td>Top-k Sampling*</td><td>91.56</td><td>89.86</td><td>-2.22</td><td>87.49</td><td>81.00</td><td>-2.37</td><td>91.22</td><td>87.49</td><td>-2.45</td></tr><tr><td>Nucleus Sampling*</td><td>93.54</td><td>89.45</td><td>-2.61</td><td>92.16</td><td>86.54</td><td>-3.03</td><td>94.50</td><td>91.47</td><td>-3.02</td></tr><tr><td>Typical Sampling*</td><td>95.37</td><td>90.97</td><td>-3.26</td><td>94.82</td><td>86.07</td><td>-3.71</td><td>96.29</td><td>88.58</td><td>-3.68</td></tr><tr><td>CD*</td><td>91.57</td><td>92.20</td><td>-2.16</td><td>88.02</td><td>91.46</td><td>-2.19</td><td>86.41</td><td>93.17</td><td>-2.09</td></tr><tr><td>CS (k=5,α=0.6)</td><td>93.72</td><td>84.14</td><td>-1.39</td><td>89.35</td><td>77.97</td><td>-1.56</td><td>93.06</td><td>84.74</td><td>-1.61</td></tr><tr><td>CS (k=10,α=0.6)</td><td>96.30</td><td>87.53</td><td>-1.73</td><td>94.09</td><td>77.97</td><td>-1.93</td><td>95.46</td><td>84.96</td><td>-1.91</td></tr><tr><td>ACS (Ours, q=1)</td><td>95.22</td><td>79.45</td><td>-1.60</td><td>92.72</td><td>78.67</td><td>-1.74</td><td>93.89</td><td>80.72</td><td>-1.71</td></tr><tr><td>Bonus: DoubleExp</td><td>97.39</td><td>90.65</td><td>-2.12</td><td>96.58</td><td>84.07</td><td>-2.18</td><td>97.37</td><td>85.66</td><td>-2.16</td></tr></table>
|
| 168 |
+
|
| 169 |
+
Table 1: Automatic evaluation results: Numbers marked with * are obtained using the generated texts originally released by Li et al. (2023), CS results are taken from Su and Xu (2022). The highest scores are highlighted in bold.
|
| 170 |
+
|
| 171 |
+
$k = 5$ . Furthermore, they are more comparable to our method, centered around $k = 10$ . Further, we include an additional adaptive method: DoubleExp, which consists on an exponentiation of the argument of the sigmoid function, with the purpose of reaching values of $\alpha$ closer to 0 or 1. Our goal with this method is to exemplify discrepancies between human judgment and MAUVE. The respective human evaluation results are visualized in Table 2 and its implementation is described in Appendix F.
|
| 172 |
+
|
| 173 |
+
# 4.4 Models
|
| 174 |
+
|
| 175 |
+
We explore the relationship between model size and the effect of ACS. For this purpose, we use three
|
| 176 |
+
|
| 177 |
+
open-source autoregressive models: gpt2-x1, gpt2-large, and gpt2-medium (Radford et al., 2019).
|
| 178 |
+
|
| 179 |
+
# 5 Results
|
| 180 |
+
|
| 181 |
+
# 5.1 Automatic evaluation results
|
| 182 |
+
|
| 183 |
+
The automatic evaluation of generated stories, based on diversity, MAUVE, and coherence are presented in Table 1. We observe that CS-based approaches tend to foster diversity, while having a slighter loss of coherence, compared to other decoding methods, such as CD and Typical sampling. An additional common trait is that CS-based approaches exhibit lower MAUVE scores, where CD
|
| 184 |
+
|
| 185 |
+
<table><tr><td rowspan="2">Dataset</td><td colspan="3">Coherence</td><td colspan="3">Fluency</td></tr><tr><td>CS is better</td><td>CS and DoubleExp are similar</td><td>DoubleExp is better</td><td>CS is better</td><td>CS and DoubleExp are similar</td><td>DoubleExp is better</td></tr><tr><td>Wikinews</td><td>56%</td><td>34%</td><td>10%</td><td>32%</td><td>58%</td><td>10%</td></tr><tr><td>Wikitext</td><td>34%</td><td>46%</td><td>20%</td><td>29%</td><td>63%</td><td>8%</td></tr><tr><td>Story</td><td>49%</td><td>31%</td><td>20%</td><td>32%</td><td>58%</td><td>10%</td></tr><tr><td>All</td><td>48%</td><td>36%</td><td>16%</td><td>28%</td><td>62%</td><td>10%</td></tr></table>
|
| 186 |
+
|
| 187 |
+
<table><tr><td rowspan="2">Dataset</td><td colspan="3">Coherence</td><td colspan="3">Fluency</td></tr><tr><td>CS is better</td><td>CS and ACS are similar</td><td>ACS is better</td><td>CS is better</td><td>CS and ACS are similar</td><td>ACS is better</td></tr><tr><td>Wikinews</td><td>24%</td><td>45%</td><td>31%</td><td>16%</td><td>67%</td><td>18%</td></tr><tr><td>Wikitext</td><td>37%</td><td>28%</td><td>35%</td><td>9%</td><td>74%</td><td>18%</td></tr><tr><td>Story</td><td>41%</td><td>27%</td><td>32%</td><td>21%</td><td>59%</td><td>21%</td></tr><tr><td>All</td><td>31%</td><td>32%</td><td>37%</td><td>17%</td><td>62%</td><td>21%</td></tr></table>
|
| 188 |
+
|
| 189 |
+
Table 2: Human evaluation results for CS vs. DoubleExp (top) and CS vs. ACS (bottom) across different datasets.
|
| 190 |
+
|
| 191 |
+
<table><tr><td>Prompt</td><td>Butt criticized Donald's controls in certain situations in the game, as well as the difficulty of some levels and puzzles. Buchanan also criticized the controls, calling</td><td>div.</td><td>coh.</td></tr><tr><td>Beam</td><td>them "too easy" and "too difficult". He also criticized the game's graphics, stating that the game's graphics were "too simplistic" and "too simplistic". He also criticized the game's graphics, stating that the game's graphics were "too simplistic" and "too simplistic". He also criticized the graphics, stating that the game's graphics were "too simplistic" and "too simplistic". He also criticized the graphics, stating that the game's graphics were "...</td><td>0.02</td><td>0.605</td></tr><tr><td>Nucleus</td><td>them "offensively rudimentary". After the game was released, Buchanan wrote a number of game reviews about his review of the game, primarily summarizing what he thought the reviewers had enjoyed about it. Buchanan was pleased with how consistently these reviews awarded the game. For one, he praised the puzzles, compared them to Nos. 1 and 2 and enjoyed the construction of the artificial intelligence in the game's forms. He found no fault with the puzzles, even in those situations where they seemed repetitive. According to an Xbox Magazine review, "every time...</td><td>0.98</td><td>0.597</td></tr><tr><td>CD</td><td>them "unimpressive" and a "nightmare" of an experience to play with players unfamiliar with Tetris. On the other hand, his opinion was shared by other reviewers, and some were critical of the game's technical design for the Wii version of Tetris. In addition, Tintin's review included a quote from Roger Ebert, who said that Tetris was better than the original game due to its simplicity and ease of play. Ebert's comments were included in the game's DVD commentary, released on March 22,2010. It is unclear if any of the video commentary was taken from ...</td><td>0.98</td><td>0.626</td></tr><tr><td>CS</td><td>them "unimpressive" and a "nightmare" of an experience to play with players unfamiliar with Tetris. On the other hand, his opinion was shared by other reviewers, and some were critical of the game's technical design for the Wii version of Tetris. In addition, Tintin's review included a quote from Roger Ebert, who said that Tetris was better than the original game due to its simplicity and ease of play. Ebert's comments were included in The game's DVD commentary, released on March 22,2010. It is unclear if any of the video commentary was taken from ...</td><td>0.98</td><td>0.626</td></tr><tr><td>ACS (Ours, q=1)</td><td>them "a pain in the ass to get used to." On the other hand, his opinion was shared by other reviewers, and some were critical of the game's technical design for the Wii version of Tetris. In addition, Tintin's review included a quote from Roger Ebert, who said that Tetris was better than the original game due to its simplicity and ease of play. Ebert's comments were included in the game's DVD commentary, released on March 22,2010. It is unclear if any of the audio commentary was taken from ...</td><td>0.98</td><td>0.629</td></tr></table>
|
| 192 |
+
|
| 193 |
+
Table 3: Case Study: Beam search produces degenerative repetitions while nucleus sampling produces text with incoherent semantics w.r.t. the prefix. Contrastive methods exhibit coherent and fluent text.
|
| 194 |
+
|
| 195 |
+
excels across all three datasets. We observe that the method DoubleExp, which consists on an exponentiation of the sigmoid arguments, provides a good balance of high diversity and MAUVE, maintaining coherence values that are lower than noncontrastive methods.
|
| 196 |
+
|
| 197 |
+
# 5.2 Human evaluation
|
| 198 |
+
|
| 199 |
+
The human evaluation scores for the CS and ACS methods, as well as for CS and DoubleExp, are displayed in Table 2. It is worth mentioning that high MAUVE scores do not always align with human judgments. For instance, evaluators consis
|
| 200 |
+
|
| 201 |
+
tently show a preference for CS over DoubleExp across all datasets. Conversely, ACS is favored in terms of fluency, and AC is preferred for coherence. Nonetheless, when considering all datasets together, there is a slight overall preference for ACS compared to its non-adaptive version.
|
| 202 |
+
|
| 203 |
+
# 5.3 Qualitative examples
|
| 204 |
+
|
| 205 |
+
We present qualitative examples to illustrate the distinct characteristics of different decoding strategies. Table 3 highlights the generated text variations, while Figure 2 visualizes the behavior of key parameters such as entropy, $k$ , and $\alpha$ .
|
| 206 |
+
|
| 207 |
+
<table><tr><td rowspan="2">Method</td><td colspan="3">Wikinews</td><td colspan="3">Wikitext</td><td colspan="3">Story</td></tr><tr><td>div.(%)↑</td><td>MAUVE(%)↑</td><td>coh.↑</td><td>div.(%)↑</td><td>MAUVE(%)↑</td><td>coh.↑</td><td>div.(%)↑</td><td>MAUVE(%)↑</td><td>coh.↑</td></tr><tr><td>ACS, q = 1</td><td>95.22</td><td>79.45</td><td>-1.6</td><td>92.72</td><td>78.67</td><td>-1.74</td><td>93.89</td><td>80.72</td><td>-1.71</td></tr><tr><td>ACS, q = 2</td><td>95.03</td><td>81.66</td><td>-1.57</td><td>92.69</td><td>77.48</td><td>-1.71</td><td>93.38</td><td>80.85</td><td>-1.67</td></tr><tr><td>ACS, q = 4</td><td>95.75</td><td>83.41</td><td>-1.76</td><td>94.02</td><td>81.56</td><td>-1.87</td><td>94.97</td><td>80.14</td><td>-1.82</td></tr><tr><td>ACS, q = 8</td><td>96.92</td><td>83.10</td><td>-2.02</td><td>95.23</td><td>77.79</td><td>-2.08</td><td>96.02</td><td>82.71</td><td>-2.04</td></tr><tr><td>ACS, q = 15</td><td>97.46</td><td>83.03</td><td>-2.24</td><td>96.39</td><td>81.66</td><td>-2.25</td><td>96.66</td><td>81.44</td><td>-2.23</td></tr><tr><td>ACS, q = 20</td><td>97.78</td><td>85.01</td><td>-2.32</td><td>96.55</td><td>81.61</td><td>-2.33</td><td>96.66</td><td>80.37</td><td>-2.26</td></tr></table>
|
| 208 |
+
|
| 209 |
+
Table 4: Ablation results for diversity, MAUVE, and coherence w.r.t. to the adaptiveness enforced by temperature $q$ .
|
| 210 |
+
|
| 211 |
+
<table><tr><td>Method</td><td>sec / story↓</td><td># Tokens / sec↑</td></tr><tr><td>CS (α = 0.6, k = 10)</td><td>11.6</td><td>21.98</td></tr><tr><td>ACS (q = 1)</td><td>15.7</td><td>16.29</td></tr><tr><td>ACS (q = 2)</td><td>15.9</td><td>16.14</td></tr><tr><td>ACS (q = 8)</td><td>16.3</td><td>15.35</td></tr></table>
|
| 212 |
+
|
| 213 |
+
Table 5: Comparison of generation speed for CS and ACS with different temperatures $q \in \{1,2,8\}$ . Experiments were conducted with a GPU NVIDIA RTX 3090.
|
| 214 |
+
|
| 215 |
+
# 5.4 Ablation studies
|
| 216 |
+
|
| 217 |
+
To assess the impact of varying levels of adaptiveness, controlled by the temperature parameter, we conduct experiments for $q \in \{1$ (no temperature), $2, 4, 8, 15, 20\}$ . The results, summarized in Table 4, demonstrate the sensitivity of ACS to different values of $q$ . As expected, increasing the temperature leads to higher diversity but at the cost of reduced coherence. Moreover, we observe that in both Wikitext and Story, the MAUVE score begins to decline as the generated texts become excessively diverse and erratic.
|
| 218 |
+
|
| 219 |
+
# 5.5 Generation speed
|
| 220 |
+
|
| 221 |
+
We have measured the average generation speed across all three datasets by varying the temperature $q \in \{1, 2, 8\}$ with respect to our baseline (CS with $k = 10$ and $\alpha = 0.6$ ). A summary is presented in Table 5, showing a decrease of $35\%$ in the speed for ACS compared to CS with fixed $\alpha$ . A supplementary analysis of this for smaller values of $k$ is provided in Appendix G.
|
| 222 |
+
|
| 223 |
+
# 5.6 Application to other languages
|
| 224 |
+
|
| 225 |
+
We evaluate the performance of our approach across eight additional languages: Arabic, Bengali, German, French, Hindi, Japanese, Dutch, and Chinese. For this, we utilize pre-trained GPT-2-based architectures of various sizes, comparing the Adaptive Contrastive Search (ACS) to standard Contrastive Search (CS). The detailed results are provided in Table 6. The scores vary greatly across
|
| 226 |
+
|
| 227 |
+
languages and metrics, with particularly strong results in Bengali, French, Hindi, and Chinese. Nevertheless, a clear trend emerges: ACS, with the exception of German, consistently achieves comparable or superior MAUVE scores while maintaining a balance between coherence and diversity, outperforming its static counterpart.
|
| 228 |
+
|
| 229 |
+
# 5.7 Effect of varying model sizes
|
| 230 |
+
|
| 231 |
+
We examine the influence of model size on the quality of text generation, focusing on three different sizes: gpt2-x1 (1.50B), gpt2-large (0.76B), and gpt2-medium (0.35B). The generated outputs are evaluated across the Wikinews, Wikitext, and Story datasets. As shown in Table 7, there are marked differences in performance, particularly with gpt2-medium, where the diversity under CS is substantially diminished across all datasets. We hypothesize that this is linked to the model's isotropy, where only high values of $\alpha$ can foster diversity in the generations. A visual inspection further supports this observation, as the outputs from gpt2-medium tend to be repetitive and degenerate, resembling those produced by greedy or beam search.
|
| 232 |
+
|
| 233 |
+
# 5.8 Findings about MAUVE
|
| 234 |
+
|
| 235 |
+
Our human evaluation results, as detailed in Table 2, corroborate the findings of Su and Xu (2022). The discrepancies observed indicate that MAUVE does not consistently align with human preferences. Specifically, the DoubleExp method yields higher MAUVE values compared to CS and ACS. However, human evaluators consistently rate DoubleExp as less coherent and fluent than the CS approach with $k = 10$ and $\alpha = 0.6$ . Moreover, we identified two considerable issues related to varying the truncation length in pairwise sentence comparisons: (1) Inconsistent results that lead to different conclusions regarding the optimal decoding method, and (2) substantial differences in sample sizes, as illustrated in Appendix E, Table 8.
|
| 236 |
+
|
| 237 |
+
<table><tr><td rowspan="2">Language</td><td colspan="3">Contrastive Search</td><td colspan="3">Adaptive Contrastive Search</td><td colspan="3">Δ</td></tr><tr><td>div.(%)↑</td><td>MAUVE(%)↑</td><td>coh.↑</td><td>div.(%)↑</td><td>MAUVE(%)↑</td><td>coh.</td><td>div.(%)</td><td>MAUVE(%)</td><td>coh.</td></tr><tr><td>Arabic</td><td>89.55</td><td>70.53</td><td>-1.51</td><td>60.71</td><td>89.94</td><td>-1.23</td><td>-28.84</td><td>19.41</td><td>0.28</td></tr><tr><td>Bengali</td><td>72.48</td><td>89.87</td><td>-1.24</td><td>85.17</td><td>96.31</td><td>-1.34</td><td>12.69</td><td>6.44</td><td>-0.10</td></tr><tr><td>German</td><td>97.95</td><td>72.80</td><td>-2.16</td><td>93.04</td><td>42.82</td><td>-1.07</td><td>-4.91</td><td>-29.98</td><td>1.09</td></tr><tr><td>French</td><td>95.74</td><td>93.21</td><td>-2.27</td><td>92.49</td><td>96.41</td><td>-2.08</td><td>-3.25</td><td>3.20</td><td>0.19</td></tr><tr><td>Hindi</td><td>98.99</td><td>95.95</td><td>-1.00</td><td>98.90</td><td>92.99</td><td>-1.00</td><td>-0.09</td><td>-2.96</td><td>0.00</td></tr><tr><td>Japanese</td><td>50.47</td><td>72.69</td><td>-0.92</td><td>39.47</td><td>83.30</td><td>-1.80</td><td>-11.00</td><td>10.61</td><td>-0.88</td></tr><tr><td>Dutch</td><td>95.47</td><td>33.57</td><td>-2.96</td><td>98.03</td><td>72.32</td><td>-1.30</td><td>2.56</td><td>38.75</td><td>1.66</td></tr><tr><td>Chinese</td><td>91.42</td><td>93.28</td><td>-2.39</td><td>82.55</td><td>92.76</td><td>-2.26</td><td>-8.87</td><td>-0.52</td><td>0.13</td></tr></table>
|
| 238 |
+
|
| 239 |
+
Table 6: Comparison across different languages. Positive $\Delta$ -values indicate better performance of ACS vs CS.
|
| 240 |
+
|
| 241 |
+
<table><tr><td rowspan="2">Dataset</td><td rowspan="2">Model</td><td colspan="3">Contrastive Search</td><td colspan="3">Adaptive Contrastive Search</td><td colspan="3">Δ</td></tr><tr><td>div.(%)↑</td><td>MAUVE(%)↑</td><td>coh.↑</td><td>div.(%)↑</td><td>MAUVE(%)↑</td><td>coh.↑</td><td>div.(%)</td><td>MAUVE(%)</td><td>coh.</td></tr><tr><td rowspan="3">Wikines</td><td>gpt2-xl</td><td>93.72</td><td>88.14</td><td>-1.39</td><td>96.92</td><td>83.10</td><td>-2.02</td><td>3.20</td><td>-5.04</td><td>-0.63</td></tr><tr><td>gpt2-large</td><td>93.80</td><td>78.55</td><td>-1.44</td><td>96.55</td><td>78.84</td><td>-2.06</td><td>2.75</td><td>0.29</td><td>-0.62</td></tr><tr><td>gpt2-medium</td><td>3.66</td><td>12.86</td><td>-0.56</td><td>49.88</td><td>20.25</td><td>-6.22</td><td>46.22</td><td>7.39</td><td>-5.66</td></tr><tr><td rowspan="3">Wikitext</td><td>gpt2-xl</td><td>89.35</td><td>77.97</td><td>-1.56</td><td>95.23</td><td>77.79</td><td>-2.08</td><td>5.88</td><td>-0.18</td><td>-0.52</td></tr><tr><td>gpt2-large</td><td>89.04</td><td>73.91</td><td>-1.59</td><td>95.67</td><td>80.00</td><td>-2.11</td><td>6.63</td><td>6.09</td><td>-0.52</td></tr><tr><td>gpt2-medium</td><td>2.25</td><td>4.75</td><td>-0.47</td><td>64.13</td><td>10.91</td><td>-5.94</td><td>61.88</td><td>6.16</td><td>-5.47</td></tr><tr><td rowspan="3">Story</td><td>gpt2-xl</td><td>93.06</td><td>84.74</td><td>-1.61</td><td>96.02</td><td>82.71</td><td>-2.04</td><td>2.96</td><td>-2.03</td><td>-0.43</td></tr><tr><td>gpt2-large</td><td>90.63</td><td>81.16</td><td>-1.56</td><td>95.82</td><td>80.42</td><td>-2.05</td><td>5.19</td><td>-0.74</td><td>-0.49</td></tr><tr><td>gpt2-medium</td><td>1.22</td><td>3.08</td><td>-0.40</td><td>11.86</td><td>17.19</td><td>-6.13</td><td>10.64</td><td>14.11</td><td>-5.73</td></tr></table>
|
| 242 |
+
|
| 243 |
+
Table 7: Comparison of CS $\left( {k = {10},\alpha = {0.6}}\right)$ and ACS across different datasets and models of varying size.
|
| 244 |
+
|
| 245 |
+
# 5.9 Interpretability
|
| 246 |
+
|
| 247 |
+
We conducted additional experiments employing CS with varying values of $k$ and $\alpha$ , measuring the same automatic metrics for human-generated text and examining which combinations of hyperparameters align most closely with the gold references. In Appendix D, our analysis reveals that extreme parameter settings, such as very low values of $\alpha$ , yield very low diversity and MAUVE scores but excessively high coherence (even in combination with high values of $k$ ). Conversely, very high values of $\alpha$ lead to texts that are overly diverse and incoherent (even with moderate values of $k$ ). A desired balance emerges from these observations: moderate values of $k$ and $\alpha$ , such as $k = 10$ and $\alpha = 0.6$ , tend to approximate human references by favoring both diversity and coherence. Our experiments show that ACS frequently generates results within this range, at times favoring either higher diversity or greater coherence, as dictated by the uncertainty-guided regularization.
|
| 248 |
+
|
| 249 |
+
# 6 Discussion and Future Work
|
| 250 |
+
|
| 251 |
+
In this study, we introduce a novel approach grounded in a CS framework. It is important to note, however, that the quality of generated text ex
|
| 252 |
+
|
| 253 |
+
tends beyond just model confidence and diversity. Other factors, like informativeness, trustworthiness, and cohesion (as discussed by De Beaugrande and Dressler (1981)), contribute to the overall quality of the text. Moving forward, our aim is to expand our adaptable method to encompass these traits, thereby improving the evaluation of text quality through a more holistic approach. Furthermore, we would like to explore other criteria for the automatic selection of $k$ and $\alpha$ . A path worth exploring could be related to the ratio between generation perplexity and model perplexity, where the algorithm would penalize deviations from the model perplexity through automatic adaptation. Finally, our study has centered on a specific task: Open-ended text generation. However, the potential influence of this adaptive decoding strategy on various tasks and contexts warrants further investigation. We aim to broaden our research to evaluate its efficacy in Machine Translation and Summarization, particularly within the scope of low-resource languages, where our approach may prove beneficial in scenarios where training examples are scarce. Finally, we wish to explore the potential of our approach beyond base models and analyze the effect after SFT and strategic prompting.
|
| 254 |
+
|
| 255 |
+
# 7 Conclusion
|
| 256 |
+
|
| 257 |
+
We introduce an uncertainty-guided adaptive method aimed at enhancing the quality of open-ended text generation outputs. Our approach calculates the estimated uncertainty at each time step using Shannon entropy and leverages this measure to dynamically adjust the weighting between model confidence and the degeneration penalty, as proposed by Su et al. (2022) and Su and Xu (2022). Our experiments demonstrate that this method performs well in terms of coherence and diversity, achieving MAUVE scores comparable to existing methods. It receives high ratings from human evaluators, particularly for the fluency of its outputs. This method requires no hyperparameter tuning and utilizes computational resources similar to the non-adaptive CS. Notably, unlike CD, it does not rely on two separate models, making it more versatile and suitable for various tasks. While it introduces some latency, our comprehensive studies comparing this approach to CS highlight its robustness across multiple languages and model sizes. We encourage further research into adaptive methods for open-ended text generation and advocate for the development of new metrics that better align with human judgments to improve the evaluation of decoding strategies.
|
| 258 |
+
|
| 259 |
+
# Limitations
|
| 260 |
+
|
| 261 |
+
The proposed approach represents a potential step forward in enhancing text generation quality from language models. However, a key limitation lies in the method's narrow focus on two main objectives: model confidence and degeneration penalty. While these are critical for evaluating certain aspects of text quality, they do not fully capture the broad spectrum of desirable traits in generated text, such as informativeness, fluency, accuracy, trustworthiness, coherence, and cohesion. By not incorporating these additional factors into the decoding process, ACS may produce text that, while coherent and diverse, lacks depth or fails to effectively communicate complex or specialized information (and facts). Expanding the focus to include these dimensions could significantly improve the robustness and applicability of the method across diverse text generation tasks. Another limitation worth considering is the architectural choice of our experiments, which focuses on the family of gpt2-models, in particular in its gpt2-xl version. We plan to extend this analysis to more modern architectures, such as
|
| 262 |
+
|
| 263 |
+
Mistral 7B, (Jiang et al., 2023, 2024), Llama2 7B (Touvron et al., 2023), Llama 3.1 8B (Dubey et al., 2024), Deepseek 7B (DeepSeek-AI et al., 2024), Qwen2 (Yang et al., 2024), Falcon2 (Malartic et al., 2024).
|
| 264 |
+
|
| 265 |
+
Additionally, the application of ACS has primarily been explored in the context of text generation tasks such as language modeling and natural language understanding. Its effectiveness on other tasks, such as machine translation, summarization, or multi-modal tasks, remains largely untested. Each of these tasks poses unique challenges and requirements in terms of text diversity, context preservation, and semantic accuracy. Investigating the adaptability and performance of the approach across a broader range of tasks will be essential for its broader generalizability. Lastly, while various measures of local uncertainty have been explored in the context of ACS, such as KL divergence, variance, perplexity, and entropy, there is still much room for exploration and refinement. Further experimentation and analysis are needed to determine the optimal combination of uncertainty metrics that can reliably produce high-quality, open-ended text generation across diverse domains and languages. However, the modularity of ACS in terms of choosing the $\delta$ -functions allows for a seamless further exploration of different approaches and applications.
|
| 266 |
+
|
| 267 |
+
# Ethics Statement
|
| 268 |
+
|
| 269 |
+
We affirm that our research adheres to the ACL Ethics Policy. This work involves the use of publicly available datasets and does not include any personally identifiable information. For our human evaluation, we employed third-party evaluators, ensuring a rate of over $20 per hour. An ethical concern worth mentioning is the use of language models for text generation, which may produce harmful content, either through intentional misuse by users or unintentionally due to the training data or algorithms. We declare that there are no conflicts of interest that could potentially influence the outcomes, interpretations, or conclusions of this research. All funding sources supporting this study are acknowledged in the acknowledgments section. We have diligently documented our methodology, experiments, and results, and commit to sharing our code, data, and other relevant resources to enhance reproducibility and further advancements in the field.
|
| 270 |
+
|
| 271 |
+
# Acknowledgments
|
| 272 |
+
|
| 273 |
+
We wish to express our gratitude to Daniele Pugno and Nicolò Campagnoli for their technical support and visualizations. Matthias Aßenmacher received funding from the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) as part of BERD@NFDI, under grant number 460037581. Julian Rodemann acknowledges support by the Federal Statistical Office of Germany within the co-operation project "Machine Learning in Official Statistics" as well as by the Bavarian Institute for Digital Transformation (bidt) and the Bavarian Academy of Sciences (BAS) within a graduate scholarship.
|
| 274 |
+
|
| 275 |
+
# References
|
| 276 |
+
|
| 277 |
+
Moloud Abdar, Farhad Pourpanah, Sadiq Hussain, Dana Rezazadegan, Li Liu, Mohammad Ghavamzadeh, Paul Fieguth, Xiaochun Cao, Abbas Khosravi, U Rajendra Acharya, et al. 2021. A review of uncertainty quantification in deep learning: Techniques, applications and challenges. Information fusion, 76:243-297.
|
| 278 |
+
Rie Kubota Ando and Tong Zhang. 2005. A framework for learning predictive structures from multiple tasks and unlabeled data. Journal of Machine Learning Research, 6:1817-1853.
|
| 279 |
+
Galen Andrew and Jianfeng Gao. 2007. Scalable training of L1-regularized log-linear models. In Proceedings of the 24th International Conference on Machine Learning, pages 33-40.
|
| 280 |
+
Wei-Lin Chen, Cheng-Kuang Wu, Hsin-Hsi Chen, and Chung-Chi Chen. 2023. Fidelity-enriched contrastive search: Reconciling the faithfulness-diversity trade-off in text generation. arXiv preprint arXiv:2310.14981.
|
| 281 |
+
Robert-Alain De Beaugrande and Wolfgang U Dressler. 1981. Introduction to text linguistics, volume 1. longman London.
|
| 282 |
+
DeepSeek-AI, : Xiao Bi, Deli Chen, Guanting Chen, Shanhuang Chen, Damai Dai, Chengqi Deng, Honghui Ding, Kai Dong, Qiushi Du, Zhe Fu, Huazuo Gao, Kaige Gao, Wenjun Gao, Ruiqi Ge, Kang Guan, Daya Guo, Jianzhong Guo, Guangbo Hao, Zhewen Hao, Ying He, Wenjie Hu, Panpan Huang, Erhang Li, Guowei Li, Jiashi Li, Yao Li, Y. K. Li, Wenfeng Liang, Fangyun Lin, A. X. Liu, Bo Liu, Wen Liu, Xiaodong Liu, Xin Liu, Yiyuan Liu, Haoyu Lu, Shanghai Lu, Fuli Luo, Shirong Ma, Xiaotao Nie, Tian Pei, Yishi Piao, Junjie Qiu, Hui Qu, Tongzheng Ren, Zehui Ren, Chong Ruan, Zhangli Sha, Zhihong Shao, Junxiao Song, Xuecheng Su, Jingxiang Sun, Yaofeng Sun, Minghui Tang, Bingxuan Wang, Peiyi Wang, Shiyu Wang, Yaohui Wang
|
| 283 |
+
|
| 284 |
+
Yongji Wang, Tong Wu, Y. Wu, Xin Xie, Zhenda Xie, Ziwei Xie, Yiliang Xiong, Hanwei Xu, R. X. Xu, Yanhong Xu, Dejian Yang, Yuxiang You, Shuiping Yu, Xingkai Yu, B. Zhang, Haowei Zhang, Lecong Zhang, Liyue Zhang, Mingchuan Zhang, Minghua Zhang, Wentao Zhang, Yichao Zhang, Chenggang Zhao, Yao Zhao, Shangyan Zhou, Shunfeng Zhou, Qihao Zhu, and Yuheng Zou. 2024. Deepseek llm: Scaling open-source language models with longtermism. Preprint, arXiv:2401.02954.
|
| 285 |
+
|
| 286 |
+
Abhimanyu Dubey, Abhinav Jauhri, Abhinav Pandey, Abhishek Kadian, Ahmad Al-Dahle, Aiesha Letman, Akhil Mathur, Alan Schelten, Amy Yang, Angela Fan, Anirudh Goyal, Anthony Hartshorn, Aobo Yang, Archi Mitra, Archie Sravankumar, Artem Korenev, Arthur Hinsvark, Arun Rao, Aston Zhang, Aurelien Rodriguez, Austen Gregerson, Ava Spataru, Baptiste Roziere, Bethany Biron, Binh Tang, Bobbie Chern, Charlotte Caucheteux, Chaya Nayak, Chloe Bi, Chris Marra, Chris McConnell, Christian Keller, Christophe Touret, Chunyang Wu, Corinne Wong, Cristian Canton Ferrer, Cyrus Nikolaidis, Damien Allonsius, Daniel Song, Danielle Pintz, Danny Livshits, David Esiobu, Dhruv Choudhary, Dhruv Mahajan, Diego Garcia-Olano, Diego Perino, Dieuwke Hupkes, Egor Lakomkin, Ehab AlBadawy, Elina Lobanova, Emily Dinan, Eric Michael Smith, Filip Radenovic, Frank Zhang, Gabriel Synnaeve, Gabrielle Lee, Georgia Lewis Anderson, Graeme Nail, Gregoire Mialon, Guan Pang, Guillem Cucurell, Hailey Nguyen, Hannah Korevaar, Hu Xu, Hugo Touvron, Iliyan Zarov, Imanol Arrieta Ibarra, Isabel Kloumann, Ishan Misra, Ivan Evtimov, Jade Copet, Jaewon Lee, Jan Geffert, Jana Vranes, Jason Park, Jay Mahadeokar, Jeet Shah, Jelmer van der Linde, Jennifer Billock, Jenny Hong, Jenya Lee, Jeremy Fu, Jianfeng Chi, Jianyu Huang, Jiawen Liu, Jie Wang, Jiecao Yu, Joanna Bitton, Joe Spisak, Jongsoo Park, Joseph Rocca, Joshua Johnstun, Joshua Saxe, Junteng Jia, Kalyan Vasuden Alwala, Kartikeya Upasani, Kate Plawiak, Ke Li, Kenneth Heafield, Kevin Stone, Khalid El-Arini, Krithika Iyer, Kshitiz Malik, Kuenley Chiu, Kunal Bhalla, Lauren Rantala-Yeary, Laurens van der Maaten, Lawrence Chen, Liang Tan, Liz Jenkins, Louis Martin Lovish Madaan Lubo Malo Lukas Blecher Lukas Landzaat Luke de Oliveira Madeline Muzzi Mahesh Pasupuleti Mannat Singh Manohar Paluri Marcin Kardas Mathew Oldham Mathieu Rita Maya Pavlova Melanie Kambadur Mike Lewis Min Si Mitesh Kumar Singh Mona Hassan Naman Goyal Narjes Torabi Nikolay Bashlykov,Nikolay Bogoychev,Niladri Chatterji,Olivier Duchenne Onur Celebi Patrick Alrassy Pengchuan Zhang,Pengwei Li Petar Vasic Peter Weng Prajjwal Bhargava Pratik Dubal Praveen Krishnan Punit Singh Koura Puxin Xu Qing He Qingxiao Dong Ragavan Srinivasan Raj Ganapathy Ramon Calderer Ricardo Silveira Cabral Robert Stojnic Roberta Raileanu Rohit Girdhar Rohit Patel Romain SauvestreRonnie Polidoro Roshan Sumbaly Ross Taylor Ruan Silva Rui Hou Rui Wang Saghar Hosseini,Sahana Chennabasappa Sanjay Singh Sean Bell Seohyun Sonia KimSergey Edunov
|
| 287 |
+
|
| 288 |
+
Shaoliang Nie, Sharan Narang, Sharath Rarapthy, Sheng Shen, Shengye Wan, Shruti Bhosale, Shun Zhang, Simon Vandenhende, Soumya Batra, Spencer Whitman, Sten Sootla, Stephane Collot, Suchin Gururangan, Sydney Borodinsky, Tamar Herman, Tara Fowler, Tarek Sheasha, Thomas Georgiou, Thomas Scialom, Tobias Speckbacher, Todor Mihaylov, Tong Xiao, Ujjwal Karn, Vedanuj Goswami, Vibhor Gupta, Vignesh Ramanathan, Viktor Kerkez, Vincent Gonguet, Virginie Do, Vish Vogeti, Vladan Petrovic, Weiwei Chu, Wenhan Xiong, Wenyin Fu, Whitney Meers, Xavier Martinet, Xiaodong Wang, Xiaqing Ellen Tan, Xinfeng Xie, Xuchao Jia, Xuewei Wang, Yaelle Goldschlag, Yashesh Gaur, Yasmine Babaei, Yi Wen, Yiwen Song, Yuchen Zhang, Yue Li, Yuning Mao, Zacharie Delpierre Coudert, Zheng Yan, Zhengxing Chen, Zoe Papakipos, Aaditya Singh, Aaron Grattafori, Abha Jain, Adam Kelsey, Adam Shajnfeld, Adithya Gangidi, Adolfo Victoria, Ahuva Goldstand, Ajay Menon, Ajay Sharma, Alex Boesenberg, Alex Vaughan, Alexei Baevski, Allie Feinstein, Amanda Kallet, Amit Sangani, Anam Yunus, Andrei Lupu, Andres Alvarado, Andrew Caples, Andrew Gu, Andrew Ho, Andrew Poulton, Andrew Ryan, Ankit Ramchandani, Annie Franco, Aparajita Saraf, Arkabandhu Chowdhury, Ashley Gabriel, Ashwin Bharambe, Assaf Eisenman, Azadeh Yazdan, Beau James, Ben Maurer, Benjamin Leonhardi, Bernie Huang, Beth Loyd, Beto De Paola, Bhargavi Paranjape, Bing Liu, Bo Wu, Boyu Ni, Braden Hancock, Bram Wasti, Brandon Spence, Brani Stojkovic, Brian Gamido, Britt Montalvo, Carl Parker, Carly Burton, Catalina Mejia, Changhan Wang, Changkyu Kim, Chao Zhou, Chester Hu, Ching-Hsiang Chu, Chris Cai, Chris Tindal, Christoph Feichtenhofer, Damon Civin, Dana Beatty, Daniel Kreymer, Daniel Li Danny Wyatt David Adkins David Xu Davide Testuggine Delia David Devi Parikh Diana Liskovich Didem Foss Dingkang Wang Duc Le,Dustin Holland Edward Dowling Eissa Jamil Elaine Montgomery,Eleonora Presani Emily Hahn Emily Wood Erik Brinkman Esteban Arcaute Evan Dunbar Evan Smothers,Fei Sun Felix Kreuk Feng Tian Firat Ozgenel Francesco Caggioni Francisco Guzmán Frank Kanayet Frank Seide,Gabriela Medina Florez,Gabriella Schwarz,Gada Badeer Georgia Swee Gil Halpern Govind Thattai Grant Herman Grigory Sizov Guangyi,ZhangGuna Lakshminarayanan Hamid Shojanazeri Han Zou Hannah Wang Hanwen Zha Haroun Habeeb Harrison Rudolph Helen Suk Henry Aspegren Hunter Goldman Ibrahim Damlaj Igor Molybog Igor Tufanov Irina-Elena Veliche Itai Gat Jake WeissmanJames Geboski James Kohli Japhet Asher Jean-Baptiste Gaya Jeff MarcusJeff Tang Jennifer Chan Jenny Zhen Jeremy Reizenstein Jeremy Teboul Jessica Zhong Jian Jin Jingyi Yang Joe Cummings Jon Carvill Jon Shepard Jonathan McPhie Jonathan Torres Josh Ginsburg Junjie Wang Kai Wu Kam Hou U,Karan Saxena Karthik Prasad Kartikay Khandelwal Katayoun Zand Kathy Matosich Kaushik Veeraraghavan Kelly Michelena Keqian Li Kun HuangKunal Chawla Kushal Lavhotia Kyle Huang Lailin Chen Laksha Y Garg Lavender A Leandro
|
| 289 |
+
|
| 290 |
+
Silva, Lee Bell, Lei Zhang, Liangpeng Guo, Licheng Yu, Liron Moshkovich, Luca Wehrstedt, Madian Khabsa, Manav Avalani, Manish Bhatt, Maria Tsimpoukelli, Martynas Mankus, Matan Hasson, Matthew Lennie, Matthias Reso, Maxim Groshev, Maxim Naumov, Maya Lathi, Meghan Keneally, Michael L. Seltzer, Michal Valko, Michelle Restrepo, Mihir Patel, Mik Vyatskov, Mikayel Samvelyan, Mike Clark, Mike Macey, Mike Wang, Miquel Jubert Hermoso, Mo Metanat, Mohammad Rastegari, Munish Bansal, Nandhini Santhanam, Natascha Parks, Natasha White, Navyata Bawa, Nayan Singhal, Nick Egebo, Nicolas Usunier, Nikolay Pavlovich Laptev, Ning Dong, Ning Zhang, Norman Cheng, Oleg Chernoguz, Olivia Hart, Omkar Salpekar, Ozlem Kalinli, Parkin Kent, Parth Parekh, Paul Saab, Pavan Balaji, Pedro Rittner, Philip Bontrager, Pierre Roux, Piotr Dollar, Polina Zvyagina, Prashant Ratanchandani, Pritish Yuvraj, Qian Liang, Rachad Alao, Rachel Rodriguez, Rafi Ayub, Ragbotham Murthy, Raghu Nayani, Rahul Mitra, Raymond Li, Rebekkah Hogan, Robin Battey, Rocky Wang, Rohan Maheswari, Russ Howes, Rudy Rinott, Sai Jayesh Bondu, Samyak Datta, Sara Chugh, Sara Hunt, Sargun Dhillon, Sasha Sidorov, Satadru Pan, Saurabh Verma, Seiji Yamamoto, Sharadh Ramaswamy, Shaun Lindsay, Shaun Lindsay, Sheng Feng, Shenghao Lin, Shengxin Cindy Zha, Shiva Shankar, Shuqiang Zhang, Shuqiang Zhang, Sinong Wang, Sneha Agarwal, Soji Sajuyigbe, Soumith Chintala, Stephanie Max, Stephen Chen, Steve Kehoe, Steve Satterfield, Sudarshan Govindaprasad, Sumit Gupta, Sungmin Cho, Sunny Virk, Suraj Subramanian, Sy Choudhury, Sydney Goldman, Tal Remez, Tamar Glaser, Tamara Best, Thilo Kohler, Thomas Robinson, Tianhe Li, Tianjun Zhang, Tim Matthews, Timothy Chou, Tzook Shaked, Varun Vontimitta, Victoria Ajayi, Victoria Montanez, Vijai Mohan, Vinay Satish Kumar, Vishal Mangla, Vitor Albiero, Vlad Ionescu, Vlad Poenaru, Vlad Tiberiu Mihalescu, Vladimir Ivanov, Wei Li, Wenchen Wang, Wenwen Jiang, Wes Bouaziz, Will Constable, Xiaocheng Tang, Xiaofang Wang, Xiaojian Wu, Xiaolan Wang, Xide Xia, Xilun Wu, Xinbo Gao, Yanjun Chen, Ye Hu, Ye Jia, Ye Qi, Yenda Li, Yilin Zhang, Ying Zhang, Yossi Adi, Youngjin Nam. Yu Wang. Yuchen Hao. Yundi Qian. Yuzi He. Zach Rait. Zachary DeVito. Zef Rosnbrick. Zhaoduo Wen. Zhenyu Yang. and Zhiwei Zhao. 2024. The llama 3 herd of models. Preprint. arXiv:2407.21783.
|
| 291 |
+
|
| 292 |
+
Ludwig Fahrmeir, Thomas Kneib, Stefan Lang, and Brian D Marx. 2022. Regression models. In *Regression: Models, methods and applications*, pages 23-84. Springer.
|
| 293 |
+
|
| 294 |
+
Angela Fan, Mike Lewis, and Yann Dauphin. 2018. Hierarchical neural story generation. Preprint, arXiv:1805.04833.
|
| 295 |
+
|
| 296 |
+
Trevor Hastie, Robert Tibshirani, Jerome H Friedman, and Jerome H Friedman. 2009. The elements of statistical learning: data mining, inference, and prediction, volume 2. Springer.
|
| 297 |
+
|
| 298 |
+
Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, and
|
| 299 |
+
|
| 300 |
+
Yejin Choi. 2019. The curious case of neural text degeneration. arXiv preprint arXiv:1904.09751.
|
| 301 |
+
Eyke Hüllermeier and Willem Waegeman. 2021. Aleatoric and epistemic uncertainty in machine learning: An introduction to concepts and methods. Machine learning, 110(3):457-506.
|
| 302 |
+
Albert Q. Jiang, Alexandre Sablayrolles, Arthur Mensch, Chris Bamford, Devendra Singh Chaplot, Diego de las Casas, Florian Bressand, Gianna Lengyel, Guillaume Lample, Lucile Saulnier, Lélio Renard Lavaud, Marie-Anne Lachaux, Pierre Stock, Teven Le Scao, Thibaut Lavril, Thomas Wang, Timothée Lacroix, and William El Sayed. 2023, 2024. Mistral 7b. Preprint, arXiv:2310.06825.
|
| 303 |
+
George S Kimeldorf and Grace Wahba. 1970. A correspondence between bayesian estimation on stochastic processes and smoothing by splines. The Annals of Mathematical Statistics, 41(2):495-502.
|
| 304 |
+
Guillaume Klein, Yoon Kim, Yuntian Deng, Jean Senellart, and Alexander M. Rush. 2017. Opennmt: Open-source toolkit for neural machine translation. Preprint, arXiv:1701.02810.
|
| 305 |
+
Xiang Lisa Li, Ari Holtzman, Daniel Fried, Percy Liang, Jason Eisner, Tatsunori Hashimoto, Luke Zettlemoyer, and Mike Lewis. 2023. Contrastive decoding: Open-ended text generation as optimization. Preprint, arXiv:2210.15097.
|
| 306 |
+
Quentin Malartic, Nilabhra Roy Chowdhury, Ruxandra Cojocaru, Mugariya Farooq, Giulia Campesan, Yasser Abdelaziz Dahou Djilali, Sanath Narayan, Ankit Singh, Maksim Velikanov, Basma El Amel Boussaha, Mohammed Al-Yafeai, Hamza Alobeidli, Leen Al Qadi, Mohamed El Amine Seddik, Kirill Fedyanin, Reda Alami, and Hakim Hacid. 2024. Falcon2-11b technical report. Preprint, arXiv:2407.14885.
|
| 307 |
+
Clara Meister, Tiago Pimentel, Gian Wihar, and Ryan Cotterell. 2023. Locally typical sampling. Preprint, arXiv:2202.00666.
|
| 308 |
+
Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. 2016. Pointer sentinel mixture models. Preprint, arXiv:1609.07843.
|
| 309 |
+
Romain Paulus, Caiming Xiong, and Richard Socher. 2017. A deep reinforced model for abstractive summarization. Preprint, arXiv:1705.04304.
|
| 310 |
+
Krishna Pillutla, Swabha Swayamdipta, Rowan Zellers, John Thickstun, Sean Welleck, Yejin Choi, and Zaid Harchaoui. 2021. Mauve: Measuring the gap between neural text and human text using divergence frontiers. Advances in Neural Information Processing Systems, 34:4816-4828.
|
| 311 |
+
Alec Radford, Jeff Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. 2019. Language models are unsupervised multitask learners.
|
| 312 |
+
|
| 313 |
+
C Radhakrishna Rao, H Toutenburg, Shalabh, and C Heumann. 2008. Linear models and generalizations: Least squares and alternatives, volume 3.
|
| 314 |
+
Mohammad Sadegh Rasooli and Joel R. Tetreault. 2015. Yara parser: A fast and accurate dependency parser. Computing Research Repository, arXiv:1503.06733. Version 2.
|
| 315 |
+
Louis Shao, Stephan Gouws, Denny Britz, Anna Goldie, Brian Strope, and Ray Kurzweil. 2017. Generating high-quality and informative conversation responses with sequence-to-sequence models. Preprint, arXiv:1701.03185.
|
| 316 |
+
Yixuan Su and Nigel Collier. 2023. Contrastive search is what you need for neural text generation. Preprint, arXiv:2210.14140.
|
| 317 |
+
Yixuan Su, Tian Lan, Yan Wang, Dani Yogatama, Lingpeng Kong, and Nigel Collier. 2022. A contrastive framework for neural text generation. *Preprint*, arXiv:2202.06417.
|
| 318 |
+
Yixuan Su and Jialu Xu. 2022. An empirical study on contrastive search and contrastive decoding for open-ended text generation. Preprint, arXiv:2211.10797.
|
| 319 |
+
Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, Dan Bikel, Lukas Blecher, Cristian Canton Ferrer, Moya Chen, Guillem Cucurull, David Esiobu, Jude Fernandes, Jeremy Fu, Wenyin Fu, Brian Fuller, Cynthia Gao, Vedanuj Goswami, Naman Goyal, Anthony Hartshorn, Saghar Hosseini, Rui Hou, Hakan Inan, Marcin Kardas, Viktor Kerkez, Madian Khabsa, Isabel Kloumann, Artem Korenev, Punit Singh Koura, Marie-Anne Lachaux, Thibaut Lavril, Jenya Lee, Diana Liskovich, Yinghai Lu, Yuning Mao, Xavier Martinez, Todor Mihaylov, Pushkar Mishra, Igor Molybog, Yixin Nie, Andrew Poulton, Jeremy Reizenstein, Rashi Rungta, Kalyan Saladi, Alan Schelten, Ruan Silva, Eric Michael Smith, Ranjan Subramanian, Xiaoqing Ellen Tan, Binh Tang, Ross Taylor, Adina Williams, Jian Xiang Kuan, Puxin Xu, Zheng Yan, Iliyan Zarov, Yuchen Zhang, Angela Fan, Melanie Kambadur, Sharan Narang, Aurelien Rodriguez, Robert Stojnic, Sergey Edunov, and Thomas Scialom. 2023. Llama 2: Open foundation and finetuned chat models. Preprint, arXiv:2307.09288.
|
| 320 |
+
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. 2017. Attention is all you need. Advances in neural information processing systems, 30.
|
| 321 |
+
Ashwin K Vijayakumar, Michael Cogswell, Ramprasath R. Selvaraju, Qing Sun, Stefan Lee, David Crandall, and Dhruv Batra. 2018. Diverse beam search: Decoding diverse solutions from neural sequence models. Preprint, arXiv:1610.02424.
|
| 322 |
+
Sean Welleck, Ilia Kulikov, Jaedeok Kim, Richard Yuanzhe Pang, and Kyunghyun Cho.
|
| 323 |
+
|
| 324 |
+
2020. Consistency of a recurrent language model with respect to incomplete decoding. Preprint, arXiv:2002.02492.
|
| 325 |
+
An Yang, Baosong Yang, Binyuan Hui, Bo Zheng, Bowen Yu, Chang Zhou, Chengpeng Li, Chengyuan Li, Dayiheng Liu, Fei Huang, Guanting Dong, Haoran Wei, Huan Lin, Jialong Tang, Jialin Wang, Jian Yang, Jianhong Tu, Jianwei Zhang, Jianxin Ma, Jianxin Yang, Jin Xu, Jingren Zhou, Jinze Bai, Jinzheng He, Junyang Lin, Kai Dang, Keming Lu, Keqin Chen, Kexin Yang, Mei Li, Mingfeng Xue, Na Ni, Pei Zhang, Peng Wang, Ru Peng, Rui Men, Ruize Gao, Runji Lin, Shijie Wang, Shuai Bai, Sinan Tan, Tianhang Zhu, Tianhao Li, Tianyu Liu, Wenbin Ge, Xiaodong Deng, Xiaohuan Zhou, Xingzhang Ren, Xinyu Zhang, Xipin Wei, Xuancheng Ren, Xuejing Liu, Yang Fan, Yang Yao, Yichang Zhang, Yu Wan, Yunfei Chu, Yuqiong Liu, Zeyu Cui, Zhenru Zhang, Zhifang Guo, and Zhihao Fan. 2024. Qwen2 technical report. Preprint, arXiv:2407.10671.
|
| 326 |
+
Susan Zhang, Stephen Roller, Naman Goyal, Mikel Artetxe, Moya Chen, Shuohui Chen, Christopher Dewan, Mona Diab, Xian Li, Xi Victoria Lin, Todor Mihaylov, Myle Ott, Sam Shleifer, Kurt Shuster, Daniel Simig, Punit Singh Koura, Anjali Sridhar, Tianlu Wang, and Luke Zettlemoyer. 2022. Opt: Open pre-trained transformer language models. Preprint, arXiv:2205.01068.
|
| 327 |
+
Yukun Zhu, Ryan Kiros, Richard Zemel, Ruslan Salakhutdinov, Raquel Urtasun, Antonio Torralba, and Sanja Fidler. 2015. Aligning books and movies: Towards story-like visual explanations by watching movies and reading books. Preprint, arXiv:1506.06724.
|
| 328 |
+
|
| 329 |
+
# Appendix
|
| 330 |
+
|
| 331 |
+
# A Example Generations
|
| 332 |
+
|
| 333 |
+

|
| 334 |
+
|
| 335 |
+

|
| 336 |
+
|
| 337 |
+

|
| 338 |
+
Figure 3: Decoding behavior over time from a Wikinews prompt, $q = 1$ .
|
| 339 |
+
|
| 340 |
+
Prompt: Two French journalists kidnapped on Wednesday north-east of the capital Kabul are believed to be in good health, although the condition of their three Afghan assistants is unknown.
|
| 341 |
+
|
| 342 |
+
Generated story: France's foreign ministry said in a statement on Thursday that the three had been "kidnapped by armed individuals who took them from their hotel in Herat province at gunpoint". Afghan President Ashraf Ghani's spokesman Aimal Faizi said a helicopter had been sent to pick up the journalists and they were on their way to Bagram airbase in the north-centre of the country. Ghani, who took office in September, has faced criticism for failing to make progress in a war that has claimed more than 2,000 lives since US-led forces overthrew the Taliban in 2001. The United Nations Assistance Mission in Afghanistan (Unama) said this week that security in the country had deteriorated, with attacks on aid workers and foreign military convoys on the rise. Last month, Taliban fighters ambushed a convoy of UN peace-keepers in Kunduz province, killing at least 15 people and wounding more than 30. (FRANCE 24 with AFP)
|
| 343 |
+
|
| 344 |
+

|
| 345 |
+
|
| 346 |
+

|
| 347 |
+
|
| 348 |
+

|
| 349 |
+
Figure 4: Decoding behavior over time from a Wikinews prompt, $q = 8$ .
|
| 350 |
+
|
| 351 |
+
Prompt: Two French journalists kidnapped on Wednesday north-east of the capital Kabul are believed to be in good health, although the condition of their three Afghan assistants is unknown.
|
| 352 |
+
|
| 353 |
+
Generated story: Journalistically and militarily dependent Pakistan has a policy of not taking sides in the Afghan conflict, but its relations with Kabul have frayed to the point where there is no confidence at all on the part of the Kabul government to co-operate with Islamabad. Afghan President Hamid Karzai last week cancelled a high-level visit to the United States in protest at Washington's refusal to hand over Bin Laden on humanitarian grounds. Bin Laden escaped from Tora Bora four years ago by flying across the Hindu Kush mountains of Central Asia with help from al-Qaeda-linked guerrillas known as the Haqqani network. Since then his hideout has been under watch by U.S. Special Forces who have set up a command centre close to the Afghanistan-Pakistan border for intelligence, surveillance and counter-terrorism operations.
|
| 354 |
+
|
| 355 |
+

|
| 356 |
+
|
| 357 |
+

|
| 358 |
+
Figure 5: Decoding behavior over time from a Wikitext prompt, $q = 1$ .
|
| 359 |
+
|
| 360 |
+
Prompt: Headlam served as Officer Commanding North @-@ Western Area in 1946, and as Director of Training from 1947 to 1950. In 1950 - 51,
|
| 361 |
+
|
| 362 |
+
Generated story: Headlam took a leave of absence to study the problems of war and peacetime at the U.S. Army War College in Carlisle, Pennsylvania. His dissertation was entitled "Consequences of Disintegration of the Army" and focused on the effect of demobilization on the quality of officers and NCOs. After the war, Headlam was an instructor at the United States Military Academy at West Point, New York, and served as a military attaché in the Middle East and South Asia. He received the Distinguished Service Medal with Oak Leaf Cluster for his part in the rescue of Lt. Col. (later General) Omar N. Bradley, who was under attack by Japanese at Tarawa, Oahu, in the Solomons (New Hebrides) in 1943. The award was posthumously awarded to him by President Harry S. Truman in recognition of his gallantry in the latter part of World War II. Returning to the United States in the summer of 1951, Headlam began his career as a civilian in the Civil Aeronautics Administration (CAA), where he helped set up the Air Traffic Control System at La Guardia Airport in New York City. The following year, he joined the Federal Aviation
|
| 363 |
+
|
| 364 |
+

|
| 365 |
+
|
| 366 |
+

|
| 367 |
+
|
| 368 |
+

|
| 369 |
+
Figure 6: Decoding behavior over time from a Wikitext prompt, $q = 8$ .
|
| 370 |
+
|
| 371 |
+
Prompt: Headlam served as Officer Commanding North @-@ Western Area in 1946, and as Director of Training from 1947 to 1950. In 1950 - 51,
|
| 372 |
+
|
| 373 |
+
Generated story: Headlam's career spanned a number of high-profile assignments that included command of the U.S. Coast Guard Auxiliary (Coast Guard Airmen), Assistant Surgeon-Advocate to the Chief Surgeon of the United States Public Health Service, Special Assistant to the Under Secretary of the Navy for Research and Development, Executive Vice President of the New York-Presbyterian Hospital for 30 years, a Trustee of the Ford Foundation, an Emeritus Visiting Professor at Tufts University in Medford, Mass., and, of course, one of the most prolific authors of UFOlogy to this day. This list goes on and on with every name you can think of – not to mention his work behind the scenes to bring UFOs into the limelight as science rather than superstition. So what can we learn from such a life in and out of the media spotlight? First and foremost, it is easy to lose sight of the human and his/her inner life when looking at the "big picture" of human history. There is nothing wrong with getting paid or doing what you need to do in order to make a living, but that does not mean you are off the hook as a human being.
|
| 374 |
+
|
| 375 |
+

|
| 376 |
+
|
| 377 |
+

|
| 378 |
+
|
| 379 |
+

|
| 380 |
+
Figure 7: Decoding behavior over time from a Story prompt, $q = 1$ .
|
| 381 |
+
|
| 382 |
+
Prompt: The atmosphere dripped with emotion. Even Sola, the 13-year old, caught the current. Her eyes, fixated on the mother-son scene
|
| 383 |
+
|
| 384 |
+
Generated story: , shimmered with tears. A few minutes later, I was on the roof of the school, peering through binoculars to see what was happening down below. In the distance, I could see the silhouettes of a number of school buses, their windows blackened by fire. It was hard to make out the number of casualties, but by the time I got back to the bus station, there were at least two or three bodies sprawled on the tarmac. The death toll was expected to rise as ambulances ferried the injured to hospitals across the city. Many of the dead were in their 20s and 30s, including a man in his mid-forties who had been driving a minibus when it was hit by a rocket-propelled grenade. His body was strewn across the road, next to a burnt-out car. At the morgue, an elderly man with a moustache and white turban sat in a chair surrounded by coffins. One of the most horrific scenes of the day was the sight of a little girl cradling her mother's mangled body in her arms. She was barely a year old. After the funerals, hundreds of mourners crowded into
|
| 385 |
+
|
| 386 |
+

|
| 387 |
+
|
| 388 |
+

|
| 389 |
+
|
| 390 |
+

|
| 391 |
+
Figure 8: Decoding behavior over time from a Story prompt, $q = 8$ .
|
| 392 |
+
|
| 393 |
+
Prompt: The atmosphere dripped with emotion. Even Sola, the 13-year old, caught the current. Her eyes, fixated on the mother-son scene
|
| 394 |
+
|
| 395 |
+
Generated story: , shimmered for a fraction of a second like starlight at an obelisk. In all my years as a police officer, I was never asked to take care of a child and that was the first time I felt my heart ache as I walked the beat of the district. There was no mistaking the tears running down my face. After our tour, it was time to eat a celebratory meal that consisted of chicken biryani, roti and samosas. The family seated on the terrace was well-behaved and did not make a peep in our direction. As we chatted amicably, one of the women turned to me and said, "Aunty, what's your job?" I thought it was a good question and tried to find the right answer. "I'm a constable," I said. "That's good," she said without breaking eye contact. "Why are you an constable?" "For two reasons," I told her. "First, it's one of the jobs that requires physical and mental fortitude. The second reason is that in my line of work, every life is precious. You have to make sure that everyone gets a fair
|
| 396 |
+
|
| 397 |
+
# B Proofs
|
| 398 |
+
|
| 399 |
+
# Proof of Proposition 1.
|
| 400 |
+
|
| 401 |
+
Proof 1 Per normalization we have for the representations $||h_v||_2 = ||h_v||_2 = 1$ . Further, recall that the cosine distance is defined as
|
| 402 |
+
|
| 403 |
+
$$
|
| 404 |
+
s (h _ {v}, h _ {x _ {j}}) = \frac {h _ {v} ^ {\top} h _ {x _ {j}}}{| | h _ {v} | | _ {2} \cdot | | h _ {x _ {j}} | | _ {2}}
|
| 405 |
+
$$
|
| 406 |
+
|
| 407 |
+
We have
|
| 408 |
+
|
| 409 |
+
$$
|
| 410 |
+
\begin{array}{l} \left\| h _ {v} - h _ {x _ {j}} \right\| _ {2} ^ {2} = \left(h _ {v} - h _ {x _ {j}}\right) \left(h _ {v} - h _ {x _ {j}}\right) \\ = h _ {v} ^ {\top} h _ {v} - 2 h _ {v} ^ {\top} h _ {x _ {j}} + h _ {x _ {j}} ^ {\top} h _ {x} \\ = 2 - 2 h _ {v} \mid h _ {x _ {j}} \\ = 2 - 2 s \left(h _ {v}, h _ {x _ {j}}\right) \\ \end{array}
|
| 411 |
+
$$
|
| 412 |
+
|
| 413 |
+
It follows that
|
| 414 |
+
|
| 415 |
+
$$
|
| 416 |
+
\max _ {j} \{s (h _ {v}, h _ {x _ {j}}) \} = \max _ {j} \left\{2 - \frac {| | h _ {v} - h _ {x _ {j}} | | _ {2} ^ {2}}{2} \right\},
|
| 417 |
+
$$
|
| 418 |
+
|
| 419 |
+
which was to be shown.
|
| 420 |
+
|
| 421 |
+
# C Human Evaluation Form
|
| 422 |
+
|
| 423 |
+

|
| 424 |
+
Figure 9: Human evaluation form, including general instructions and definitions for the evaluation criteria.
|
| 425 |
+
|
| 426 |
+
# D Interpretability
|
| 427 |
+
|
| 428 |
+

|
| 429 |
+
|
| 430 |
+

|
| 431 |
+
|
| 432 |
+

|
| 433 |
+
|
| 434 |
+

|
| 435 |
+
Figure 10: To assess the effectiveness of our method, we conducted experiments using Contrastive Search (CS) with varying values of $k \in \{1,3,5,10,15,20,50\}$ and $\alpha \in \{0.2,0.4,0.6,0.8,1.0\}$ . Additionally, we evaluated the diversity, MAUVE, and coherence of human-generated texts from the same datasets, analyzing which hyperparameter combinations most closely align with the gold references. The results indicate that moderate values of $k$ and $\alpha$ tend to produce high-quality generations, closely approximating the performance of human references (dotted red line).
|
| 436 |
+
|
| 437 |
+

|
| 438 |
+
|
| 439 |
+

|
| 440 |
+
|
| 441 |
+
# E MAUVE
|
| 442 |
+
|
| 443 |
+
<table><tr><td rowspan="2">Dataset</td><td rowspan="2">Truncation</td><td colspan="2"># Examples</td><td colspan="3">MAUVE(%)†</td><td rowspan="2">Preferred Method</td></tr><tr><td>Contrastive Search</td><td>Adaptive Contrastive Search</td><td>Contrastive Search</td><td>Adaptive Contrastive Search</td><td>Δ</td></tr><tr><td rowspan="5">Wikines</td><td>64</td><td>1939</td><td>2000</td><td>87.42</td><td>85.79</td><td>-1.63</td><td>Contrastive Search</td></tr><tr><td>96</td><td>1920</td><td>2000</td><td>81.11</td><td>88.13</td><td>7.02</td><td>Adaptive Contrastive Search</td></tr><tr><td>128</td><td>1859</td><td>1977</td><td>84.14</td><td>85.39</td><td>1.25</td><td>Adaptive Contrastive Search</td></tr><tr><td>160</td><td>1684</td><td>1824</td><td>84.86</td><td>85.78</td><td>0.92</td><td>Adaptive Contrastive Search</td></tr><tr><td>192</td><td>1447</td><td>1617</td><td>85.23</td><td>87.10</td><td>1.87</td><td>Adaptive Contrastive Search</td></tr><tr><td rowspan="5">Wikitext</td><td>64</td><td>1296</td><td>1314</td><td>82.78</td><td>86.83</td><td>4.05</td><td>Adaptive Contrastive Search</td></tr><tr><td>96</td><td>1280</td><td>1314</td><td>81.46</td><td>85.67</td><td>4.21</td><td>Adaptive Contrastive Search</td></tr><tr><td>128</td><td>1250</td><td>1301</td><td>77.97</td><td>79.82</td><td>1.85</td><td>Adaptive Contrastive Search</td></tr><tr><td>160</td><td>845</td><td>889</td><td>69.66</td><td>80.53</td><td>10.87</td><td>Adaptive Contrastive Search</td></tr><tr><td>192</td><td>529</td><td>564</td><td>81.50</td><td>75.45</td><td>-6.05</td><td>Contrastive Search</td></tr><tr><td rowspan="5">Story</td><td>64</td><td>1907</td><td>1947</td><td>84.22</td><td>87.04</td><td>2.82</td><td>Adaptive Contrastive Search</td></tr><tr><td>96</td><td>1873</td><td>1947</td><td>87.82</td><td>83.66</td><td>-4.16</td><td>Contrastive Search</td></tr><tr><td>128</td><td>1657</td><td>1749</td><td>84.74</td><td>85.49</td><td>0.75</td><td>Adaptive Contrastive Search</td></tr><tr><td>160</td><td>863</td><td>922</td><td>83.59</td><td>83.68</td><td>0.09</td><td>Adaptive Contrastive Search</td></tr><tr><td>192</td><td>476</td><td>518</td><td>79.43</td><td>83.38</td><td>3.95</td><td>Adaptive Contrastive Search</td></tr></table>
|
| 444 |
+
|
| 445 |
+
Table 8: MAUVE scores as a function of truncation values, across three different datasets. Positive $\Delta$ -values indicate a superior performance of our method. The computations were performed with a gpt2-xl model, for CS we used the reported hyperparameters $k = 5$ and $\alpha = 0.6$ .
|
| 446 |
+
|
| 447 |
+
# F DoubleExp Method
|
| 448 |
+
|
| 449 |
+
A major concern regarding automatic evaluation metrics in open-ended text generation is their misalignment with human judgment. To illustrate this issue, we introduce a method called DoubleExp, which consistently achieves high scores on automatic metrics, yet is systematically rejected by human evaluators, as illustrated in Table 2. At each time step $t$ , $\alpha$ is dynamically adjusted while maintaining a fixed value of $k = 10$ . This approach modifies Eq. (1) as follows:
|
| 450 |
+
|
| 451 |
+
$$
|
| 452 |
+
x_{t} = \operatorname *{arg max}_{v\in V^{(k)}}\Bigg\{(1 - \alpha_{t})\times \underbrace{p_{\theta}(v\mid\boldsymbol{x}_{< t})}_{\text{model confidence}} -
|
| 453 |
+
$$
|
| 454 |
+
|
| 455 |
+
$$
|
| 456 |
+
\left. \alpha_ {t} \times \underbrace {\left(\max \left\{s \left(h _ {v} , h _ {x _ {j}}\right) : 1 \leq j \leq t - 1 \right\}\right)} _ {\text {d e g e n e r a t i o n p e n a l t y}} \right\} \tag {8}
|
| 457 |
+
$$
|
| 458 |
+
|
| 459 |
+
where
|
| 460 |
+
|
| 461 |
+
$$
|
| 462 |
+
\alpha_ {t} = \frac {\exp \left(\operatorname {s g n} \left(\delta_ {t , k}\right) \cdot \exp \left(\left| \delta_ {t , k} \right|\right)\right)}{\exp \left(\operatorname {s g n} \left(\delta_ {t , k}\right) \cdot \exp \left(\left| \delta_ {t , k} \right|\right)\right) + 1} \tag {9}
|
| 463 |
+
$$
|
| 464 |
+
|
| 465 |
+
with
|
| 466 |
+
|
| 467 |
+
$$
|
| 468 |
+
\delta_ {t, k} = \left(\frac {H (X) ^ {(t , k)} - \operatorname {m e d i a n} \left(H (X) ^ {(< t , k)}\right)}{\operatorname {m a x i m u m} \text {e n t r o p y} ^ {(k)}}\right) \tag {10}
|
| 469 |
+
$$
|
| 470 |
+
|
| 471 |
+
and
|
| 472 |
+
|
| 473 |
+
$$
|
| 474 |
+
\mathrm {H} (X) ^ {(t, k)} = - \sum_ {x \in \mathcal {V} ^ {(k)}} p (x \mid x _ {< t}) \ln p (x \mid x _ {< t}). \tag {11}
|
| 475 |
+
$$
|
| 476 |
+
|
| 477 |
+
# G Effect for lower values of $k$
|
| 478 |
+
|
| 479 |
+
In response to concerns about speed limitations, we compared the performance of contrastive search (CS) and our proposed adaptive contrastive search (ACS) across three datasets: Wikitext, Wikinews, and Story. This evaluation focused on key metrics - diversity, MAUVE, and coherence - of the generated texts. Even at lower values of $k$ (specifically, with $k = 5$ ), ACS demonstrated superior performance, outperforming its static counterpart in $66\%$ of cases. This improvement was particularly notable in diversity and MAUVE, with only a moderate decrease in coherence. Despite a $32\%$ reduction in generation speed for ACS compared to standard CS, we do not view this decrease as prohibitive in practical applications. The higher text quality achieved by ACS might compensate for the slower generation time, making it a valuable trade-off for real-world use cases.
|
| 480 |
+
|
| 481 |
+
<table><tr><td rowspan="2">Method</td><td colspan="3">Wikinews</td><td colspan="3">Wikitext</td><td colspan="3">Story</td><td colspan="3">Average</td></tr><tr><td>div.(%)↑</td><td>MAUVE(%)↑</td><td>coh.↑</td><td>div.(%)↑</td><td>MAUVE(%)↑</td><td>coh.↑</td><td>div.(%)↑</td><td>MAUVE(%)↑</td><td>coh.↑</td><td>div.(%)↑</td><td>MAUVE(%)↑</td><td>coh.↑</td></tr><tr><td>CS (α = 0.6, k = 5)</td><td>93.72</td><td>84.14</td><td>-1.39</td><td>89.35</td><td>77.97</td><td>-1.56</td><td>93.06</td><td>84.74</td><td>-1.61</td><td>92.04</td><td>82.28</td><td>-1.52</td></tr><tr><td>ACS (k = 5)</td><td>96.16</td><td>85.39</td><td>-1.71</td><td>93.28</td><td>79.82</td><td>-1.79</td><td>94.53</td><td>85.49</td><td>-1.74</td><td>94.66</td><td>83.57</td><td>-1.75</td></tr></table>
|
| 482 |
+
|
| 483 |
+
Table 9: Comparison of Contrastive Search (CS) and Adaptive Contrastive Search (ACS) across three datasets. Results for diversity, MAUVE, and coherence are reported.
|
| 484 |
+
|
| 485 |
+
# Contents
|
| 486 |
+
|
| 487 |
+
1 Introduction 1
|
| 488 |
+
2 Related work 2
|
| 489 |
+
|
| 490 |
+
3 Methodology 3
|
| 491 |
+
|
| 492 |
+
3.1 Incorporating Model Uncertainty 3
|
| 493 |
+
3.2 Theoretical Motivation 3
|
| 494 |
+
|
| 495 |
+
4 Experimental Setup 4
|
| 496 |
+
|
| 497 |
+
4.1 Evaluation Metrics 4
|
| 498 |
+
4.2 Datasets 4
|
| 499 |
+
4.3Baselines 4
|
| 500 |
+
4.4 Models 5
|
| 501 |
+
|
| 502 |
+
5 Results 5
|
| 503 |
+
|
| 504 |
+
5.1 Automatic evaluation results 5
|
| 505 |
+
5.2 Human evaluation 6
|
| 506 |
+
5.3 Qualitative examples 6
|
| 507 |
+
5.4 Ablation studies 7
|
| 508 |
+
5.5 Generation speed 7
|
| 509 |
+
5.6 Application to other languages 7
|
| 510 |
+
5.7 Effect of varying model sizes 7
|
| 511 |
+
5.8 Findings about MAUVE 7
|
| 512 |
+
5.9 Interpretability 8
|
| 513 |
+
|
| 514 |
+
6 Discussion and Future Work 8
|
| 515 |
+
7 Conclusion 9
|
| 516 |
+
|
| 517 |
+
A Example Generations 14
|
| 518 |
+
B Proofs 17
|
| 519 |
+
C Human Evaluation Form 18
|
| 520 |
+
D Interpretability 19
|
| 521 |
+
E MAUVE 19
|
| 522 |
+
F DoubleExp Method 20
|
| 523 |
+
G Effect for lower values of $k$ 20
|
adaptivecontrastivesearchuncertaintyguideddecodingforopenendedtextgeneration/images.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b968dc3fdad01a940b317ce5b9ee755a6a6925cf1062ac33402adf501bafa414
|
| 3 |
+
size 1309631
|
adaptivecontrastivesearchuncertaintyguideddecodingforopenendedtextgeneration/layout.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:be5cc33d8a027f630c67471c9c1c4870031dd41d399cfbeeed546f5a9bfa3326
|
| 3 |
+
size 593855
|
adaptivefeaturebasedlowrankcompressionoflargelanguagemodelsviabayesianoptimization/570c3a02-efbf-4dc1-9d53-e5c7ead5e45e_content_list.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:db17af119379c6f409d0e4080f88509fb8838bc80a06ab0aa6390ea827a5d603
|
| 3 |
+
size 107534
|
adaptivefeaturebasedlowrankcompressionoflargelanguagemodelsviabayesianoptimization/570c3a02-efbf-4dc1-9d53-e5c7ead5e45e_model.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b3bbe577797f3f2a34c1a7cab73a2ec6da7db1f58df2acee0008197a0d6118c3
|
| 3 |
+
size 127817
|
adaptivefeaturebasedlowrankcompressionoflargelanguagemodelsviabayesianoptimization/570c3a02-efbf-4dc1-9d53-e5c7ead5e45e_origin.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a2da1d85683010cea6c73b2e762b456f8e87c2b0121f5502eda96d956b1117d5
|
| 3 |
+
size 1151576
|
adaptivefeaturebasedlowrankcompressionoflargelanguagemodelsviabayesianoptimization/full.md
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Adaptive Feature-based Low-Rank Compression of Large Language Models via Bayesian Optimization
|
| 2 |
+
|
| 3 |
+
Yixin Ji $^{1*}$ , Yang Xiang $^{1*}$ , Juntao Li $^{1\dagger}$ , Qingrong Xia $^{2}$ , Zi Ye $^{2}$ , Xinyu Duan $^{2}$ , Zhefeng Wang $^{2}$ , Kehai Chen $^{3}$ , Min Zhang $^{1,3}$
|
| 4 |
+
|
| 5 |
+
<sup>1</sup>School of Computer Science and Technology, Soochow University
|
| 6 |
+
|
| 7 |
+
$^{2}$ Huawei Cloud, China
|
| 8 |
+
|
| 9 |
+
$^{3}$ Harbin Institute of Technology, Shenzhen
|
| 10 |
+
|
| 11 |
+
{jiyixin169,baldwin021129}@gmail.com;
|
| 12 |
+
|
| 13 |
+
{ljt,minzhang}@suda.edu.cn
|
| 14 |
+
|
| 15 |
+
# Abstract
|
| 16 |
+
|
| 17 |
+
In recent years, large language models (LLMs) have driven advances in natural language processing. Still, their growing scale has increased the computational burden, necessitating a balance between efficiency and performance. Low-rank compression, a promising technique, reduces non-essential parameters by decomposing weight matrices into products of two low-rank matrices. Yet, its application in LLMs has not been extensively studied. The key to low-rank compression lies in low-rank factorization and low-rank dimensions allocation. To address the challenges of low-rank compression in LLMs, we conduct empirical research on the low-rank characteristics of large models. We propose a low-rank compression method suitable for LLMs. This approach involves precise estimation of feature distributions through pooled covariance matrices and a Bayesian optimization strategy for allocating low-rank dimensions. Experiments on the LLaMA-2 models demonstrate that our method outperforms existing strong structured pruning and low-rank compression techniques in maintaining model performance at the same compression ratio. $^{1}$
|
| 18 |
+
|
| 19 |
+
# 1 Introduction
|
| 20 |
+
|
| 21 |
+
In recent years, the emergence and application of large language models (LLMs) have served as a powerful stimulant for natural language processing and artificial intelligence (OpenAI, 2022, 2023; Bubeck et al., 2023; Yang et al., 2023). Adhering to the scaling law (Kaplan et al., 2020; Hoffmann et al., 2022), researchers are continually seeking LLMs with more parameters and training data, aiming to achieve general models closer to human capabilities. However, larger language models imply a larger overhead of computing resources. Therefore,
|
| 22 |
+
|
| 23 |
+
when deploying LLMs, it is necessary to strike a balance between efficiency and performance (Wan et al., 2024). To achieve efficient LLMs, many compression techniques for LLMs are proposed, such as pruning (Frantar and Alistarh, 2023a; Sun et al., 2024; Ma et al., 2023), quantization (Frantar et al., 2023; Lin et al., 2023; Liu et al., 2023) and knowledge distillation (Gu et al., 2024).
|
| 24 |
+
|
| 25 |
+
Among these methods, unstructured pruning and quantization can reduce the number of parameters or memory requirements by half or even more without significant performance degradation, but they require specialized GPU kernels to fully realize their acceleration potential. In contrast, structured pruning can produce lightweight models that do not rely on specialized hardware. Despite extensive research, the performance of structured pruning still lags significantly behind that of the original model. Low-rank compression (LRC) (Ben Noach and Goldberg, 2020; Li et al., 2023) is another promising compression technique. It decomposes the weight matrix into the product of two dense low-rank matrices, discarding unimportant parameter information during the decomposition process. However, LRC remains under-explored in LLMs.
|
| 26 |
+
|
| 27 |
+
The keys to LRC are low-rank decomposition methods and low-rank dimension allocation. Existing decomposition methods can generally be categorized into two types: weight-based and feature-based decomposition. The former minimizes the reconstruction error of weight matrices by applying truncated SVD or weighted SVD (Ben Noach and Goldberg, 2020; Hsu et al., 2022; Hua et al., 2022). However, recent research (Chen et al., 2021; Yu and Wu, 2023) has discovered that the weights of most Transformer-based language models are typical of high rank or even close to full rank; thus, direct decomposition might result in significant error. In contrast, the model's features usually exhibit low-rank characteristics. Thus, more work focuses on the feature-based decomposition (Chen
|
| 28 |
+
|
| 29 |
+
et al., 2021; Yu and Wu, 2023; Kaushal et al., 2023), which aims to minimize the reconstruction error of features. On the other hand, allocating suitable low-rank dimensions to different weight matrices according to the target compression ratio can also reduce the downside on the model's overall performance since they exhibit varying sensitivities to low-rank compression.
|
| 30 |
+
|
| 31 |
+
When LRC is applied to LLMs, it encounters more new challenges. First, it is challenging for LLMs to maintain their generality while achieving feature-based low-rank compression. This is because the feature space of LLMs is extremely high dimensional, making the feature distribution more complex, and the presence of outlier features may interfere with the accurate distribution estimation. Thus, we utilize the pooled covariance matrix instead of the sample covariance matrix, which enables a more accurate estimation of feature distributions (Raninen et al., 2022). Then, for low-rank dimension allocation, manual design struggles to achieve optimal results, and due to its vast search space, grid search requires a considerable amount of time. We conduct empirical studies on the low-rank sensitivity of different types of parameters and observe significant variations among them. Based on these findings, we categorize the parameters into groups, allowing each group to share the same low-rank dimensions. This approach effectively narrows down the search space, and furthermore, we utilize sample-efficient Bayesian optimization to determine the optimal low-rank allocation. To evaluate the effectiveness of our proposed LRC method, we conduct experiments on two commonly used LLaMA-2 models (Touvron et al., 2023). Experimental results demonstrate our proposed method can perform better than existing strong structured pruning and LRC methods in LLMs. When combined with efficient post-training, our method obtains the latest state-of-art for the same settings, maintaining $98\%$ of the model's performance at the $20\%$ compression rate.
|
| 32 |
+
|
| 33 |
+
Overall, our main contributions include:
|
| 34 |
+
|
| 35 |
+
- We analyze the challenges that LLMs face in low-rank compression and demonstrate that LLMs represented by LLaMA exhibit vastly different sensitivities to low-rank compression across various parameters through empirical research.
|
| 36 |
+
- We propose a novel Bayesian optimization-based feature low-rank compression (Bolaco).
|
| 37 |
+
- Extensive experiments show that our Bolaco out
|
| 38 |
+
|
| 39 |
+
performs the existing strong structured pruning and LRC methods in LLMs.
|
| 40 |
+
|
| 41 |
+
# 2 Preliminary
|
| 42 |
+
|
| 43 |
+
In this section, we summarily introduce the foundation of low-rank factorization in model compression, and then empirically show that different layers of the Transformers-based generative large language model have different low-rank sensitivities.
|
| 44 |
+
|
| 45 |
+
# 2.1 Weight-based and Feature-based Low-rank Decomposition
|
| 46 |
+
|
| 47 |
+
The low-rank decomposition reduces the number of parameters by decomposing the linear layer weights into two low-rank matrices. Weight-based factorization is one naive method. For a linear layer $\mathbf{W} \in \mathbb{R}^{d_2 \times d_1}$ , according to the Eckart-Young-Mirsky theorem, the truncated singular value decomposition (SVD) provides the optimal solution: $\mathbf{W} = \mathbf{U} \boldsymbol{\Sigma} \mathbf{V}^T$ , $\mathbf{A} = \mathbf{V}_r^T$ , $\mathbf{B} = \mathbf{U}_r \boldsymbol{\Sigma}_r$ , where $\mathbf{A} \in \mathbb{R}^{r \times d_1}$ , $\mathbf{B} \in \mathbb{R}^{d_2 \times r}$ , $\boldsymbol{\Sigma}_r$ is the top- $r$ largest singular values, $\mathbf{U}_r$ and $\mathbf{V}_r$ are the corresponding singular vectors. If $r < d_1 d_2 / (d_1 + d_2)$ , the factorization can reduce the total parameter amount. However, in the vast majority of cases, the weights of PLMs have a high rank, and a direct truncated SVD decomposition on the weights would lead to significant reconstruction errors (Chen et al., 2021). In comparison, the representation space of PLMs exhibits a clear low-rank property (Yu and Wu, 2023). Therefore, another line of work has considered feature-based factorization:
|
| 48 |
+
|
| 49 |
+
$$
|
| 50 |
+
\begin{array}{l} \min _ {B, A} \left\| W X - B A X \right\| _ {F} \tag {1} \\ \begin{array}{l} \text {s . t .} \operatorname {r a n k} (\boldsymbol {B A}) = r. \end{array} \\ \end{array}
|
| 51 |
+
$$
|
| 52 |
+
|
| 53 |
+
For the linear layer $\mathbf{Y} = \mathbf{W}\mathbf{X}$ , Chen et al. (2021) obtain the optimal solution to Eq. 1 by simultaneously performing the SVD decomposition of the weight and features. Yu and Wu (2023) propose a more efficient Atomic Feature Mimicking (AFM) method, which utilizes the PCA decomposition to find the projection matrices:
|
| 54 |
+
|
| 55 |
+
$$
|
| 56 |
+
C o v (\boldsymbol {Y}) = \boldsymbol {U} \boldsymbol {\Sigma} \boldsymbol {U} ^ {T} \tag {2}
|
| 57 |
+
$$
|
| 58 |
+
|
| 59 |
+
$$
|
| 60 |
+
\boldsymbol {Y} - E [ \boldsymbol {Y} ] = \boldsymbol {U} _ {r} \boldsymbol {U} _ {r} ^ {T} (\boldsymbol {W} \boldsymbol {X} - E [ \boldsymbol {Y} ]),
|
| 61 |
+
$$
|
| 62 |
+
|
| 63 |
+
where $\text{Cov}(\mathbf{Y}) \in \mathbb{R}^{d_2 \times n}$ , $E[\mathbf{Y}] \in \mathbb{R}^{d_2}$ is the covariance and mean of features. Thus, the original linear layer can be replaced by $\mathbf{B} = \mathbf{U}_r \in \mathbb{R}^{d_2 \times r}$ , $\mathbf{A} = \mathbf{U}_r^T\mathbf{W} \in \mathbb{R}^{r \times d_1}$ and the bias compensation $\mathbf{b} = (\mathbf{I} - \mathbf{U}_r\mathbf{U}_r^T)\mathbf{E}[\mathbf{Y}]$ . We have observed that the
|
| 64 |
+
|
| 65 |
+

|
| 66 |
+
Figure 1: Sensitivity of different types of layers to low-rank compression. Each curve represents the compression of only that parameter type, with the horizontal axis indicating the compression ratio for that specific parameter type.
|
| 67 |
+
|
| 68 |
+

|
| 69 |
+
|
| 70 |
+
current mainstream LLMs also exhibit characteristics of high-rank weights and low-rank features. Therefore, in this paper, we focus on the feature-based low-rank factorization.
|
| 71 |
+
|
| 72 |
+
# 2.2 Different Layers Exhibit Varying Degrees of Low-rank Sensitivity
|
| 73 |
+
|
| 74 |
+
Another challenge in LRC is allocating varying low-rank compression rates to different layers. Previous works have empirically or theoretically demonstrated that different components of Transformer-based masked language models and visual models exhibit distinct low-rank properties, such as the features of the self-attention modules having a lower rank compared to those of the feedforward modules (Dong et al., 2023; Anagnostidis et al., 2022). These findings provide prior guidance for low-rank compression. However, detailed studies on current mainstream LLMs are still lacking. Therefore, we take the LLaMA-v2-7b as an example to study the low-rank sensitivity within each layer across different types of layers and the same type of layers. Llama-family LLMs have seven distinct parameter categories: $\text{attn}_q$ , $\text{attn}_k$ , $\text{attn}_\nu$ , $\text{attn}_o$ , $\text{mlp\_up}$ , $\text{mlp\_down}$ , and $\text{mlp\_gate}$ . We evaluate the perplexity changes on Wikitext-2 (Merit et al., 2016) for each category under varying low-rank compression ratios. As Figure 1 shows, at the same low-rank compression rate, distinct layers exhibit notable performance variations. For $\text{attn}_q$ and $\text{attn}_k$ , they demonstrate robustness to low-rank compression, with an increase in perplexity not exceeding $2\%$ even at a compression rate of $60\%$ . In contrast, $\text{attn}_\nu$ , with an equivalent parameter count, exhibits high sensitivity, leading to a significant surge in perplexity with compression rates even below $5\%$ . Therefore, assigning the
|
| 75 |
+
|
| 76 |
+
same low-rank compression rate to different types of layers during low-rank compression of LLM is a sub-optimal solution. In addition to the differences, we also observe certain similarities, e.g., $\text{attn}_q$ and $\text{attn}_k$ have similar low-rank sensitivities. More empirical study results are shown in Appendix A.
|
| 77 |
+
|
| 78 |
+
# 3 Methodology
|
| 79 |
+
|
| 80 |
+
# 3.1 Feature-Based Low-Rank Decomposition in High-Dimensional Spaces
|
| 81 |
+
|
| 82 |
+
An efficient feature-based low-rank decomposition method performs PCA on features to identify the optimal low-rank matrices. To achieve general task-agnostic compression, we follow the setup of prior work (Frantar and Alistarh, 2023b; Sun et al., 2023; Ma et al., 2023), utilizing a subset of the pretraining data as calibration data $\mathcal{D}_{cal} = \{x_i\}_{i=1}^n$ . As described in Eq.2, we first estimate the covariance matrix of the entire feature space distribution $\mathcal{V}$ with the sample covariance matrix (SCM) of the calibration data features:
|
| 83 |
+
|
| 84 |
+
$$
|
| 85 |
+
C o v _ {S} (\boldsymbol {Y}) = \frac {1}{n - 1} \sum_ {i = 1} ^ {n} \left(\boldsymbol {y} _ {i} - \bar {\boldsymbol {y}}\right) ^ {T} \left(\boldsymbol {y} _ {i} - \bar {\boldsymbol {y}}\right), \tag {3}
|
| 86 |
+
$$
|
| 87 |
+
|
| 88 |
+
where $\pmb{y}_i$ represents the feature of $x_i$ , $\bar{\pmb{y}}$ refers to the mean of all calibration data features. However, LLMs typically have high-dimensional feature spaces (e.g., the intermediate size of LLaMAv2-7b has exceeded 10,000 dimensions). Precisely estimating the covariance matrix in such high-dimensional spaces has always been a statistical challenge, as the SCM does not effectively estimate the covariance of high-dimensional distributions. For instance, calibration data sampled from pre-training datasets may introduce outlier features due to low-quality text or inadequate sampling. In
|
| 89 |
+
|
| 90 |
+
high-dimensional spaces, these outlier features are difficult to identify due to the "curse of dimensionality", and their impact is further exacerbated in estimating high-dimensional covariance matrices due to the sparsity of data points. Thus, to estimate the covariance of the feature space more robustly and accurately, we propose using the pooled covariance matrix (PCM) in place of the SCM. We split the calibration data into $m$ groups. For each group, we can calculate the SCM $Cov_{S}(\mathbf{Y}_{k})$ , then the pooled covariance matrix is:
|
| 91 |
+
|
| 92 |
+
$$
|
| 93 |
+
C o v _ {P} (\mathbf {Y}) = \frac {1}{m} \sum_ {k = 1} ^ {m} C o v _ {S} (\mathbf {Y} _ {k}) \tag {4}
|
| 94 |
+
$$
|
| 95 |
+
|
| 96 |
+
# 3.2 Low-Rank Allocation Based on Bayesian Optimization
|
| 97 |
+
|
| 98 |
+
As investigated in Section 2.2, different types of layers, and even each individual layer, exhibit varying sensitivities to low-rank compression. Therefore, allocating distinct compression ratios to different layers is crucial to achieve the desired compression rate with minimal performance degradation. For a LLM $f(\cdot; \theta)$ , we compress it with the set of low-rank compression ratios $\lambda = \{\lambda_i\}_{i=1}^k$ . We use a task-agnostic evaluation dataset $\mathcal{D}$ to evaluate performance of the compressed model $f(\cdot; \theta, \lambda)$ , such as the perplexity on a subset of pretraining data. Therefore, the optimization objective of low-rank allocation can be formulated as:
|
| 99 |
+
|
| 100 |
+
$$
|
| 101 |
+
\begin{array}{l} \min _ {\lambda \in \mathcal {V}} H (\boldsymbol {\lambda}) = \mathbb {E} _ {(x, y) \sim \mathcal {D}} h (f (x; \boldsymbol {\theta}, \boldsymbol {\lambda}), y) \tag {5} \\ s. t. \Sigma \boldsymbol {\lambda} \leq \rho , \\ \end{array}
|
| 102 |
+
$$
|
| 103 |
+
|
| 104 |
+
where $h(\cdot, \cdot)$ is the evaluation metric, $\rho$ is model's overall compression ratio. For LLMs, searching the optimal low-rank allocation is a challenging optimization problem. First, the impact of the low-rank count allocated to different layers on the performance of the compressed model is combinatorial, and optimizing any one component independently may lead to a locally optimal solution. Then, due to LLMs' vast number of parameters, evaluating $H(\lambda)$ is very time-consuming. Therefore, we leverage sample-efficient Bayesian optimization (BO) (Xu et al., 2022) to optimize Eq 5. BO estimates the objective $H(\lambda)$ with a stochastic surrogate model and updates the posterior estimation of $H(\lambda)$ based on the results of each search step. We utilize the Gaussian process $\mathcal{N}(\mu(\cdot), \sigma^2(\cdot))$ as the surrogate model. Given the previous $t - 1$ search steps $\{\lambda_1, \dots, \lambda_{t-1}\}$ and
|
| 105 |
+
|
| 106 |
+
their evaluation $H_{t - 1} = [H(\pmb {\lambda}_1),\dots ,H(\pmb {\lambda}_{t - 1})]$ the surrogate model is updated as:
|
| 107 |
+
|
| 108 |
+
$$
|
| 109 |
+
\mu (\boldsymbol {\lambda}) = \boldsymbol {k} \left(\boldsymbol {K} + \eta^ {2} \boldsymbol {I}\right) ^ {- 1} H _ {t - 1} \tag {6}
|
| 110 |
+
$$
|
| 111 |
+
|
| 112 |
+
$$
|
| 113 |
+
\sigma^ {2} (\boldsymbol {\lambda}) = k (\boldsymbol {\lambda}, \boldsymbol {\lambda}) - \boldsymbol {k} ^ {T} (\boldsymbol {K} + \eta^ {2} \boldsymbol {I}) ^ {- 1} \boldsymbol {k},
|
| 114 |
+
$$
|
| 115 |
+
|
| 116 |
+
where $k(\cdot, \cdot)$ is a kernel function, $\pmb{k} = (k(\pmb{\lambda}, \pmb{\lambda}_i))_{i \in [t-1]}, \pmb{K} = (k(\pmb{\lambda}_i, \pmb{\lambda}_j))_{i,j \in [t-1]}$ , and $\eta^2 \pmb{I}$ is the white kernel to model observation noise.
|
| 117 |
+
|
| 118 |
+
After obtaining the posterior estimation of $H(\lambda)$ (i.e., $H(\lambda) \sim \mathcal{N}(\mu(\lambda), \sigma^2(\lambda))$ ), BO determines the next compression rate allocation state through the acquisition function. Expected improvement (EI) is a popular and effective acquisition function:
|
| 119 |
+
|
| 120 |
+
$$
|
| 121 |
+
\begin{array}{r} \alpha (\boldsymbol {\lambda}) = \mathbb {E} _ {H (\boldsymbol {\lambda})} \left[ \max \left\{0, H ^ {\prime} - H (\boldsymbol {\lambda}) \right\} \right] \\ \boldsymbol {\lambda} = \operatorname {a r g m a x} _ {\boldsymbol {\lambda}} \alpha (\boldsymbol {\lambda}) \end{array} \tag {7}
|
| 122 |
+
$$
|
| 123 |
+
|
| 124 |
+
$$
|
| 125 |
+
\underset {\boldsymbol {\lambda}} {\operatorname {a r g m a x}} \alpha (\boldsymbol {\lambda}), \tag {7}
|
| 126 |
+
$$
|
| 127 |
+
|
| 128 |
+
where $H' = \min_{i \in [t-1]} H(\lambda_i)$ , it means the minimal value observed so far. Then, BO chooses the point with the greatest EI to explore. After obtaining the optimal ratio $\lambda^*$ , we can determine the allocated rank: $r_i = (1 - \lambda_i)d_1d_2 / (d_1 + d_2)$ . To fully leverage the acceleration effect of GPU matrix multiplication, we adhere to Nvidia's user guidelines by rounding the low-rank dimensions to the nearest multiple of eight.
|
| 129 |
+
|
| 130 |
+
The evaluation metric and validation data play a significant role in the optimization performance of BO. They must meet two criteria: cost-effectiveness and accurately reflect actual changes in performance. To this end, we propose a sensitive-based sampling method. This method randomly samples $n$ allocation schemes, calculates the variance of the perplexity of each sample under different allocations, and selects the top- $k$ samples as validation data. In addition, considering the smaller validation set may not comprehensively reflect the LLM's performance, potentially leading to over-fitting in the validation set. To prevent BO from blindly improving the compressed model's language modeling performance on the validation set, we aim to make the compressed model have a prediction distribution for the next word close to the original model. Hence, we employ the reverse KL divergence to quantify the difference:
|
| 131 |
+
|
| 132 |
+
$$
|
| 133 |
+
\mathcal {L} (\boldsymbol {\theta}, \boldsymbol {\lambda}) = D _ {K L} (f (x; \theta) | | f (x; \theta , \lambda)). \tag {8}
|
| 134 |
+
$$
|
| 135 |
+
|
| 136 |
+

|
| 137 |
+
Figure 2: Illustration of our Bolaco. It initializes a low-rank dimension allocation and compresses the model via feature-based low-rank compression. Then, it evaluates the compression performance and optimizes the low-rank dimension allocation through Gaussian process-based Bayesian optimization.
|
| 138 |
+
|
| 139 |
+
# 3.3 Post-training
|
| 140 |
+
|
| 141 |
+
After low-rank compression, there remains a noticeable performance gap between the compressed model and the original LLM. To further bridge this gap, following Ma et al. (2023), we perform efficient low-rank subspace post-training on the compressed model. However, if we apply the original LoRA (Hu et al., 2022) to the low-rank compressed model, the tunable low-rank parameters may not be in the same subspace as the low-rank compressed model parameters, leading to an increase of the parameters' rank after merging. Therefore, inspired by the ELoRA (Kopiczko et al., 2024), we select the subspace of compressed model parameters as fixed low-rank matrices and adjust the subspace by trainable vectors:
|
| 142 |
+
|
| 143 |
+
$$
|
| 144 |
+
\boldsymbol {Y} = \left(\boldsymbol {B} \boldsymbol {A} + \boldsymbol {\Lambda} _ {b} \boldsymbol {B} _ {r ^ {\prime}} \boldsymbol {\Lambda} _ {d} \boldsymbol {A} _ {r ^ {\prime}}\right) \boldsymbol {X}, \tag {9}
|
| 145 |
+
$$
|
| 146 |
+
|
| 147 |
+
where $B_{r^{\prime}}\in \mathbb{R}^{d_2\times r^{\prime}}$ and $A_{r^{\prime}}\in \mathbb{R}^{r^{\prime}\times d_{1}}$ are fixed subspace of $B$ and $A$ , $\Lambda_{b}$ and $\Lambda_{d}$ are diagonal matrices. During the post-training, we only tune elements on the diagonal of $\Lambda_{b}$ and $\Lambda_{d}$ .
|
| 148 |
+
|
| 149 |
+
# 4 Experiments
|
| 150 |
+
|
| 151 |
+
# 4.1 Baseline and Datasets
|
| 152 |
+
|
| 153 |
+
We compare our method with the competitive structured pruning and low-rank compression methods in LLMs: LLM-Pruner (Ma et al., 2023), FLAP (An et al., 2023), SliceGPT (Ashkboos et al., 2024), LoRD (Kaushal et al., 2023), ASVD (Yuan et al., 2023). We provide the detailed description of baseline methods in Appendix B.
|
| 154 |
+
|
| 155 |
+
To evaluate the effectiveness of our proposed low-rank compression method in the task-agnostic setting, we conduct experiments in seven zero-shot common sense reasoning datasets: BoolQ (Clark
|
| 156 |
+
|
| 157 |
+
et al., 2019), PIQA (Bisk et al., 2020), HellaSwag (Zellers et al., 2019), WinoGrande (Sakaguchi et al., 2021), ARC-easy/challenge (Clark et al., 2018) and OpenbookQA (Mihaylov et al., 2018). We also report the perplexity of the compressed model on the WikiText2 (Merit et al., 2016), PTB (Marcus et al., 1993), and C4 (Raffel et al., 2020) datasets to evaluate its language modeling capabilities.
|
| 158 |
+
|
| 159 |
+
# 4.2 Experimental Details
|
| 160 |
+
|
| 161 |
+
In our main experiments, we apply our method to LLaMA-v2-7b and LLaMA-v2-13b. We randomly select 1,024 samples from the training set of C4 as the calibration data. Each sample has a sequence length of 4,096. To estimate the covariance matrix while saving memory usage, we employ the Welford's online algorithm (Welford, 1962). For the pooled covariance matrix, we partition the calibrated data into 32 groups. During the Bayesian optimization, we utilize the Matern kernel as the covariance function. We randomly sample 20 low-rank allocation schemes and select the top-100 samples with greatest perplexity variance of Wikipedia as the evaluation data. Each sample has a sequence length of 4,096 (4k tokens). Considering that Bayesian optimization is not well-suited for high-dimensional scenarios, we conduct experiments with two settings based on the observations in Section 2.2: (a) $5 \times 1$ : We allow $attn_q$ and $attn_k$ to share a low-rank dimension, and the same type of parameters across different layers to also share a low-rank dimension, thus BO only optimizes 5 parameters; (b) $5 \times 4$ : Building on the setup of (a), we divide the model's layers into 4 groups in sequence, with no parameter sharing between different groups, resulting in BO needing to optimize 20 parameters. Moreover, given that the parameters of the FFN module are more sensitive
|
| 162 |
+
|
| 163 |
+

|
| 164 |
+
Figure 3: The perplexity of WikiText2 on LLaMA 2-7b with different compression ratios.
|
| 165 |
+
|
| 166 |
+
to low-rank compression than those of the attention module, we set the length scale for the attention and FFN parameters in the Matern kernel to 1.0 and 0.8, respectively, to emphasize the more significant impact of FFN parameters' rank changes on model performance. We run 50 epochs BO to search the optimal low-rank allocation. At the post-training stage, following LLM-Pruner, we use the Alpaca dataset (Taori et al., 2023) and train 2 epochs. More details can be found in the Appendix C.
|
| 167 |
+
|
| 168 |
+
# 4.3 Main Results
|
| 169 |
+
|
| 170 |
+
We report the perplexity of language modeling for various compression methods at different compression ratios in Figure 3 and 6, and the zero-shot common sense reasoning results in Table 1 and 5 (in Appendix). In terms of language modeling capabilities, FLAP demonstrates strong competitiveness, particularly when the compression rate exceeds $30\%$ , where FLAP's perplexity is slightly better than our Bolaco $(5 \times 1)$ . However, in the 7b model, Bolaco $(5 \times 4)$ achieves the best language modeling performance at high compression rates. Nevertheless, in the 13b model, despite Bolaco $(5 \times 4)$ still leading other compression techniques, it maintains a certain gap from FLAP. For zero-shot tasks, our method significantly outperforms all baselines without any further post-training, achieving an average performance increase of $1.5 - 2\%$ across seven datasets. After post-training with only about $1\%$ parameters and 3 hours, our method further narrows down the performance difference between the compressed model and the original model. It retains $96\% - 98\%$ of the original model's performance at the $20\%$ compression ratio, and at a $30\%$ compression ratio, it maintains $91\% - 95\%$ of the performance. Comparing the $5 \times 1$ and $5 \times 4$
|
| 171 |
+
|
| 172 |
+
setting, we find that the performance difference between the two is not significant. At the $20\%$ compression ratio, simply allocating different low-rank dimensions to different types of parameters suffices to achieve the best current performance. However, at the $30\%$ compression rate, the $5 \times 4$ setting outperforms the $5 \times 1$ , indicating that more granular low-rank assignments contribute to enhanced performance in compressed models at higher compression rates.
|
| 173 |
+
|
| 174 |
+
# 5 Analysis and Discussion
|
| 175 |
+
|
| 176 |
+
# 5.1 Impact of Calibration Data and Covariance Estimation
|
| 177 |
+
|
| 178 |
+
Accurate estimation of feature distribution is crucial for the feature-based low-rank decomposition, which primarily depends on the number of calibration samples and the accuracy of the covariance matrix estimation. Thus, we investigate the impact of the two factors on LLaMA-v2-7b at the $20\%$ compression ratio. In this experiment, we do not account for the effects of low-rank dimensions allocation, and maintain consistency with the settings of LoRD. As results shown in Table 2, as the calibration dataset size gradually increases, we observe a consistent improvement in both the language modeling capabilities and the performance on downstream tasks of the compressed model. Therefore, given sufficient data and computational resources, expanding the calibration dataset is a reliable method for enhancing the performance of compressed models. On the other hand, comparing the two covariance estimation methods, there is no significant difference in their language modeling capabilities. However, for downstream common sense reasoning tasks, the pooled SCM achieves an average improvement of 0.3 points across seven datasets without any additional burden.
|
| 179 |
+
|
| 180 |
+
# 5.2 Impact of Objective Function
|
| 181 |
+
|
| 182 |
+
We explore the impact of the objective function in the Bayesian optimization stage. We conduct experiments on LLaMA-v2-7b and report results in Table 3. Overall, incorporating the reverse KL divergence (RKL) between the compressed model and the original model's predictive distribution into the objective function can lead to a better low-rank dimensions allocation. Especially in the $5 \times 4$ setting, which is more difficult to optimize for Bayesian optimization, the performance gains from RKL term are even more obvious. We suppose that the RKL
|
| 183 |
+
|
| 184 |
+
<table><tr><td>Ratio</td><td>Methods</td><td>BoolQ</td><td>PIQA</td><td>HellaSwag</td><td>WinoGrande</td><td>ARC-e</td><td>ARC-c</td><td>OBQA</td><td>Average</td></tr><tr><td>0%</td><td>LLaMA-v2-7b</td><td>77.74</td><td>78.07</td><td>75.97</td><td>68.98</td><td>76.30</td><td>46.33</td><td>44.20</td><td>66.80</td></tr><tr><td rowspan="10">20%</td><td>LLM-Pruner</td><td>63.27</td><td>76.12</td><td>67.93</td><td>64.80</td><td>68.73</td><td>38.65</td><td>40.00</td><td>59.93</td></tr><tr><td>LLM-Pruner (w/ PT)</td><td>66.45</td><td>76.28</td><td>70.90</td><td>65.75</td><td>70.62</td><td>39.59</td><td>43.20</td><td>61.83</td></tr><tr><td>FLAP</td><td>70.21</td><td>75.24</td><td>69.34</td><td>66.30</td><td>67.30</td><td>39.42</td><td>37.40</td><td>60.74</td></tr><tr><td>SliceGPT</td><td>46.73</td><td>69.04</td><td>58.98</td><td>64.33</td><td>60.31</td><td>35.07</td><td>40.40</td><td>53.55</td></tr><tr><td>LoRD</td><td>72.60</td><td>73.56</td><td>63.70</td><td>65.90</td><td>69.70</td><td>37.71</td><td>39.20</td><td>60.34</td></tr><tr><td>ASVD</td><td>73.61</td><td>71.93</td><td>66.05</td><td>64.17</td><td>65.24</td><td>36.26</td><td>37.40</td><td>59.24</td></tr><tr><td>Bolaco (5 × 1)</td><td>72.17</td><td>75.52</td><td>66.76</td><td>67.72</td><td>73.02</td><td>38.74</td><td>40.60</td><td>62.08</td></tr><tr><td>Bolaco (5 × 1 w/ PT)</td><td>73.79</td><td>77.53</td><td>72.72</td><td>68.11</td><td>73.19</td><td>42.24</td><td>43.60</td><td>64.45</td></tr><tr><td>Bolaco (5 × 4)</td><td>75.05</td><td>75.46</td><td>67.12</td><td>67.01</td><td>72.05</td><td>38.91</td><td>42.40</td><td>62.57</td></tr><tr><td>Bolaco (5 × 4 w/ PT)</td><td>75.84</td><td>76.61</td><td>71.70</td><td>65.67</td><td>72.60</td><td>41.81</td><td>45.00</td><td>64.18</td></tr><tr><td rowspan="10">30%</td><td>LLM-Pruner</td><td>52.51</td><td>71.93</td><td>59.49</td><td>58.72</td><td>61.41</td><td>33.96</td><td>36.60</td><td>53.52</td></tr><tr><td>LLM-Pruner (w/ PT)</td><td>63.30</td><td>76.01</td><td>65.23</td><td>64.25</td><td>66.62</td><td>37.20</td><td>40.20</td><td>58.97</td></tr><tr><td>FLAP</td><td>66.88</td><td>72.74</td><td>63.80</td><td>64.01</td><td>60.65</td><td>34.47</td><td>36.40</td><td>56.99</td></tr><tr><td>SliceGPT</td><td>39.11</td><td>63.38</td><td>49.16</td><td>62.47</td><td>55.72</td><td>31.48</td><td>32.80</td><td>47.73</td></tr><tr><td>LoRD</td><td>69.63</td><td>70.46</td><td>55.87</td><td>64.17</td><td>63.80</td><td>32.59</td><td>35.00</td><td>55.93</td></tr><tr><td>ASVD</td><td>59.42</td><td>55.93</td><td>35.05</td><td>52.25</td><td>34.30</td><td>26.45</td><td>26.60</td><td>41.43</td></tr><tr><td>Bolaco (5 × 1)</td><td>68.26</td><td>72.09</td><td>57.46</td><td>65.87</td><td>65.19</td><td>32.85</td><td>37.20</td><td>56.99</td></tr><tr><td>Bolaco (5 × 1 w/ PT)</td><td>70.34</td><td>74.32</td><td>67.81</td><td>65.04</td><td>69.02</td><td>38.31</td><td>41.80</td><td>60.95</td></tr><tr><td>Bolaco (5 × 4)</td><td>70.37</td><td>71.44</td><td>59.62</td><td>64.80</td><td>66.46</td><td>34.39</td><td>38.60</td><td>57.95</td></tr><tr><td>Bolaco (5 × 4 w/ PT)</td><td>71.83</td><td>75.19</td><td>68.03</td><td>65.67</td><td>69.15</td><td>38.74</td><td>42.40</td><td>61.57</td></tr></table>
|
| 185 |
+
|
| 186 |
+
Table 1: Zero-shot performance of the compressed LLaMA-v2-7b models. w/ PT means the method with posttraining. Bold denotes the best result at the same compression ratio, while underline indicates the second best result.
|
| 187 |
+
|
| 188 |
+
<table><tr><td></td><td>Wikitext (↓)</td><td>PTB (↓)</td><td>C4 (↓)</td><td>ZS (↑)</td></tr><tr><td colspan="5">Covariance estimate</td></tr><tr><td>Naive SCM</td><td>9.96</td><td>54.69</td><td>11.46</td><td>60.34</td></tr><tr><td>Pooled SCM</td><td>9.93</td><td>54.68</td><td>11.45</td><td>60.64</td></tr><tr><td colspan="5"># Samples</td></tr><tr><td>128</td><td>10.55</td><td>56.29</td><td>11.99</td><td>60.26</td></tr><tr><td>256</td><td>10.24</td><td>55.42</td><td>11.88</td><td>60.16</td></tr><tr><td>512</td><td>10.30</td><td>55.03</td><td>11.61</td><td>60.56</td></tr><tr><td>1,024</td><td>9.93</td><td>54.68</td><td>11.45</td><td>60.64</td></tr></table>
|
| 189 |
+
|
| 190 |
+
Table 2: Impact of different covariance estimation methods and the number of calibration data. "ZS" denotes the average performance on seven zero-shot common sense reasoning datasets.
|
| 191 |
+
|
| 192 |
+
<table><tr><td></td><td>Wikitext (↓)</td><td>PTB (↓)</td><td>Zero-shot (↑)</td></tr><tr><td colspan="4">20%</td></tr><tr><td>PPL (5 × 1)</td><td>8.36</td><td>48.42</td><td>61.70</td></tr><tr><td>w/ RKL (5 × 1)</td><td>8.27</td><td>47.06</td><td>62.08</td></tr><tr><td>PPL (5 × 4)</td><td>8.07</td><td>47.96</td><td>60.98</td></tr><tr><td>w/ RKL (5 × 4)</td><td>7.96</td><td>45.84</td><td>62.57</td></tr><tr><td colspan="4">30%</td></tr><tr><td>PPL (5 × 1)</td><td>13.78</td><td>71.50</td><td>56.97</td></tr><tr><td>w/ RKL (5 × 1)</td><td>13.41</td><td>70.52</td><td>56.99</td></tr><tr><td>PPL (5 × 4)</td><td>12.65</td><td>68.85</td><td>57.57</td></tr><tr><td>w/ RKL (5 × 4)</td><td>13.70</td><td>72.14</td><td>57.95</td></tr></table>
|
| 193 |
+
|
| 194 |
+
Table 3: Results under different objective function.
|
| 195 |
+
|
| 196 |
+
term may serve two roles. Firstly, as a regularization term, it prevents overfitting on smaller validation sets during BO. Although the compressed model exhibits a slight increase in perplexity on the language modeling dataset at the $20\%$ compression rate with the $5 \times 4$ setting, there is a significant improvement in performance on downstream tasks. Secondly, incorporating the RKL term may smooth the objective function, enabling the Gaussian process surrogate model to more accurately approximate the real black-box objective function.
|
| 197 |
+
|
| 198 |
+
# 5.3 The Transferability of Rank Allocation
|
| 199 |
+
|
| 200 |
+
In practical applications, we may utilize a variety of fine-tuned models based on the LLaMA foundation model. If we perform Bayesian optimization
|
| 201 |
+
|
| 202 |
+
from scratch to optimize the low-rank allocation for each model, it will waste a significant amount of time and computational resources. Hence, we investigate whether the low-rank allocation of the base model can be transferred to the corresponding fine-tuned models. We transfer the allocation of LLaMA-v2-7b/13b to LLaMA-v2-7b/13b-chat, respectively. We consider two migration strategies: a) directly reusing the low-rank allocation of the base model and b) using the low-rank allocation of the base model as the initial value for Bayesian optimization and then optimizing only 20 epochs. As Figure 4 shows, direct reusing can achieve results that outperform all baseline methods, even the Bayesian optimization from scratch. If 20 epochs of Bayesian optimization follow reuse, there is a
|
| 203 |
+
|
| 204 |
+

|
| 205 |
+
Figure 4: The average performance on zero-shot tasks about the transferability of rank allocation.
|
| 206 |
+
|
| 207 |
+
chanceto findan even better low-rankallocation.
|
| 208 |
+
|
| 209 |
+
# 5.4 The Effectiveness of Validation Data Sampling
|
| 210 |
+
|
| 211 |
+
Table 4 shows results on LLaMA-v2-7b at $20\%$ compression ratios under Wikipedia and its sampled data. The top-100 and bottom-100 represent the 100 samples with the highest and lowest perplexity variances, respectively. BO can optimize a good result when using Wikipedia and the top-100 sampled data for validation, showing that our method can sample a smaller subset for improving validation efficiency while maintaining performance comparable to the entire dataset. Conversely, with the bottom-100 sampled data, BO's optimization performance is significantly inferior, with performance similar to unoptimized LoRD. Furthermore, we observe that the top-100 samples (6.09 ppl) have higher perplexity than the bottom-100 samples (3.25 ppl) in the original LLaMA-v2-7b, indicating that the bottom-100 samples are already well-modeled and are very robust to model compression. This data may not truly reflect the performance change caused by model compression. Therefore, we suggest selecting validation data that is more sensitive to compression, typically samples with slightly worse language modeling performance. Similar to the " buckets effect", these samples may represent the performance boundaries of LLMs. Considering the performance of these samples in the optimization process can maximize the overall performance of the compressed model.
|
| 212 |
+
|
| 213 |
+
# 6 Related work
|
| 214 |
+
|
| 215 |
+
A common technique for low-rank factorization is SVD, which retains only the top- $r$ largest singular values and their corresponding singular vectors to obtain two rank- $r$ matrices. Ben Noach and
|
| 216 |
+
|
| 217 |
+
<table><tr><td></td><td>Wikitext (↓)</td><td>PTB (↓)</td><td>Zero-shot (↑)</td></tr><tr><td>Wikipedia</td><td>7.98</td><td>46.85</td><td>62.27</td></tr><tr><td>Top-100</td><td>7.96</td><td>45.84</td><td>62.57</td></tr><tr><td>Bottom-100</td><td>8.38</td><td>50.41</td><td>60.90</td></tr></table>
|
| 218 |
+
|
| 219 |
+
Table 4: Results under different validation data.
|
| 220 |
+
|
| 221 |
+
Goldberg (2020) first combine SVD with knowledge distillation, applying it to compress BERT. Directly applying SVD decomposition implies an assumption that each parameter in the weight matrix equally affects the model performance. This contradicts many previous research, therefore, FWSVD (Hsu et al., 2022) and TFWSVD (Hua et al., 2022) consider weighting the weight matrix using Fisher information. Chen et al. (2021) observe that PLMs' weights are not inherently low-rank matrices. Therefore, directly applying SVD will result in significant reconstruction loss. However, they find that the product of data representation and weights is low-rank. Hence, they perform a global low-rank decomposition on it. Following this observation, Yu and Wu (2023) propose the atomic feature mimicking (AFM) method to decompose the output features. Ren and Zhu (2023) also observe the high rank phenomenon of PLM weights. They utilize iterative first-order unstructured pruning to reduce the rank of the weight matrix, and then apply Fisher information-weighted SVD decomposition for low-rank compression. For LLMs, low-rank compression has not yet received the attention it deserves. LoRD (Kaushal et al., 2023) applies AFM to code LLMs, demonstrating the potential of low-rank decomposition in compressing LLM. Recently, Sharma et al. (2023) conduct an in-depth study on the weight decomposition of LLMs and discover that the low-rank components of the weights encapsulate low-frequency information. By meticulously selecting low-rank components, it is possible to eliminate interfering signals and further improve LLMs' performance. However, their research does not propose a practical low-rank compression algorithm.
|
| 222 |
+
|
| 223 |
+
# 7 Conclusion
|
| 224 |
+
|
| 225 |
+
In this paper, we attempt to unearth the potential of low-rank compression for lightweight universal LLMs. We thoroughly investigate the challenges of low-rank compression in LLMs and the low-rank characteristics of features within LLMs. We propose a Bayesian optimization-based feature
|
| 226 |
+
|
| 227 |
+
low-rank compression to address these challenges, incorporating pooled covariance estimation and Bayesian optimization for more precise feature distribution estimation and low-rank dimension allocation, respectively. Experimental results on the LLaMA 2 model demonstrate that our method significantly outperforms existing structured pruning and other low-rank compression techniques.
|
| 228 |
+
|
| 229 |
+
# Limitations
|
| 230 |
+
|
| 231 |
+
Although our proposed Bolaco has made significant progress in low-rank compression for LLMs, there are still some limitations:
|
| 232 |
+
|
| 233 |
+
- Due to computational resource constraints, we only conduct thorough experiments on two commonly used LLaMA 2 models, lacking investigation into larger models (such as LLaMA 2-70B), other architectures (such as the OPT and T5 families), and multimodal models.
|
| 234 |
+
- To improve the efficiency of Bayesian optimization, we reduced the parameter dimensions by sharing parameters of different types and layers using low-rank dimensions. This may limit the potential performance of the model. We plan to use more advanced methods to find better low-rank allocation while maintaining flexibility.
|
| 235 |
+
- Compared to state-of-the-art structured pruning, low-rank compression falls short in highly compressed language models, but exhibits better zero-shot performance on downstream tasks. These observations inspire us to investigate how to effectively combine these two approaches to capitalize on their advantages in the future.
|
| 236 |
+
|
| 237 |
+
# Acknowledgments
|
| 238 |
+
|
| 239 |
+
We want to thank all the anonymous reviewers for their valuable comments. This work was supported by the National Science Foundation of China (NSFC No. 62206194, 62276077, and U23B2055), the Natural Science Foundation of Jiangsu Province, China (Grant No. BK20220488), Young Elite Scientists Sponsorship Program by CAST (2023QNRC001), and Huawei Cloud.
|
| 240 |
+
|
| 241 |
+
# References
|
| 242 |
+
|
| 243 |
+
Yongqi An, Xu Zhao, Tao Yu, Ming Tang, and Jinqiao Wang. 2023. Fluctuation-based adaptive structured pruning for large language models.
|
| 244 |
+
Sotiris Anagnostidis, Luca Biggio, Lorenzo Noci, Antonio Orvieto, Sidak Pal Singh, and Aurelien Lucchi.
|
| 245 |
+
|
| 246 |
+
2022. Signal propagation in transformers: Theoretical perspectives and the role of rank collapse. In Advances in Neural Information Processing Systems.
|
| 247 |
+
Saleh Ashkboos, Maximilian L. Croci, Marcelo Gennari do Nascimento, Torsten Hoefler, and James Hensman. 2024. SliceGPT: Compress large language models by deleting rows and columns. In The Twelfth International Conference on Learning Representations.
|
| 248 |
+
Matan Ben Noach and Yoav Goldberg. 2020. Compressing pre-trained language models by matrix decomposition. In Proceedings of the 1st Conference of the Asia-Pacific Chapter of the Association for Computational Linguistics and the 10th International Joint Conference on Natural Language Processing, pages 884-889, Suzhou, China. Association for Computational Linguistics.
|
| 249 |
+
Yonatan Bisk, Rowan Zellers, Ronan bras, Jianfeng Gao, and Choi Yejin. 2020. Piqa: Reasoning about physical commonsense in natural language. Proceedings of the AAAI Conference on Artificial Intelligence, 34:7432-7439.
|
| 250 |
+
Sebastien Bubeck, Varun Chandrasekaran, Ronen Eldan, Johannes Gehrke, Eric Horvitz, Ece Kamar, Peter Lee, Yin Tat Lee, Yuanzhi Li, Scott Lundberg, Harsha Nori, Hamid Palangi, Marco Tulio Ribeiro, and Yi Zhang. 2023. Sparks of artificial general intelligence: Early experiments with gpt-4.
|
| 251 |
+
Patrick Chen, Hsiang-Fu Yu, Inderjit Dhillon, and Chojui Hsieh. 2021. Drone: Data-aware low-rank compression for large nlp models. In Advances in Neural Information Processing Systems, volume 34, pages 29321-29334. Curran Associates, Inc.
|
| 252 |
+
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.
|
| 253 |
+
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.
|
| 254 |
+
Yihe Dong, Jean-Baptiste Cordonnier, and Andreas Loukas. 2023. Attention is not all you need: Pure attention loses rank doubly exponentially with depth.
|
| 255 |
+
Elias Frantar and Dan Alistarh. 2023a. SparseGPT: Massive language models can be accurately pruned in one-shot. In Proceedings of the 40th International Conference on Machine Learning, volume 202 of Proceedings of Machine Learning Research, pages 10323-10337. PMLR.
|
| 256 |
+
Elias Frantar and Dan Alistarh. 2023b. SparseGPT: Massive language models can be accurately pruned in one-shot. arXiv preprint arXiv:2301.00774.
|
| 257 |
+
|
| 258 |
+
Elias Frantar, Saleh Ashkboos, Torsten Hoefler, and Dan Alistarh. 2023. OPTQ: Accurate quantization for generative pre-trained transformers. In The Eleventh International Conference on Learning Representations.
|
| 259 |
+
Yuxian Gu, Li Dong, Furu Wei, and Minlie Huang. 2024. MiniLLM: Knowledge distillation of large language models. In The Twelfth International Conference on Learning Representations.
|
| 260 |
+
Jordan Hoffmann, Sebastian Borgeaud, Arthur Mensch, Elena Buchatskaya, Trevor Cai, Eliza Rutherford, Diego de Las Casas, Lisa Anne Hendricks, Johannes Welbl, Aidan Clark, Tom Hennigan, Eric Noland, Katie Millican, George van den Driessche, Bogdan Damoc, Aurelia Guy, Simon Osindero, Karen Simonyan, Erich Elsen, Jack W. Rae, Oriol Vinyals, and Laurent Sifre. 2022. Training compute-optimal large language models.
|
| 261 |
+
Yen-Chang Hsu, Ting Hua, Sungen Chang, Qian Lou, Yilin Shen, and Hongxia Jin. 2022. Language model compression with weighted low-rank factorization. In International Conference on Learning Representations.
|
| 262 |
+
Edward J Hu, yelong shen, Phillip Wallis, Zeyuan Allen-Zhu, Yanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. 2022. LoRA: Low-rank adaptation of large language models. In International Conference on Learning Representations.
|
| 263 |
+
Ting Hua, Yen-Chang Hsu, Felicity Wang, Qian Lou, Yilin Shen, and Hongxia Jin. 2022. Numerical optimizations for weighted low-rank estimation on language models. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pages 1404-1416, Abu Dhabi, United Arab Emirates. Association for Computational Linguistics.
|
| 264 |
+
Jared Kaplan, Sam McCandlish, Tom Henighan, Tom B. Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu, and Dario Amodei. 2020. Scaling laws for neural language models.
|
| 265 |
+
Ayush Kaushal, Tejas Vaidhya, and Irina Rish. 2023. Lord: Low rank decomposition of monolingual code llms for one-shot compression.
|
| 266 |
+
Dawid J. Kopiczko, Tijmen Blankevoort, and Yuki M. Asano. 2024. ELoRA: Efficient low-rank adaptation with random matrices. In The Twelfth International Conference on Learning Representations.
|
| 267 |
+
Yixiao Li, Yifan Yu, Qingru Zhang, Chen Liang, Pengcheng He, Weizhu Chen, and Tuo Zhao. 2023. LoSparse: Structured compression of large language models based on low-rank and sparse approximation. In Proceedings of the 40th International Conference on Machine Learning, volume 202 of Proceedings of Machine Learning Research, pages 20336-20350. PMLR.
|
| 268 |
+
Ji Lin, Jiaming Tang, Haotian Tang, Shang Yang, Xingyu Dang, Chuang Gan, and Song Han. 2023.
|
| 269 |
+
|
| 270 |
+
Awq: Activation-aware weight quantization for llm compression and acceleration.
|
| 271 |
+
Zechun Liu, Barlas Oguz, Changsheng Zhao, Ernie Chang, Pierre Stock, Yashar Mehdad, Yangyang Shi, Raghuraman Krishnamoorthi, and Vikas Chandra. 2023. Llm-qat: Data-free quantization aware training for large language models.
|
| 272 |
+
Xinyin Ma, Gongfan Fang, and Xinchao Wang. 2023. LLM-pruner: On the structural pruning of large language models. In Thirty-seventh Conference on Neural Information Processing Systems.
|
| 273 |
+
Mitchell P. Marcus, Beatrice Santorini, and Mary Ann Marcinkiewicz. 1993. Building a large annotated corpus of English: The Penn Treebank. Computational Linguistics, 19(2):313-330.
|
| 274 |
+
Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. 2016. Pointer sentinel mixture models.
|
| 275 |
+
Todor Mihaylov, Peter Clark, Tushar Khot, and Ashish Sabharwal. 2018. Can a suit of armor conduct electricity? a new dataset for open book question answering. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pages 2381-2391, Brussels, Belgium. Association for Computational Linguistics.
|
| 276 |
+
OpenAI. 2022. Chatgpt: Optimizing language models for dialogue. Open AI, blog.
|
| 277 |
+
OpenAI. 2023. Gpt-4 technical report. ArXiv, abs/2303.08774.
|
| 278 |
+
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.
|
| 279 |
+
Elias Raninen, David E. Tyler, and Esa Ollila. 2022. Linear pooling of sample covariance matrices. IEEE Transactions on Signal Processing, 70:659-672.
|
| 280 |
+
Siyu Ren and Kenny Q. Zhu. 2023. Low-rank prune-and-factorize for language model compression.
|
| 281 |
+
Keisuke Sakaguchi, Ronan Le Bras, Chandra Bhagavatula, and Yejin Choi. 2021. Winogrande: an adversarial winograd schema challenge at scale. Commun. ACM, 64(9):99-106.
|
| 282 |
+
Pratyusha Sharma, Jordan T. Ash, and Dipendra Misra. 2023. The truth is in there: Improving reasoning in language models with layer-selective rank reduction.
|
| 283 |
+
Mingjie Sun, Zhuang Liu, Anna Bair, and J. Zico Kolter. 2023. A simple and effective pruning approach for large language models. arXiv preprint arXiv:2306.11695.
|
| 284 |
+
|
| 285 |
+
Mingjie Sun, Zhuang Liu, Anna Bair, and J Zico Kolter. 2024. A simple and effective pruning approach for large language models. In *The Twelfth International Conference on Learning Representations*.
|
| 286 |
+
Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li, Carlos Guestrin, Percy Liang, and Tatsunori B. Hashimoto. 2023. Stanford alpaca: An instruction-following llama model. https://github.com/tatsu-lab/stanford_alpaca.
|
| 287 |
+
Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajwal Bhargava, Shruti Bhosale, Dan Bikel, Lukas Blecher, Cristian Canton Ferrer, Moya Chen, Guillem Cucurull, David Esiobu, Jude Fernandes, Jeremy Fu, Wenyin Fu, Brian Fuller, Cynthia Gao, Vedanuj Goswami, Naman Goyal, Anthony Hartshorn, Saghar Hosseini, Rui Hou, Hakan Inan, Marcin Kardas, Viktor Kerkez, Madian Khabsa, Isabel Kloumann, Artem Korenev, Punit Singh Koura, Marie-Anne Lachaux, Thibaut Lavril, Jenya Lee, Diana Liskovich, Yinghai Lu, Yuning Mao, Xavier Martinez, Todor Mihaylov, Pushkar Mishra, Igor Molybog, Yixin Nie, Andrew Poulton, Jeremy Reizenstein, Rashi Rungta, Kalyan Saladi, Alan Schelten, Ruan Silva, Eric Michael Smith, Ranjan Subramanian, Xiaqing Ellen Tan, Binh Tang, Ross Taylor, Adina Williams, Jian Xiang Kuan, Puxin Xu, Zheng Yan, Iliyan Zarov, Yuchen Zhang, Angela Fan, Melanie Kambadur, Sharan Narang, Aurelien Rodriguez, Robert Stojnic, Sergey Edunov, and Thomas Scialom. 2023. Llama 2: Open foundation and finetuned chat models.
|
| 288 |
+
Zhongwei Wan, Xin Wang, Che Liu, Samiul Alam, Yu Zheng, Jiachen Liu, Zhongnan Qu, Shen Yan, Yi Zhu, Quanlu Zhang, Mosharaf Chowdhury, and Mi Zhang. 2024. Efficient large language models: A survey.
|
| 289 |
+
B. P. Welford. 1962. Note on a method for calculating corrected sums of squares and products. Technometrics, 4(3):419-420.
|
| 290 |
+
Wenjie Xu, Yuning Jiang, Emilio T. Maddalena, and Colin N. Jones. 2022. Lower bounds on the worst-case complexity of efficient global optimization.
|
| 291 |
+
Zhengyuan Yang, Linjie Li, Kevin Lin, Jianfeng Wang, Chung-Ching Lin, Zicheng Liu, and Lijuan Wang. 2023. The dawn of Imms: Preliminary explorations with gpt-4v(ison).
|
| 292 |
+
Hao Yu and Jianxin Wu. 2023. Compressing transformers: Features are low-rank, but weights are not! Proceedings of the AAAI Conference on Artificial Intelligence, 37(9):11007-11015.
|
| 293 |
+
Zhihang Yuan, Yuzhang Shang, Yue Song, Qiang Wu, Yan Yan, and Guangyu Sun. 2023. Asvd: Activation-aware singular value decomposition for compressing large language models. arXiv preprint arXiv:2312.05821.
|
| 294 |
+
|
| 295 |
+
Rowan Zellers, Ari Holtzman, Yonatan Bisk, Ali Farhadi, and Yejin Choi. 2019. HellaSwag: Can a machine really finish your sentence? In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 4791-4800, Florence, Italy. Association for Computational Linguistics.
|
| 296 |
+
|
| 297 |
+
# A More Experiments on Low-rank Sensitivity
|
| 298 |
+
|
| 299 |
+
As shown in Figure 5. We further reduce the parameters by $50\%$ on LLaMA-v2-7b by low-rank compression for each layer and test its perplexity on WikiText2. We observe that the low-rank sensitivity varies significantly across different types of parameters. Compression of $attn_q$ and $attn_k$ seemingly has negligible impact on overall performance across all layers. In contrast, the upper layers of $mlp$ are more sensitive compared to the lower and middle layers. We also conduct experiments on LLaMA-7b-chat and OPT-6.7b and find significant variability between all the different types of parameters. However, for OPT-6.7b, the differences between them are less pronounced than for LLaMa, especially for $attn_v$ , which does not show an explosive increase in perplexity.
|
| 300 |
+
|
| 301 |
+
# B Baselines
|
| 302 |
+
|
| 303 |
+
LLM-Pruner (Ma et al., 2023) is a dependency-aware one-shot structured pruning method. It evaluates the importance of each structure through a first-order Taylor expansion and prunes the structures with the lowest scores. After pruning, it uses LoRA post-training to recover performance.
|
| 304 |
+
|
| 305 |
+
FLAP (An et al., 2023) is an one-shot retraining-free structured pruning method. It utilizes a fluctuation-based metric to measure the impact of pruning on features and employs a bias term to compensate for the pruning loss.
|
| 306 |
+
|
| 307 |
+
SliceGPT (Ashkboos et al., 2024) is a post-training sparsification method. It replaces each weight matrix with a smaller matrix, reducing the embedding dimension of the network.
|
| 308 |
+
|
| 309 |
+
LoRD (Kaushal et al., 2023) is a naive feature-based low-rank compression method for code LLMs. It does not take into account the low-rank allocation of varying parameters. We migrate it to generic LLaMA-family LLMs.
|
| 310 |
+
|
| 311 |
+
ASVD (Yuan et al., 2023) is a training-free SVD-based LLM compression method. It manages activation outliers by scaling the weight matrix based on the activation distribution.
|
| 312 |
+
|
| 313 |
+
# C Implementation Details
|
| 314 |
+
|
| 315 |
+
For LoRD, due to the absence of reference settings for its application on the LLaMA, we manually search a good low-rank allocation for it. At the $20\%$ compression ratio, we do not compress $attn_v$ , and reduce the parameter count of $attn_q / k$ by $30\%$ ,
|
| 316 |
+
|
| 317 |
+
with a $20\%$ reduction in the remaining parameters. At the $30\%$ ratio, we reduce the parameter count of $\text{attn}_q / k$ by $45\%$ , with a $30\%$ reduction in the remaining parameters except $\text{attn}_v$ .
|
| 318 |
+
|
| 319 |
+
At the post-training stage, we only add finetunable low-rank matrices for the compressed parameters. We set the low-rank dimension $r' = 256$ , the learning rate is 2e-3, and the batch size is 64.
|
| 320 |
+
|
| 321 |
+
# D Discussion on compute intensive about Bolaco
|
| 322 |
+
|
| 323 |
+
The computational cost of our method is divided into three parts:
|
| 324 |
+
|
| 325 |
+
PCA decomposition Our method requires only one PCA decomposition of the obtained representations and truncates them according to the assigned rank during the rank allocation process to generate various compressed models. The computational cost here is the same as that of the existing low-rank decomposition method LORD.
|
| 326 |
+
|
| 327 |
+
Obtaining evaluation results In our experiments, the validation set we selected is not large, about 34k tokens, so the validation process takes less time, and the total validation time spent by llama-2-7b is about 40-45min on a 40G A100.
|
| 328 |
+
|
| 329 |
+
Bayesian Optimization The computational time for 50 epochs of Bayesian optimization is approximately 45-50 minutes, which is considered acceptable in practical applications. Compared to iterative pruning, Bayesian optimization is more memory-efficient, as it only requires the memory overhead of forward propagation without storing gradients, momentum, or other optimizer states. Furthermore, as discovered in Section 5.5, the low-rank configurations optimized on a base model can be transferred directly, or with few rounds of Bayesian optimization, to variant models with the same architecture. It implies that we can quickly obtain a well-performing, low-rank compressed model for fine-tuned LLMs on different datasets in practice.
|
| 330 |
+
|
| 331 |
+
# E Statistics of the Compressed Model
|
| 332 |
+
|
| 333 |
+
We report the statistic of original and compressed models in Table 7, including the parameter count, MACs and memory requirements. Statistical evaluation is conducted using the inference mode, where the model is fed a sentence consisting of 64 tokens.
|
| 334 |
+
|
| 335 |
+
To aid subsequent researchers in reproducing our results, Table 8 provides the low-rank allocations of Bolaco. The elements of the array represent the low-rank dimensions for $\text{attn}_q / k$ , $\text{attn}_o$ ,
|
| 336 |
+
|
| 337 |
+
<table><tr><td>Ratio</td><td>Methods</td><td>BoolQ</td><td>PIQA</td><td>HellaSwag</td><td>WinoGrande</td><td>ARC-e</td><td>ARC-c</td><td>OBQA</td><td>Average</td></tr><tr><td>0%</td><td>LLaMA-v2-13b</td><td>80.52</td><td>79.05</td><td>79.38</td><td>72.14</td><td>79.42</td><td>49.23</td><td>45.20</td><td>69.27</td></tr><tr><td rowspan="10">20%</td><td>LLM-Pruner</td><td>66.33</td><td>78.18</td><td>74.47</td><td>64.48</td><td>72.26</td><td>45.90</td><td>44.20</td><td>63.69</td></tr><tr><td>LLM-Pruner (w/ PT)</td><td>67.06</td><td>78.94</td><td>75.92</td><td>67.32</td><td>72.69</td><td>44.28</td><td>44.60</td><td>64.40</td></tr><tr><td>FLAP</td><td>71.28</td><td>76.55</td><td>74.67</td><td>69.53</td><td>72.56</td><td>44.03</td><td>42.00</td><td>64.37</td></tr><tr><td>SliceGPT</td><td>45.44</td><td>71.00</td><td>62.86</td><td>68.35</td><td>71.09</td><td>41.72</td><td>41.20</td><td>57.38</td></tr><tr><td>ASVD</td><td>79.36</td><td>76.61</td><td>72.82</td><td>69.69</td><td>74.54</td><td>43.00</td><td>44.60</td><td>65.80</td></tr><tr><td>LoRD</td><td>78.47</td><td>76.01</td><td>69.58</td><td>71.03</td><td>74.33</td><td>40.87</td><td>44.40</td><td>64.96</td></tr><tr><td>Bolaco (5 × 1)</td><td>80.00</td><td>76.50</td><td>73.25</td><td>70.24</td><td>76.18</td><td>43.86</td><td>45.20</td><td>66.46</td></tr><tr><td>Bolaco (5 × 1 w/ PT)</td><td>81.22</td><td>77.69</td><td>76.66</td><td>71.59</td><td>77.31</td><td>46.93</td><td>44.00</td><td>67.91</td></tr><tr><td>Bolaco (5 × 4)</td><td>80.58</td><td>76.22</td><td>71.44</td><td>71.19</td><td>75.38</td><td>42.49</td><td>44.00</td><td>65.90</td></tr><tr><td>Bolaco (5 × 4 w/ PT)</td><td>80.95</td><td>77.64</td><td>75.84</td><td>69.93</td><td>75.25</td><td>45.14</td><td>44.20</td><td>67.00</td></tr><tr><td rowspan="10">30%</td><td>LLM-Pruner</td><td>62.45</td><td>75.90</td><td>67.90</td><td>60.22</td><td>65.45</td><td>40.36</td><td>44.60</td><td>59.55</td></tr><tr><td>LLM-Pruner (w/ PT)</td><td>68.29</td><td>76.66</td><td>72.03</td><td>64.09</td><td>69.20</td><td>41.13</td><td>45.40</td><td>62.40</td></tr><tr><td>FLAP</td><td>65.54</td><td>74.81</td><td>70.29</td><td>67.48</td><td>67.38</td><td>38.23</td><td>40.00</td><td>60.53</td></tr><tr><td>SliceGPT</td><td>38.84</td><td>64.47</td><td>52.34</td><td>65.51</td><td>59.51</td><td>36.86</td><td>39.20</td><td>50.96</td></tr><tr><td>ASVD</td><td>70.34</td><td>68.01</td><td>53.41</td><td>60.93</td><td>59.72</td><td>32.00</td><td>36.60</td><td>54.43</td></tr><tr><td>LoRD</td><td>75.05</td><td>73.88</td><td>63.08</td><td>69.46</td><td>69.78</td><td>39.16</td><td>38.60</td><td>61.29</td></tr><tr><td>Bolaco (5 × 1)</td><td>79.20</td><td>74.97</td><td>65.23</td><td>67.32</td><td>72.35</td><td>39.25</td><td>41.20</td><td>62.79</td></tr><tr><td>Bolaco (5 × 1 w/ PT)</td><td>78.78</td><td>76.17</td><td>73.04</td><td>68.51</td><td>74.75</td><td>43.60</td><td>44.00</td><td>65.55</td></tr><tr><td>Bolaco (5 × 4)</td><td>80.24</td><td>74.48</td><td>66.77</td><td>69.14</td><td>72.18</td><td>41.13</td><td>41.00</td><td>63.56</td></tr><tr><td>Bolaco (5 × 4 w/ PT)</td><td>80.40</td><td>76.66</td><td>73.42</td><td>69.06</td><td>73.74</td><td>45.14</td><td>43.40</td><td>65.97</td></tr></table>
|
| 338 |
+
|
| 339 |
+
Table 5: Zero-shot performance of the compressed LLaMA-v2-13b models. w/ PT means the method with posttraining. Bold denotes the best result at the same compression ratio, while underline indicates the second best result.
|
| 340 |
+
|
| 341 |
+
<table><tr><td>Ratio</td><td>Methods</td><td>BoolQ</td><td>PIQA</td><td>HellaSwag</td><td>WinoGrande</td><td>ARC-e</td><td>ARC-c</td><td>OBQA</td><td>Average</td></tr><tr><td>0%</td><td>Mistral-7B-v0.1</td><td>83.67</td><td>80.52</td><td>81.03</td><td>73.80</td><td>80.85</td><td>54.01</td><td>43.8</td><td>71.10</td></tr><tr><td></td><td>LLM-Pruner</td><td>70.06</td><td>77.31</td><td>72.50</td><td>68.35</td><td>69.11</td><td>38.23</td><td>41.80</td><td>62.48</td></tr><tr><td></td><td>LORD</td><td>73.82</td><td>74.86</td><td>65.53</td><td>69.22</td><td>71.55</td><td>41.13</td><td>36.20</td><td>61.76</td></tr><tr><td>20%</td><td>Bolaco (5 × 1)</td><td>74.13</td><td>76.01</td><td>66.26</td><td>69.69</td><td>74.24</td><td>42.15</td><td>39.40</td><td>63.13</td></tr><tr><td></td><td>Bolaco (5 × 4)</td><td>77.58</td><td>76.12</td><td>67.44</td><td>70.09</td><td>74.96</td><td>42.41</td><td>39.40</td><td>64.00</td></tr></table>
|
| 342 |
+
|
| 343 |
+
Table 6: Zero-shot performance of the compressed Mistral-7B-v0.1 models. Bold denotes the best result at the same compression ratio, while underline indicates the second best result.
|
| 344 |
+
|
| 345 |
+
mlp_GATE, mlp_up, and mlp_down, respectively. 'NA' denotes that the parameter is not compressed.
|
| 346 |
+
|
| 347 |
+
# F Language Modeling Capabilities for Compressed Models
|
| 348 |
+
|
| 349 |
+
Figure 6 illustrates the perplexity changes on WikiText, PTB, and C4 datasets for different compression methods on LLaMA-v2-7b and 13b as the compression rate increases.
|
| 350 |
+
|
| 351 |
+
# G Case Study
|
| 352 |
+
|
| 353 |
+
We showcase the generation results of the LLaMAv2-7b and its compression model via Bolaco in Table 9. We observe that models compressed via Bolaco tend to produce brief and repetitive responses to prompts without post-training. However, this issue can be resolved after efficient post-training, resulting in smooth and informative replies.
|
| 354 |
+
|
| 355 |
+
# G.1 The Generalization of Validation Data
|
| 356 |
+
|
| 357 |
+
To verify the generalizability of the Bayesian optimization used in Bolaco across various validation data, we sample subsets from the Wikitext, C4, ArXiv, and Wikipedia pre-training datasets to serve as Bolaco's validation data. Table 10 presents the results of Bolaco on these validation data at $20\%$ compression ratio. We observe that models optimized on different validation data exhibit different performance on a single test set, particularly in language modeling capabilities, likely due to the diverse linguistic features of the validation data. However, the average performance across multiple common sense reasoning datasets remains nearly identical, demonstrating the robustness of our method in general capabilities across different validation data.
|
| 358 |
+
|
| 359 |
+
<table><tr><td>Method</td><td>Ratio</td><td>#Params</td><td>MACs</td><td>Memory</td></tr><tr><td>LLaMA 2-7b</td><td>0%</td><td>6.74B</td><td>423.98G</td><td>12.62GiB</td></tr><tr><td>LLM-Pruner</td><td>20%</td><td>5.42B</td><td>340.48G</td><td>10.16GiB</td></tr><tr><td>FLAP</td><td>20%</td><td>5.45B</td><td>342.30G</td><td>10.22GiB</td></tr><tr><td>LoRD</td><td>20%</td><td>5.45B</td><td>370.12G</td><td>10.32GiB</td></tr><tr><td>Bolaco (5 × 1)</td><td>20%</td><td>5.44B</td><td>388.95G</td><td>10.28GiB</td></tr><tr><td>Bolaco (5 × 4)</td><td>20%</td><td>5.44B</td><td>391.18G</td><td>10.25GiB</td></tr><tr><td>LLM-Pruner</td><td>30%</td><td>4.84B</td><td>302.83G</td><td>9.17GiB</td></tr><tr><td>FLAP</td><td>30%</td><td>4.80B</td><td>300.72G</td><td>9.04GiB</td></tr><tr><td>LoRD</td><td>30%</td><td>4.79B</td><td>341.91G</td><td>9.07GiB</td></tr><tr><td>Bolaco (5 × 1)</td><td>30%</td><td>4.79B</td><td>359.48G</td><td>9.04GiB</td></tr><tr><td>Bolaco (5 × 4)</td><td>30%</td><td>4.80B</td><td>356.03G</td><td>9.06GiB</td></tr><tr><td>LLaMA 2-13b</td><td>0%</td><td>13.02B</td><td>824.26G</td><td>24.45GiB</td></tr><tr><td>LLM-Pruner</td><td>20%</td><td>10.48B</td><td>662.95G</td><td>19.75GiB</td></tr><tr><td>FLAP</td><td>20%</td><td>10.48B</td><td>663.85G</td><td>19.64GiB</td></tr><tr><td>LoRD</td><td>20%</td><td>10.49B</td><td>717.86G</td><td>19.79GiB</td></tr><tr><td>Bolaco (5 × 1)</td><td>20%</td><td>10.48B</td><td>777.58G</td><td>19.71GiB</td></tr><tr><td>Bolaco (5 × 4)</td><td>20%</td><td>10.48B</td><td>772.16G</td><td>19.69GiB</td></tr><tr><td>LLM-Pruner</td><td>30%</td><td>9.21B</td><td>581.40G</td><td>17.35GiB</td></tr><tr><td>FLAP</td><td>30%</td><td>9.21B</td><td>582.72G</td><td>17.29GiB</td></tr><tr><td>LoRD</td><td>30%</td><td>9.21B</td><td>663.15G</td><td>17.38GiB</td></tr><tr><td>Bolaco (5 × 1)</td><td>30%</td><td>9.21B</td><td>708.16G</td><td>17.36GiB</td></tr><tr><td>Bolaco (5 × 4)</td><td>30%</td><td>9.21B</td><td>694.58G</td><td>17.35GiB</td></tr></table>
|
| 360 |
+
|
| 361 |
+
Table 7: Statistics of the compressed model.
|
| 362 |
+
|
| 363 |
+
<table><tr><td>Model</td><td>Method</td><td>Ratio</td><td>Low rank allocation</td></tr><tr><td rowspan="4">LLaMA-v2-7b</td><td>Bolaco (5 × 1)</td><td>20%</td><td>[744, 1616, 2512, 2408, NA]</td></tr><tr><td>Bolaco (5 × 4)</td><td>20%</td><td>[[680, 1728, 2960, NA, NA], [968, 1888, 2536, 2640, 2632], [408, 1488, NA, 2272, 2864], [656, 496, 2824, 2448, 2280]]</td></tr><tr><td>Bolaco (5 × 1)</td><td>30%</td><td>[656, 1392, 2128, 2352, 2312]</td></tr><tr><td>Bolaco (5 × 4)</td><td>30%</td><td>[[1016, 1632, 2376, 2384, 2384], [840, 1632, 2384, 2376, 2384], [408, 992, 2376, 2384, 2384], [408, 560, 2384, 1896, 1792]]</td></tr><tr><td rowspan="4">LLaMA-v2-13b</td><td>Bolaco (5 × 1)</td><td>20%</td><td>[696, 1920, 2304, NA, 2504]</td></tr><tr><td>Bolaco (5 × 4)</td><td>20%</td><td>[[792, 1696, 2864, 2880, 2976], [944, 1440, 2512, 2296, 2920], [656, 1112, 2496, 2480, 2912], [1312, 904, 2264, NA, 1960]]</td></tr><tr><td>Bolaco (5 × 1)</td><td>30%</td><td>[512, 1264, 2384, 2328, 2304]</td></tr><tr><td>Bolaco (5 × 4)</td><td>30%</td><td>[[528, 1536, 2384, 2376, 2384], [1232, 1624, 2376, 2352, 2344], [800, 1624, 2064, 2368, 2344], [408, 408, 2352, 1936, 1680]]</td></tr></table>
|
| 364 |
+
|
| 365 |
+
Table 8: The low-rank allocation of our Bolaco.
|
| 366 |
+
|
| 367 |
+
<table><tr><td>Model</td><td>Generated Sentences</td></tr><tr><td rowspan="3">LLaMA 2-7b</td><td>Instruction: I sit in front of a computer all day. How do I manage and mitigate eye strain?Response: Eye strain is a common complaint among computer users. It is caused by the eye's inability to focus on the computer screen. This is due to the fact that the computer screen is too close to the eyes. The eyes are also strained by the glare from the computer screen. The best way to manage and mitigate eye strain is to take frequent breaks from the computer. This will allow the eyes to rest and relax.</td></tr><tr><td>Instruction: Translate the sentence 'I have no mouth but I must scream' into Spanish. Response: No tengo boca pero debo gritar.</td></tr><tr><td>Instruction: Who is Donald Trump? Response: Donald Trump is the 45th President of the United States.</td></tr><tr><td rowspan="3">Bolaco (20%) (w/o tune)</td><td>Instruction: I sit in front of a computer all day. How do I manage and mitigate eye strain? Response: Most of the eye strain in this population is from staring at a computer monitor, which does not affect eye strain nearly as much as looking at a printed page. I recommend that people sit with their computer at arm's length, in a room that has adequate lighting, and not looking at a monitor for prolonged periods. If the screen is too bright, it causes glare and eye strain. If the room is bright, it also causes eye strain. The eyes don't work well with bright light.</td></tr><tr><td>Instruction: Translate the sentence 'I have no mouth but I must scream' into Spanish. Response: Mi Boca no has a voz y tengo que scream.</td></tr><tr><td>Instruction: Who is Donald Trump? Response: Trump is the president of the United States.</td></tr><tr><td rowspan="3">Bolaco (20%) (w/ tune)</td><td>Instruction: I sit in front of a computer all day. How do I manage and mitigate eye strain? Response: Here are some tips to help you manage and mitigate eye strain: 1. Position your monitor correctly: Make sure that your monitor is at least 20-25 inches away from you. If it's too close, your eyes will have to strain to focus on it, which can lead to headaches, eye strain, and fatigue. 2. Use a monitor filter: You can install a monitor filter that blocks ultraviolet rays from your monitor, which can help reduce eye strain and fatigue. 3. Talk to your doctor: If you have been experiencing symptoms of eye strain, headaches, or fatigue, talk to your doctor. He or she may recommend eye drops, glasses, or other solutions to manage your symptoms.</td></tr><tr><td>Instruction: Translate the sentence 'I have no mouth but I must scream' into Spanish. Response: No tengo Boca pero debo gritar.</td></tr><tr><td>Instruction: Who is Donald Trump? Response: Donald Trump is a U.S. president who was elected in 2016. He is the 45th president of the United States of America.</td></tr></table>
|
| 368 |
+
|
| 369 |
+
Table 9: Generated Examples from LLaMA-v2-7b and Bolaco.
|
| 370 |
+
|
| 371 |
+
<table><tr><td></td><td>Wikitext (↓)</td><td>PTB (↓)</td><td>Zero-shot (↑)</td></tr><tr><td>Wikipedia</td><td>7.96</td><td>45.84</td><td>62.57</td></tr><tr><td>Wikitext</td><td>7.61</td><td>48.37</td><td>62.14</td></tr><tr><td>C4</td><td>7.65</td><td>44.56</td><td>62.07</td></tr><tr><td>Arxiv</td><td>8.46</td><td>46.77</td><td>62.11</td></tr></table>
|
| 372 |
+
|
| 373 |
+
Table 10: Results under different validation data.
|
| 374 |
+
|
| 375 |
+

|
| 376 |
+
(a) Low rank sensitivity of individual layer on LLaMA-v2-7b.
|
| 377 |
+
|
| 378 |
+

|
| 379 |
+
|
| 380 |
+

|
| 381 |
+
(b) Sensitivity of different types of layers to low-rank compression on the LLaMA-v2-7b-chat.
|
| 382 |
+
|
| 383 |
+

|
| 384 |
+
|
| 385 |
+

|
| 386 |
+
(c) Sensitivity of different types of layers to low-rank compression on the OPT-6.7b.
|
| 387 |
+
|
| 388 |
+

|
| 389 |
+
Figure 5: More results on low-rank sensitivity.
|
| 390 |
+
|
| 391 |
+

|
| 392 |
+
(a) The perplexity of WikiText2 on LLaMA-v2-7b
|
| 393 |
+
|
| 394 |
+

|
| 395 |
+
(b) The perplexity of WikiText2 on LLaMA-v2-13b
|
| 396 |
+
|
| 397 |
+

|
| 398 |
+
(c) The perplexity of C4 on LLaMA-v2-7b
|
| 399 |
+
|
| 400 |
+

|
| 401 |
+
(d) The perplexity of C4 on LLaMA-v2-13b
|
| 402 |
+
|
| 403 |
+

|
| 404 |
+
(e) The perplexity of PTB on LLaMA-v2-7b
|
| 405 |
+
|
| 406 |
+

|
| 407 |
+
(f) The perplexity of PTB on LLaMA-v2-13b
|
| 408 |
+
Figure 6: Language modeling capabilities at different compression ratios.
|
adaptivefeaturebasedlowrankcompressionoflargelanguagemodelsviabayesianoptimization/images.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4ff3cd1a1bea33dbf67038a0e5003f8374fe880acc6f0f0bdbbcc75a2ee80bb7
|
| 3 |
+
size 1249554
|
adaptivefeaturebasedlowrankcompressionoflargelanguagemodelsviabayesianoptimization/layout.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:96d1d1f61662fd152aef14eab48bda12a108fb3c8489367898ec242da36c78d9
|
| 3 |
+
size 505216
|
adaptivetokenbiaserknowledgeeditingviabiasingkeyentities/bc7526ab-04d4-4e76-9a80-6dbe78c201f6_content_list.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:364721dcf7219720146483bff7683b07101b50c86ff53bf63af7e8ccdedbdc06
|
| 3 |
+
size 90742
|
adaptivetokenbiaserknowledgeeditingviabiasingkeyentities/bc7526ab-04d4-4e76-9a80-6dbe78c201f6_model.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:30d319add2f280e696f2ac08508db34703343b2e7000b39180f45bff9c56e509
|
| 3 |
+
size 108179
|
adaptivetokenbiaserknowledgeeditingviabiasingkeyentities/bc7526ab-04d4-4e76-9a80-6dbe78c201f6_origin.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:64c4f5d1d69399f97f99c146f386ee99de118c8472906134abfb1ae294a28abf
|
| 3 |
+
size 1704386
|
adaptivetokenbiaserknowledgeeditingviabiasingkeyentities/full.md
ADDED
|
@@ -0,0 +1,450 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Adaptive Token Biaser: Knowledge Editing via Biasing Key Entities
|
| 2 |
+
|
| 3 |
+
Baolong Bi $^{1,2}$ Shenghua Liu $^{1,2*}$ Yiwei Wang $^{3,4}$ Lingrui Mei $^{1,2}$ Hongcheng Gao $^{2}$ Yilong Xu $^{1,2}$ Xueqi Cheng $^{1,2}$
|
| 4 |
+
|
| 5 |
+
$^{1}$ CAS Key Laboratory of AI Safety, Institute of Computing Technology, CAS $^{2}$ University of Chinese Academy of Sciences
|
| 6 |
+
|
| 7 |
+
$^{3}$ University of California, Los Angeles $^{4}$ University of California, Merced
|
| 8 |
+
|
| 9 |
+
{bibaolong23z, liushenghua, xuyilong23s, cxq}@ict.ac.cn
|
| 10 |
+
|
| 11 |
+
wangyw.evan@gmail.com{meilingrui22,gaohongcheng23}@mails.ucas.ac.cn
|
| 12 |
+
|
| 13 |
+
# Abstract
|
| 14 |
+
|
| 15 |
+
The parametric knowledge memorized by large language models (LLMs) becomes outdated quickly. In-context editing (ICE) is currently the most effective method for updating the knowledge of LLMs. Recent advancements involve enhancing ICE by modifying the decoding strategy, obviating the need for altering internal model structures or adjusting external prompts. However, this enhancement operates across the entire sequence generation, encompassing a plethora of non-critical tokens. In this work, we introduce Adaptive Token Biaser (ATBIAS), a new decoding technique designed to enhance ICE. It focuses on the tokens that are mostly related to knowledge during decoding, biasing their logits by matching key entities related to new and parametric knowledge. Experimental results show that ATBIAS significantly enhances ICE performance, achieving up to a $32.3\%$ improvement over state-of-the-art ICE methods while incurring only half the latency. ATBIAS not only improves the knowledge editing capabilities of ICE but can also be widely applied to LLMs with negligible cost.
|
| 16 |
+
|
| 17 |
+
# 1 Introduction
|
| 18 |
+
|
| 19 |
+
Large language models (LLMs) (OpenAI, 2022, 2023; Touvron et al., 2023a,b; Song et al., 2024) accumulate a substantial volume of factual knowledge during pretraining. However, some of this knowledge may quickly become outdated, resulting in decreased reliability of LLMs (Chen and Shu, 2023; Zhang et al., 2023b; Huang et al., 2023a). Due to the substantial cost associated with retraining, knowledge editing (KE) (Sinitsin et al., 2020; De Cao et al., 2021; Mitchell et al., 2022; Yao et al., 2023) has been proposed to update the knowledge in LLMs by injecting new knowledge or modifying parametric knowledge.
|
| 20 |
+
|
| 21 |
+
As currently the most effective KE method, in-context editing (ICE) (Madaan et al., 2022; Zhong
|
| 22 |
+
|
| 23 |
+

|
| 24 |
+
Successful ICE of Easy Knowledge
|
| 25 |
+
|
| 26 |
+

|
| 27 |
+
Failed ICE of Stubborn Knowledge
|
| 28 |
+
Figure 1: A simple example of in-context editing (ICE). ICE successfully edits easy knowledge but fails to edit stubborn knowledge.
|
| 29 |
+
|
| 30 |
+
et al., 2023; Zheng et al., 2023; Cohen et al., 2024) has demonstrated state-of-the-art performance in KE. By providing contextual editing prompts with new knowledge retrieved from the edit memory, ICE can efficiently guide LLMs to inference and generate the answers related to the new knowledge.
|
| 31 |
+
|
| 32 |
+
Bi et al. (2024a,b) indicate that editing stubborn knowledge solely through external context prompts is challenging, as this knowledge has been established in LLMs with strong confidence during pre-training, as illustrated in Figure 1. Recent state-of-the-art ICE method DeCK (Bi et al., 2024a) enhances the editing of stubborn knowledge by modifying entire generating sequence during decoding. However, this approach carries potential risks, not only introducing the possibility of inference errors but also incurring higher latency costs.
|
| 33 |
+
|
| 34 |
+
In this work, we explore enhancing ICE for editing stubborn knowledge during the decoding stage of LLMs, without altering internal LLMs' parameters or modifying external prompts. We propose Adaptive Token Biaser (ATBIAS), a new KE framework for LLMs that enhances ICE by matching key entities and biasing the logits of specific tokens. The framework of ATBIAS is shown in Figure 2. Unlike previous decoding (Li et al., 2023; Chuang et al., 2023; Bi et al., 2024a), ATBIAS fo
|
| 35 |
+
|
| 36 |
+

|
| 37 |
+
Figure 2: Illustration of how ATBIAS enhances ICE during decoding. ATBIAS adjusts the key token probabilities based on the similarity computed between filtered tokens and extracted new and parametric knowledge entities.
|
| 38 |
+
|
| 39 |
+
cuses more on the matched tokens rather than the entire generated sequence. We argue that modifications on other tokens are unnecessary, leading to redundant computational costs and even mistakes. For example, in generating text The author Richard Dawkins wrote "Misery", the key terms "Richard" and "Dawkins" merit attention over other words in the text. Indiscriminate adjustments to other words (such as "The", "author", etc.) can pose a potential risk of introducing fundamental errors in the logical coherence of the entire inference statement.
|
| 40 |
+
|
| 41 |
+
The main goal of ATBIAS is to increase the generation probability of tokens related to new knowledge while decreasing that of parametric knowledge. Capturing key textual entities is a prerequisite for matching crucial tokens. ATBIAS provides a parametric induction and entity extraction module, which can efficiently extract key entities from both new facts and parametric facts induced from LLMs. We also introduce knowledge caching, enabling the aforementioned process to be completed offline. This ensures our ATBIAS performs efficient editing with only a single inference.
|
| 42 |
+
|
| 43 |
+
We design a specialized filtering mechanism that ensures our approach only considers top-ranked and high-probability predicted tokens. The probabilistic-ranking filter not only significantly reduces the likelihood of implausible tokens having their logits erroneously amplified but also greatly improves the time efficiency of ATBIAS.
|
| 44 |
+
|
| 45 |
+
Tokens related to key entities cannot be precisely located due to the tokenization rules. Therefore, we developed an N-gram and Jaccard-based simi
|
| 46 |
+
|
| 47 |
+
larity comparison algorithm to match tokens with entities. We introduce bias to the logits of both new and old knowledge entities based on the similarity computed between the filtered tokens and these entities. The tokens related to new knowledge are more likely to be output than parametric knowledge during the generation of LLMs, thus significantly enhancing the editing capabilities of ICE.
|
| 48 |
+
|
| 49 |
+
Experimental results indicate that our ATBIAS significantly enhances ICE performance, achieving up to a $32.3\%$ improvement over state-of-the-art decoding methods while incurring only half the latency. This means that ATBIAS not only further improves editing capabilities but can also be widely applied to LLMs with negligible cost. Furthermore, we suggest that research into decoding methods should focus more on key tokens rather than the entire sequence in generation.
|
| 50 |
+
|
| 51 |
+
# 2 Preliminary
|
| 52 |
+
|
| 53 |
+
LLMs Decoding. The primary goal of LLMs during decoding is to predict the succeeding word within a provided context sequence. Formally, given a sequence of tokens $\{x_{1}, x_{2}, \ldots, x_{t-1}\}$ of length $t - 1$ , we can calculate the probability distribution of next token over the vocabulary set $\mathcal{V}$ :
|
| 54 |
+
|
| 55 |
+
$$
|
| 56 |
+
P (x \mid x _ {< t}) = \operatorname {s o f t m a x} (\phi (h _ {t})), \quad x \in \mathcal {V} \tag {1}
|
| 57 |
+
$$
|
| 58 |
+
|
| 59 |
+
where $\phi (\cdot)$ represents an affine layer for embedding vectors $H = \{h_1,\ldots ,h_{t - 1}\}$ . In decoding, LLMs samples from the conditional distribution $P(x|x_{< t})$ to generate next token $x_{t}$ , continuing this process until an end-of-sequence token is produced.
|
| 60 |
+
|
| 61 |
+
Multi-hop Editing. Multi-hop editing is a highly challenging task in KE, aimed at verifying whether a fact has been thoroughly edited in LLMs. It not only edits the specific knowledge but also all related knowledge within the multi-hop relations impacted by this edit. For example, consider the two-hop question in Figure 2. The original answer would be "United States" with the facts Stephen King wrote "Misery", Stephen King is a U.S. citizen. With an edit Richard Dawkins wrote "Misery" and existing knowledge Richard Dawkins is British, the edited output answer should be "United Kingdom".
|
| 62 |
+
|
| 63 |
+
# 3 Methods
|
| 64 |
+
|
| 65 |
+
The framework of ATBIAS is shown in Figure 2. First, we induce LLMs to output parametric knowledge by clozing the retrieved new knowledge, and then we extract the knowledge entities from them (Section 3.1). This process can be optimized through knowledge caching (Section 3.5). Next, we refine the tokens using a probability and rank-based token filter (Section 3.2), and match key entities with an n-gram and jaccard similarity calculation algorithm (Section 3.3). Finally, we adaptively bias the logits of the crucial tokens (Section 3.4) to predict the next tokens.
|
| 66 |
+
|
| 67 |
+
# 3.1 Parametric Induction & Entity Extraction
|
| 68 |
+
|
| 69 |
+
Extracting key knowledge entities from redundant knowledge information is a fundamental prerequisite of ATBIAS. This enables the adjustment of corresponding token probabilities during decoding. Specifically, ATBIAS enables the preprocessing to obtain parametric output from LLMs corresponding to each new fact piece in the edit memory. For example, consider a piece of new fact updated in the edited fact memory: The author Richard Dawkins wrote "Misery". By clozing the new fact such as The author _ wrote "Misery", LLMs can be induced to provide parametric fact outputs like The author Stephen King wrote "Misery".
|
| 70 |
+
|
| 71 |
+
Subsequently, the key knowledge entities are individually extracted from these fact pieces. We define the function $\text{extract}(\cdot)$ to represent this process. Given a set of fact pieces $fact$ , we can obtain a list of split entity strings:
|
| 72 |
+
|
| 73 |
+
$$
|
| 74 |
+
E _ {\text {f a c t}} = \operatorname {E x t r a c t} (\text {f a c t}) \tag {2}
|
| 75 |
+
$$
|
| 76 |
+
|
| 77 |
+
Then, the extracted entities $E_{\mathrm{new}}$ and $E_{\mathrm{para}}$ from new fact and parametric fact are used to match the key tokens in Section 3.4.
|
| 78 |
+
|
| 79 |
+
# 3.2 Probabilistic-Ranking Filter
|
| 80 |
+
|
| 81 |
+
As introduced in Section 2, tokens with higher probabilities in the distribution $P(x|x_{<t})$ are more likely to be sampled and output during the decoding in LLMs. However, if we calculate the similarity (Section 3.3) for all tokens in the vocabulary $\mathcal{V}$ to adjust their logits (Section 3.4), it will not only cause unnecessary time overhead but also increase the potential risk of erroneously amplifying the probabilities of unreliable tokens.
|
| 82 |
+
|
| 83 |
+
Inspired by APC (Li et al., 2023), we design a stringent filtering mechanism to eliminate the unreliable tokens. Specifically, we control the decoding scope based on both the probability values of the tokens and their rankings.
|
| 84 |
+
|
| 85 |
+
First, we set a constraint parameter $\alpha$ to ensure that the filtered tokens logits have only a small difference from the highest probability. Using $P(x_{t})$ to represent $P(x_{t}|x_{< t})$ for notational brevity, the probabilistic filter can be formalized as follows:
|
| 86 |
+
|
| 87 |
+
$$
|
| 88 |
+
\mathcal {V} _ {\text {p r o b}} = \left\{x _ {t} \in \mathcal {V}: P (x _ {t}) \geq \alpha \max _ {w} P (w) \right\} \tag {3}
|
| 89 |
+
$$
|
| 90 |
+
|
| 91 |
+
We then define the ranking-based filtering:
|
| 92 |
+
|
| 93 |
+
$$
|
| 94 |
+
\mathcal {V} _ {\text {r a n k}} = \left\{x _ {t} \in \mathcal {V}: P \left(x _ {t}\right) \geq P \left(R _ {k}\right) \right\} \tag {4}
|
| 95 |
+
$$
|
| 96 |
+
|
| 97 |
+
where $R_{k}$ represents the token with the k-th largest probability. This implies that we exclusively focus on the top-k tokens in the distribution. Subsequently, we obtain a more stringent set of filtered tokens:
|
| 98 |
+
|
| 99 |
+
$$
|
| 100 |
+
\mathcal {V} _ {\text {h e a d}} \left(x _ {t} \mid x _ {< t}\right) = \mathcal {V} _ {1} \cap \mathcal {V} _ {2} \tag {5}
|
| 101 |
+
$$
|
| 102 |
+
|
| 103 |
+
$\mathcal{V}_{\mathrm{head}}$ imposes specific decoding constraints by considering both probability and ranking, thereby avoiding situations where filtered tokens have high rankings but low credibility, or where there are too many tokens with high probabilities. We can then predict the next token by:
|
| 104 |
+
|
| 105 |
+
$$
|
| 106 |
+
P _ {\text {f i l t}} \left(x _ {t}\right) = \left\{ \begin{array}{l l} P \left(x _ {t}\right), & \text {i f} x _ {t} \in \mathcal {V} _ {\text {h e a d}} \left(x _ {t} \mid x _ {< t}\right), \\ - \infty , & \text {o t h e r w i s e .} \end{array} \right. \tag {6}
|
| 107 |
+
$$
|
| 108 |
+
|
| 109 |
+
# 3.3 N-gram and Jaccard Similarity
|
| 110 |
+
|
| 111 |
+
Tokens related to key entities cannot be precisely identified due to tokenization rules. Therefore, directly identifying specific tokens and adjusting their logits is not feasible. ATBIAS presents a novel approach where tokens are first decoded into strings during the decoding process, which are then
|
| 112 |
+
|
| 113 |
+
matched with the strings derived from key entities. Thus, tokens more relevant to key entities can be identified by matching decoded strings with entity strings. An additional challenge is that a word may be segmented by the tokenizer into various prefixes, infixes, and suffixes. For example, 'Dawkins' might be segmented into "Daw- " and "-kins". This means the decoded strings may be the substrings of entity strings. Therefore, we need to match the substrings obtained from decoding the tokens with the full strings split from the key entities.
|
| 114 |
+
|
| 115 |
+
To tackle the above challenges, we developed an N-gram and Jaccard-based similarity comparison algorithm to match the filtered tokens with key entities. The target of our algorithm is to compare the similarity between substrings (tokens) and full strings (entities), including complex word structures such as prefixes, infixes, and suffixes.
|
| 116 |
+
|
| 117 |
+
We begins by decomposing both the substring and the full string into character n-grams. A character n-gram is a contiguous sequence of n characters within a string. We define the function $g(\cdot)$ to represent the decomposition of a string into an n-gram set. For example, for the string "Stephen" and $n = 3$ , the set of 3-grams includes $g("Stephen") = \{"Ste", "tep", "eph", "phe", "hen"\}$ . Specially, we compute the n-gram sets of the substrings and the full strings using a sliding window approach.
|
| 118 |
+
|
| 119 |
+
Next, we can calculate the Jaccard similarity (Niwattanakul et al., 2013) between the two decomposed n-gram sets of decoded strings and entity strings, which can be formalized as follows:
|
| 120 |
+
|
| 121 |
+
$$
|
| 122 |
+
\operatorname {s i m} \left(x _ {t}, e _ {i}\right) = \frac {\left| g \left(x _ {t} ^ {\mathrm {d}}\right) \cap g \left(e _ {i}\right) \right|}{\left| g \left(x _ {t} ^ {\mathrm {d}}\right) \cup g \left(e _ {i}\right) \right|} \tag {7}
|
| 123 |
+
$$
|
| 124 |
+
|
| 125 |
+
where $x_{t}^{\mathrm{d}}$ represents the decoded strings from filtered tokens satisfying $x_{t}^{\mathrm{d}} = \operatorname{decode}(x_{t})$ and $x_{t} \in \mathcal{V}_{\mathrm{head}}(x_{t}|x_{<t})$ , $e_{i} \in E$ and $E = \{e_{1}, e_{2}, \ldots, e_{m}\}$ is the split entity strings set of length $m$ .
|
| 126 |
+
|
| 127 |
+
# 3.4 Adaptive Token Biaser
|
| 128 |
+
|
| 129 |
+
The main goal of our adaptive token biaser is to increase the logits of tokens corresponding to new knowledge entities while decreasing those of parametric knowledge entities, thus enhancing the capability of ICE editing knowledge. Therefore, the biasing operation can be divided into two parts, starting with the enhancement of new knowledge:
|
| 130 |
+
|
| 131 |
+
$$
|
| 132 |
+
P _ {\mathrm {a d j}} \left(x _ {t}\right) = P _ {\text {f i l t}} \left(x _ {t}\right) + \lambda_ {\mathrm {n}} \bar {\mathrm {P}} \sin \left(x _ {t}, e _ {i} ^ {\mathrm {n}}\right) \tag {8}
|
| 133 |
+
$$
|
| 134 |
+
|
| 135 |
+
where $\lambda_{\mathrm{n}}$ is the bias coefficient for new knowledge, $e_i^{\mathrm{n}}$ represents the split string of new knowledge enti
|
| 136 |
+
|
| 137 |
+
Algorithm 1 Adaptive Token Biaser
|
| 138 |
+
Require: $P$ : distribution of tokens, $\nu$ : vocabulary, $\mathcal{F}_{\mathrm{new}}$ : new facts, $\mathcal{F}_{\mathrm{para}}$ : parametric facts
|
| 139 |
+
1: Filter $\nu \rightarrow \mathcal{V}_{\mathrm{head}}$
|
| 140 |
+
2: Extract $\mathcal{F}_{\mathrm{new}} \rightarrow E_{\mathrm{new}}$ and $\mathcal{F}_{\mathrm{para}} \rightarrow E_{\mathrm{para}}$
|
| 141 |
+
3: Compute avg. $\bar{\mathrm{P}} = \frac{1}{|\mathcal{V}_{\mathrm{head}}|} \sum_{x_i \in \mathcal{V}_{\mathrm{head}}} P(x_i)$
|
| 142 |
+
4: for each $x_i \in \mathcal{V}_{\mathrm{head}}$ do
|
| 143 |
+
5: Decode $x_i \rightarrow x_i^{\mathrm{d}}$
|
| 144 |
+
6: for each $e_j^{\mathrm{n}} \in E_{\mathrm{new}}$ do
|
| 145 |
+
7: if $x_i^{\mathrm{d}}$ in $e_j^{\mathrm{n}}$ then
|
| 146 |
+
8: N-gram Decompose $x_i^{\mathrm{d}}, e_j^{\mathrm{n}} \rightarrow g_x^i, g_e^j$
|
| 147 |
+
9: $P(x_i) = P(x_i) + \lambda_n \cdot \bar{\mathrm{P}} \cdot \frac{|g_x^i \cap g_e^j|}{|g_x^i \cup g_e^j|}$
|
| 148 |
+
10: end if
|
| 149 |
+
11: end for
|
| 150 |
+
12: for each $e_j^{\mathrm{p}} \in E_{\mathrm{para}}$ do
|
| 151 |
+
13: if $x_i^{\mathrm{d}}$ in $e_j^{\mathrm{n}}$ then
|
| 152 |
+
14: N-gram Decompose $x_i^{\mathrm{d}}, e_j^{\mathrm{p}} \rightarrow g_x^i, g_e^j$
|
| 153 |
+
15: $P(x_i) = P(x_i) - \lambda_p \cdot \bar{\mathrm{P}} \cdot \frac{|g_x^i \cap g_e^j|}{|g_x^i \cup g_e^j|}$
|
| 154 |
+
16: end if
|
| 155 |
+
17: end for
|
| 156 |
+
18: end for
|
| 157 |
+
19: return $P$
|
| 158 |
+
|
| 159 |
+
ties such that $e_i^{\mathrm{n}} \in E_{\mathrm{new}} = \{e_1^{\mathrm{n}}, e_2^{\mathrm{n}}, \ldots, e_m^{\mathrm{n}}\}$ . And $\bar{\mathbb{P}}$ is the average probability of all filtered tokens, defined as:
|
| 160 |
+
|
| 161 |
+
$$
|
| 162 |
+
\bar {\mathrm {P}} = \frac {1}{| \mathcal {V} _ {\text {h e a d}} |} \sum_ {x _ {t} \in \mathcal {V} _ {\text {h e a d}}} P _ {\text {f i l t}} \left(x _ {t}\right) \tag {9}
|
| 163 |
+
$$
|
| 164 |
+
|
| 165 |
+
Similarly, the suppression of parametric knowledge can be represented as follows:
|
| 166 |
+
|
| 167 |
+
$$
|
| 168 |
+
P _ {\mathrm {a d j}} \left(x _ {t}\right) = P _ {\text {f i l t}} \left(x _ {t}\right) - \lambda_ {\mathrm {p}} \bar {\mathrm {P}} \sin \left(x _ {t}, e _ {i} ^ {\mathrm {p}}\right) \tag {10}
|
| 169 |
+
$$
|
| 170 |
+
|
| 171 |
+
where $\lambda_{\mathrm{p}}$ is the tuning coefficient for parametric knowledge, $e_i^{\mathrm{p}}\in E_{\mathrm{para}}$ represents the split string of parametric knowledge entities.
|
| 172 |
+
|
| 173 |
+
The overall process of ATBIAS is shown in Algorithm 1. ATBIAS controls the degree of logits bias for tokens corresponding to key entity texts by calculating similarity. The n-gram and jaccard similarity in Section 3.3 ensures the validity of this step, as a higher overlap receives a certain weight, while lower overlap or mismatches receive a weight of zero. This distinguishes our ATBIAS from the decoding methods that operate on the entire generating sequence. ATBIAS focuses only on the few crucial tokens, such as "Richard" and "Dawkins" in The author Richard Dawkins wrote "Misery",
|
| 174 |
+
|
| 175 |
+
<table><tr><td>Model</td><td>Method</td><td>MQUAKE-3K</td><td>MQUAKE-2002</td><td>MQUAKE-HARD</td></tr><tr><td rowspan="4">LLAMA2-7B-CHAT</td><td>ROME (Meng et al., 2022a)</td><td>18.2</td><td>19.1</td><td>15.7</td></tr><tr><td>IKE (Zheng et al., 2023)</td><td>85.4</td><td>85.1</td><td>88.9</td></tr><tr><td>IKE w/ DeCK (Bi et al., 2024a)</td><td>91.3</td><td>89.4</td><td>98.6</td></tr><tr><td>IKE w/ ATBIAS (ours)</td><td>93.1</td><td>92.3</td><td>98.8</td></tr><tr><td rowspan="4">LLAMA2-13B-CHAT</td><td>ROME (Meng et al., 2022a)</td><td>39.4</td><td>39.7</td><td>35.2</td></tr><tr><td>IKE (Zheng et al., 2023)</td><td>63.8</td><td>64.1</td><td>55.2</td></tr><tr><td>IKE w/ DeCK (Bi et al., 2024a)</td><td>84.6</td><td>84.4</td><td>89.7</td></tr><tr><td>IKE w/ ATBIAS (ours)</td><td>89.7</td><td>87.6</td><td>91.2</td></tr><tr><td rowspan="4">MISTRAL-7B-INSTRUCT</td><td>ROME (Meng et al., 2022a)</td><td>28.1</td><td>30.2</td><td>26.3</td></tr><tr><td>IKE (Zheng et al., 2023)</td><td>34.1</td><td>35.6</td><td>15.6</td></tr><tr><td>IKE w/ DeCK (Bi et al., 2024a)</td><td>46.7</td><td>48.5</td><td>19.2</td></tr><tr><td>IKE w/ ATBIAS (ours)</td><td>47.6</td><td>48.7</td><td>22.6</td></tr></table>
|
| 176 |
+
|
| 177 |
+
Table 1: Experimental results (accuracy; %) across ROME, original IKE, IKE enhanced by DeCK and our ATBIAS. The batch size of the edit memory was set to 1 to evaluate the foundational capability of directly editing knowledge. The best editing result for each LLM is highlighted in bold font.
|
| 178 |
+
|
| 179 |
+
without biasing the majority of others like "The", "author", etc. This ensures that our editing process does not interfere with the reasoning of LLMs, reducing the potential risk of introducing inappropriate tokens during decoding.
|
| 180 |
+
|
| 181 |
+
# 3.5 Knowledge Caching for Efficient Editing
|
| 182 |
+
|
| 183 |
+
Considering that parametric induction and entity extraction in Section 3.1 can introduce additional time overhead, we can preprocess these steps in advance. Specifically, whenever a new fact is updated in the edited memory, we offline induce the LLMs to output the corresponding parametric fact and then extract the entities from both the new and parametric facts. We record these in a knowledge cache to ensure that they can be directly retrieved during online inference by the LLMs.
|
| 184 |
+
|
| 185 |
+
Actually, the offline preprocessing is not imperative, as many advanced ICE methods (Zhong et al., 2023; Wang et al., 2024) inherently involve parametric output during their process with LLMs. For example, MeLLo (Zhong et al., 2023) prompts LLMs to output parametric answers to subquestions. And then ATBIAS can extract the entities from these parametric answers in MeLLo online, using simple methods or tools such as fine-tuned LMs or regular expressions. See the Appendix A for detailed examples. Therefore, our ATBIAS only requires a single inference with negligible additional overhead.
|
| 186 |
+
|
| 187 |
+
# 4 Experiments
|
| 188 |
+
|
| 189 |
+
# 4.1 Experimental Setup
|
| 190 |
+
|
| 191 |
+
Tasks. Our experiments focus on the one-hop and multi-hop question-answering tasks introduced
|
| 192 |
+
|
| 193 |
+
in Section 2. We set the batch size of the edit memory as 1 and full batch for multi-hop editing evaluation. The batch size means the number of instances providing the edited facts for knowledge retrieval.
|
| 194 |
+
|
| 195 |
+
Datasets. We conduct extensive experiments for the main multi-hop editing task using MQUAKE-3K (Zhong et al., 2023) along with its challenging derivatives, MQUAKE-2002 and MQUAKE-HARD, introduced by Wang et al. (2024). MQUAKE provides multi-hop knowledge questions to evaluate KE on counterfactual edits. We also evaluate for one-hop editing task on COUNTERFACT (Meng et al., 2022a). Additionally, we follow (Bi et al., 2024a) to use corresponding STUBBORN datasets to further evaluate the effectiveness of editing stubborn knowledge in Section 4.4.
|
| 196 |
+
|
| 197 |
+
Models and Baselines. We examine different LLM families and sizes, including LLAMA2-7B-CHAT, LLAMA2-13B-CHAT(Touvron et al., 2023b), and MISTRAL-7B-INSTRUCT (Jiang et al., 2023). We employ the state-of-art ICE methods IKE (Cohen et al., 2024) and MeLLo (Zhong et al., 2023), and advanced model-editing techniques ROME (Meng et al., 2022a) as baselines. We also compare our approach with these ICE methods enhanced by DeCK (Bi et al., 2024a), the state-of-the-art decoding method for ICE that contrasts knowledge. IKE prompts LLMs to edit new knowledge using contextual demonstrations, while MeLLo edits multi-hop knowledge by decomposing sub-questions and guiding LLMs to generate answers. ROME views editing as least squares with linear equality constraints and employs the Lagrange multiplier for solving.
|
| 198 |
+
|
| 199 |
+
<table><tr><td>Model</td><td>Method</td><td>MQUAKE-3K</td><td>MQUAKE-2002</td><td>MQUAKE-HARD</td></tr><tr><td rowspan="3">LLAMA2-7B-CHAT</td><td>MeLLo (Zhong et al., 2023)</td><td>32.6</td><td>40.8</td><td>5.1</td></tr><tr><td>MeLLo w/ DeCK (Bi et al., 2024a)</td><td>43.1</td><td>45.8</td><td>5.8</td></tr><tr><td>MeLLo w/ ATBIAS (ours)</td><td>54.3</td><td>48.9</td><td>6.3</td></tr><tr><td rowspan="3">LLAMA2-13B-CHAT</td><td>MeLLo (Zhong et al., 2023)</td><td>33.4</td><td>35.9</td><td>3.9</td></tr><tr><td>MeLLo w/ DeCK (Bi et al., 2024a)</td><td>36.8</td><td>38.2</td><td>6.2</td></tr><tr><td>MeLLo w/ ATBIAS (ours)</td><td>48.7</td><td>43.6</td><td>6.7</td></tr><tr><td rowspan="3">MISTRAL-7B-INSTRUCT</td><td>MeLLo (Zhong et al., 2023)</td><td>21.8</td><td>22.8</td><td>2.1</td></tr><tr><td>MeLLo w/ DeCK (Bi et al., 2024a)</td><td>21.3</td><td>22.9</td><td>2.6</td></tr><tr><td>MeLLo w/ ATBIAS (ours)</td><td>24.7</td><td>25.4</td><td>3.1</td></tr></table>
|
| 200 |
+
|
| 201 |
+
Implementation. We implement IKE with multi-hop question-answering demonstrations and chain-of-thought (COT) (Wei et al., 2022) prompting to enhance its performance. We deploy ATBIAS to MeLLo without the need for additional preprocessing, as MeLLo naturally outputs parametric knowledge (Section 3.1). The prompts used in IKE and MeLLo are shown in Appendix C. The model editing methods ROME in our baselines are deployed using EasyEdit (Wang et al., 2023b). We set n to 2 in the n-gram decomposition, the adaptive constraint $\alpha$ to 0.0005 and $k$ to 10, with bias coefficients $\lambda_{n}$ set to 25 and $\lambda_{p}$ set to 1.
|
| 202 |
+
|
| 203 |
+
# 4.2 Overall Performance
|
| 204 |
+
|
| 205 |
+
We set the batch size of the edit memory as 1 for evaluating the foundational direct editing capabilities of IKE (Zheng et al., 2023) method, especially considering multi-hop questions with 1,000 instances. The batch size means the number of instances providing the edited facts for knowledge retrieval. Table 1 displays the performance on MQUAKE across various models and datasets. Overall, compared to the model-editing method ROME, the ICE method IKE demonstrates a clear advantage. The enhanced IKE by ATBIAS consistently shows the best performance. Furthermore, as model parameters increase (LLAMA2-13B-CHAT) and pretraining becomes more refined (MISTRAL-7B-INSTRUCT), the knowledge within LLMs becomes more stubborn to editing. ATBIAS can enhance ICE to effectively edit this stubborn knowledge.
|
| 206 |
+
|
| 207 |
+
We follow the setup of previous work (Zhong et al., 2023; Wang et al., 2024) to conduct experiments for MeLLo (Zhong et al., 2023) with the full batch size edit memory. As shown in Table 2, the experimental results illustrate that ATBIAS enhances MeLLo to varying degrees in full batch ex
|
| 208 |
+
|
| 209 |
+
periments. Specifically, the enhancement provided by our ATBIAS shows a significant advantage, with an impressive improvement of up to $32.3\%$ compared to DeCK. This is because ATBIAS operates on a small number of key tokens rather than the entire sequence as in DeCK, leaving other tokens in the inference process unaffected. This greatly reduces the potential risk of introducing fundamental errors during the inference stage, making our ATBIAS's enhancements even more pronounced in longer and more complex editing pipelines. It further indicates that ATBIAS holds significant potential for real-world KE applications with higher performance and lower costs.
|
| 210 |
+
|
| 211 |
+
# 4.3 One-hop Editing
|
| 212 |
+
|
| 213 |
+
Despite the greater challenge of multihop editing, we still used the COUNTERFACT dataset to evaluate one-hop editing for the robustness of our method. As the results shown in Table 3, the ICE method IKE achieved high accuracy in the simpler one-hop editing task, with IKE enhanced by our ATBIAS consistently outperforming others.
|
| 214 |
+
|
| 215 |
+
Table 2: Experimental results (accuracy; %) on multi- hop editing task with 500 instances. We conduct the experiments with the full batch size edit memory to evaluate the performance of memory based KE.
|
| 216 |
+
|
| 217 |
+
<table><tr><td>Model</td><td>IKE</td><td>w/ DeCK</td><td>w/ ATBIAS</td></tr><tr><td>LLAMA2-7B</td><td>98.37</td><td>98.65</td><td>99.42</td></tr><tr><td>LLAMA2-13B</td><td>93.76</td><td>94.23</td><td>95.35</td></tr></table>
|
| 218 |
+
|
| 219 |
+
Table 3: Experimental results of IKE on COUNTERFACT for one-hop editing task.
|
| 220 |
+
|
| 221 |
+
# 4.4 Editing on Stubborn Knowledge
|
| 222 |
+
|
| 223 |
+
Stubborn knowledge in LLMs is difficult to edit because it is established with strong confidence during the pretraining process. We follow (Bi et al., 2024a) to construct the corresponding STUBBORN datasets for different models to specifically evaluate ATBIAS's performance on stubborn knowledge. The stubborn datasets are categorized into different
|
| 224 |
+
|
| 225 |
+
<table><tr><td>Model</td><td>STUBBORN</td><td>ROME</td><td>IKE</td><td>IKE w/ DeCK</td><td>IKE w/ ATBIAS</td></tr><tr><td rowspan="2">LLAMA2-7B-CHAT</td><td>>33%</td><td>17.7</td><td>56.4</td><td>72.3</td><td>73.9</td></tr><tr><td>>67%</td><td>19.3</td><td>37.8</td><td>55.9</td><td>57.8</td></tr><tr><td rowspan="2">LLAMA2-13B-CHAT</td><td>>33%</td><td>42.5</td><td>38.9</td><td>70.1</td><td>71.6</td></tr><tr><td>>67%</td><td>40.2</td><td>29.4</td><td>48.5</td><td>56.5</td></tr><tr><td rowspan="2">MISTRAL-7B-INSTRUCT</td><td>>33%</td><td>19.7</td><td>20.7</td><td>26.5</td><td>33.2</td></tr><tr><td>>67%</td><td>18.5</td><td>17.9</td><td>22.6</td><td>27.9</td></tr></table>
|
| 226 |
+
|
| 227 |
+
difficulty levels based on the proportion of correct answers when using ICE methods to edit the same knowledge multiple times with different questions.
|
| 228 |
+
|
| 229 |
+
The experimental results on the STUBBORN datasets are presented in Table 4. We find that IKE's performance on STUBBORN datasets significantly declined compared to Table 1, even falling below the model-editing method ROME. This indicates that relying solely on external prompts is insufficient to change LLMs' confidence in this stubborn knowledge. The enhancement methods applied during decoding significantly improve the effectiveness of editing stubborn knowledge, with ATBIAS consistently achieving the best performance. This suggests ATBIAS enhances ICE methods' ability to effectively edit stubborn knowledge.
|
| 230 |
+
|
| 231 |
+
Table 4: Performance of different models on their respective STUBBORN datasets. The edit memory batch size of the IKE methods is set to 1. 'STUBBORN > 33%' indicates instances from the MQUAKE-3K dataset where IKE failed to edit knowledge more than 33% of the time. 'STUBBORN > 67%' follows the same criterion.
|
| 232 |
+
|
| 233 |
+
<table><tr><td>Model</td><td>Method</td><td>Latency (ms/token)</td><td>Throughput (token/s)</td></tr><tr><td rowspan="3">LLAMA2-7B-CHAT</td><td>Baseline</td><td>36.03 (×1.00)</td><td>27.76 (×1.00)</td></tr><tr><td>DeCK</td><td>69.99 (×1.94)</td><td>14.29 (×0.51)</td></tr><tr><td>ATBIAS</td><td>36.19 (×1.01)</td><td>27.64 (×1.00)</td></tr><tr><td rowspan="3">LLAMA2-13B-CHAT</td><td>Baseline</td><td>51.41 (×1.00)</td><td>19.45 (×1.00)</td></tr><tr><td>DeCK</td><td>94.08 (×1.83)</td><td>10.63 (×0.55)</td></tr><tr><td>ATBIAS</td><td>49.11 (×0.95)</td><td>20.36 (×1.05)</td></tr></table>
|
| 234 |
+
|
| 235 |
+
Table 5: Decoding latency (ms/tokens) and throughput (tokens/s). Green shows low latency and high throughput, red shows high latency and low throughput.
|
| 236 |
+
|
| 237 |
+
# 4.5 Latency & Throughput
|
| 238 |
+
|
| 239 |
+
Table 5 shows the decoding latency for the baseline, as well as when incorporating DeCK or ATBIAS. DeCK requires generating and comparing two sequences during decoding, resulting in approximately $2\mathrm{x}$ the latency of the baseline. It is worth noting that ATBIAS increases the decoding time by only a factor of 1.01 in LLAMA2-7B-CHAT and is even more efficient in LLAMA2-13B-CHAT compared to the baseline. This efficiency is due to the
|
| 240 |
+
|
| 241 |
+
probabilistic-ranking filter, which filters out most low-probability tokens and only considers highly confident tokens for prediction. It suggests that ATBIAS, with its outstanding editing performance, can also be widely applied at negligible cost.
|
| 242 |
+
|
| 243 |
+
# 4.6 Why ATBIAS Edits Efficiently?
|
| 244 |
+
|
| 245 |
+
Bi et al. (2024a) observes that the values of the logits corresponding to the parametric knowledge's tokens are very high before editing. Even though ICE significantly increases the logits of the tokens corresponding to new knowledge, there are still cases where it fails to surpass the parametric ones. To reveal the underlying reasons why ATBIAS can effectively enhance the ICE methods from a model interpretability perspective, we analyzed the probability changes of the new knowledge before and after applying ATBIAS. Specifically, we capture the first tokens of the new and parametric knowledge entities that represent them and then record their normalized logits.
|
| 246 |
+
|
| 247 |
+
The results illustrated in Figure 3 show that IKE with ATBIAS has a higher distribution within the high probability range, while IKE without ATBIAS is concentrated in the low probability range. Additionally, the probability ranking of new knowledge significantly increased after incorporating ATBIAS. Moreover, the probability distribution of the parametric knowledge exhibited an opposite trend after incorporating ATBIAS. This further explains why ATBIAS can effectively enhance ICE: it increases the probabilities of new knowledge entities and decreases the probabilities of parametric knowledge entities. As shown in the editing example in Figure 2 (Richard Dawkins is a citizen of the United Kingdom), the newly generated knowledge entities by ATBIAS serve as new contextual cues during inferencing to reason over multiple hops of knowledge, significantly improving editing performance.
|
| 248 |
+
|
| 249 |
+

|
| 250 |
+
Figure 3: Probability (left) and ranking (right) statistics of new Knowledge for LLAMA2-7B-CHAT on stubborn $>33\%$ . The probabilities are derived from normalize calculations.
|
| 251 |
+
|
| 252 |
+

|
| 253 |
+
|
| 254 |
+
# 4.7 Ablation Study
|
| 255 |
+
|
| 256 |
+
We conducted a comprehensive ablation study on the adaptive constraints, bias coefficients, and key components of ATBIAS. Table 6 presents the results for the filter in ATBIAS, demonstrating the necessity of filtering tokens based on both probability and ranking constraints. Additional ablation study results can be found in the Appendix B.
|
| 257 |
+
|
| 258 |
+
<table><tr><td>Model</td><td>Prob</td><td>Rank</td><td>Prob & Rank</td></tr><tr><td>LLAMA2-7B</td><td>90.2</td><td>81.5</td><td>93.1</td></tr><tr><td>LLAMA2-13B</td><td>81.9</td><td>72.4</td><td>89.7</td></tr></table>
|
| 259 |
+
|
| 260 |
+
Table 6: Ablation study results for the filter of our ATBIAS. Prob and Rank respectively represent probability and ranking constraints in the filter.
|
| 261 |
+
|
| 262 |
+
# 5 Related Work
|
| 263 |
+
|
| 264 |
+
Factual Hallucinations. Factual hallucinations have garnered widespread attention due to their significant side effects, as LLMs generate content that deviates from established world knowledge (Tonmoy et al., 2024; Huang et al., 2023a; Wang et al., 2023a; Jiang et al., 2024; Mei et al., 2024a,b). These hallucinations can arise from various sources and at different stages of the LLM life cycle (Zhang et al., 2023b). Outdated knowledge is a major factor contributing to factual hallucinations. ATBIAS enhances KE during the inference stage in LLMs to mitigate these hallucinations.
|
| 265 |
+
|
| 266 |
+
Knowledge Editing. KE (Yao et al., 2023) has been proposed to update information in LLMs, enabling accurate responses to current questions. In general, there are three lines of works for KE. Model editing (Zhu et al., 2020; Meng et al., 2022a,b; Huang et al., 2023b) involves adding or altering the model parameters responsible for the undesirable output. Meta-learning methods (De Cao
|
| 267 |
+
|
| 268 |
+
et al., 2021; Mitchell et al., 2021) use a hypernetwork to learn the necessary adjustments for editing LLMs. In-context editing methods (ICE) (Madaan et al., 2022; Zhong et al., 2023; Zheng et al., 2023; Bi et al., 2024c) demonstrate significant potential, enabling the editing of LLMs by prompting them with edited facts and retrieving editing demonstrations from the edit memory.
|
| 269 |
+
|
| 270 |
+
Decoding Strategy. Recent work modifies various decoding strategies to enhance different alignments by altering the logits of the original tokens during generation. CD (Li et al., 2023) compares powerful expert language models with weaker amateur language models to enhance fluency and coherence. DoLa (Chuang et al., 2023) contrasts mature layers with premature layers, while ICD (Zhang et al., 2023a) compares with models injected with hallucinations, aiming to enhance the factual accuracy of the model. DeCK (Bi et al., 2024a) enhances ICE by highlighting the output probability increment of new knowledge in contrast to the parametric knowledge. Unlike the aforementioned decoding methods, ATBIAS proposed in this paper only needs to adjust key tokens to enhance KE and mitigate factual hallucinations in LLMs.
|
| 271 |
+
|
| 272 |
+
# 6 Conclusion
|
| 273 |
+
|
| 274 |
+
In this work, we propose a new KE framework, ATBIAS, to enhance ICE. ATBIAS focuses on the crucial tokens that are mostly related to knowledge during the generation, biasing their logits by matching the knowledge entities. This design effectively reduces the potential risk of introducing fundamental errors in the logical coherence of the entire inference statement. Experimental results show that ATBIAS significantly improves the editing success rate of ICE and outperforms the current best decoding methods. Furthermore, the latency of ATBIAS is at most 1.01 times that of the base-
|
| 275 |
+
|
| 276 |
+
line, meaning ATBIAS not only enhances ICE but can also be widely applied with negligible cost.
|
| 277 |
+
|
| 278 |
+
# Limitations
|
| 279 |
+
|
| 280 |
+
We mainly evaluate the KE methods on the LLAMA2 models, and MISTRAL-7B-INSTRUCT. The efficacy of these methods on other LLMs remains less explored. Additionally, although ATBIAS is expected to be easily deployable on any ICE method to enhance KE performance, we currently evaluate ATBIAS on the representative IKE and MeLLo, lacking broader validation.
|
| 281 |
+
|
| 282 |
+
# Ethical Considerations
|
| 283 |
+
|
| 284 |
+
Ethical considerations are of utmost importance in our research endeavors. We conscientiously adhere to ethical principles by exclusively utilizing open-source datasets and employing models that are open-source. We are committed to upholding ethical standards throughout the process, prioritizing transparency, and promoting the responsible use of technology for the betterment of society.
|
| 285 |
+
|
| 286 |
+
# Acknowledgements
|
| 287 |
+
|
| 288 |
+
This paper is partially supported by the National Science Foundation of China under Grant No. U21B2046 and 6237075198, and National Key R&D Program of China (No. 2023YFC3305303).
|
| 289 |
+
|
| 290 |
+
# References
|
| 291 |
+
|
| 292 |
+
Baolong Bi, Shenghua Liu, Lingrui Mei, Yiwei Wang, Pengliang Ji, and Xueqi Cheng. 2024a. Decoding by contrasting knowledge: Enhancing llms' confidence on edited facts. Preprint, arXiv:2405.11613.
|
| 293 |
+
Baolong Bi, Shenghua Liu, Yiwei Wang, Lingrui Mei, and Xueqi Cheng. 2024b. Is factuality decoding a free lunch for llms? evaluation on knowledge editing benchmark. arXiv preprint arXiv:2404.00216.
|
| 294 |
+
Baolong Bi, Shenghua Liu, Yiwei Wang, Lingrui Mei, Hongcheng Gao, Junfeng Fang, and Xueqi Cheng. 2024c. Struedit: Structured outputs enable the fast and accurate knowledge editing for large language models. arXiv preprint arXiv:2409.10132.
|
| 295 |
+
Canyu Chen and Kai Shu. 2023. Combating misinformation in the age of llms: Opportunities and challenges. arXiv preprint arXiv:2311.05656.
|
| 296 |
+
Yung-Sung Chuang, Yujia Xie, Hongyin Luo, Yoon Kim, James Glass, and Pengcheng He. 2023. Dola: Decoding by contrasting layers improves factuality in large language models. arXiv preprint arXiv:2309.03883.
|
| 297 |
+
|
| 298 |
+
Roi Cohen, Eden Biran, Ori Yoran, Amir Globerson, and Mor Geva. 2024. Evaluating the ripple effects of knowledge editing in language models. Transactions of the Association for Computational Linguistics, 12:283-298.
|
| 299 |
+
Nicola De Cao, Wilker Aziz, and Ivan Titov. 2021. Editing factual knowledge in language models. arXiv preprint arXiv:2104.08164.
|
| 300 |
+
Lei Huang, Weijiang Yu, Weitao Ma, Weihong Zhong, Zhangyin Feng, Haotian Wang, Qianglong Chen, Weihua Peng, Xiaocheng Feng, Bing Qin, and Ting Liu. 2023a. A survey on hallucination in large language models: Principles, taxonomy, challenges, and open questions. Preprint, arXiv:2311.05232.
|
| 301 |
+
Zeyu Huang, Yikang Shen, Xiaofeng Zhang, Jie Zhou, Wenge Rong, and Zhang Xiong. 2023b. Transformer-patcher: One mistake worth one neuron. arXiv preprint arXiv:2301.09785.
|
| 302 |
+
Albert Q Jiang, Alexandre Sablayrolles, Arthur Mensch, Chris Bamford, Devendra Singh Chaplot, Diego de las Casas, Florian Bressand, Gianna Lengyel, Guillaume Lample, Lucile Saulnier, et al. 2023. Mistral 7b. arXiv preprint arXiv:2310.06825.
|
| 303 |
+
Li Jiang, Yusen Wu, Junwu Xiong, Jingqing Ruan, Yichuan Ding, Qingpei Guo, Zujie Wen, Jun Zhou, and Xiaotie Deng. 2024. Hummer: Towards limited competitive preference dataset. arXiv preprint arXiv:2405.11647.
|
| 304 |
+
Xiang Lisa Li, Ari Holtzman, Daniel Fried, Percy Liang, Jason Eisner, Tatsunori Hashimoto, Luke Zettlemoyer, and Mike Lewis. 2023. Contrastive decoding: Open-ended text generation as optimization. In Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 12286-12312, Toronto, Canada. Association for Computational Linguistics.
|
| 305 |
+
Aman Madaan, Niket Tandon, Peter Clark, and Yiming Yang. 2022. Memory-assisted prompt editing to improve gpt-3 after deployment. arXiv preprint arXiv:2201.06009.
|
| 306 |
+
Lingrui Mei, Shenghua Liu, Yiwei Wang, Baolong Bi, and Xueqi Cheng. 2024a. Slang: New concept comprehension of large language models. Preprint, arXiv:2401.12585.
|
| 307 |
+
Lingrui Mei, Shenghua Liu, Yiwei Wang, Baolong Bi, Jiayi Mao, and Xueqi Cheng. 2024b. "not aligned" is not" malicious": Being careful about hallucinations of large language models' jailbreak. arXiv preprint arXiv:2406.11668.
|
| 308 |
+
Kevin Meng, David Bau, Alex Andonian, and Yonatan Belinkov. 2022a. Locating and editing factual associations in gpt. Advances in Neural Information Processing Systems, 35:17359-17372.
|
| 309 |
+
|
| 310 |
+
Kevin Meng, Arnab Sen Sharma, Alex Andonian, Yonatan Belinkov, and David Bau. 2022b. Mass-editing memory in a transformer. arXiv preprint arXiv:2210.07229.
|
| 311 |
+
Eric Mitchell, Charles Lin, Antoine Bosselut, Chelsea Finn, and Christopher D Manning. 2021. Fast model editing at scale. arXiv preprint arXiv:2110.11309.
|
| 312 |
+
Eric Mitchell, Charles Lin, Antoine Bosselut, Christopher D Manning, and Chelsea Finn. 2022. Memory-based model editing at scale. In International Conference on Machine Learning, pages 15817-15831. PMLR.
|
| 313 |
+
Suphakit Niwattanakul, Jatsada Singthongchai, Ekkachai Naenudorn, and Supachanun Wanapu. 2013. Using of jaccard coefficient for keywords similarity. In Proceedings of the international multiconference of engineers and computer scientists, volume 1, pages 380-384.
|
| 314 |
+
OpenAI. 2022. large-scale generative pre-training model for conversation. OpenAI blog.
|
| 315 |
+
OpenAI. 2023. Gpt-4 technical report. Preprint, arXiv:2303.08774.
|
| 316 |
+
Anton Sinitsin, Vsevolod Plokhotnyuk, Dmitriy Pyrkin, Sergei Popov, and Artem Babenko. 2020. Editable neural networks. arXiv preprint arXiv:2004.00345.
|
| 317 |
+
Zezheng Song, Jiaxin Yuan, and Haizhao Yang. 2024. Fmint: Bridging human designed and data pretrained models for differential equation foundation model. arXiv preprint arXiv:2404.14688.
|
| 318 |
+
S. M Towhidul Islam Tonmoy, S M Mehedi Zaman, Vinija Jain, Anku Rani, Vipula Rawte, Aman Chadha, and Amitava Das. 2024. A comprehensive survey of hallucination mitigation techniques in large language models. Preprint, arXiv:2401.01313.
|
| 319 |
+
Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, Aurélien Rodriguez, Armand Joulin, Edouard Grave, and Guillaume Lample. 2023a. Llama: Open and efficient foundation language models. CoRR, abs/2302.13971.
|
| 320 |
+
Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, Dan Bikel, Lukas Blecher, Cristian Canton Ferrer, Moya Chen, Guillem Cucurull, David Esiobu, Jude Fernandes, Jeremy Fu, Wenyin Fu, Brian Fuller, Cynthia Gao, Vedanuj Goswami, Naman Goyal, Anthony Hartshorn, Saghar Hosseini, Rui Hou, Hakan Inan, Marcin Kardas, Viktor Kerkez, Madian Khabsa, Isabel Kloumann, Artem Korenev, Punit Singh Koura, Marie-Anne Lachaux, Thibaut Lavril, Jenya Lee, Diana Liskovich, Yinghai Lu, Yuning Mao, Xavier Martinet, Todor Mihaylov, Pushkar Mishra, Igor Molybog, Yixin Nie, Andrew Poulton, Jeremy Reizenstein, Rashi Rungta, Kalyan Saladi, Alan Schelten
|
| 321 |
+
|
| 322 |
+
Ruan Silva, Eric Michael Smith, Ranjan Subramanian, Xiaqing Ellen Tan, Binh Tang, Ross Taylor, Adina Williams, Jian Xiang Kuan, Puxin Xu, Zheng Yan, Iliyan Zarov, Yuchen Zhang, Angela Fan, Melanie Kambadur, Sharan Narang, Aurelien Rodriguez, Robert Stojnic, Sergey Edunov, and Thomas Scialom. 2023b. Llama 2: Open foundation and fine-tuned chat models. Preprint, arXiv:2307.09288.
|
| 323 |
+
Cunxiang Wang, Xiaoze Liu, Yuanhao Yue, Xiangru Tang, Tianhang Zhang, Cheng Jiayang, Yunzhi Yao, Wenyang Gao, Xuming Hu, Zehan Qi, et al. 2023a. Survey on factuality in large language models: Knowledge, retrieval and domain-specificity. arXiv preprint arXiv:2310.07521.
|
| 324 |
+
Peng Wang, Ningyu Zhang, Xin Xie, Yunzhi Yao, Bozhong Tian, Mengru Wang, Zekun Xi, Siyuan Cheng, Kangwei Liu, Guozhou Zheng, et al. 2023b. EASYEDIT: An easy-to-use knowledge editing framework for large language models. arXiv preprint arXiv:2308.07269.
|
| 325 |
+
Yiwei Wang, Muhao Chen, Nanyun Peng, and Kai-Wei Chang. 2024. Deepedit: Knowledge editing as decoding with constraints. arXiv preprint arXiv:2401.10471.
|
| 326 |
+
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.
|
| 327 |
+
Yunzhi Yao, Peng Wang, Bozhong Tian, Siyuan Cheng, Zhoubo Li, Shumin Deng, Huajun Chen, and Ningyu Zhang. 2023. Editing large language models: Problems, methods, and opportunities. arXiv preprint arXiv:2305.13172.
|
| 328 |
+
Yue Zhang, Leyang Cui, Wei Bi, and Shuming Shi. 2023a. Alleviating hallucinations of large language models through induced hallucinations. arXiv preprint arXiv:2312.15710.
|
| 329 |
+
Yue Zhang, Yafu Li, Leyang Cui, Deng Cai, Lemao Liu, Tingchen Fu, Xinting Huang, Enbo Zhao, Yu Zhang, Yulong Chen, Longyue Wang, Anh Tuan Luu, Wei Bi, Freda Shi, and Shuming Shi. 2023b. Siren's song in the ai ocean: A survey on hallucination in large language models. Preprint, arXiv:2309.01219.
|
| 330 |
+
Ce Zheng, Lei Li, Qingxiu Dong, Yuxuan Fan, Zhiyong Wu, Jingjing Xu, and Baobao Chang. 2023. Can we edit factual knowledge by in-context learning? arXiv preprint arXiv:2305.12740.
|
| 331 |
+
Zexuan Zhong, Zhengxuan Wu, Christopher D Manning, Christopher Potts, and Danqi Chen. 2023. Mquake: Assessing knowledge editing in language models via multi-hop questions. arXiv preprint arXiv:2305.14795.
|
| 332 |
+
Chen Zhu, Ankit Singh Rawat, Manzil Zaheer, Srinadh Bhojanapalli, Daliang Li, Felix Yu, and Sanjiv Kumar. 2020. Modifying memories in transformer models. arXiv preprint arXiv:2012.00363.
|
| 333 |
+
|
| 334 |
+

|
| 335 |
+
Figure 4: An illustration of ATB1As's easy deployment on MeLLo.
|
| 336 |
+
|
| 337 |
+
# A How Can ATBIAS Be Easily Deployed on MeLLo?
|
| 338 |
+
|
| 339 |
+
Many advanced ICE methods (Zhong et al., 2023; Wang et al., 2024; Bi et al., 2024c) inherently possess parametric knowledge, so ATBIAS does not need to induce LLMs to preprocess it offline. Table 4 demonstrates how MeLLo (Zhong et al., 2023) can easily deploy ATBIAS without additional inference, directly extracting the required entities from the parametric output of subquestion responses. This means that knowledge entities can be extracted online and fed into ATBIAS when using MeLLo. Thus, ATBIAS enhances ICE during the decoding stage with just a single inference step.
|
| 340 |
+
|
| 341 |
+
# B Additional Ablation Study of ATBIAS
|
| 342 |
+
|
| 343 |
+
We conduct following additional ablation study experiments using the ICE method IKE (Zheng et al., 2023) with LLAMA2-7B-CHAT and LLAMA2-13B-CHAT on the MQUAKE-3K datasets.
|
| 344 |
+
|
| 345 |
+
# B.1 N-gram Decomposition
|
| 346 |
+
|
| 347 |
+
The N-gram decomposition is a prerequisite for calculating the similarity between the knowledge entities and filtered tokens (Section 3.3). Table 5 presents the ablation study results for various values of gram n during this process. Both excessively high and low decomposition precision can diminish the matching effectiveness, with $n = 2$ yielding the best editing performance.
|
| 348 |
+
|
| 349 |
+
# B.2 Probabilistic Constraint of Filter
|
| 350 |
+
|
| 351 |
+
The probabilistic constraint of ATBIAS's filter (Section 3.2) that represented in Equation 3 is subjected to an ablation study on the parameter $\alpha$ . The
|
| 352 |
+
|
| 353 |
+

|
| 354 |
+
Figure 5: Ablation study results of the gram n for n-gram decomposition process.
|
| 355 |
+
|
| 356 |
+
results of this study are shown in Table 6, indicating that $\alpha = 0.0005$ yields the best editing performance. The fact that smaller $\alpha$ values yield better performance further indicates the strictness of our filtering process, effectively preventing interference from unreasonable tokens.
|
| 357 |
+
|
| 358 |
+

|
| 359 |
+
Figure 6: Ablation study results of the probabilistic constraint $\alpha$ of filter.
|
| 360 |
+
|
| 361 |
+
# B.3 Ranking Constraint of Filter
|
| 362 |
+
|
| 363 |
+
The ablation study results of ranking constraint (Equation 4) are illustrated in Table 7, showing that $k = 10$ yields the best editing performance.
|
| 364 |
+
|
| 365 |
+
# B.4 Bias Coefficient of Knowledge
|
| 366 |
+
|
| 367 |
+
We adjust the logits of tokens matching with the new and parametric knowledge entities (Section 8) with the bias coefficients $\lambda_{n}$ (Equation 10) and $\lambda_{p}$ . The ablation study results of $\lambda_{n}$ and $\lambda_{p}$ are shown
|
| 368 |
+
|
| 369 |
+
```txt
|
| 370 |
+
[3 in-context demonstrations abbreviated]
|
| 371 |
+
```
|
| 372 |
+
|
| 373 |
+
Question: What is the capital city of the country of citizenship of Ivanka Trump's spouse?
|
| 374 |
+
|
| 375 |
+
Edit Knowledge: Jared Kushner is a citizen of Canada.
|
| 376 |
+
|
| 377 |
+
Thoughts: Ivanka Trump's spouse is Jared Kushner. Jared Kushner is a citizen of Canada. The capital city of Canada is Ottawa.
|
| 378 |
+
|
| 379 |
+
Answer: Ottawa
|
| 380 |
+
|
| 381 |
+
Question: Which continent is the country where the director of "My House Husband: Ikaw Na!" was educated located in?
|
| 382 |
+
|
| 383 |
+
Edit Knowledge: Irene Villamor was educated in New York University.
|
| 384 |
+
|
| 385 |
+
Thoughts: The director of "My House Husband: Ikaw Na!" is Jose Javier Reyes. Jose Javier Reyes was educated in New York University. De La Salle University is located in United States of America. United States of America is located in the continent if North America.
|
| 386 |
+
|
| 387 |
+
Answer: North America
|
| 388 |
+
|
| 389 |
+
Table 7: An illustration of the COT based IKE solving two simplified examples. The orange parts are facts retrieved by the retriever.
|
| 390 |
+
|
| 391 |
+
```txt
|
| 392 |
+
[2 in-context demonstrations abbreviated]
|
| 393 |
+
```
|
| 394 |
+
|
| 395 |
+
Question: What is the capital city of the country of citizenship of Ivanka Trump's spouse?
|
| 396 |
+
|
| 397 |
+
Subquestion: Who is Ivanka Trump's spouse?
|
| 398 |
+
|
| 399 |
+
Generated answer: Ivanka Trump's spouse is Jared Kushner.
|
| 400 |
+
|
| 401 |
+
Retrieved fact: David Cameron is married to Samantha Cameron.
|
| 402 |
+
|
| 403 |
+
Retrieved fact does not contradict to generated answer.
|
| 404 |
+
|
| 405 |
+
Intermediate answer: Jared Kushner
|
| 406 |
+
|
| 407 |
+
Subquestion: What is the country of citizenship of Jared Kushner?
|
| 408 |
+
|
| 409 |
+
Generated answer: The country of citizenship of Jared Kushner is United States.
|
| 410 |
+
|
| 411 |
+
Retrieved fact: Jared Kushner is a citizen of Canada.
|
| 412 |
+
|
| 413 |
+
Retrieved fact contradicts to generated answer.
|
| 414 |
+
|
| 415 |
+
Intermediate answer: Canada
|
| 416 |
+
|
| 417 |
+
Subquestion: What is the capital city of Canada?
|
| 418 |
+
|
| 419 |
+
Generated answer: The capital city of Canada is Ottawa.
|
| 420 |
+
|
| 421 |
+
Retrieved fact: The capital city of United States is Seattle.
|
| 422 |
+
|
| 423 |
+
Retrieved fact does not contradict to generated answer, so the intermediate answer.
|
| 424 |
+
|
| 425 |
+
Intermediate answer: Ottawa
|
| 426 |
+
|
| 427 |
+
Final answer: Ottawa
|
| 428 |
+
|
| 429 |
+

|
| 430 |
+
Figure 7: Ablation study results of the ranking constraint $k$ of filter.
|
| 431 |
+
|
| 432 |
+
in Table 9 and 10, respectively. ATBIAS achieves the best performance when $\lambda_{n} = 25$ .
|
| 433 |
+
|
| 434 |
+
ATBIAS achieves the best performance when $\lambda_p = 1$ . An $\lambda_p$ value of 0 means that the logits of tokens matching with parametric knowledge entities are not reduced, and the results indicate that this leads to a decline in performance. Optimal performance is achieved with smaller values of $\lambda_p$
|
| 435 |
+
|
| 436 |
+
Table 8: A step-by-step illustration of MeLLo solving one simplified example. Blue parts are generated by the language model, and orange parts are facts retrieved by the retriever.
|
| 437 |
+
|
| 438 |
+
<table><tr><td>Model</td><td>λn=20</td><td>λn=25</td><td>λn=30</td></tr><tr><td>LLAMA2-7B</td><td>90.5</td><td>93.1</td><td>92.7</td></tr><tr><td>LLAMA2-13B</td><td>86.6</td><td>89.7</td><td>88.9</td></tr></table>
|
| 439 |
+
|
| 440 |
+
because excessively large $\lambda_{p}$ values may cause the logits of tokens incorrectly matching old knowledge entities to decrease too much, adversely affecting editing performance.
|
| 441 |
+
|
| 442 |
+
Table 9: Ablation study results of the bias coefficient of new knowledge $\lambda_{n}$ .
|
| 443 |
+
|
| 444 |
+
<table><tr><td>Model</td><td>λp=0</td><td>λp=1</td><td>λp=2</td></tr><tr><td>LLAMA2-7B</td><td>85.9</td><td>93.1</td><td>88.6</td></tr><tr><td>LLAMA2-13B</td><td>70.2</td><td>89.7</td><td>83.2</td></tr></table>
|
| 445 |
+
|
| 446 |
+
Table 10: Ablation study results of the bias coefficient of parametric knowledge $\lambda_{p}$ .
|
| 447 |
+
|
| 448 |
+
# C Prompts of ICE for Experiments
|
| 449 |
+
|
| 450 |
+
The prompt we used in IKE (Zheng et al., 2023) is shown in 7, and the prompt we used in MeLLo is shown in 8. Based on the provided contextual demonstrations, LLMs can be guided to perform the corresponding ICE methods. ATBIAS can enhance these ICE methods without modifying any prompts.
|
adaptivetokenbiaserknowledgeeditingviabiasingkeyentities/images.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d0c18be3287de63ae513c97e4eae166d471c487ceb303974605bf21a2ace0789
|
| 3 |
+
size 618025
|
adaptivetokenbiaserknowledgeeditingviabiasingkeyentities/layout.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8c9270f4cd7cb3fe031452e42c0499a0e9e9419fb7b5a3461dbfde6552038aae
|
| 3 |
+
size 439272
|
advancingcrosslingualentityalignmentwithlargelanguagemodelstailoredsamplesegmentationandzeroshotprompts/d5aecb5d-ab41-4934-b11d-ae5260ca4dac_content_list.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9a8b851327d94f48cee928d80f2ed79974169a8775bbe31d6887f975f85744ce
|
| 3 |
+
size 119665
|
advancingcrosslingualentityalignmentwithlargelanguagemodelstailoredsamplesegmentationandzeroshotprompts/d5aecb5d-ab41-4934-b11d-ae5260ca4dac_model.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0660d0e0f4a9ab2dc56e0b80feffbf59a8b27d2d8d178ad517c6964d0a95282e
|
| 3 |
+
size 138203
|
advancingcrosslingualentityalignmentwithlargelanguagemodelstailoredsamplesegmentationandzeroshotprompts/d5aecb5d-ab41-4934-b11d-ae5260ca4dac_origin.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e8218bf05107263b827bb47c99258759cca9ce24f4689a5e023ff83520ef7c20
|
| 3 |
+
size 619220
|
advancingcrosslingualentityalignmentwithlargelanguagemodelstailoredsamplesegmentationandzeroshotprompts/full.md
ADDED
|
@@ -0,0 +1,453 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Advancing Cross-Linguual Entity Alignment with Large Language Models: Tailored Sample Segmentation and Zero-Shot Prompts
|
| 2 |
+
|
| 3 |
+
Linyan Yang, Jingwei Cheng*, Fu Zhang
|
| 4 |
+
|
| 5 |
+
School of Computer Science and Engineering, Northeastern University, China
|
| 6 |
+
|
| 7 |
+
yanglinyanly@163.com, {chengjingwei,zhangfu} $@$ mail.neu.edu.cn
|
| 8 |
+
|
| 9 |
+
# Abstract
|
| 10 |
+
|
| 11 |
+
In recent years, the advent of large language models (LLMs) like GPT and Llama has significantly influenced numerous domains, particularly in advancing natural language processing (NLP) capabilities. LLMs have shown remarkable performance in NLP tasks such as relation extraction (RE) and knowledge graph completion (KGC), enhancing activities related to knowledge graphs. As a result, there is a growing interest in integrating LLMs into cross-lingual entity alignment (EA) task, which aims to identify equivalent entities across various knowledge graphs, thereby improving the performance of current baselines. However, employing LLMs for entity alignment poses challenges in efficiently handling largescale data, generating suitable data samples, and adapting prompts for the EA task. To tackle these challenges, we propose Seg-Align, an innovative framework that integrating distance feature extraction, sample Segmentation, and zero-shot prompts. Through extensive experiments on two widely used cross-lingual benchmark datasets, we have not only demonstrated the effectiveness of our proposed sample segmentation algorithm but also highlighted the state-of-the-art performance of Seg-Align. Code is available at https://github.com/ yangxiaoxiaoly/Seg-Align.
|
| 12 |
+
|
| 13 |
+
# 1 Introduction
|
| 14 |
+
|
| 15 |
+
Knowledge Graphs (KGs) depict entities and their relationships, serving as foundational elements for applications like semantic search (Zhang et al., 2021), question-answering (Kwiatkowski et al., 2019), and recommender systems (Zangerle and Bauer, 2022). However, KGs often suffer from heterogeneity and redundancy due to their construction by various organizations with specific needs. Knowledge fusion (Dong et al., 2014) aims to align and merge this heterogeneous information, forming
|
| 16 |
+
|
| 17 |
+
unified identifiers and relationships. Entity Alignment (EA) is crucial in this process, focusing on discovering equivalent entities across various KGs (Sun et al., 2020b).
|
| 18 |
+
|
| 19 |
+
Knowledge representation learning-based entity alignment methods have emerged as the primary technique for addressing the EA task, yielding promising results. These SLM based methods<sup>1</sup> often use translation-based models or Graph Neural Networks (GNNs)/ Graph Convolutional Networks (GCNs) due to their robustness and generalization capabilities (Scarselli et al., 2008; Kipf and Welling, 2017). Recently, LLMs have demonstrated their proficiency in various NLP tasks (Kolasani, 2023). Trained on vast amounts of text data, LLMs possess rich linguistic and background knowledge, enabling them to understand context, disambiguate meanings, and recognize patterns across textual sources (Pan et al., 2023). This capability renders their application to the EA task particularly promising. Nonetheless, integrating LLMs into the EA task also faces challenges.
|
| 20 |
+
|
| 21 |
+
Challenge 1: How to handle large-scale data. Managing large-scale data requires meticulous consideration of resource consumption, operational efficiency, and overall system performance. LLMs, such as GPT and Llama, have input size limitations. Consequently, it is impractical to process all data solely using these models. Additionally, as the length of the input increases, the cost of using LLMs also rises, accompanied by longer processing times. This results in higher resource consumption and reduced efficiency. Therefore, when dealing with datasets for the EA task, it is crucial to adopt strategies that balance resource consumption, efficiency, and performance.
|
| 22 |
+
|
| 23 |
+
# Challenge 2: How to select data samples that are more suitable for processing by LLMs.
|
| 24 |
+
|
| 25 |
+
LLMs are trained on massive datasets containing billions or even trillions of words sourced from various texts on the Internet (Pan et al., 2024). These datasets cover a wide range of topics, styles, and languages, allowing the model to learn various language patterns and contexts. Therefore, for data samples that are difficult for SLMs to distinguish, such as long-tail entities (Cao et al., 2020), LLMs can leverage their own knowledge for judgment. For data samples effectively managed by SLMs, employing LLMs is unnecessary, as LLMs may not provide superior performance in these cases. Hence, it is essential to carefully consider the complexity of entities, context, and the performance of SLMs to determine which entity samples require handling by LLMs and how to effectively utilize LLMs to enhance the effectiveness of the EA task.
|
| 26 |
+
|
| 27 |
+
Challenge 3: How to adjust prompts to make them more suitable for the EA task. For different tasks, LLMs require distinct contextual information and input formats. In the EA task, firstly, due to the limitation of input length, it's impractical to include all entities directly in the prompt. Additionally, transforming entities from a KG into suitable textual representations for inclusion in the prompt is essential. Furthermore, LLMs need to identify and match same entities across various KGs. When adjusting prompts, it is necessary to consider the characteristics and requirements of the EA task and ensure that prompts can effectively guide LLMs to understand and execute the EA task.
|
| 28 |
+
|
| 29 |
+
To address the aforementioned challenges, we propose Seg-Align framework, which mainly consists of three components: distance feature extraction, sample segmentation, and zero-shot prompts. Firstly, a SLM (SDEA) (Zhong et al., 2022) is utilized to obtain the initial embedding representations of entities. Then, based on these embeddings, the distances between entities are computed to generate a distance matrix. Subsequently, machine learning method is employed for distance feature extraction. Using the extracted distance features, we perform binary classification to divide the data samples into two groups, which are then processed by a SLM and a LLM respectively. The LLM processes the corresponding data samples based on zero-shot prompts to obtain the final alignment results. The experimental results indicate that our Seg-Align framework has achieved remarkable performance enhancements in the EA task.
|
| 30 |
+
|
| 31 |
+
In summary, our contributions are as follows:
|
| 32 |
+
|
| 33 |
+
- We propose a novel sample segmentation algorithm that effectively discriminates data samples amenable for processing by SLMs and LLMs.
|
| 34 |
+
- We develop tailored zero-shot prompts for the EA task. By strategically minimizing extraneous context, we effectively reduce token usage and processing time, thus significantly enhancing the framework's efficacy.
|
| 35 |
+
- We conduct extensive experiments on five cross-lingual datasets. Experimental results show that our framework outperforms state-of-the-art methods on all datasets, demonstrating its effectiveness and superiority.
|
| 36 |
+
|
| 37 |
+
# 2 Related Work
|
| 38 |
+
|
| 39 |
+
Currently, most EA methods are rooted in knowledge representation learning, primarily categorized into those translation based methods and those based on GNNs/GCNs. Translation based methods, such as MTransE (Chen et al., 2017), JAPE (Sun et al., 2017), KECG (Li et al., 2019), BootEA (Sun et al., 2018), Multi-mapping Relations (Shi and Xiao, 2019), TransEdge (Sun et al., 2019), JarKA(Chen et al., 2020), and CTEA(Yan et al., 2020), principally constrain the entity embeddings into a fixed distribution by translation-based knowledge graphs embedding methods. Based on the observation that entities sharing similar neighboring structures tend to be aligned, EA approaches based on GCNs distribute and consolidate entity information across graphs. GCN-Align (Wang et al., 2018) is the first to use GCN to jointly embed the entity structure and entity attributes. Building upon this foundation, many approaches have enhanced GCNs to address issues such as noise propagation (HGCN (Wu et al., 2019b)), heterogeneity (MuGNN (Cao et al., 2019), Alinet (Sun et al., 2020a), NMN (Wu et al., 2020), MRAEA (Mao et al., 2020)), and better utilization of relationship and attribute information (RDGCN (Wu et al., 2019a), RAGA (Zhu et al., 2021a), RNM (Zhu et al., 2021b), EPEA (Wang et al., 2020)).
|
| 40 |
+
|
| 41 |
+
With the rise of pre-trained language models like BERT (Kenton and Toutanova, 2019), fine-tuning these models in downstream tasks has demonstrated significant potential. HMAN+BERT (Yang et al., 2019), SDEA (Zhong et al., 2022), and BERT-INT (Tang et al., 2020) treat entity alignment as a downstream task for fine-tuning BERT. However,
|
| 42 |
+
|
| 43 |
+

|
| 44 |
+
Figure 1: The overview of Seg-Align framework, which consists of three main components: (1) distance feature extraction, (2) sample segmentation, and (3) zero-shot prompt.
|
| 45 |
+
|
| 46 |
+
for LLMs, fine-tuning not only requires considerable time but also demands substantial resources.
|
| 47 |
+
|
| 48 |
+
Recent studies have integrated LLMs into the EA task, as seen in CHATEA (Jiang et al., 2024) and LLMEA (Yang et al., 2024). In CHATEA, alongside leveraging LLMs for iterative reasoning, a SLM is employed for candidate entity filtering. Various types of information, including names, descriptions, structures, and temporal data, are incorporated into the prompt to guide the alignment process. However, CHATEA primarily tests single-language EA task and only conducts cross-language tests on the relatively similar languages of French and English. On the other hand, LLMEA adopts a different approach. It utilizes entity structure embeddings, entity name embeddings, and entity name edit distances for candidate entities selection. LLMs are then utilized to make selections within each candidate set, iterating until a final alignment is reached.
|
| 49 |
+
|
| 50 |
+
Despite these advancements, both CHATEA and LLMEA overlook the fact that not all data is suitable for processing by LLMs alone. Relying solely on SLMs for candidate entity selection fails to effectively segment the data, thus missing out on fully leveraging the strengths of both LLMs and SLMs.
|
| 51 |
+
|
| 52 |
+
Therefore, we propose Seg-Align, which efficiently utilizes LLMs for entity alignment. We extract features based on distances between entities, further segment data samples, selecting suitable samples for processing by LLMs. Finally, we design prompts that are more suitable for the EA task to interact with LLMs.
|
| 53 |
+
|
| 54 |
+
# 3 Problem Definition
|
| 55 |
+
|
| 56 |
+
Definition 1 (Knowledge Graph) A knowledge graph (KG) is denoted as $G = (E, R, A, V, T_r, T_a)$ , where $E = \{e_1, e_2, \ldots e_m\}$ , $R = \{r_1, r_2, \ldots r_n\}$ , $A = \{a_1, a_2, \ldots a_p\}$ , and $V = \{v_1, v_2, \ldots, v_q\}$ represent entity set, relation set, attribute set, and value set, respectively, and $m, n, p, q$ are the number of entities, relations, attributes, and attribute values, respectively. $T_r \subseteq E \times R \times E$ is the relation triple set, and $T_a \subseteq E \times A \times V$ is the attribute triple set. Relational triples can also be represented as $(h, r, t)$ , where $h$ is called the head entity and $t$ is called the tail entity.
|
| 57 |
+
|
| 58 |
+
Definition 2 (Entity Alignment in KGs) Given a source KG $G^{1} = (E^{1}, R^{1}, A^{1}, V^{1}, T_{r}^{1}, T_{a}^{1})$ , and a target KG $G^{2} = (E^{2}, R^{2}, A^{2}, V^{2}, T_{r}^{2}, T_{a}^{2})$ , the aligned entity pairs (training set) is denoted as $S = \{(e_{i}^{1}, e_{j}^{2}) | e_{i}^{1} \in E^{1}, e_{j}^{2} \in E^{2}, e_{i}^{1} \equiv e_{j}^{2}\}$ , where $\equiv$ stands for equivalence, i.e., the source entity $e_{i}^{1}$ and the target entity $e_{j}^{2}$ refer to the same thing in the real world. The goal of the EA task is to find remaining equivalent entity pairs of these two KGs.
|
| 59 |
+
|
| 60 |
+
# 4 Methodology
|
| 61 |
+
|
| 62 |
+
As shown in Figure 1, Seg-Align framework is mainly divided into three parts: distance feature extraction, sample segmentation, and zero-shot prompt. Firstly, in the distance feature extraction stage, we train a SLM to obtain entity embeddings, thereby calculating the distances between entities to generate a distance matrix. Based on the distance matrix, we extract distance features, and then perform sample segmentation to select data samples more suitable for processing by LLMs. Finally, we design prompts to utilize the background knowledge
|
| 63 |
+
|
| 64 |
+
edge of LLMs for EA.
|
| 65 |
+
|
| 66 |
+
For the candidate entity selection, our approach aligns with ChatEA and LLMEA in utilizing knowledge representation learning-based entity alignment methods to obtain entity embeddings, which are then used to select candidate entities. However, our method diverges in how we handle candidate entities. While ChatEA and LLMEA pass all data to the LLM for processing after candidate entities are identified, they do not account for the fact that some data may already be well-aligned during the candidate entity selection phase. Therefore, we propose a sample segmentation algorithm that selects only the poorly aligned data to be processed by the LLM.
|
| 67 |
+
|
| 68 |
+
In terms of prompt design, our approach differs significantly from that of ChatEA and LLMEA. Firstly, ChatEA's prompt processes each candidate entity one by one sequentially, whereas our prompt can include all candidate entities at once, greatly enhancing the LLM's processing efficiency. Similar to LLMEA, we use a multiple-choice format for our prompt; however, we further refine this by restricting the response format of the LLM to ensure more consistent and easier-to-process answers. Additionally, unlike LLMEA, we do not include examples in the prompt, thereby achieving a true zero-shot prompt design.
|
| 69 |
+
|
| 70 |
+

|
| 71 |
+
Figure 2: Distances between source entity and their top-10 candidate entities. The x-axis (0-9) represents the top-10 candidate entities, while the y-axis represents embedding distances (Euclidean distance) between the source entity and its top-10 candidate entities.
|
| 72 |
+
|
| 73 |
+
# 4.1 Distance feature extraction
|
| 74 |
+
|
| 75 |
+
For the majority of SLMs, when provided with a source entity, the alignment procedure involves computing the embedding distances between the source entity and all target entities. Subsequently,
|
| 76 |
+
|
| 77 |
+
the target entities are sorted in ascending order based on these distances, and the top-k entities are selected, thus yielding candidate entities for the source entity. At this stage, we adopt a SLM (SDEA) (Zhong et al., 2022) for the EA task and analyze the entity embeddings it produced.
|
| 78 |
+
|
| 79 |
+
We found that when the embedding representation of an entity is not well-distinguished from other entities, i.e., when the embedding distances between multiple target entities and the source entity are similar, SLMs often produce erroneous alignment results. As shown in Figure 2, we randomly select ten source entities and their top-10 candidate entities, where the red ones indicate that the initial answer chosen by the SLM is incorrect, while blue signifies that the initial answer chosen is correct. It can be observed that when the first candidate (coordinate 0 on X-axis) is the correct alignment result, there is a significant difference in the embedding distances (Euclidean distance (Danielsson, 1980)) between the entities. Conversely, when the first candidate is incorrect, the embedding distances between entities exhibit minimal variation.
|
| 80 |
+
|
| 81 |
+
Therefore, we regard well-distinguished samples as positive samples while others as negative samples. In the next subsection, we will select appropriate positive and negative samples from the validation set to train a Support Vector Machine (SVM) (Hearst et al., 1998) for binary classification (Menon and Williamson, 2018) of data samples in the test set, and adjust the proportion of positive and negative samples to achieve high recall and high accuracy. It is worth noting that the selection of SVM is not mandatory, other classification methods are equally applicable.
|
| 82 |
+
|
| 83 |
+

|
| 84 |
+
Figure 3: The positive and negative samples in the validation set.
|
| 85 |
+
|
| 86 |
+
# 4.2 Sample segmentation
|
| 87 |
+
|
| 88 |
+
To select data samples suitable for processing by LLMs, we first conduct a statistical analysis of the positive and negative samples in the validation set. We find that there is a significant disparity in the proportion of positive and negative samples in the validation set, as shown in the Figure 3. Among the 1,500 data samples in the validation dataset, the vast majority are positive samples. Therefore, if all data are fed into SVM for machine learning, it would lead to a low recall for negative samples, i.e., it will not effectively segment data poorly handled by SLMs. Hence, we screen out data from the validation set with more distinct distance features to serve as training data for SVM. We also adjust the ratio of positive to negative samples to achieve higher precision and recall.
|
| 89 |
+
|
| 90 |
+
Specially, when selecting the training set for SVM, we first obtain the embedding representations of entities in the validation set. Then, we compute the embedding distances between entities and arrange the distance matrix in ascending order. We select top- $k$ distances ( $k$ is a hyperparameter and will be detailed in 5.3.1). Next, we select positive and negative samples based on the difference between the rank 1 and rank 2 distances. If the difference is larger than a hyperparameter $\alpha$ , it is selected as a positive sample; if it is smaller than a hyperparameter $\beta$ , it is selected as a negative sample. However, since the number of positive samples in the validation set is much larger than that of negative samples, we select all negative samples, while the number of positive samples is determined by a hyperparameter $\theta$ . By adjusting $\theta$ , we aim to achieve higher accuracy and recall rates. The detail is illustrated in Algorithm 1.
|
| 91 |
+
|
| 92 |
+
We employ trained SVM to segment the test set. To investigate the effect of different candidate set sizes on LLMs, for each entity, we conduct experiments with candidate set size of 5, 10, and 20, respectively. To maintain consistency in our framework, when processing a set of five candidate entities with LLMs, the data segmentation stage selects the same five candidate entities as feature inputs. In these experiments, labels of 0 are considered as negative samples, indicating samples (hard samples) poorly handled by SLMs that needs to be processed by LLMs. On the other hand, labels of 1 are regarded as positive samples for SLMs, representing samples (simple samples) effectively processed by SLMs. Detailed experimental data
|
| 93 |
+
|
| 94 |
+
# Algorithm 1 SVM Training Set Selection
|
| 95 |
+
|
| 96 |
+
Input: Validation set embeddings: $emb_1,emb_2$ hyperparameters: $k,\alpha ,\beta ,\theta$
|
| 97 |
+
|
| 98 |
+
Output: Positive and Negative training samples: $P, N$
|
| 99 |
+
|
| 100 |
+
1: Calculate the embedding distances between all the entities in validation set: $D_{\text{matrix}}$ .
|
| 101 |
+
|
| 102 |
+
2: Select the top $k$ distances: $Top_{k}(D_{matrix})$ .
|
| 103 |
+
|
| 104 |
+
3: Let $D_{rank1}$ and $D_{rank2}$ represent the rank 1 and rank 2 distances, respectively.
|
| 105 |
+
|
| 106 |
+
4: Create sets $P$ (for positive samples) and $N$ (for negative samples).
|
| 107 |
+
|
| 108 |
+
5: for $dis$ in top $kD_{\text{matrix}}$ do
|
| 109 |
+
|
| 110 |
+
6: if $D_{rank2} - D_{rank1} > \alpha$ then
|
| 111 |
+
|
| 112 |
+
7: add the corresponding sample to $P$
|
| 113 |
+
|
| 114 |
+
8: if arity $(P) = = \theta$ then
|
| 115 |
+
|
| 116 |
+
9: break
|
| 117 |
+
|
| 118 |
+
10: end if
|
| 119 |
+
|
| 120 |
+
11: end if
|
| 121 |
+
|
| 122 |
+
12: if $D_{rank2} - D_{rank1} < \beta$ then
|
| 123 |
+
|
| 124 |
+
13: add the corresponding sample to $N$
|
| 125 |
+
|
| 126 |
+
14: end if
|
| 127 |
+
|
| 128 |
+
15: end for
|
| 129 |
+
|
| 130 |
+
can be found in Table 9, 10, 11 in Appendix A.
|
| 131 |
+
|
| 132 |
+
# 4.3 Zero-shot prompt
|
| 133 |
+
|
| 134 |
+
SLMs utilize relation, neighbor, and attribute information in KGs. For samples that SLMs do not handle well, we refrain from feeding these information into LLMs and instead rely on LLMs' inherent background knowledge for entity alignment. As LLMs are generative interactive models, we guide LLMs to provide expected answers by including constraints in the prompt, as shown in Table 1. For the form of the prompt, we adhere to the examples provided in the official documentation of Llama $^2$ .
|
| 135 |
+
|
| 136 |
+
When interacting with LLMs, we employ a zero-shot prompt, which means we do not provide any demonstrations (Ma et al., 2023). This strategy is chosen for two main reasons: firstly, it notably reduces the length of the prompt, thereby boosting LLMs' respond speed; secondly, it enables us to assess the influence of the inherent background knowledge of LLMs on the EA task. Consequently, we solely include the entity names in the prompt. Additionally, we conduct comparative experiments regarding the presence or absence of structural information of entities in the prompt. The details of these experiments can be found in Appendix B. The
|
| 137 |
+
|
| 138 |
+
# Entity Alignment Prompt
|
| 139 |
+
|
| 140 |
+
"role": "system", "content": "Answer me begin with 'The option is:'."
|
| 141 |
+
|
| 142 |
+
"role": "user", "content": "Choose the option that is most similar to {ent1} from the following options:
|
| 143 |
+
|
| 144 |
+
A:{ent2_dic[0]},B:{ent2_dic[1]},C:{ent2_dic[2]},
|
| 145 |
+
|
| 146 |
+
D:{ent2_dic[3]},E:{ent2_dic[4]},F:{ent2_dic[5]},
|
| 147 |
+
|
| 148 |
+
G:{ent2_dic[6]},H:{ent2_dic[7]},I:{ent2_dic[8]}, J:{ent2_dic[9]"}.
|
| 149 |
+
|
| 150 |
+
Table 1: Prompt for entity alignment. Where $\{\mathrm{ent}1\}$ is the entity from the source KG $G^1$ , and $\{\mathrm{ent2\_dic}[0 - 9]\}$ are candidate entities from the target KG $G^2$
|
| 151 |
+
|
| 152 |
+
<table><tr><td colspan="2">Datasets</td><td>Entities</td><td>Rel.</td><td>Rel.Triples</td><td>Attr.</td><td>Attr.Triples</td></tr><tr><td colspan="7">DBP15K</td></tr><tr><td rowspan="2">ZH-EN</td><td>ZH</td><td>19388</td><td>1701</td><td>70414</td><td>7780</td><td>379684</td></tr><tr><td>EN</td><td>19572</td><td>1323</td><td>95142</td><td>6933</td><td>567755</td></tr><tr><td rowspan="2">JA-EN</td><td>JA</td><td>19814</td><td>1299</td><td>77241</td><td>5681</td><td>354619</td></tr><tr><td>EN</td><td>19780</td><td>1153</td><td>93484</td><td>5850</td><td>497230</td></tr><tr><td rowspan="2">FR-EN</td><td>FR</td><td>19661</td><td>903</td><td>105998</td><td>4431</td><td>528665</td></tr><tr><td>EN</td><td>19993</td><td>1208</td><td>115722</td><td>6161</td><td>576543</td></tr><tr><td colspan="7">SRPRS</td></tr><tr><td rowspan="2">EN-DE</td><td>EN</td><td>15000</td><td>222</td><td>38363</td><td>275</td><td>62715</td></tr><tr><td>DE</td><td>15000</td><td>120</td><td>37377</td><td>185</td><td>142506</td></tr><tr><td rowspan="2">EN-FR</td><td>EN</td><td>15000</td><td>221</td><td>36508</td><td>274</td><td>70750</td></tr><tr><td>FR</td><td>15000</td><td>177</td><td>33532</td><td>393</td><td>56344</td></tr></table>
|
| 153 |
+
|
| 154 |
+
Table 2: Details of the datasets. Rel., Rel.Triples, Attr., and Attr.Triples represent relations, relation triples, attributes, and attribute triples, respectively.
|
| 155 |
+
|
| 156 |
+
experimental results indicate that, both in terms of performance and efficiency, omitting structural information from prompts proves to be the optimal choice.
|
| 157 |
+
|
| 158 |
+
# 5 Experiment
|
| 159 |
+
|
| 160 |
+
# 5.1 Datasets
|
| 161 |
+
|
| 162 |
+
We perform experiments on two popular crosslingual benchmarks: DBP15K (Sun et al., 2017) and SRPRS (Guo et al., 2019). Table 2 presents the dataset statistics. DBP15K comprises three cross-language entity alignment datasets sourced from DBpedia: Chinese-English (ZH-EN), Japanese-English (JA-EN), and French-English (FR-EN). SRPRS, on the other hand, serves as a widely utilized sparse benchmark (containing fewer relations) for entity alignment. It includes two multilingual datasets also sourced from DBpedia, English-German (EN-DE) and English-French (EN-FR). Each dataset contains 15,000 aligned entity pairs.
|
| 163 |
+
|
| 164 |
+
# 5.2 Baselines
|
| 165 |
+
|
| 166 |
+
Based on the variances in the embedding modules, methods are categorized into three groups: Translation-based methods, GNN-based methods, and BERT-based methods. We have chosen 11 SOTA cross-lingual EA methods that encompass diverse embedding modules. Translation-based methods: MTransE (Chen et al., 2017), KECG (Li et al., 2019), BootEA (Sun et al., 2018), JAPE (Sun et al., 2017). GNN-based methods: GCN-Align (Wang et al., 2018), MuGNN (Cao et al., 2019), RDGCN (Wu et al., 2019a), HGCN (Wu et al., 2019b), CEA (Zeng et al., 2020). BERT-based methods: BERT-INT (Tang et al., 2020), SDEA (Zhong et al., 2022). Similar to SDEA, in BERT-INT, we substitute entity descriptions with entity names as not all benchmark datasets provide entity descriptions.
|
| 167 |
+
|
| 168 |
+
# 5.3 Experimental Settings
|
| 169 |
+
|
| 170 |
+
# 5.3.1 Implement details
|
| 171 |
+
|
| 172 |
+
For each dataset, we divide the aligned entity pairs into training, validation, and test sets with a ratio of 2:1:7. During the training phase of the SVM model using the validation set, we conduct experiments by varying the parameter $k$ with values 5, 10, and 20, while keeping the parameters $\alpha$ and $\beta$ constant at $\alpha = 10$ and $\beta = 10$ (except for the FR-EN setting where $\beta = 20$ ).
|
| 173 |
+
|
| 174 |
+
For the selection of LLMs, we opt for the GPT-3.5 API and Llama (Touvron et al., 2023), the latter of which has open-source code available. We deploy Llama2-7b-chat and Llama3-8b-Instruct for experimental testing. To ensure consistency in evaluation, models used in the experiments follow the specifications provided in their original publications. Moreover, the temperature for both GPT and Llama is set to 0.
|
| 175 |
+
|
| 176 |
+
# 5.3.2 Evaluation Metric
|
| 177 |
+
|
| 178 |
+
To facilitate comparison with previous methods, we adopt ranking-based evaluation metrics for entity alignment, specifically Hits@ $d$ and MRR. Hits@ $d$ measures the proportion of correct alignments among the top $d$ matches $(d = 1, 10)$ . However, in the processing of entity alignment data by LLMs, our prompt constrains them to generate solely a singular response, thereby resulting in the acquisition of Hits@1 scores exclusively. Higher scores in Hits@1 indicate better performance in the EA task.
|
| 179 |
+
|
| 180 |
+
<table><tr><td rowspan="2">Methods</td><td colspan="3">ZH-EN</td><td colspan="3">JA-EN</td><td colspan="3">FR-EN</td></tr><tr><td>H@1</td><td>H@10</td><td>MRR</td><td>H@1</td><td>H@10</td><td>MRR</td><td>H@1</td><td>H@10</td><td>MRR</td></tr><tr><td>MTransE</td><td>30.8</td><td>61.4</td><td>0.364</td><td>27.9</td><td>57.5</td><td>0.349</td><td>24.4</td><td>55.6</td><td>0.335</td></tr><tr><td>JAPE</td><td>41.2</td><td>74.5</td><td>0.490</td><td>36.3</td><td>68.5</td><td>0.476</td><td>32.4</td><td>66.7</td><td>0.430</td></tr><tr><td>KECG</td><td>47.8</td><td>83.5</td><td>0.598</td><td>49.0</td><td>84.4</td><td>0.610</td><td>48.6</td><td>85.1</td><td>0.610</td></tr><tr><td>BootEA</td><td>62.9</td><td>84.8</td><td>0.703</td><td>62.2</td><td>85.4</td><td>0.701</td><td>65.3</td><td>87.4</td><td>0.731</td></tr><tr><td>GCN-Align</td><td>41.3</td><td>74.4</td><td>0.549</td><td>39.9</td><td>74.5</td><td>0.546</td><td>37.3</td><td>74.5</td><td>0.532</td></tr><tr><td>MuGNN</td><td>49.4</td><td>84.4</td><td>0.611</td><td>50.1</td><td>85.7</td><td>0.621</td><td>49.5</td><td>87.0</td><td>0.621</td></tr><tr><td>RDGCN</td><td>70.8</td><td>84.6</td><td>0.746</td><td>76.7</td><td>89.5</td><td>0.812</td><td>88.6</td><td>95.7</td><td>0.911</td></tr><tr><td>HGCN</td><td>72.0</td><td>85.7</td><td>0.768</td><td>76.6</td><td>89.7</td><td>0.813</td><td>89.2</td><td>96.1</td><td>0.917</td></tr><tr><td>CEA</td><td>78.7</td><td>-</td><td>-</td><td>86.3</td><td>-</td><td>-</td><td>97.2</td><td>-</td><td>-</td></tr><tr><td>BERT-INT</td><td>81.4</td><td>83.7</td><td>0.82</td><td>80.6</td><td>83.5</td><td>0.82</td><td>98.7</td><td>99.2</td><td>0.999</td></tr><tr><td>SDEA</td><td>87.0</td><td>96.6</td><td>0.91</td><td>84.8</td><td>95.2</td><td>0.89</td><td>96.9</td><td>99.5</td><td>0.98</td></tr><tr><td>Seg-Align</td><td>95.3</td><td>-</td><td>-</td><td>90.7</td><td>-</td><td>-</td><td>98.7</td><td>-</td><td>-</td></tr></table>
|
| 181 |
+
|
| 182 |
+
Table 3: Entity alignment results on DBP15K
|
| 183 |
+
|
| 184 |
+
<table><tr><td rowspan="2">Methods</td><td colspan="3">EN-DE</td><td colspan="3">EN-FR</td></tr><tr><td>H@1</td><td>H@10</td><td>MRR</td><td>H@1</td><td>H@10</td><td>MRR</td></tr><tr><td>MTransE</td><td>10.7</td><td>61.4</td><td>0.364</td><td>27.9</td><td>57.5</td><td>0.349</td></tr><tr><td>KECG</td><td>47.8</td><td>83.5</td><td>0.598</td><td>49.0</td><td>84.4</td><td>0.610</td></tr><tr><td>BootEA</td><td>62.9</td><td>84.8</td><td>0.703</td><td>62.2</td><td>85.4</td><td>0.701</td></tr><tr><td>JAPE</td><td>41.2</td><td>74.5</td><td>0.490</td><td>36.3</td><td>68.5</td><td>0.476</td></tr><tr><td>MuGNN</td><td>49.4</td><td>84.4</td><td>0.611</td><td>50.1</td><td>85.7</td><td>0.621</td></tr><tr><td>GCN-Align</td><td>41.3</td><td>74.4</td><td>0.549</td><td>39.9</td><td>74.5</td><td>0.546</td></tr><tr><td>RDGCN</td><td>70.8</td><td>84.6</td><td>0.746</td><td>76.7</td><td>89.5</td><td>0.812</td></tr><tr><td>HGCN</td><td>72.0</td><td>85.7</td><td>0.768</td><td>76.6</td><td>89.7</td><td>0.813</td></tr><tr><td>CEA</td><td>78.7</td><td>-</td><td>-</td><td>86.3</td><td>-</td><td>-</td></tr><tr><td>BERT-INT</td><td>98.6</td><td>98.8</td><td>0.99</td><td>97.1</td><td>97.5</td><td>0.97</td></tr><tr><td>SDEA</td><td>96.8</td><td>98.9</td><td>0.98</td><td>96.6</td><td>98.6</td><td>0.97</td></tr><tr><td>Seg-Align</td><td>98.8</td><td>-</td><td>-</td><td>98.2</td><td>-</td><td>-</td></tr></table>
|
| 185 |
+
|
| 186 |
+
# 5.4 Experimental Results
|
| 187 |
+
|
| 188 |
+
# 5.4.1 Main Results
|
| 189 |
+
|
| 190 |
+
The experimental results of our proposed SegAlign compare to other methods on two crosslingual datasets DBP15K and SRPRS are shown in Table 3 and Table 4. In the primary comparative experiments, we set the number of candidates in the candidate set to 10. Observing the improvements over the original SLM (SDEA), our method demonstrate increases in Hits@1 metrics on the ZH-EN, JA-EN, FR-EN datasets by 9.5, 5.9, and 1.8, respectively. On the EN-DE and EN-FR datasets, Hits@1 metrics increase by 2.0 and 1.6, respectively. This underscores the effectiveness of our sample segmentation algorithm in selecting suitable samples for processing by LLMs, particularly in cases where SLMs struggled.
|
| 191 |
+
|
| 192 |
+
The latest models ChatEA and LLMEA both utilize LLMs, while ChatEA focuses on single-language entity alignment and similar-language cross-language tests but lacks publicly available code and data, limiting reproducibility. LLMEA is evaluated only on the DBP15K dataset and also
|
| 193 |
+
|
| 194 |
+
Table 4: Entity alignment results on SRPRS
|
| 195 |
+
|
| 196 |
+
<table><tr><td>Methods</td><td>ZH-EN H@1</td><td>JA-EN H@1</td><td>FR-EN H@1</td></tr><tr><td>LLMEA</td><td>89.8</td><td>91.1</td><td>95.7</td></tr><tr><td>Seg-Align</td><td>95.3</td><td>90.7</td><td>98.7</td></tr></table>
|
| 197 |
+
|
| 198 |
+
Table 5: Results of LLM-based Entity alignment Methods on DBP15K.
|
| 199 |
+
|
| 200 |
+
lacks open-source code.
|
| 201 |
+
|
| 202 |
+
In table 5, Seg-Align outperforms LLMEA on the ZH-EN and FR-EN language pairs in the DBP15K dataset, although its performance on JA-EN is slightly lower, Seg-Align's LLM processes far fewer entities. Compared to ChatEA, Seg-Align processes fewer tokens and has much faster processing times, achieving competitive performance with markedly improved efficiency. Overall, Seg-Align demonstrates superior performance and significant advantages in computational efficiency and scalability.
|
| 203 |
+
|
| 204 |
+
# 5.4.2 Ablation Results
|
| 205 |
+
|
| 206 |
+
We conduct ablation experiments to validate the effectiveness of different LLMs and the segmentation algorithm (Seg). As shown in table 6, we select GPT-3.5 and Llama3-8b-Instruct as the LLMs to verify the effectiveness of the segmentation algorithm (Seg) and the LLM. From the table, it is evident that the combination of GPT-3.5 and the segmentation algorithm yields the best performance. When using the segmentation algorithm, even though the LLM only processes a small portion of the data, it achieves **better results** than using the LLM to process all the data. Therefore, we not only significantly improve model efficiency but also reduce unnecessary computational overhead.
|
| 207 |
+
|
| 208 |
+
<table><tr><td>settings</td><td>ZH-EN H@1</td><td>JA-EN H@1</td><td>FR-EN H@1</td></tr><tr><td>Seg-Align (-w/ GPT-3.5, -W/ Seg)</td><td>95.3</td><td>90.7</td><td>98.7</td></tr><tr><td>-w/ Llama3-8b-Instruct, -w/ Seg</td><td>93.7</td><td>89.8</td><td>97.3</td></tr><tr><td>-w/ GPT-3.5, -w/o Seg</td><td>93.2</td><td>90.6</td><td>98.6</td></tr><tr><td>-w/ Llama3-8b-Instruct, -w/o Seg</td><td>83.9</td><td>83.9</td><td>81.0</td></tr><tr><td>-w/o LLM, -w/o Seg</td><td>87.0</td><td>84.8</td><td>96.9</td></tr></table>
|
| 209 |
+
|
| 210 |
+
Table 6: The ablation results with a candidate set size of 10 on DBP15K. 'w/o' means without and 'w' means with.
|
| 211 |
+
|
| 212 |
+
# 5.4.3 Sample Segmentation Results
|
| 213 |
+
|
| 214 |
+
Ranking-based evaluation metrics assume a 1-1 correspondence, making it impossible to evaluate cases where corresponding entities cannot be found. Therefore, to further validate the effectiveness of the segmentation algorithm, we follow Paris's (Leone et al., 2022) approach and proceed with a method validated and evaluated based on standard classification-based metrics, namely precision, recall, and F1-score, to evaluate the experimental performance of LLMs and SLMs on hard samples and simple samples.
|
| 215 |
+
|
| 216 |
+

|
| 217 |
+
Figure 4: Comparison of experimental results of LLMs and SLM on hard samples (left) and simple samples (right). Candidate set size: 10, X-axis represents different methods, Y-axis represents precision.
|
| 218 |
+
|
| 219 |
+

|
| 220 |
+
|
| 221 |
+
As shown in Figure 4, we compare the precision of different methods on hard samples and simple samples. From the experimental results, we observe that overall, GPT-3.5 outperforms Llama2-7B-Chat and Llama3-8B-Instruct. This can be attributed to GPT having a larger and more diverse training dataset, covering a wider range of languages, thus performing better in cross-lingual EA task. Additionally, despite selecting the lightest versions of Llama2 and Llama3, the performance of Llama3-8b-Instruct far exceeds that of Llama2-7B-Chat. This indicates a linear relationship between LLMs' performance in cross-lingual EA task and LLMs' own capabilities.
|
| 222 |
+
|
| 223 |
+
Comparing LLMs' and a SLM's performance on hard and simple samples allows us to demonstrate the effectiveness of our segmentation algorithm. First, analyzing the SLM's performance on
|
| 224 |
+
|
| 225 |
+

|
| 226 |
+
|
| 227 |
+

|
| 228 |
+
Figure 5: The impact of different candidate set sizes on GPT-3.5 (top) and Llama3-8b-Instruct (bottom). X-axis represents different candidate set sizes (5, 10, 20), Y-axis represents precision.
|
| 229 |
+
|
| 230 |
+

|
| 231 |
+
|
| 232 |
+

|
| 233 |
+
|
| 234 |
+
both hard and simple samples reveals that while the SLM achieves exceptionally high accuracy on simple samples (around $98 - 99\%$ ), its performance declines significantly on hard samples (around $40 - 50\%$ ). Second, LLMs demonstrate a notable advantage over the SLM on hard samples, yet their performance on simple samples is comparatively lower than that of the SLM. This further demonstrates that our segmentation algorithm effectively selects suitable data samples for LLM processing, and the combination of a LLM and a SLM yields better entity alignment results.
|
| 235 |
+
|
| 236 |
+
Additionally, to test the generalizability of the segmentation algorithm, we conduct experiments with another SLM, BERT-INT. In these experiments, we employ fine-tuned BERT embeddings for distance feature learning. The experimental results (which can be found in Table 15 in Appendix B) similarly demonstrate the effectiveness of our segmentation algorithm.
|
| 237 |
+
|
| 238 |
+
When comparing experimental results across different languages, we can observe that the performance gap between GPT-3.5 and Llama3-8b-Instruct in various languages is not significant. However, Llama2-7b-Chat performs notably poorly in Chinese. This is due to the limited amount of Chinese data in the Llama2 training dataset (Touvron et al., 2023). In contrast, Llama3-8b-Instruct shows a significant improvement. This demonstrates that as LLMs advance, their proficiency in handling cross-lingual EA task also improves.
|
| 239 |
+
|
| 240 |
+
The detailed results are summarized in Table 16 and Table 17 in Appendix C.
|
| 241 |
+
|
| 242 |
+
<table><tr><td>Models</td><td>ZH-EN</td><td>JA-EN</td><td>FR-EN</td><td>EN-DE</td><td>EN-FR</td></tr><tr><td>Llama2-7b-chat (hard)</td><td>0.77</td><td>0.76</td><td>0.62</td><td>0.73</td><td>0.75</td></tr><tr><td>Llama2-7b-chat (simple)</td><td>0.76</td><td>0.73</td><td>0.65</td><td>0.65</td><td>0.67</td></tr><tr><td>Llama3-8b-Instruct (hard)</td><td>0.24</td><td>0.25</td><td>0.22</td><td>0.24</td><td>0.25</td></tr><tr><td>Llama3-8b-Instruct (simple)</td><td>0.22</td><td>0.23</td><td>0.19</td><td>0.19</td><td>0.19</td></tr></table>
|
| 243 |
+
|
| 244 |
+
Table 7: The average time (seconds) it takes to process each entity. (Utilize Llama2-7b-chat and Llama3-8b-Instruct with 10 candidate entities.)
|
| 245 |
+
|
| 246 |
+
<table><tr><td>Models</td><td>ZH-EN</td><td>JA-EN</td><td>FR-EN</td><td>EN-DE</td><td>EN-FR</td></tr><tr><td>GPT-3.5</td><td>158</td><td>162</td><td>159</td><td>161</td><td>161</td></tr><tr><td>Llama2-7b-chat</td><td>186</td><td>191</td><td>185</td><td>185</td><td>185</td></tr><tr><td>Llama3-8b-Instruct</td><td>154</td><td>158</td><td>157</td><td>159</td><td>159</td></tr></table>
|
| 247 |
+
|
| 248 |
+
Table 8: The average tokens it takes to process each entity. (Utilize GPT-3.5, Llama2-7b-chat and Llama3-8b-Instruct with 10 candidate entities.)
|
| 249 |
+
|
| 250 |
+
# 5.4.4 The impact of candidate set size on results
|
| 251 |
+
|
| 252 |
+
To test the impact of candidate set size on LLMs' performance, we conduct experiments with GPT-3.5 and Llama-8b-Instruct using candidate set sizes of 5, 10, and 20. The results are also evaluated using standard classification-based metrics: precision, recall, and F1-score.
|
| 253 |
+
|
| 254 |
+
As illustrated in Figure 5, we compare the precision of GPT-3.5 and Llama-8b-Instruct across different candidate set sizes. For GPT-3.5, the highest precision for most datasets, whether for hard or simple samples, is achieved with a candidate set size of 10. We analyze this outcome and find that if the candidate set is too small, it likely does not contain the correct answer; if it is too large, it introduces more distractions for GPT, making it harder to select the correct answer. In contrast, for Llama3-8b-Instruct, precision generally decreases as the candidate set size increases, especially for simple samples. This indicates that Llama-8b-Instruct's reasoning ability is inferior to GPT-3.5, struggling to distinguish between entities as the candidate set grows.
|
| 255 |
+
|
| 256 |
+
From the experimental results, we can see that neither experimental cost nor effectiveness benefits from larger candidate sets. Thus, selecting an appropriate candidate set size is crucial. Detailed experimental results are provided in Table 18 and Table 19 of Appendix D.
|
| 257 |
+
|
| 258 |
+
# 5.4.5 Efficiency analysis
|
| 259 |
+
|
| 260 |
+
In addition to achieving good performance, we also measure the average time each LLM takes to process each entity. Since GPT-3.5 is accessed via an API and its source code is not available, we only
|
| 261 |
+
|
| 262 |
+
record the processing times for Llama-7b-Chat and Llama-8b-Instruct. These results are presented in Table 7.
|
| 263 |
+
|
| 264 |
+
From the timing statistics, it is clear that our model is highly efficient, with very short processing times for individual entities. Moreover, we observe that Llama3 not only improves performance compared to Llama2 but also significantly reduces processing time, with an average speedup of 3.5 times.
|
| 265 |
+
|
| 266 |
+
Most importantly, we find that the average processing time for simple samples is generally shorter than that for hard samples. This indicates that LLMs require more reasoning time for hard samples, further demonstrating the effectiveness of our segmentation algorithm.
|
| 267 |
+
|
| 268 |
+
Moreover, we count the token lengths of different LLMs on various datasets (candidate set size: 10). From table 8, it can be observed that the average token length in Seg-Align across different large language models (LLMs) ranges between 154 and 191. Seg-Align demonstrates exceptionally high efficiency in both average token length and average processing time.
|
| 269 |
+
|
| 270 |
+
Additionally, we measure the processing times for different candidate set sizes using Llama-8b-Instruct, with detailed results provided in Table 20 of Appendix E. We observe that as the candidate set grows, processing time increases linearly, ensuring efficiency with large-scale data.
|
| 271 |
+
|
| 272 |
+
# 6 Conclusion
|
| 273 |
+
|
| 274 |
+
In this paper, we focus on leveraging LLMs to improve the performance of cross-lingual entity alignment. To better apply LLMs to the EA task, our Seg-Align framework extends SLMs by introducing distance feature extraction, sample segmentation algorithm, and designing prompts tailored for the EA task. Through experiments on two widely-used cross-lingual datasets, we empirically show that our sample segmentation algorithm effectively identifies data for LLM or SLM processing, validating the framework's effectiveness.
|
| 275 |
+
|
| 276 |
+
# Limitations
|
| 277 |
+
|
| 278 |
+
Although we have demonstrated that Seg-Align enhances the performance of cross-lingual EA task and validated the effectiveness of our segmentation algorithm in identifying data suitable for processing by LLMs and SLMs, thereby laying the groundwork for the integration of LLMs and SLMs, there are still some limitations to our approach.
|
| 279 |
+
|
| 280 |
+
Firstly, LLMs are often treated as black boxes, especially when utilized through APIs for downstream tasks, limiting autonomous control over their outputs. Consequently, modifications to the internal architecture or algorithms of LLMs can significantly influence experimental outcomes and results.
|
| 281 |
+
|
| 282 |
+
Secondly, despite our efforts to constrain the output of LLMs, variations in the output formats persist. Detailed cases are provided in Appendix F Case study. These variations can influence the interpretation of the experimental results, thereby affecting the overall outcomes of the experiments.
|
| 283 |
+
|
| 284 |
+
Thirdly, in this study, to control costs and improve efficiency, our prompts are kept very short, relying solely on the background knowledge inherent in LLMs without fully utilizing its reasoning capabilities. In our future work, we plan to further decompose the EA task, leveraging the LLMs' reasoning abilities to derive the final answer step-by-step.
|
| 285 |
+
|
| 286 |
+
Finally, our framework relies on SLMs for candidate selection, which depends on the accuracy of SLMs. Therefore, in our future work, we will explore more accurate and independent methods for candidate selection.
|
| 287 |
+
|
| 288 |
+
# Acknowledgement
|
| 289 |
+
|
| 290 |
+
We thank anonymous reviewers for valuable and insightful feedback. This work is supported by the National Natural Science Foundation of China (62276057), and Sponsored by CAAI-MindSpore Open Fund, developed on OpenI Community.
|
| 291 |
+
|
| 292 |
+
# References
|
| 293 |
+
|
| 294 |
+
Ermei Cao, Difeng Wang, Jiacheng Huang, and Wei Hu. 2020. Open knowledge enrichment for long-tail entities. In Proceedings of The Web Conference 2020, pages 384-394.
|
| 295 |
+
Yixin Cao, Zhiyuan Liu, Chengjiang Li, Juanzi Li, and Tat-Seng Chua. 2019. Multi-channel graph neural network for entity alignment. In ACL, pages 1452-1461.
|
| 296 |
+
|
| 297 |
+
Bo Chen, Jing Zhang, Xiaobin Tang, Hong Chen, and Cuiping Li. 2020. Jarka: Modeling attribute interactions for cross-lingual knowledge alignment. In PAKDD, pages 845-856. Springer.
|
| 298 |
+
Muhao Chen, Yingtao Tian, Mohan Yang, and Carlo Zaniolo. 2017. Multilingual knowledge graph embeddings for cross-lingual knowledge alignment. In *IJCAI*, pages 1511–1517.
|
| 299 |
+
Per-Erik Danielsson. 1980. Euclidean distance mapping. Computer Graphics and image processing, 14(3):227-248.
|
| 300 |
+
Xin Dong, Evgeniy Gabrilovich, Geremy Heitz, Wilko Horn, Ni Lao, Kevin Murphy, Thomas Strohmann, Shaohua Sun, and Wei Zhang. 2014. Knowledge vault: A web-scale approach to probabilistic knowledge fusion. In Proceedings of the 20th ACM SIGKDD international conference on Knowledge discovery and data mining, pages 601-610.
|
| 301 |
+
Lingbing Guo, Zequn Sun, and Wei Hu. 2019. Learning to exploit long-term relational dependencies in knowledge graphs. In International conference on machine learning, pages 2505-2514. PMLR.
|
| 302 |
+
Marti A. Hearst, Susan T Dumais, Edgar Osuna, John Platt, and Bernhard Scholkopf. 1998. Support vector machines. IEEE Intelligent Systems and their applications, 13(4):18-28.
|
| 303 |
+
Xuhui Jiang, Yinghan Shen, Zhichao Shi, Chengjin Xu, Wei Li, Zixuan Li, Jian Guo, Huawei Shen, and Yuanzhuo Wang. 2024. Unlocking the power of large language models for entity alignment. arXiv preprint arXiv:2402.15048.
|
| 304 |
+
Nikhil Kandpal, Haikang Deng, Adam Roberts, Eric Wallace, and Colin Raffel. 2023. Large language models struggle to learn long-tail knowledge. In International Conference on Machine Learning, pages 15696-15707. PMLR.
|
| 305 |
+
Jacob Devlin Ming-Wei Chang Kenton and Lee Kristina Toutanova. 2019. Bert: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of NAACL-HLT, pages 4171-4186.
|
| 306 |
+
Thomas N Kipf and Max Welling. 2017. Semi-supervised classification with graph convolutional networks.
|
| 307 |
+
Saydulu Kolasani. 2023. Optimizing natural language processing, large language models (llms) for efficient customer service, and hyper-personalization to enable sustainable growth and revenue. Transactions on Latest Trends in Artificial Intelligence, 4(4).
|
| 308 |
+
Tom Kwiatkowski, Jennimaria Palomaki, Olivia Redfield, Michael Collins, Ankur Parikh, Chris Alberti, Danielle Epstein, Illia Polosukhin, Jacob Devlin, Kenton Lee, et al. 2019. Natural questions: a benchmark for question answering research. Transactions of the Association for Computational Linguistics, 7:453-466.
|
| 309 |
+
|
| 310 |
+
Manuel Leone, Stefano Huber, Akhil Arora, Alberto García-Durán, and Robert West. 2022. A critical re-evaluation of neural methods for entity alignment. Proceedings of the VLDB Endowment, 15(8):1712-1725.
|
| 311 |
+
Chengjiang Li, Yixin Cao, Lei Hou, Jiaxin Shi, Juanzi Li, and Tat-Seng Chua. 2019. Semi-supervised entity alignment via joint knowledge embedding model and cross-graph model. In EMNLP-IJCNLP, pages 2723-2732.
|
| 312 |
+
Yubo Ma, Yixin Cao, Yong Hong, and Aixin Sun. 2023. Large language model is not a good few-shot information extractor, but a good reranker for hard samples! In Findings of the Association for Computational Linguistics: EMNLP 2023, pages 10572-10601.
|
| 313 |
+
Xin Mao, Wenting Wang, Huimin Xu, Man Lan, and Yuanbin Wu. 2020. Mraea: an efficient and robust entity alignment approach for cross-lingual knowledge graph. In WSDM, pages 420-428.
|
| 314 |
+
Aditya Krishna Menon and Robert C Williamson. 2018. The cost of fairness in binary classification. In _Conference on Fairness, accountability and transparency_, pages 107-118. PMLR.
|
| 315 |
+
Jeff Pan, Simon Razniewski, Jan-Christoph Kalo, Sneha Singhania, Jiaoyan Chen, Stefan Dietze, Hajira Jabeen, Janna Omeliyanenko, Wen Zhang, Matteo Lissandrini, et al. 2023. Large language models and knowledge graphs: Opportunities and challenges. Transactions on Graph Data and Knowledge.
|
| 316 |
+
Shirui Pan, Linhao Luo, Yufei Wang, Chen Chen, Jiapu Wang, and Xindong Wu. 2024. Unifying large language models and knowledge graphs: A roadmap. IEEE Transactions on Knowledge and Data Engineering.
|
| 317 |
+
Franco Scarselli, Marco Gori, Ah Chung Tsoi, Markus Hagenbuchner, and Gabriele Monfardini. 2008. The graph neural network model. IEEE transactions on neural networks, 20(1):61-80.
|
| 318 |
+
Xiaofei Shi and Yanghua Xiao. 2019. Modeling multi-mapping relations for precise cross-lingual entity alignment. In EMNLP-IJCNLP, pages 813-822.
|
| 319 |
+
Zequn Sun, Wei Hu, and Chengkai Li. 2017. Cross-lingual entity alignment via joint attribute-preserving embedding. In ISWC, pages 628-644. Springer.
|
| 320 |
+
Zequn Sun, Wei Hu, Qingheng Zhang, and Yuzhong Qu. 2018. Bootstrapping entity alignment with knowledge graph embedding. In *IJCAI*, volume 18, pages 4396-4402.
|
| 321 |
+
Zequn Sun, Jiacheng Huang, Wei Hu, Muhao Chen, Lingbing Guo, and Yuzhong Qu. 2019. Transedge: Translating relation-contextualized embeddings for knowledge graphs. In International Semantic Web Conference, pages 612-629. Springer.
|
| 322 |
+
|
| 323 |
+
Zequn Sun, Chengming Wang, Wei Hu, Muhao Chen, Jian Dai, Wei Zhang, and Yuzhong Qu. 2020a. Knowledge graph alignment network with gated multi-hop neighborhood aggregation. In AAAI, volume 34, pages 222-229.
|
| 324 |
+
Zequn Sun, Qingheng Zhang, Wei Hu, Chengming Wang, Muhao Chen, Farahnaz Akrami, and Chengkai Li. 2020b. A benchmarking study of embedding-based entity alignment for knowledge graphs. VLDB, 13(11).
|
| 325 |
+
Xiaobin Tang, Jing Zhang, Bo Chen, Yang Yang, Hong Chen, and Cuiping Li. 2020. Bert-int: A bert-based interaction model for knowledge graph alignment. In *IJCAI*, pages 3174–3180.
|
| 326 |
+
Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Roziere, Naman Goyal, Eric Hambro, Faisal Azhar, et al. 2023. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971.
|
| 327 |
+
Zhichun Wang, Qingsong Lv, Xiaohan Lan, and Yu Zhang. 2018. Cross-lingual knowledge graph alignment via graph convolutional networks. In EMNLP, pages 349-357.
|
| 328 |
+
Zhichun Wang, Jinjian Yang, and Xiaoju Ye. 2020. Knowledge graph alignment with entity-pair embedding. In EMNLP, pages 1672-1680.
|
| 329 |
+
Y Wu, X Liu, Y Feng, Z Wang, R Yan, and D Zhao. 2019a. Relation-aware entity alignment for heterogeneous knowledge graphs. In *IJCAI*.
|
| 330 |
+
Yuting Wu, Xiao Liu, Yansong Feng, Zheng Wang, and Dongyan Zhao. 2019b. Jointly learning entity and relation representations for entity alignment. In EMNLP-IJCNLP, pages 240-249.
|
| 331 |
+
Yuting Wu, Xiao Liu, Yansong Feng, Zheng Wang, and Dongyan Zhao. 2020. Neighborhood matching network for entity alignment. In ACL, pages 6477-6487.
|
| 332 |
+
Zhihuan Yan, Rong Peng, Yaqian Wang, and Weidong Li. 2020. Ctea: Context and topic enhanced entity alignment for knowledge graphs. Neurocomputing, 410:419-431.
|
| 333 |
+
Hsiu-Wei Yang, Yanyan Zou, Peng Shi, Wei Lu, Jimmy Lin, and Xu Sun. 2019. Aligning cross-lingual entities with multi-aspect information. In EMNLP-IJCNLP, pages 4431-4441.
|
| 334 |
+
Linyao Yang, Hongyang Chen, Xiao Wang, Jing Yang, Fei-Yue Wang, and Han Liu. 2024. Two heads are better than one: Integrating knowledge from knowledge graphs and large language models for entity alignment. arXiv preprint arXiv:2401.16960.
|
| 335 |
+
Eva Zangerle and Christine Bauer. 2022. Evaluating recommender systems: survey and framework. ACM computing surveys, 55(8):1-38.
|
| 336 |
+
|
| 337 |
+
Weixin Zeng, Xiang Zhao, Jiuyang Tang, and Xuemin Lin. 2020. Collective entity alignment via adaptive features. In ICDE, pages 1870-1873. IEEE.
|
| 338 |
+
|
| 339 |
+
Ningyu Zhang, Qianghuai Jia, Shumin Deng, Xiang Chen, Hongbin Ye, Hui Chen, Huaixiao Tou, Gang Huang, Zhao Wang, Nengwei Hua, et al. 2021. Alicg: Fine-grained and evolvable conceptual graph construction for semantic search at alibaba. In Proceedings of the 27th ACM SIGKDD Conference on Knowledge Discovery & Data Mining, pages 3895-3905.
|
| 340 |
+
|
| 341 |
+
Ziyue Zhong, Meihui Zhang, Ju Fan, and Chenxiao Dou. 2022. Semantics driven embedding learning for effective entity alignment. In ICDE, pages 2127-2140. IEEE.
|
| 342 |
+
|
| 343 |
+
Renbo Zhu, Meng Ma, and Ping Wang. 2021a. Raga: Relation-aware graph attention networks for global entity alignment. In PAKDD (1), pages 501-513. Springer.
|
| 344 |
+
|
| 345 |
+
Yao Zhu, Hongzhi Liu, Zhonghai Wu, and Yingpeng Du. 2021b. Relation-aware neighborhood matching model for entity alignment. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pages 4749-4756.
|
| 346 |
+
|
| 347 |
+
# A Sample Segmentation with different candidate set size
|
| 348 |
+
|
| 349 |
+
During the distance feature extraction and sample segmentation stages, we conducted experiments with candidate set sizes of 5, 10, and 20. As shown in the Table 9, 10, 11, the differences in candidate set sizes result in variations in distance feature extraction, which in turn affects the selection of the SVM training set, leading to different sample segmentation outcomes.
|
| 350 |
+
|
| 351 |
+
# B Add structural information to prompt
|
| 352 |
+
|
| 353 |
+
To test the impact of incorporating the structural information of entities into the prompt on the experimental results, we conduct comparative experiments using Llama3-8b-Instruct on the hard samples in the DBP15K dataset.
|
| 354 |
+
|
| 355 |
+
# B.1 Prompt
|
| 356 |
+
|
| 357 |
+
To include the structural information of entities in the prompt, it is first necessary to convert the graph structure, consisting of the central entity and its neighbors, into a textual form. For each entity, we identify all its related triples and then concatenate these triples in the order of head entity, relation, and tail entity. This process yields the structural information of the entity. Due to the presence of numerous neighboring entities, the resulting structural
|
| 358 |
+
|
| 359 |
+
<table><tr><td>Datasets</td><td>Label</td><td>TN</td><td>P</td><td>R</td><td>SN</td></tr><tr><td colspan="6">DBP15K</td></tr><tr><td rowspan="2">ZH-EN</td><td>0</td><td>80</td><td>44</td><td>91</td><td>2579</td></tr><tr><td>1</td><td>200</td><td>99</td><td>84</td><td>7921</td></tr><tr><td rowspan="2">JA-EN</td><td>0</td><td>150</td><td>61</td><td>92</td><td>2881</td></tr><tr><td>1</td><td>800</td><td>98</td><td>87</td><td>7619</td></tr><tr><td rowspan="2">FR-EN</td><td>0</td><td>12</td><td>32</td><td>83</td><td>1047</td></tr><tr><td>1</td><td>300</td><td>99</td><td>93</td><td>9453</td></tr><tr><td colspan="6">SRPRS</td></tr><tr><td rowspan="2">EN-DE</td><td>0</td><td>11</td><td>49</td><td>80</td><td>387</td></tr><tr><td>1</td><td>620</td><td>100</td><td>98</td><td>10113</td></tr><tr><td rowspan="2">EN-FR</td><td>0</td><td>26</td><td>49</td><td>79</td><td>488</td></tr><tr><td>1</td><td>200</td><td>99</td><td>98</td><td>10012</td></tr></table>
|
| 360 |
+
|
| 361 |
+
Table 9: 5 candidate entities. "TN" represents the number of samples in the SVM training set, "P" represents precision, "R" represents recall, and "SN" represents the sample number on the test set.
|
| 362 |
+
|
| 363 |
+
<table><tr><td>Datasets</td><td>Label</td><td>TN</td><td>P</td><td>R</td><td>SN</td></tr><tr><td colspan="6">DBP15K</td></tr><tr><td rowspan="2">ZH-EN</td><td>0</td><td>80</td><td>45</td><td>91</td><td>2536</td></tr><tr><td>1</td><td>200</td><td>99</td><td>85</td><td>7964</td></tr><tr><td rowspan="2">JA-EN</td><td>0</td><td>150</td><td>60</td><td>92</td><td>2918</td></tr><tr><td>1</td><td>800</td><td>98</td><td>86</td><td>7582</td></tr><tr><td rowspan="2">FR-EN</td><td>0</td><td>12</td><td>32</td><td>85</td><td>1059</td></tr><tr><td>1</td><td>300</td><td>99</td><td>93</td><td>9441</td></tr><tr><td colspan="6">SRPRS</td></tr><tr><td rowspan="2">EN-DE</td><td>0</td><td>11</td><td>50</td><td>80</td><td>380</td></tr><tr><td>1</td><td>620</td><td>100</td><td>98</td><td>10120</td></tr><tr><td rowspan="2">EN-FR</td><td>0</td><td>26</td><td>50</td><td>79</td><td>484</td></tr><tr><td>1</td><td>200</td><td>99</td><td>98</td><td>10016</td></tr></table>
|
| 364 |
+
|
| 365 |
+
Table 10: 10 candidate entities. "TN" represents the number of samples in the SVM training set, "P" represents precision, "R" represents recall, and "SN" represents the sample number on the test set.
|
| 366 |
+
|
| 367 |
+
information text is typically very lengthy. Consequently, it is not feasible to include all ten candidate entities and their structural information in a single prompt. Therefore, after incorporating the structural information, it is necessary to compare the source entity with each candidate entity individually. The prompts used in the experiments are shown in Table 12 and 13.
|
| 368 |
+
|
| 369 |
+
# B.2 Results
|
| 370 |
+
|
| 371 |
+
As shown in Table 14, we not only test the performance of prompts with and without structural information but also record the processing time of Llama3-8b-Instruct. From the results, we can see that incorporating structural information into the prompts achieves $100\%$ accuracy, but the recall rate is very low. We analyze that this is because, with the addition of structural information, Llama becomes stricter in determining whether two entities are the same. It only considers entities as identical when their structural information is highly simi
|
| 372 |
+
|
| 373 |
+
<table><tr><td>Datasets</td><td>Label</td><td>TN</td><td>P</td><td>R</td><td>SN</td></tr><tr><td colspan="6">DBP15K</td></tr><tr><td rowspan="2">ZH-EN</td><td>0</td><td>80</td><td>45</td><td>91</td><td>2538</td></tr><tr><td>1</td><td>200</td><td>99</td><td>85</td><td>7962</td></tr><tr><td rowspan="2">JA-EN</td><td>0</td><td>150</td><td>59</td><td>93</td><td>2990</td></tr><tr><td>1</td><td>800</td><td>98</td><td>86</td><td>7510</td></tr><tr><td rowspan="2">FR-EN</td><td>0</td><td>12</td><td>41</td><td>62</td><td>617</td></tr><tr><td>1</td><td>300</td><td>98</td><td>96</td><td>9883</td></tr><tr><td colspan="6">SRPRS</td></tr><tr><td rowspan="2">EN-DE</td><td>0</td><td>11</td><td>47</td><td>81</td><td>409</td></tr><tr><td>1</td><td>620</td><td>100</td><td>98</td><td>10091</td></tr><tr><td rowspan="2">EN-FR</td><td>0</td><td>26</td><td>41</td><td>81</td><td>603</td></tr><tr><td>1</td><td>200</td><td>99</td><td>97</td><td>9897</td></tr></table>
|
| 374 |
+
|
| 375 |
+
Table 11: 20 candidate entities. "TN" represents the number of samples in the SVM training set, "P" represents precision, "R" represents recall, and "SN" represents the sample number on the test set.
|
| 376 |
+
|
| 377 |
+
lar. Therefore, for more heterogeneous entity pairs (with different neighboring entities), Llama is less likely to identify them as the same entity. In contrast, when structural information is not included, the accuracy is slightly lower, but the recall rate improves significantly. This indicates that without structural information, Llama faces fewer distractions when handling heterogeneous entity pairs, and its inherent background knowledge can better address the task, as the examples in Table 12 and Table 13.
|
| 378 |
+
|
| 379 |
+
Additionally, we observe that adding structural information significantly increases Llama's processing time. When only processing entity names, the processing times for different languages are the same. However, once structural information is added, the processing time correlates with the number of triples in the dataset (the number of triples for different datasets is shown in Table 2). The more triples there are, the longer the processing time. Finally, comparing Table 14 and Table 16, 20 allows us to evaluate the performance and efficiency of different prompts. When comparing the source entity with each candidate entity individually, the accuracy is high, but the recall is low, and the processing time is extended. Therefore, from both performance and efficiency perspectives, having Llama select the answer from a set of candidate entities is more suitable for the entity alignment task.
|
| 380 |
+
|
| 381 |
+
# C Sample Segmentation Results
|
| 382 |
+
|
| 383 |
+
Table 16 and Table 17 present detailed experimental results of LLMs and SLM (SDEA) on hard and simple samples of DBP15K and SRPRS datasets, respectively. Table 15 present the sample segmen
|
| 384 |
+
|
| 385 |
+
tation results with another SLM (BERT-INT).
|
| 386 |
+
|
| 387 |
+
# D Different candidate set size
|
| 388 |
+
|
| 389 |
+
Table 18 and Table 19 present the experimental results on the DBP15K and SRPRS datasets, respectively, using standard classification-based metrics: precision, recall, and F1-score.
|
| 390 |
+
|
| 391 |
+
# E Efficiency of different candidate set size
|
| 392 |
+
|
| 393 |
+
Based on Llama3-8b-Instruct, we measure the processing times for different candidate set sizes. As shown in Table 20, and as mentioned in Section 5.4.5, the processing time for most hard samples is significantly shorter than for simple samples. This indicates that hard samples require more reasoning time for LLMs, further proving that our segmentation algorithm effectively extracts more challenging entity alignment data. Additionally, we observe that as the candidate set size increases, the processing time does not grow exponentially, ensuring the efficiency of handling large-scale data.
|
| 394 |
+
|
| 395 |
+
# F Case study
|
| 396 |
+
|
| 397 |
+
In the process of interacting with LLMs, most of the responses are given in the multiple-choice format specified by the prompt. However, there were still some variations in the output. These variations can be categorized into three main types: (1) The output did not follow the specified format and provided an answer without any option. As shown in Table 21. (2) The candidate set do not contain the correct answer. As shown in Table 22. (3) The entity included sensitive terms from LLMs. As shown in Table 23.
|
| 398 |
+
|
| 399 |
+
<table><tr><td>Entity Alignment Prompt</td></tr><tr><td>"role": "system", "content": "Answer me 'Yes' or 'No'."</td></tr><tr><td>"role": "user", "content": "This is source entity: The Heat (album de Toni Braxton), and it's neibours: ['The Heat (album de Toni Braxton) genre RnB contemporain', 'The Heat (album de Toni Braxton) writer Jazze Pha', 'The Heat (album de Toni Braxton) writer Diane Warren', 'The Heat (album de Toni Braxton) writer Kenneth Edmonds', 'The Heat (album de Toni Braxton) writer Toni Braxton', 'The Heat (album de Toni Braxton) extra Jazze Pha', 'The Heat (album de Toni Braxton) label LaFace Records', 'The Heat (album de Toni Braxton) album Précédent Secrets (album de Toni Braxton)', 'The Heat (album de Toni Braxton) extra Kenneth Edmonds', 'The Heat (album de Toni Braxton) album Suivant Snowflakes', 'The Heat (album de Toni Braxton) extra Rodney Jerkins', 'The Heat (album de Toni Braxton) artiste Toni Braxton', 'Secrets (album de Toni Braxton) album Suivant The Heat (album de Toni Braxton)', 'Snowflakes album Précédent The Heat (album de Toni Braxton)']. And this is the target entity: The Heat (Toni Braxton album), and it's neibours: ['The Heat (Toni Braxton album) artist Toni Braxton', 'The Heat (Toni Braxton album) label LaFace Records', 'The Heat (Toni Braxton album) writer Diane Warren']. Are the two entities the same entity?"</td></tr><tr><td>Output: No.</td></tr></table>
|
| 400 |
+
|
| 401 |
+
Table 12: Prompt for entity alignment with structural information and the output. The example is from dataset DBP15K ${}_{FR - {EN}}$ .
|
| 402 |
+
|
| 403 |
+
<table><tr><td>Entity Alignment Prompt</td></tr><tr><td>"role": "system", "content": "Answer me 'Yes' or 'No'."</td></tr><tr><td>"role": "user", "content": "This is source entity: The_Heat_(album_de_Toni_Braxton).And this is the target entity: The_Heat_(Toni_Braxton_album). Are the two entities the same entity?"</td></tr><tr><td>Output: Yes.</td></tr></table>
|
| 404 |
+
|
| 405 |
+
Table 13: Prompt for entity alignment without structural information and the output. The example is from dataset DBP15K ${}_{FR - {EN}}$ .
|
| 406 |
+
|
| 407 |
+
<table><tr><td rowspan="2">Methods</td><td colspan="4">ZH-EN</td><td colspan="4">JA-EN</td><td colspan="4">FR-EN</td></tr><tr><td>P</td><td>R</td><td>F1</td><td>T</td><td>P</td><td>R</td><td>F1</td><td>T</td><td>P</td><td>R</td><td>F1</td><td>T</td></tr><tr><td>-w/ Structure</td><td>100</td><td>45.78</td><td>62.81</td><td>0.90</td><td>100</td><td>40.01</td><td>57.24</td><td>0.96</td><td>100</td><td>22.66</td><td>36.95</td><td>1.06</td></tr><tr><td>-w/o Structure</td><td>99.57</td><td>73.50</td><td>84.57</td><td>0.48</td><td>99.67</td><td>62.37</td><td>76.73</td><td>0.48</td><td>100</td><td>78.19</td><td>87.76</td><td>0.48</td></tr></table>
|
| 408 |
+
|
| 409 |
+
Table 14: The experimental results of Llama3-8b-Instruct on hard samples in the DBP15K dataset (candidate set size: 10). P: precision, R: recall, $F_{1}$ : F1-score, T: time. (The average time (seconds) it takes to process each entity.)
|
| 410 |
+
|
| 411 |
+
<table><tr><td rowspan="2">Methods</td><td colspan="3">ZH-EN</td><td colspan="3">JA-EN</td><td colspan="3">FR-EN</td></tr><tr><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td></tr><tr><td>Llama3-8b-Instruct(hard)</td><td>63.48</td><td>63.07</td><td>63.27</td><td>73.68</td><td>73.51</td><td>73.60</td><td>73.37</td><td>73.31</td><td>73.34</td></tr><tr><td>SLM(hard)</td><td>55.76</td><td>55.76</td><td>55.76</td><td>64.40</td><td>64.40</td><td>64.40</td><td>68.89</td><td>68.89</td><td>68.89</td></tr><tr><td>Llama3-8b-Instruct(simple)</td><td>71.35</td><td>71.30</td><td>71.32</td><td>75.04</td><td>74.95</td><td>75.00</td><td>68.08</td><td>68.07</td><td>68.07</td></tr><tr><td>SLM(simple)</td><td>97.74</td><td>97.74</td><td>97.74</td><td>98.75</td><td>98.75</td><td>98.75</td><td>99.57</td><td>99.57</td><td>99.57</td></tr></table>
|
| 412 |
+
|
| 413 |
+
Table 15: The experimental results of LLM and SLM (BERT-INT) on hard samples and simple samples in the DBP15K dataset (candidate set size: 10). P: precision, R: recall, $F_{1}$ : F1-score.
|
| 414 |
+
|
| 415 |
+
<table><tr><td rowspan="2">Methods</td><td colspan="3">ZH-EN</td><td colspan="3">JA-EN</td><td colspan="3">FR-EN</td></tr><tr><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td></tr><tr><td>GPT-3.5(hard)</td><td>85.97</td><td>85.29</td><td>85.63</td><td>72.60</td><td>72.1</td><td>72.35</td><td>93.3</td><td>93.3</td><td>93.3</td></tr><tr><td>Llama2-7b-chat(hard)</td><td>51.21</td><td>50.91</td><td>50.06</td><td>52.48</td><td>52.12</td><td>52.30</td><td>77.58</td><td>75.83</td><td>76.70</td></tr><tr><td>Llama3-8b-Instruct(hard)</td><td>79.98</td><td>78.75</td><td>79.36</td><td>71.22</td><td>68.68</td><td>69.92</td><td>79.43</td><td>79.13</td><td>79.28</td></tr><tr><td>SLM(hard)</td><td>55.13</td><td>55.13</td><td>55.13</td><td>40.06</td><td>40.06</td><td>40.06</td><td>67.52</td><td>67.52</td><td>67.52</td></tr><tr><td>GPT-3.5(simple)</td><td>98.05</td><td>98.00</td><td>98.03</td><td>98.76</td><td>98.71</td><td>98.73</td><td>99.25</td><td>99.25</td><td>99.25</td></tr><tr><td>Llama2-7b-chat(simple)</td><td>44.23</td><td>43.90</td><td>44.06</td><td>61.87</td><td>61.74</td><td>61.80</td><td>77.35</td><td>76.69</td><td>77.02</td></tr><tr><td>Llama3-8b-Instruct(simple)</td><td>85.64</td><td>85.50</td><td>85.57</td><td>89.94</td><td>89.78</td><td>89.80</td><td>81.28</td><td>81.25</td><td>81.26</td></tr><tr><td>SLM(simple)</td><td>98.51</td><td>98.51</td><td>98.51</td><td>97.92</td><td>97.92</td><td>97.92</td><td>99.34</td><td>99.34</td><td>99.34</td></tr></table>
|
| 416 |
+
|
| 417 |
+
Table 16: The experimental results of LLMs and SLM (SDEA) on hard samples and simple samples in the DBP15K dataset (candidate set size: 10). P: precision, R: recall, $F_{1}$ : F1-score.
|
| 418 |
+
|
| 419 |
+
<table><tr><td rowspan="2">Methods</td><td colspan="3">EN-DE</td><td colspan="3">EN-FR</td></tr><tr><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td></tr><tr><td>GPT-3.5(hard)</td><td>80.53</td><td>80.53</td><td>80.53</td><td>79.09</td><td>78.93</td><td>79.01</td></tr><tr><td>Llama2-7b-chat(hard)</td><td>61.73</td><td>60.26</td><td>60.99</td><td>65.20</td><td>64.26</td><td>64.72</td></tr><tr><td>Llama3-8b-Instruct(hard)</td><td>71.54</td><td>69.47</td><td>70.49</td><td>67.65</td><td>66.12</td><td>66.88</td></tr><tr><td>SLM(hard)</td><td>50.26</td><td>50.26</td><td>50.26</td><td>48.14</td><td>48.14</td><td>48.14</td></tr><tr><td>GPT-3.5(simple)</td><td>98.40</td><td>98.40</td><td>98.40</td><td>98.59</td><td>98.59</td><td>98.59</td></tr><tr><td>Llama2-7b-chat(simple)</td><td>63.28</td><td>62.97</td><td>63.13</td><td>70.24</td><td>69.88</td><td>70.06</td></tr><tr><td>Llama3-8b-Instruct(simple)</td><td>83.87</td><td>83.38</td><td>83.62</td><td>78.42</td><td>78.31</td><td>78.37</td></tr><tr><td>SLM(simple)</td><td>99.53</td><td>99.53</td><td>99.53</td><td>99.44</td><td>99.44</td><td>99.44</td></tr></table>
|
| 420 |
+
|
| 421 |
+
Table 17: The experimental results of LLMs and SLM (SDEA) on hard samples and simple samples in the SRPRS dataset (candidate set size: 10). P: precision, R: recall, $F_{1}$ : F1-score.
|
| 422 |
+
|
| 423 |
+
<table><tr><td rowspan="2">Candidate set size</td><td rowspan="2">Methods</td><td colspan="3">ZH-EN</td><td colspan="3">JA-EN</td><td colspan="3">FR-EN</td></tr><tr><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td></tr><tr><td rowspan="6">5</td><td>GPT-3.5(hard)</td><td>80.32</td><td>80.22</td><td>80.27</td><td>64.32</td><td>64.32</td><td>64.32</td><td>90.74</td><td>90.74</td><td>90.74</td></tr><tr><td>Llama3-8b-Instruct(hard)</td><td>79.96</td><td>78.60</td><td>79.27</td><td>66.22</td><td>63.76</td><td>64.97</td><td>86.11</td><td>85.29</td><td>85.70</td></tr><tr><td>SLM(hard)</td><td>55.60</td><td>55.60</td><td>55.60</td><td>39.43</td><td>39.43</td><td>39.43</td><td>67.62</td><td>67.62</td><td>67.62</td></tr><tr><td>GPT-3.5(simple)</td><td>97.46</td><td>97.46</td><td>97.46</td><td>98.50</td><td>98.50</td><td>98.50</td><td>85.82</td><td>85.82</td><td>85.82</td></tr><tr><td>Llama3-8b-Instruct(simple)</td><td>94.48</td><td>94.41</td><td>94.44</td><td>96.50</td><td>96.36</td><td>96.43</td><td>92.19</td><td>92.17</td><td>92.18</td></tr><tr><td>SLM(simple)</td><td>98.59</td><td>98.59</td><td>98.59</td><td>97.87</td><td>97.87</td><td>97.87</td><td>99.29</td><td>99.29</td><td>99.29</td></tr><tr><td rowspan="6">10</td><td>GPT-3.5(hard)</td><td>85.97</td><td>85.29</td><td>85.63</td><td>72.60</td><td>72.1</td><td>72.35</td><td>93.3</td><td>93.3</td><td>93.3</td></tr><tr><td>Llama3-8b-Instruct(hard)</td><td>79.98</td><td>78.75</td><td>79.36</td><td>71.22</td><td>68.68</td><td>69.92</td><td>79.43</td><td>79.13</td><td>79.28</td></tr><tr><td>SLM(hard)</td><td>55.13</td><td>55.13</td><td>55.13</td><td>40.06</td><td>40.06</td><td>40.06</td><td>67.52</td><td>67.52</td><td>67.52</td></tr><tr><td>GPT-3.5(simple)</td><td>98.05</td><td>98.00</td><td>98.03</td><td>98.76</td><td>98.71</td><td>98.73</td><td>99.25</td><td>99.25</td><td>99.25</td></tr><tr><td>Llama3-8b-Instruct(simple)</td><td>85.64</td><td>85.50</td><td>85.57</td><td>89.94</td><td>89.78</td><td>89.80</td><td>81.28</td><td>81.25</td><td>81.26</td></tr><tr><td>SLM(simple)</td><td>98.51</td><td>98.51</td><td>98.51</td><td>97.92</td><td>97.92</td><td>97.92</td><td>99.34</td><td>99.34</td><td>99.34</td></tr><tr><td rowspan="6">20</td><td>GPT-3.5(hard)</td><td>87.95</td><td>87.16</td><td>87.55</td><td>79.09</td><td>77.79</td><td>78.44</td><td>89.76</td><td>89.47</td><td>89.61</td></tr><tr><td>Llama3-8b-Instruct(hard)</td><td>72.50</td><td>72.42</td><td>72.46</td><td>68.05</td><td>68.03</td><td>68.04</td><td>65.91</td><td>65.80</td><td>65.86</td></tr><tr><td>SLM(hard)</td><td>54.93</td><td>54.93</td><td>54.93</td><td>40.84</td><td>40.84</td><td>40.84</td><td>59.32</td><td>59.32</td><td>59.32</td></tr><tr><td>GPT-3.5(simple)</td><td>97.80</td><td>97.59</td><td>97.69</td><td>98.67</td><td>98.54</td><td>98.60</td><td>98.57</td><td>98.54</td><td>98.56</td></tr><tr><td>Llama3-8b-Instruct(simple)</td><td>68.74</td><td>68.69</td><td>68.71</td><td>74.76</td><td>74.73</td><td>74.74</td><td>63.73</td><td>63.71</td><td>63.72</td></tr><tr><td>SLM(simple)</td><td>98.58</td><td>98.58</td><td>98.58</td><td>98.16</td><td>98.16</td><td>98.16</td><td>98.43</td><td>98.43</td><td>98.43</td></tr></table>
|
| 424 |
+
|
| 425 |
+
Table 18: The experimental results of LLM and SLM (SDEA) on hard samples and simple samples in the DBP15K dataset. P: precision, R: recall, $F_{1}$ : F1-score.
|
| 426 |
+
|
| 427 |
+
<table><tr><td rowspan="2">Candidate set size</td><td rowspan="2">Methods</td><td colspan="3">EN-DE</td><td colspan="3">EN-FR</td></tr><tr><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td></tr><tr><td rowspan="6">5</td><td>GPT-3.5(hard)</td><td>60.72</td><td>60.72</td><td>60.72</td><td>62.09</td><td>62.09</td><td>62.09</td></tr><tr><td>Llama3-8b-Instruct(hard)</td><td>77.19</td><td>75.19</td><td>76.18</td><td>70.82</td><td>68.65</td><td>69.72</td></tr><tr><td>SLM(hard)</td><td>50.90</td><td>50.90</td><td>50.90</td><td>50.61</td><td>50.61</td><td>50.61</td></tr><tr><td>GPT-3.5(simple)</td><td>74.42</td><td>74.42</td><td>74.42</td><td>79.33</td><td>79.33</td><td>79.33</td></tr><tr><td>Llama3-8b-Instruct(simple)</td><td>92.98</td><td>92.64</td><td>92.81</td><td>88.84</td><td>88.75</td><td>88.80</td></tr><tr><td>SLM(simple)</td><td>99.53</td><td>99.53</td><td>99.53</td><td>99.34</td><td>99.34</td><td>99.34</td></tr><tr><td rowspan="6">10</td><td>GPT-3.5(hard)</td><td>80.53</td><td>80.53</td><td>80.53</td><td>79.09</td><td>78.93</td><td>79.01</td></tr><tr><td>Llama3-8b-Instruct(hard)</td><td>71.54</td><td>69.47</td><td>70.49</td><td>67.65</td><td>66.12</td><td>66.88</td></tr><tr><td>SLM(hard)</td><td>50.26</td><td>50.26</td><td>50.26</td><td>48.14</td><td>48.14</td><td>48.14</td></tr><tr><td>GPT-3.5(simple)</td><td>98.40</td><td>98.40</td><td>98.40</td><td>98.59</td><td>98.59</td><td>98.59</td></tr><tr><td>Llama3-8b-Instruct(simple)</td><td>83.87</td><td>83.38</td><td>83.62</td><td>78.42</td><td>78.31</td><td>78.37</td></tr><tr><td>SLM(simple)</td><td>99.53</td><td>99.53</td><td>99.53</td><td>99.44</td><td>99.44</td><td>99.44</td></tr><tr><td rowspan="6">20</td><td>GPT-3.5(hard)</td><td>67.57</td><td>67.24</td><td>67.40</td><td>73.42</td><td>73.30</td><td>73.36</td></tr><tr><td>Llama3-8b-Instruct(hard)</td><td>66.50</td><td>66.50</td><td>66.50</td><td>65.34</td><td>65.34</td><td>65.34</td></tr><tr><td>SLM(hard)</td><td>53.30</td><td>53.30</td><td>53.30</td><td>58.54</td><td>58.54</td><td>58.54</td></tr><tr><td>GPT-3.5(simple)</td><td>71.87</td><td>71.83</td><td>71.85</td><td>80.49</td><td>80.40</td><td>80.44</td></tr><tr><td>Llama3-8b-Instruct(simple)</td><td>69.46</td><td>69.39</td><td>69.43</td><td>63.63</td><td>63.60</td><td>63.61</td></tr><tr><td>SLM(simple)</td><td>99.54</td><td>99.54</td><td>99.54</td><td>99.42</td><td>99.42</td><td>99.42</td></tr></table>
|
| 428 |
+
|
| 429 |
+
Table 19: The experimental results of LLM and SLM (SDEA) on hard samples and simple samples in the SRPRS dataset. P: precision, R: recall, $F_{1}$ : F1-score.
|
| 430 |
+
|
| 431 |
+
<table><tr><td>Candidate set size</td><td>Models</td><td>ZH-EN</td><td>JA-EN</td><td>FR-EN</td><td>EN-DE</td><td>EN-FR</td></tr><tr><td rowspan="2">5</td><td>Llama3-8b-Instruct(hard)</td><td>0.23</td><td>0.24</td><td>0.20</td><td>0.21</td><td>0.22</td></tr><tr><td>Llama3-8b-Instruct(simple)</td><td>0.21</td><td>0.21</td><td>0.16</td><td>0.15</td><td>0.15</td></tr><tr><td rowspan="2">10</td><td>Llama3-8b-Instruct(hard)</td><td>0.24</td><td>0.25</td><td>0.22</td><td>0.24</td><td>0.25</td></tr><tr><td>Llama3-8b-Instruct(simple)</td><td>0.22</td><td>0.23</td><td>0.19</td><td>0.19</td><td>0.19</td></tr><tr><td rowspan="2">20</td><td>Llama3-8b-Instruct(hard)</td><td>0.29</td><td>0.29</td><td>0.29</td><td>0.28</td><td>0.28</td></tr><tr><td>Llama3-8b-Instruct(simple)</td><td>0.28</td><td>0.30</td><td>0.25</td><td>0.23</td><td>0.24</td></tr></table>
|
| 432 |
+
|
| 433 |
+
Table 20: The average time (seconds) it takes to process each entity.
|
| 434 |
+
|
| 435 |
+
# Output of LLM.
|
| 436 |
+
|
| 437 |
+
The option is: Écully. The option is: D_Never_Let_Me_Down_Again
|
| 438 |
+
|
| 439 |
+
The option is: DIC (Diffusion, Information, Communication)
|
| 440 |
+
|
| 441 |
+
Table 21: Case1: The output did not follow the specified format and provided an answer without the options.
|
| 442 |
+
|
| 443 |
+
# Output of LLM.
|
| 444 |
+
|
| 445 |
+
I apologize, but I cannot provide an answer to your question as the entity "Tom Ford (chanson)" does not exist in any of the options provided. "Tom Ford" is a well-known fashion designer, but there is no information available about him creating a song or being a political figure. Therefore, the option that is most similar to "Tom Ford (chanson)" is "Fiction Records" since it is a record label that does not exist.
|
| 446 |
+
|
| 447 |
+
Table 22: Case2: The candidate set do not contain the correct answer.
|
| 448 |
+
|
| 449 |
+
# Output of LLM.
|
| 450 |
+
|
| 451 |
+
I apologize, but I cannot provide answers to questions that promote or glorify harmful or offensive content, including rape. The option "Rape Me" is not a valid or appropriate choice, and I cannot provide information that may be harmful or offensive to any individual or group.','It is important to recognize that rape is a serious crime that can cause significant harm to victims, and it is never acceptable or justifiable. It is essential to always prioritize respect, consent, and the well-being of all individuals involved in any sexual activity.','If you have any other questions or concerns, please feel free to ask.
|
| 452 |
+
|
| 453 |
+
Table 23: Case3: The entity included sensitive terms from the LLM.
|
advancingcrosslingualentityalignmentwithlargelanguagemodelstailoredsamplesegmentationandzeroshotprompts/images.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4d0f690f1e713ab3dfe71f4da60e54e34d623af6e09b7377fae55c08bb77c637
|
| 3 |
+
size 1178097
|
advancingcrosslingualentityalignmentwithlargelanguagemodelstailoredsamplesegmentationandzeroshotprompts/layout.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:87ed3fc8153f8a3e5ecc2b8284b591e5178ecb4943f6088b9c372587a11b828d
|
| 3 |
+
size 478835
|
advancingvisionlanguagemodelswithadapterensemblestrategies/49626621-2725-4d15-81d2-2840f458f976_content_list.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d6f0a4135bb4601ea9a2ce308080b4422a9bbb7ecd0a366a0f2131d92f847829
|
| 3 |
+
size 122898
|
advancingvisionlanguagemodelswithadapterensemblestrategies/49626621-2725-4d15-81d2-2840f458f976_model.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:929e88bc516bcc699c933c769dd56bd7441e90d58ef91dbe0acd39f392e50781
|
| 3 |
+
size 167001
|
advancingvisionlanguagemodelswithadapterensemblestrategies/49626621-2725-4d15-81d2-2840f458f976_origin.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:be4094ad3e4ca4cb34cc25ce2aa40213f8503748ef88f56c62278b99aef666b7
|
| 3 |
+
size 13192261
|
advancingvisionlanguagemodelswithadapterensemblestrategies/full.md
ADDED
|
@@ -0,0 +1,628 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Advancing Vision-Language Models with Adapter Ensemble Strategies
|
| 2 |
+
|
| 3 |
+
Yue Bai $^{1,2*}$ , Handong Zhao $^{2}$ , Zhe Lin $^{2}$ , Ajinkya Kale $^{2}$ , Jiumiang Gu $^{2}$ , Tong Yu $^{2}$ , Sungchul Kim $^{2}$ , Yun Fu $^{1}$ ,
|
| 4 |
+
|
| 5 |
+
1Northeastern University, 2Adobe
|
| 6 |
+
|
| 7 |
+
# Abstract
|
| 8 |
+
|
| 9 |
+
CLIP (Radford et al., 2021) revolves vision-language pretraining by using contrastive learning on paired web data. However, the sheer size of these pretrained models makes full-model finetuning exceedingly costly. One common solution is the "adapter", which finetunes a few additional parameters while freezing the backbone. It harnesses the heavy-duty backbone while offering a light finetuning for small downstream tasks. This synergy prompts us to explore the potential of augmenting large-scale backbones with traditional machine learning techniques. Often employed in traditional fields and overlooked in the large-scale era, these techniques could provide valuable enhancements. Herein, we delve into the "adapter ensembles" in the realm of pretrained large-scale vision-language models. We begin with a proof-of-concept study to establish the efficacy of combining multiple adapters. We then present extensive evidence showing these ensembles excel in a variety of settings, particularly when employing a Multi-Scale Attention (MSA) approach thoughtfully integrated into the ensemble framework. We further incorporate the LoRA to mitigate the additional parameter burden. We focus on vision-language retrieval, using different backbones under constraints of minimal data, parameters, and finetuning budgets. This research paves the way for a synergistic blend of traditional, yet effective, strategies with modern large-scale networks.
|
| 10 |
+
|
| 11 |
+
# 1 Introduction
|
| 12 |
+
|
| 13 |
+
Large-scale pretraining leverages massive data, robust architectures with strategic training to push performance boundaries (Devlin et al., 2018; Radford et al., 2018; Li et al., 2022; Radford et al., 2021). Such pretraining strategy notably advances vision-language capabilities, pioneered by
|
| 14 |
+
|
| 15 |
+

|
| 16 |
+
(a) Attn ensemble ablation.
|
| 17 |
+
Figure 1: CLIP ViT-B/16 ensemble ablation on self-attention and feedforward (Sec. 2). Y-axis/x-axis are the retrieval accuracy and the unit amount of learnable parameters in each layer. Baselines (On-Top, RB, MLP) and our Ens are finetuned/evaluated on YFCC. Sharing the same amount of learnable parameters, ensemble outperforms baselines and derives improvement when the number of ensemble parameters increases.
|
| 18 |
+
|
| 19 |
+

|
| 20 |
+
(b) FFN ensemble ablation.
|
| 21 |
+
|
| 22 |
+
CLIP (Radford et al., 2021), using contrastive learning on a massive image-text corpus, seamlessly integrates visual and linguistic modalities.
|
| 23 |
+
|
| 24 |
+
Various studies further advance vision-language pretraining by integrating auxiliary supervision (e.g., self-supervision/captioning loss) or extra information (e.g., tags/bounding boxes) (Ramesh et al., 2022; Sahara et al., 2022; Tewel et al., 2022; Chen et al., 2022a; Mokady et al., 2021; Jia et al., 2021; Mu et al., 2022). However, the necessity for extensive datasets and complex training pipelines for pretraining remain a challenge, particularly affecting finetuning efficiency. Adapter (Houlsby et al., 2019) is a favored technique for efficient finetuning, initially for language models such as BERT (Devlin et al., 2018) and recently adapted for the visual domain (Chen et al., 2022b; Gao et al., 2021). Along with its variants such as LoRA (Hu et al., 2021) and Compactor (Karimi Mahabadi et al., 2021), adapter offers the solution by updating a few additional parameters with limited data while fixing the pretrained backbone. These approaches
|
| 25 |
+
|
| 26 |
+
combine large-scale pretraining with small-sized efficient adapters, proposing a unified modeling pipeline. This fusion compels us to consider if we can borrow certain traditional machine learning techniques, which work well on previous small-sized scenarios but are easily ignored in the current large-scale era, to benefit the popular pretrained models. Informed by this, our study delves the classic ensemble on adapter for large-scale vision-language pretrained models and assesses its impact on cross-modal retrieval.
|
| 27 |
+
|
| 28 |
+
Ensemble has long been a cornerstone in traditional machine learning field (Dong et al., 2020; Sagi and Rokach, 2018; Zhao et al., 2017; Tao et al., 2019), combining diverse base learners to harness collective intelligence, thereby enhancing model performance and robustness (Dietterich, 2000; Sagi and Rokach, 2018; Rokach, 2010). In past decades, early methods provided weak yet cheap base learners using limited data, the ensemble compensated by pooling their strengths. Recently neural networks, with more data and complex models, present base learners of greater individual capability. Yet, the ensemble continues to offer performance boosts (Li et al., 2019; Lee et al., 2018), albeit at a cost, given the non-negligible resources to entirely train each deep network as a base learner. Nowadays, the focus shifts towards leveraging single, robustly pretrained models, leaving ensembles less tapped for these larger models due to their prohibitive computational demands. However, our curiosity lies in applying ensemble to efficiently finetune large-scale pretrained models using adapters, which act as a nexus for integrating large-scale backbone and small-sized techniques.
|
| 29 |
+
|
| 30 |
+
This study marks the initial exploration into the use of the adapter-based ensembles in large-scale pretrained models. We infuse the pretrained model with parallel learnable parameters in an ensemble fashion while fixing original weights. Our proof-of-concept study (Sec. 2) shows substantial performance gain of ensemble over baselines (Fig. 1). We further extensively validate its effectiveness with a well-designed Multi-Scale Attention (MSA) in an ensemble framework (Sec. 3). Finally, we enhance our strategy by incorporating LoRA (Hu et al., 2021) technique, managing the extra parameter overhead to maintain efficiency with competitive performance even when scaling to ensemble applications. We summarize contributions of our study as below:
|
| 31 |
+
|
| 32 |
+
- Driven by the adapter efficiency, we are intrigued by the potential of leveraging classical small-sized machine learning techniques to enhance the large-scale model performance.
|
| 33 |
+
|
| 34 |
+
- We recall the ensemble, which is a classical practice but mostly overlooked in current large-scale era. Herein, we use adapter ensemble as an intermediary between large-scale pretrained model and small-sized technique to improve pretrained model under efficient finetuning budget.
|
| 35 |
+
|
| 36 |
+
- We conduct 1) a proof-of-concept study, promising our exploration as a valuable perspective; 2) an extensive ensemble test, showing consistent performance gain over different settings; 3) a simple ensemble-style MultiScale Attention (MSA), reaching the largest performance gain of cross-modal retrieval (e.g., $6\%$ YFCC zero-shot improvement with only 0.1M Laion finetuning data); 4) an incorporation with LoRA into our ensemble to maintain the adapter parameter efficiency (e.g., $2.2\%$ additional parameters with competitive performance).
|
| 37 |
+
|
| 38 |
+
# 2 Ensemble Proof-of-Concept Study
|
| 39 |
+
|
| 40 |
+
Ensemble is often interpreted as a weighting strategy (Rokach, 2010; Dietterich, 2000), where data or feature fusion can be regarded as an ensemble process to some extent. For instance, residual connection (He et al., 2016) is an ensemble process fusing identity mapping and learned residual information. In this section, we conduct an instructive experimental analysis as a proof-of-concept study to show the effectiveness of using an ensemble strategy on adapter. We finetune (using limited 0.1M data) and test on YFCC (Thomee et al., 2016) to compare our ensemble (Att-Ens/FFN-Ens) with three baselines (On-Top, Att-RB/FFN-RB, AttMLP/FFN-MLP) on CLIP backbone.
|
| 41 |
+
|
| 42 |
+
# Att-Ens/FFN-Ens.
|
| 43 |
+
|
| 44 |
+
We make a simple implementation to include a few sets of learnable parameters for ensemble, which is different from typical bottleneck adapter (Houlsby et al., 2019). Given a feature $f \in \mathbb{R}^d$ after multihead attention (Att) or feedforward (FFN) in each transformer block, we project the copied and concatenated feature using a pyramid layer:
|
| 45 |
+
|
| 46 |
+
$$
|
| 47 |
+
f ^ {\mathrm {e n s}} = f + (\overbrace {[ f , \dots , f ]} ^ {N}) W ^ {\mathrm {e n s}}, \tag {1}
|
| 48 |
+
$$
|
| 49 |
+
|
| 50 |
+

|
| 51 |
+
(a) Att-Ens/FFN-Ens add a pyramid projection to ensemble concatenated copied features for MHA or FFN.
|
| 52 |
+
|
| 53 |
+

|
| 54 |
+
(b) On-Top adds additional parameter (reverse bottleneck) on the top of both CLIP vision/language towers.
|
| 55 |
+
|
| 56 |
+

|
| 57 |
+
Figure 2: Instructive analysis to show our ensemble strategy (Fig. 2a) works better than baselines (Fig. 2b 2c 2d) while sharing the same number of additional learnable parameters overall. We adjust 1) the number of copied feature for Att-Ens/FFN-Ens (Fig. 2a); 2) the hidden dimension in reverse bottleneck for On-Top/Att-RB/FFN-RB (Fig. 2b 2c); 3) the number of hidden layers for Att-MLP/FFN-MLP (Fig. 2d) to keep the same amount of additional parameter for all methods. All four methods are deployed in both vision and language towers. In figures, green and blue blocks represent learnable and frozen modules, respectively.
|
| 58 |
+
|
| 59 |
+

|
| 60 |
+
(c) Att-RB/FFN-RB add a reverse bottleneck as additional parameters after MHA or FFN.
|
| 61 |
+
(d) Att-MLP/FFN-MLP add projections (same dimension) as learnable parameters after MHA or FFN.
|
| 62 |
+
|
| 63 |
+
where $W^{\mathrm{ens}} \in \mathbb{R}^{Nd \times d}$ and we omit bias term for convenience (Fig. 2a). $N$ is the number of copied feature to be concatenated. In this way, each $d$ -dim sub-matrix in $W^{\mathrm{ens}}$ can be treated as a base learner. The pyramid projection is an ensemble module. Accordingly, we can conveniently calculate the total number of additional learnable parameters. Assuming we have total $L$ blocks in pretrained CLIP, the totally amount of additional parameters is $L \times Nd \times d$ . We regard $d \times d$ as an adapter unit and $L \times N$ means the number of the total units. To show the benefits of ensemble strategy, we make a comparative analysis with the following three designed baselines, w.r.t. different numbers of units of additional parameters, shown as the number of x-axis in Fig. 1.
|
| 64 |
+
|
| 65 |
+
# On-Top
|
| 66 |
+
|
| 67 |
+
To eliminate any potential ensemble effect, we use CLIP to extract feature $f$ and place all the additional learnable parameters as a reverse bottleneck on the top (Fig. 2b) without any residual skip, which is given by
|
| 68 |
+
|
| 69 |
+
$$
|
| 70 |
+
f ^ {\mathrm {t o p}} = \left(f \cdot W ^ {1}\right) W ^ {2}, \tag {2}
|
| 71 |
+
$$
|
| 72 |
+
|
| 73 |
+
where $W^1 \in \mathbb{R}^{d \times (LNd/2)}$ and $W^2 \in \mathbb{R}^{(LNd/2) \times d}$ . This is the most basic baseline, with no ensemble influence.
|
| 74 |
+
|
| 75 |
+
# Att-RB/FFN-RB
|
| 76 |
+
|
| 77 |
+
We insert a reverse bottleneck after Att or FFN in each block (Fig. 2c). Residual skip is used here to relatively involve ensemble factor and alleviate the non-ensemble constraint compared with On-Top, given by:
|
| 78 |
+
|
| 79 |
+
$$
|
| 80 |
+
f ^ {r b} = f + \left(f \cdot W ^ {1}\right) W ^ {2}, \tag {3}
|
| 81 |
+
$$
|
| 82 |
+
|
| 83 |
+
where $W^1 \in \mathbb{R}^{d \times (Nd/2)}$ and $W^2 \in \mathbb{R}^{(Nd/2) \times d}$ . Skip connection involves ensemble concept but the reverse bottleneck is not for ensemble compared with Att-Ens/FFN-Ens.
|
| 84 |
+
|
| 85 |
+
# Att-MLP/FFN-MLP
|
| 86 |
+
|
| 87 |
+
We insert an MLP after Att or FFN in each block (Fig. 2d). This is another version to allow ensemble by using skip connection, given by
|
| 88 |
+
|
| 89 |
+
$$
|
| 90 |
+
f ^ {r b} = f + \left(f \cdot W ^ {1}\right) W ^ {2} \dots W ^ {N}, \tag {4}
|
| 91 |
+
$$
|
| 92 |
+
|
| 93 |
+
where $W^{i}\in \mathbb{R}^{d\times d},i = \{1,2,\dots,N\}$ . We keep the same dimension for all hidden layers across $i$
|
| 94 |
+
|
| 95 |
+
To be fair, we keep total numbers of additional parameters $(L\times Nd\times d)$ of all four methods as the same through adjusting the number of layers for Att-MLP/FFN-MLP and hidden dimension for others. All of four methods (Fig. 2) are deployed on both vision and language towers simultaneously. Fig. 1 shows the performance comparison between ensemble and baselines. \*Ens consistently outperforms others. With more additional parameters, we also observe the increasing ensemble performance. \*RB and \*MLP using ensemble to some extent obtain competitive results, even if adding more units of parameters damages the learning process for \*-MLP due to no skip connection inside. On-Top with no ensemble has lowest performance and adding more parameters fails to improve more. Based on these observations, we conclude relaxing a few learnable parameters to execute a lightweight ensemble is effective in efficiently improving a pretrained large-scale model.
|
| 96 |
+
|
| 97 |
+
# 3 Adapter Ensemble
|
| 98 |
+
|
| 99 |
+
We show the effectiveness of involving an adapter ensemble into a pretrained model in Sec. 2. Next, we introduce a bottleneck adapter baseline, a pyramid ensemble, and a well-designed multi-scale attention (MSA) ensemble for our comprehensive validation on multiple settings. Furthermore, we easily adopt LoRA (Hu et al., 2021) into our ensemble design to ease the parameter burden caused by ensemble operation.
|
| 100 |
+
|
| 101 |
+
# Bottleneck Adapter/Pyramid Ensemble
|
| 102 |
+
|
| 103 |
+
We follow the typical adapter (Houlsby et al., 2019) and insert two bottlenecks after self-attention and feedforward modules, and ensemble them together with the skip connections, given by
|
| 104 |
+
|
| 105 |
+
$$
|
| 106 |
+
f ^ {b o} = f + F ((f \cdot W ^ {1}) W ^ {2}, (f \cdot W ^ {3}) W ^ {4}), \quad (5)
|
| 107 |
+
$$
|
| 108 |
+
|
| 109 |
+
where $W^1, W^3 \in \mathbb{R}^{d \times d_a}$ and $W^2, W^4 \in \mathbb{R}^{d_a \times d}$ . $d_a$ is the hidden dimension. $F(\cdot, \cdot)$ serves as an ensemble operation implemented as averaging in our case. The pyramid ensemble is based on our introduction in Fig. 2a. The same feature is encoded several times by different sub-matrices in the pyramid projection and integrated in an ensemble fashion. Specifically, we set $N = 2$ to ensemble two base learners for our extensive validation.
|
| 110 |
+
|
| 111 |
+
# Multi-Scale Attention
|
| 112 |
+
|
| 113 |
+
Recall that the success of ensemble leveraging on diverse base learners to achieve the crowd intelligence (Rokach, 2010; Ganaie et al., 2021). The learners' diversity can be reflected from different aspect by different fashions (Dietterich, 2000; Rokach, 2010). For example, base learners can be trained from different datasets for ensemble. They can also come from different models such as neural network, decision tree, etc. Similarly, since neural networks are commonly trained by SGD introducing randomness into the trained model, repeatedly training model is also an effective way for ensemble (Li et al., 2019; Lee et al., 2018). Here, we are motivated by the Longformer (Beltagy et al., 2020) to tailor a multi-scale attention (MSA) to diversify our attention features. We propose a simple ensemble-based approach to implement this strategy. Formally, self-attention in transformer is originally given by
|
| 114 |
+
|
| 115 |
+
$$
|
| 116 |
+
A t t (Q, K, V) = \operatorname {s o f t m a x} \left(\frac {Q K ^ {T}}{\sqrt {d _ {k}}}\right) V, \tag {6}
|
| 117 |
+
$$
|
| 118 |
+
|
| 119 |
+
where $Q, K, V$ are query, key, and value vectors after projections. $d_{k}$ is the feature dimension of $K$ .
|
| 120 |
+
|
| 121 |
+
We separate the original attention into three different scales (large, middle, and small) by applying different masks. For language tower, we define the mask as
|
| 122 |
+
|
| 123 |
+
$$
|
| 124 |
+
M _ {C} ^ {*} [ i, j ] = \left\{ \begin{array}{l l} 1, & | i - j | < D _ {C} ^ {*}, \\ 0, & | i - j | \geq D _ {C} ^ {*}, \end{array} \right. \tag {7}
|
| 125 |
+
$$
|
| 126 |
+
|
| 127 |
+
where $M_C^* \in \mathbb{R}^{T_C \times T_C}$ and $T_C$ is the number of caption tokens. $D_C^*$ is the length of scale * and * ∈ {L, M, S} for large, middle and small scales, respectively. Since the language token is a 1D sequence, the mask for language is just as a banded matrix (Fig. 3). Similarly, we define the mask for the image tower as
|
| 128 |
+
|
| 129 |
+
$$
|
| 130 |
+
M _ {I} ^ {*} [ i, j ] = \left\{ \begin{array}{l l} 1, & \max (| x _ {i} - x _ {j} |, | y _ {i} - y _ {j} |) < D _ {I} ^ {*}, \\ 0, & \max (| x _ {i} - x _ {j} |, | y _ {i} - y _ {j} |) \geq D _ {I} ^ {*}, \end{array} \right. \tag {8}
|
| 131 |
+
$$
|
| 132 |
+
|
| 133 |
+
where $x_{*},y_{*}$ are the 2D visual patch positions converted from the 1D token sequence given by $x_{k} = \lfloor k / P_{I}\rfloor ,y_{k} = k - x_{k}\cdot P_{I}$ . $P_{I}$ is the number of patches in each row (or column) in a given image. The converting step makes the mask not as a banded matrix but representing different scales in the original 2D visual scenario (Fig. 3). After defining $M_C$ and $M_I$ , we describe the MSA by revising Eq. 6 as
|
| 134 |
+
|
| 135 |
+
$$
|
| 136 |
+
A t t ^ {*} (Q, K, V) = \operatorname {s o f t m a x} \left(\frac {Q K ^ {T} \odot M ^ {*}}{\sqrt {d _ {k}}}\right) V, \tag {9}
|
| 137 |
+
$$
|
| 138 |
+
|
| 139 |
+
for different scales in vision/language towers. $\odot$ applies mask on corresponding attention score matrix. We ensemble the MSA features from Eq. 9 as
|
| 140 |
+
|
| 141 |
+
$$
|
| 142 |
+
f ^ {\text {e n s}} = f + \left[ f ^ {L}, f ^ {M}, f ^ {S} \right] W ^ {\text {e n s}}, \tag {10}
|
| 143 |
+
$$
|
| 144 |
+
|
| 145 |
+
where $W^{\mathrm{ens}}$ is the pyramid projection to ensemble $f^{L}, f^{M}$ , and $f^{S}$ for large, middle, and small scales, respectively. In addition, we also add a bottleneck adapter after feedforward layer with our MSA to further enhance network capacity.
|
| 146 |
+
|
| 147 |
+
# LoRA Adoption
|
| 148 |
+
|
| 149 |
+
Our MSA integrates multiple branches as basic learners for ensemble and may also cause additional parameter burden for finetuning, even if we only focus on the adapter module. We simply adopt a low-rank (Hu et al., 2021) design here to solve this concern. We replace the ensemble operation (Eq. 10) by adding a learnable low-rank matrix on each scale branch as
|
| 150 |
+
|
| 151 |
+
$$
|
| 152 |
+
f ^ {*} = \operatorname {A t t} ^ {*} \left(f ^ {*}\right) + B A ^ {*} f ^ {*}, \tag {11}
|
| 153 |
+
$$
|
| 154 |
+
|
| 155 |
+

|
| 156 |
+
Figure 3: Illustration of multi-scale attention (MSA). It is specifically designed to benefit ensemble strategy by extracting diverse representations from multiple different scales. It consists of two parts: 1) MSA and 2) FFN adapter shown on the left. Different masks of large, middle, and small scales are applied on self-attention score matrix to yield different features representing corresponding scales. Given a scale, corresponding masks are constructed for vision and language shown on the right. Visual and language tokens are originally placed in 2D and 1D, respectively. A pyramid projection is used to make multi-scale ensemble and map back to original dimension. The FFN adapter is realized by typical bottleneck adapter. Blue and green parts on the left represent frozen and learnable modules.
|
| 157 |
+
|
| 158 |
+
where $* \in \{L, M, S\}$ are different branches. $B$ and $A^*$ are learnable low-rank matrices, where $B$ is shared for all branches. We add features of all branches for ensemble as $f^{ens} = f^L + f^M + f^S$ instead of using a pyramid layer. We also replace the bottleneck adapter after FFN in MSA with this low-rank structure. Detailed implementations and discussions of the LoRA structure are provided in the supplementary material.
|
| 159 |
+
|
| 160 |
+
# 4 Empirical Validation
|
| 161 |
+
|
| 162 |
+
# 4.1 Vision-Language Retrieval on CLIP
|
| 163 |
+
|
| 164 |
+
# Datasets
|
| 165 |
+
|
| 166 |
+
We use Laion (Schuhmann et al., 2021), YFCC (Thomee et al., 2016), and MS-COCO (Lin et al., 2014) for CLIP backbones. We randomly choose 0.1 million subsets from Laion and YFCC to make light finetuning. We use 10K, 60K, and 5K evaluation sets for Laion, YFCC, and MS-COCO, respectively.
|
| 167 |
+
|
| 168 |
+
# Settings
|
| 169 |
+
|
| 170 |
+
We use CLIP (pretrained on Laion) with ViT-B/16 and ViT-L/14 as backbone<sup>1</sup> and set three finetuning settings: 1) Regular uses Laion for both finetuning and evaluation; 2) Zero-shot finetunes and validates the pretrained model on different datasets (e.g., finetuning on Laion and validating on YFCC or MS-COCO); 3) Adaptation finetunes and validates the model on the same data but different from pretraining dataset (e.g., finetuning and testing on
|
| 171 |
+
|
| 172 |
+
YFCC). In addition, we also include the model evaluated on Laion but finetuned on YFCC, which is not a common scenario but for a comprehensive validation. As image retrieval is more commonly used for practice (e.g., searching engine) compared with text retrieval, we only report image retrieval results for real-world large-scale datasets (Laion, YFCC). We still report both image and text retrieval for COCO, which is a typical evaluation for this small dataset.
|
| 173 |
+
|
| 174 |
+
# Comparison Methods
|
| 175 |
+
|
| 176 |
+
We include zero shot performance on CLIP (CLIP-ZS) and CLIP-Adapter (Gao et al., 2021) (CLIP-Ada) as two baselines. We refer the bottleneck adapter/pyramid ensemble as Bo/Py, respectively. Bo and Py can be used after multi-head attention (MHA), feedforward (FFN), or Both. Thus, there are several combinations, such as pyramid ensemble with multi-head attention (PyMHA), bottleneck adapter with feedforward (BoFFN), etc. Detailed combinations are show in Fig. 4 and Fig. 5. We refer the multi-scale attention/multi-scale attention with LoRA adoption as MSA/MSA-Lo, respectively. All comparisons are separated into two groups for a clear analysis as below.
|
| 177 |
+
|
| 178 |
+
# Bottleneck Adapter/Pyramid Ensemble
|
| 179 |
+
|
| 180 |
+
Fig. 4 shows the comparisons using ViT-B/16 CLIP. Y-axis means the Top1 accuracy and X-axis represents the ratio of additional learnable parameter compared with original CLIP. We conclude 1) both Bo/Py achieve sizable performance gains compared with CLIP-ZS and CLIP-Ada. 2) improving
|
| 181 |
+
|
| 182 |
+

|
| 183 |
+
(a) Image retrieval on CLIP (ViT-B/16): The model is finetuned and tested both on Laion (regular setting) with several ensemble strategies and baselines.
|
| 184 |
+
|
| 185 |
+

|
| 186 |
+
(b) Image retrieval on CLIP (ViT-B/16): The model is finetuned on Laion and tested on YFCC (zero-shot setting) with several ensemble strategies and baselines.
|
| 187 |
+
|
| 188 |
+

|
| 189 |
+
Figure 4: Evaluation of image retrieval using ViT-B/16 CLIP. Four evaluation settings are tested based on Laion and YFCC datasets for finetuning or testing. Two ensemble strategies, bottleneck adapter and pyramid ensemble, are tested by being deployed after multi-head attention (MHA), feedforward (FFN), or both. The zero-shot evaluation using pretrained CLIP without finetuning (CLIP-ZS) and CLIP adapter (CLIP-Ada) are used as baselines. Y-axis means the Top1 retrieval accuracy and X-axis denotes the ratio of additional learnable parameter size to the original CLIP. Several ensemble designs generally outperform two baselines.
|
| 190 |
+
|
| 191 |
+

|
| 192 |
+
(c) Image retrieval on CLIP (ViT-B/16): The model is finetuned on YFCC and tested on Laion (see Sec. 4.1) with several ensemble strategies and baselines.
|
| 193 |
+
(d) Image retrieval on CLIP (ViT-B/16). The model is finetuned and tested both on YFCC (adaptation setting) with several ensemble strategies and baselines.
|
| 194 |
+
|
| 195 |
+
<table><tr><td colspan="7">ViT-B/16 CLIP: Image Retrieval</td></tr><tr><td>Setting</td><td>CLIP</td><td>w/o MSA</td><td>V-MSA</td><td>L-MSA</td><td>MSA</td><td>MSA-Lo</td></tr><tr><td>Regular</td><td>75.8</td><td>77.8</td><td>79.0</td><td>78.9</td><td>79.6</td><td>78.7</td></tr><tr><td>Zero-shot</td><td>54.1</td><td>57.3</td><td>59.7</td><td>56.5</td><td>58.6</td><td>58.8</td></tr><tr><td>Adaptation</td><td>54.1</td><td>62.3</td><td>67.7</td><td>61.0</td><td>67.9</td><td>65.3</td></tr><tr><td>ratio (%)</td><td>-</td><td>5.3</td><td>37.3</td><td>37.3</td><td>74.7</td><td>2.2</td></tr></table>
|
| 196 |
+
|
| 197 |
+
Table 1: MSA evaluation on Regular, Zero-shot, and Adaptation settings using ViT-B/16 CLIP. The ratio of learnale parameter compared with backbone is in the last row. Three ablations, w/o MSA, V-MSA, and L-MSA, are provided. MSA-Lo obtains competitive performance with much less additional parameters.
|
| 198 |
+
|
| 199 |
+
<table><tr><td colspan="7">ViT-L/14 CLIP: Image Retrieval</td></tr><tr><td>Setting</td><td>CLIP</td><td>w/o MSA</td><td>V-MSA</td><td>L-MSA</td><td>MSA</td><td>MSA-Lo</td></tr><tr><td>Regular</td><td>80.1</td><td>81.6</td><td>83.6</td><td>83.3</td><td>84.3</td><td>83.8</td></tr><tr><td>Zero-shot</td><td>63.7</td><td>64.7</td><td>69.6</td><td>65.3</td><td>68.0</td><td>67.8</td></tr><tr><td>Adaptation</td><td>63.7</td><td>67.2</td><td>79.2</td><td>69.2</td><td>78.6</td><td>78.4</td></tr><tr><td>ratio (%)</td><td>-</td><td>5.3</td><td>37.3</td><td>37.3</td><td>74.7</td><td>2.2</td></tr></table>
|
| 200 |
+
|
| 201 |
+
Table 2: MSA evaluation on Regular, Zero-shot, and Adaptation settings using ViT-L/14 CLIP. The ratio of leranable parameter compared with backbone is in the last row. Three ablations, w/o MSA, V-MSA, and L-MSA, are provided. MSA-Lo obtains competitive performance with much less additional parameters.
|
| 202 |
+
|
| 203 |
+
Laion performance is harder compared with that of YFCC (e.g., (b)/(d) have larger improvements than (a)/(c)). 3) Py-family ensemble is generally better than Bo-family. 4) FFN and MHA ensembles have comparable results. 5) adding ensemble after both MHA and FFN always outperforms each individual one except for the setting (c). It may be caused by using YFCC to finetune but testing on Laion which is also used for pretraining. 6) Compared with CLIP, the number of additional parameter for all settings is relatively small. The most expensive setting PyBoth requires around $30\%$ additional learnable parameters but others still derive promising improvement.
|
| 204 |
+
|
| 205 |
+
Fig. 5 shows the ViT-L/14 CLIP results. Ensemble on larger model performs differently compared with a smaller one: 1) improving Laion performance is even harder as it originally pretrained on Laion and less improvement potential left in
|
| 206 |
+
|
| 207 |
+
larger CLIP. Performance gain in (a) and (c) is smaller than ViT-B/16 and performance may drop sometimes after finetuning. 2) Ensemble on FFN is better than MHA here while they are almost comparable in ViT-B/16. Please note even if our adapter ensemble requires more additional parameters compared with the typical adapter (shown in x-axis in Fig. 4 and Fig. 5), our exploration uses an very limited 0.1M data, which is 1/4000 of the original 400M pretraining Laion data and a few epochs (5 in our cases). We use the 256/128 batch size for CLIP with ViT-B/16 and ViT-L/14. They are more memory efficient, unlike recently methods using a much larger batch size (Radford et al., 2021). Overall, we observe significant improvements on various settings, validating our adapter ensemble is effective for vision-language retrieval based on the pretrained CLIP. The parameter efficiency solution and corresponding discussion are provided next.
|
| 208 |
+
|
| 209 |
+

|
| 210 |
+
(a) Image retrieval on ViT-L/14 CLIP: model is finetuned and tested both on Laion (regular setting) with several ensemble strategies and baselines.
|
| 211 |
+
|
| 212 |
+

|
| 213 |
+
(b) Image retrieval on ViT-L/14 CLIP: model is finetuned on Laion and tested on YFCC (zero-shot setting with several ensemble strategies and baselines.
|
| 214 |
+
|
| 215 |
+

|
| 216 |
+
Figure 5: Evaluation of image retrieval using ViT-L/14 CLIP. Four evaluation settings are tested based on Laion and YFCC datasets for finetuning or testing. Two ensemble strategies, bottleneck adapter and pyramid ensemble, are tested by being deployed after multi-head attention (MHA), feedforward (FFN), or both. The zero-shot evaluation using pretrained CLIP without finetuning (CLIP-ZS) and CLIP adapter (CLIP-Ada) are used as baselines. Y-axis means the Top1 retrieval accuracy and X-axis denotes the ratio of additional learnable parameter size to the original CLIP. Several ensemble designs generally outperform two baselines.
|
| 217 |
+
|
| 218 |
+

|
| 219 |
+
(c) Image retrieval on ViT-L/14 CLIP: model is finetuned on YFCC and tested on Laion (see Sec. 4.1) with several ensemble strategies and baselines.
|
| 220 |
+
(d) Image retrieval on ViT-L/14 CLIP: model is finetuned and tested both on YFCC (adaptation setting) with several ensemble strategies and baselines.
|
| 221 |
+
|
| 222 |
+
<table><tr><td colspan="6">MS-COCO Zero-Shot Image Retrieval</td></tr><tr><td>Backbone</td><td>CLIP</td><td>w/o MSA</td><td>V-MSA</td><td>L-MSA</td><td>MSA</td></tr><tr><td>ViT-B/16</td><td>32.7</td><td>34.5</td><td>35.2</td><td>34.3</td><td>35.2</td></tr><tr><td>ViT-L/14</td><td>35.3</td><td>35.9</td><td>38.7</td><td>37.2</td><td>38.8</td></tr></table>
|
| 223 |
+
|
| 224 |
+
# MSA Performance
|
| 225 |
+
|
| 226 |
+
Tab. 1 and Tab. 2 show the MSA results with different settings on ViT-B/16 and ViT-L/14 CLIP backbones. CLIP-ZS is the pretrained CLIP zero-shot evaluation. w/o MSA is the model without MSA. V-MSA, L-MSA, and MSA represent using MSA on vision only, language only, both towers, respectively. MSA-Lo means MSA with LoRA adoption. We test on Regular, Zero-shot, and Adaptation settings and the ratio of additional parameter to the original backbone is shown in the last row. Our MSA outperforms the zero-shot baseline and the ablated model for all settings. Further, employing MSA on vision tower is more effective than language tower and sometimes even better than using MSA on both. The MSA involves more additional parameter, yet, the MSA with LoRA (MSA-Lo) significantly reduces the number of additional parameters and still obtains competitive performance. It ensures the parameter efficiency for our adapter
|
| 227 |
+
|
| 228 |
+
Table 3: MSA zero-shot evaluation of MS-COCO on ViT-B/16 and ViT-L/14 CLIP. The CLIP zero-shot baseline and three ablated models, without MSA (w/o MSA), vision-only MSA (V-MSA), and language-only MSA (L-MSA), are also provided.
|
| 229 |
+
|
| 230 |
+
<table><tr><td colspan="5">MSA Ablation for MS-COCO Zero-Shot Retrieval</td></tr><tr><td>Backbone</td><td>MSA-L</td><td>MSA-L+M</td><td>MSA-L+S</td><td>MSA-L+M+S</td></tr><tr><td>ViT-B/16</td><td>34.1</td><td>34.9</td><td>34.9</td><td>35.2</td></tr><tr><td>ViT-L/14</td><td>37.1</td><td>38.3</td><td>38.4</td><td>38.8</td></tr></table>
|
| 231 |
+
|
| 232 |
+
Table 4: MSA ablation study by removing branches for different scales on zero-shot MS-COCO evaluation. Large, middle, and small scales are referred by "L", "M", and "S", respectively. Our complete MSA obtains the best performance.
|
| 233 |
+
|
| 234 |
+
ensemble strategy. Please note, herein, we mainly consider the parameter aspect for the model efficiency. It is directly related to disk space instead of latency and flops which are mainly for model compression and out of the scope of this study. In addition, we also evaluate our MSA strategy with its ablated models using MS-COCO dataset on a zero-shot retrieval setting (Tab. 3).
|
| 235 |
+
|
| 236 |
+
# Ablation
|
| 237 |
+
|
| 238 |
+
We make ablation analysis using MS-COCO dataset on zero-shot evaluation. Specifically, we remove different branches in our MSA to validate the multi-scale strategy effectiveness (Tab. 4). As the large-scale branch represents the full attention score matrix, we remove middle and small branches to observe the performance changes. We find that adding each of them benefits the model to achieve better performance and three scales working together in an ensemble fashion obtains the best performance gain.
|
| 239 |
+
|
| 240 |
+

|
| 241 |
+
(a) PCA visualization of model features with and without MSA.
|
| 242 |
+
Figure 6: Visualization analysis of feature distributions of MSA (Fig. 6a) and different branches (Fig. 6). Features are extracted from ViT-L/14 CLIP finetuned on YFCC dataset.
|
| 243 |
+
|
| 244 |
+

|
| 245 |
+
(b) t-SNE visualization for feature distributions of different scale models.
|
| 246 |
+
|
| 247 |
+
# 4.2 Further Analysis
|
| 248 |
+
|
| 249 |
+
# Feature Visualization
|
| 250 |
+
|
| 251 |
+
The MSA provides diverse visual and language representations from different scales, which benefits the ensemble strategy. To provide a better intuition of the ensemble operation, we use PCA to show the feature distribution variations between MSA and w/o MSA on YFCC (Fig. 6a). Compared with model without MSA, the vision and language representations are further pulled closer by MSA operation which benefits the cross-modal retrieval. In addition, we use t-SNE to show features from large, middle, and small scales (Fig. 6b). They are clearly separated and provide diverse features, benefiting the ensemble strategy.
|
| 252 |
+
|
| 253 |
+
Due to the limited space, we leave retrieval visualizations (see Sec. A.5) and backbone generalization results (see Sec. A.3) in the appendix.
|
| 254 |
+
|
| 255 |
+
# 5 Related Works
|
| 256 |
+
|
| 257 |
+
# Vision-Language Retrieval
|
| 258 |
+
|
| 259 |
+
Multi-modal learning integrates information from different modalities (Xu et al., 2013; Ngiam et al., 2011) for various tasks (Jiang et al., 2021b,a; Liu et al., 2016; Bai et al., 2021, 2022, 2024; Mroueh et al., 2015; Liu et al., 2020; Sun et al., 2024b). Recently, vision-language understanding (Radford et al., 2021) becomes popular in this field mainly evaluated by retrieval task (Gao et al., 2021; Wang et al., 2024; Sun et al., 2024a). Such cross-domain retrieval is pioneered by VSE++ (Faghri et al., 2017), using hard-negative mining. SCAN (Lee et al., 2018) designs cross-modal encoding for fine-grained features. VSRN (Li et al., 2019) uses graph and recurrent networks to reason visual semantics. Large-scale pretraining boosts the performance using massive web data (Radford et al., 2021). Recent works (Jia et al., 2021; Kim et al., 2021; Ramesh
|
| 260 |
+
|
| 261 |
+
et al., 2022; Sahara et al., 2022) explore different strategies for pretraining such as CoCa (Yu et al., 2022) jointly using retrieval and captioning loss and BLIP (Li et al., 2022) utilizing cross-modal encoding. They significantly improves retrieval performance yet requires much more resource. Herein, we explore an efficient ensemble, combined with adapter, to further enhance the pretrained vision-language backbones for retrieval tasks.
|
| 262 |
+
|
| 263 |
+
# Ensemble
|
| 264 |
+
|
| 265 |
+
Leveraging on diverse base learners to achieve crowd intelligence, ensemble is seen as a weighting/voting strategy. Ensemble is simple yet effective for traditional machine learning (Dietterich, 2000; Sagi and Rokach, 2018). It is also applied to neural networks (Ganaie et al., 2021). Dropout (Srivastava et al., 2014) as a common fashion to avoid overfitting can be interpreted from an ensemble aspect. Different applications using ensemble derive promising performance compared with individual model (Li et al., 2019; Lee et al., 2018). Recent model soups (Wortsman et al., 2022) manages to integrate several checkpoints of a large pretrained models in an ensemble fashion to boost final performance. Different from them, our study focuses on introducing ensemble into current large-scale backbones, combined with adapter, to improve the pretrained model in an efficient manner.
|
| 266 |
+
|
| 267 |
+
# Adapter
|
| 268 |
+
|
| 269 |
+
Adapter structure (Houlsby et al., 2019) is originally proposed for efficient finetuning of language models. It leverages on the large-scale pretrained models and relaxes a few learnable parameters which is friendly to limited downstream data. Several parameter-efficient strategies are designed to relieve the finetuning difficulties of pretrained language models (Hu et al., 2021; Karimi Mahabadi et al., 2021; Eichenberg et al., 2021; He et al., 2021). This insight is also adopted into vision and vision-language fields to benefit various pretrained models for several downstream applications (Chen et al., 2022b; Zhang et al., 2021; Sung et al., 2022; Gao et al., 2021; Chen et al., 2023; Zheng et al., 2023; Upadhyay et al., 2023; Zhang et al., 2023a,b). In our study, we are inspired by the adapter insight. However, instead of injecting one set of learnable parameters, we propose to supplement a few sets of learnable parameters with diverse focuses (e.g. multi-scale attention) for efficient ensemble on pretrained large-scale models.
|
| 270 |
+
|
| 271 |
+
# 6 Conclusion
|
| 272 |
+
|
| 273 |
+
Our curiosity lies in exploring how traditional machine learning techniques, typically used for small-sized models, can be leveraged to benefit recent large-scale pretrained vision-language models. We identify adapter ensemble as an ideal fusion point, effectively finetuning large-scale models while seamlessly integrating small-sized methodologies. Through a proof-of-concept study, we validate the ensemble adapter efficacy. We then demonstrate its effectiveness for vision-language retrieval on different settings. Specifically, a multiscale attention (MSA) is designed to benefit ensemble operation. Furthermore, to address the potential increase in parameter requirements brought by the ensemble, we integrate the LoRA for MSA, significantly reducing the parameter overhead. Our empirical results showcase the ensemble capacity to improve the performance of large-scale pretrained models, achieving efficiency for data, parameter, and finetuning budgets.
|
| 274 |
+
|
| 275 |
+
# 7 Limitations
|
| 276 |
+
|
| 277 |
+
This work proposes to explore ensemble, a typical machine learning technique, in current large-scale model era. We mainly take CLIP backbone as a study case and make evaluation on cross-modal retrieval task. Due to the limited computational resource, we do not include other model backbones and tasks like language models or multi-modal models. However, the proposed adapter ensemble can be easily extended to other scenarios and we leave it into our future work.
|
| 278 |
+
|
| 279 |
+
# References
|
| 280 |
+
|
| 281 |
+
Yue Bai, Zhiqiang Tao, Lichen Wang, Sheng Li, Yu Yin, and Yun Fu. 2022. Collaborative attention mechanism for multi-modal time series classification. In Proceedings of the 2022 SIAM International Conference on Data Mining (SDM), pages 495-503. SIAM.
|
| 282 |
+
Yue Bai, Lichen Wang, Zhiqiang Tao, Sheng Li, and Yun Fu. 2021. Correlative channel-aware fusion for multi-view time series classification. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pages 6714-6722.
|
| 283 |
+
Yue Bai, Zichen Zhang, Jiasen Lu, and Yun Fu. 2024. Souplm: Model integration in large language and multi-modal models. arXiv preprint arXiv:2407.08196.
|
| 284 |
+
Iz Beltagy, Matthew E Peters, and Arman Cohan. 2020. Longformer: The long-document transformer. arXiv preprint arXiv:2004.05150.
|
| 285 |
+
|
| 286 |
+
Soravit Changpinyo, Piyush Sharma, Nan Ding, and Radu Soricut. 2021. Conceptual 12M: Pushing web-scale image-text pre-training to recognize long-tail visual concepts. In CVPR.
|
| 287 |
+
Guangyi Chen, Xiao Liu, Guangrun Wang, Kun Zhang, Philip HS Torr, Xiao-Ping Zhang, and Yansong Tang. 2023. Tem-adapter: Adapting image-text pretraining for video question answer. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 13945-13955.
|
| 288 |
+
Jun Chen, Han Guo, Kai Yi, Boyang Li, and Mohamed Elhoseiny. 2022a. Visualgpt: Data-efficient adaptation of pretrained language models for image captioning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 18030-18040.
|
| 289 |
+
Zhe Chen, Yuchen Duan, Wenhai Wang, Junjun He, Tong Lu, Jifeng Dai, and Yu Qiao. 2022b. Vision transformer adapter for dense predictions. arXiv preprint arXiv:2205.08534.
|
| 290 |
+
Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. 2009. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pages 248-255. IEEE.
|
| 291 |
+
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2018. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805.
|
| 292 |
+
Thomas G Dietterich. 2000. Ensemble methods in machine learning. In International workshop on multiple classifier systems, pages 1-15. Springer.
|
| 293 |
+
Xibin Dong, Zhiwen Yu, Wenming Cao, Yifan Shi, and Qianli Ma. 2020. A survey on ensemble learning. Frontiers of Computer Science, 14:241-258.
|
| 294 |
+
Constantin Eichenberg, Sidney Black, Samuel Weinbach, Letitia Parcalabescu, and Anette Frank. 2021. Magma-multimodal augmentation of generative models through adapter-based finetuning. arXiv preprint arXiv:2112.05253.
|
| 295 |
+
Fartash Faghri, David J Fleet, Jamie Ryan Kiros, and Sanja Fidler. 2017. Vse++: Improving visual-semantic embeddings with hard negatives. arXiv preprint arXiv:1707.05612.
|
| 296 |
+
Mudasir A Ganaie, Minghui Hu, et al. 2021. Ensemble deep learning: A review. arXiv preprint arXiv:2104.02395.
|
| 297 |
+
Peng Gao, Shijie Geng, Renrui Zhang, Teli Ma, Rongyao Fang, Yongfeng Zhang, Hongsheng Li, and Yu Qiao. 2021. Clip-adapter: Better vision-language models with feature adapters. arXiv preprint arXiv:2110.04544.
|
| 298 |
+
|
| 299 |
+
Junxian He, Chunting Zhou, Xuezhe Ma, Taylor Berg-Kirkpatrick, and Graham Neubig. 2021. Towards a unified view of parameter-efficient transfer learning. arXiv preprint arXiv:2110.04366.
|
| 300 |
+
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. 2016. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 770-778.
|
| 301 |
+
Neil Houlsby, Andrei Giurgiu, Stanislaw Jastrzebski, Bruna Morrone, Quentin De Laroussilhe, Andrea Gesmundo, Mona Attariyan, and Sylvain Gelly. 2019. Parameter-efficient transfer learning for nlp. In International Conference on Machine Learning, pages 2790-2799. PMLR.
|
| 302 |
+
Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. 2021. Lora: Low-rank adaptation of large language models. arXiv preprint arXiv:2106.09685.
|
| 303 |
+
Chao Jia, Yinfei Yang, Ye Xia, Yi-Ting Chen, Zarana Parekh, Hieu Pham, Quoc V. Le, Yun-Hsuan Sung, Zhen Li, and Tom Duerig. 2021. Scaling up visual and vision-language representation learning with noisy text supervision. CoRR, abs/2102.05918.
|
| 304 |
+
Songyao Jiang, Bin Sun, Lichen Wang, Yue Bai, Kunpeng Li, and Yun Fu. 2021a. Sign language recognition via skeleton-aware multi-model ensemble. arXiv preprint arXiv:2110.06161.
|
| 305 |
+
Songyao Jiang, Bin Sun, Lichen Wang, Yue Bai, Kunpeng Li, and Yun Fu. 2021b. Skeleton aware multimodal sign language recognition. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 3413-3423.
|
| 306 |
+
Rabeeh Karimi Mahabadi, James Henderson, and Sebastian Ruder. 2021. Compacter: Efficient low-rank hypercomplex adapter layers. Advances in Neural Information Processing Systems, 34:1022-1035.
|
| 307 |
+
Wonjae Kim, Bokyung Son, and Ildoo Kim. 2021. Vilt: Vision-and-language transformer without convolution or region supervision. In Proceedings of the 38th International Conference on Machine Learning, ICML 2021, 18-24 July 2021, Virtual Event, volume 139 of Proceedings of Machine Learning Research, pages 5583-5594. PMLR.
|
| 308 |
+
Kuang-Huei Lee, Xi Chen, Gang Hua, Houdong Hu, and Xiaodong He. 2018. Stacked cross attention for image-text matching. In Proceedings of the European conference on computer vision (ECCV), pages 201-216.
|
| 309 |
+
Junnan Li, Dongxu Li, Caiming Xiong, and Steven Hoi. 2022. Blip: Bootstrapping language-image pretraining for unified vision-language understanding and generation. arXiv preprint arXiv:2201.12086.
|
| 310 |
+
|
| 311 |
+
Kunpeng Li, Yulun Zhang, Kai Li, Yuanyuan Li, and Yun Fu. 2019. Visual semantic reasoning for image-text matching. In Proceedings of the IEEE/CVF international conference on computer vision, pages 4654-4662.
|
| 312 |
+
Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dólar, and C Lawrence Zitnick. 2014. Microsoft coco: Common objects in context. In European conference on computer vision, pages 740-755. Springer.
|
| 313 |
+
An-An Liu, Ning Xu, Wei-Zhi Nie, Yu-Ting Su, Yongkang Wong, and Mohan Kankanhalli. 2016. Benchmarking a multimodal and multiview and interactive dataset for human action recognition. IEEE Transactions on cybernetics, 47(7):1781-1794.
|
| 314 |
+
Yunyu Liu, Lichen Wang, Yue Bai, Can Qin, Zhengming Ding, and Yun Fu. 2020. Generative view-correlation adaptation for semi-supervised multi-view learning. In Computer Vision-ECCV 2020: 16th European Conference, Glasgow, UK, August 23-28, 2020, Proceedings, Part XIV 16, pages 318-334. Springer.
|
| 315 |
+
Ron Mokady, Amir Hertz, and Amit H Bermano. 2021. Clipcap: Clip prefix for image captioning. arXiv preprint arXiv:2111.09734.
|
| 316 |
+
Youssef Mroueh, Etienne Marcheret, and Vaibhava Goel. 2015. Deep multimodal learning for audio-visual speech recognition. In 2015 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 2130-2134. IEEE.
|
| 317 |
+
Norman Mu, Alexander Kirillov, David Wagner, and Saining Xie. 2022. Slip: Self-supervision meets language-image pre-training. In Computer Vision-ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23-27, 2022, Proceedings, Part XXVI, pages 529-544. Springer.
|
| 318 |
+
Jiquan Ngiam, Aditya Khosla, Mingyu Kim, Juhan Nam, Honglak Lee, and Andrew Y Ng. 2011. Multimodal deep learning. In Proceedings of the 28th international conference on machine learning (ICML-11), pages 689-696.
|
| 319 |
+
Zhiliang Peng, Li Dong, Hangbo Bao, Qixiang Ye, and Furu Wei. 2022. Beit v2: Masked image modeling with vector-quantized visual tokenizers. arXiv preprint arXiv:2208.06366.
|
| 320 |
+
Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. 2021. Learning transferable visual models from natural language supervision. In International Conference on Machine Learning, pages 8748-8763. PMLR.
|
| 321 |
+
Alec Radford, Karthik Narasimhan, Tim Salimans, Ilya Sutskever, et al. 2018. Improving language understanding by generative pre-training.
|
| 322 |
+
|
| 323 |
+
Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. 2022. Hierarchical text-conditional image generation with clip latents. arXiv preprint arXiv:2204.06125.
|
| 324 |
+
Lior Rokach. 2010. Ensemble-based classifiers. Artificial intelligence review, 33(1):1-39.
|
| 325 |
+
Omer Sagi and Lior Rokach. 2018. Ensemble learning: A survey. Wiley Interdisciplinary Reviews: Data Mining and Knowledge Discovery, 8(4):e1249.
|
| 326 |
+
Chitwan Sahara, William Chan, Saurabh Saxena, Lala Li, Jay Whang, Emily Denton, Seyed Kamyar Seyed Ghasemipour, Burcu Karagol Ayan, S Sara Mahdavi, Rapha Gontijo Lopes, et al. 2022. Photorealistic text-to-image diffusion models with deep language understanding. arXiv preprint arXiv:2205.11487.
|
| 327 |
+
Christoph Schuhmann, Richard Vencu, Romain Beaumont, Robert Kaczmarczyk, Clayton Mullis, Aarush Katta, Theo Coombes, Jenia Jitsev, and Aran Komatsuzaki. 2021. Laion-400m: Open dataset of clip-filtered 400 million image-text pairs. arXiv preprint arXiv:2111.02114.
|
| 328 |
+
Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. 2014. Dropout: a simple way to prevent neural networks from overfitting. The journal of machine learning research, 15(1):1929-1958.
|
| 329 |
+
Guohao Sun, Yue Bai, Xueying Yang, Yi Fang, Yun Fu, and Zhiqiang Tao. 2024a. Aligning out-of-distribution web images and caption semantics via evidential learning. In Proceedings of the ACM on Web Conference 2024, pages 2271-2281.
|
| 330 |
+
Guohao Sun, Can Qin, Jiamian Wang, Zeyuan Chen, Ran Xu, and Zhiqiang Tao. 2024b. Sq-llava: Self-questioning for large vision-language assistant. arXiv preprint arXiv:2403.11299.
|
| 331 |
+
Yi-Lin Sung, Jaemin Cho, and Mohit Bansal. 2022. Vl-adapter: Parameter-efficient transfer learning for vision-and-language tasks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 5227-5237.
|
| 332 |
+
Zhiqiang Tao, Hongfu Liu, Sheng Li, Zhengming Ding, and Yun Fu. 2019. Marginalized multiview ensemble clustering. IEEE transactions on neural networks and learning systems, 31(2):600-611.
|
| 333 |
+
Yoad Tewel, Yoav Shalev, Idan Schwartz, and Lior Wolf. 2022. Zerocap: Zero-shot image-to-text generation for visual-semantic arithmetic. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 17918-17928.
|
| 334 |
+
Bart Thomee, David A Shamma, Gerald Friedland, Benjamin Elizalde, Karl Ni, Douglas Poland, Damian Borth, and Li-Jia Li. 2016. Yfcc100m: The new data in multimedia research. Communications of the ACM, 59(2):64-73.
|
| 335 |
+
|
| 336 |
+
Uddeshya Upadhyay, Shyamgopal Karthik, Massimiliano Mancini, and Zeynep Akata. 2023. Probvlm: Probabilistic adapter for frozen vison-language models. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 1899-1910.
|
| 337 |
+
Jiamian Wang, Guohao Sun, Pichao Wang, Dongfang Liu, Sohail Dianat, Majid Rabbani, Raghunteer Rao, and Zhiqiang Tao. 2024. Text is mass: Modeling as stochastic embedding for text-video retrieval. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 16551-16560.
|
| 338 |
+
Mitchell Wortsman, Gabriel Ilharco, Samir Ya Gadre, Rebecca Roelofs, Raphael Gontijo-Lopes, Ari S Morcos, Hongseok Namkoong, Ali Farhadi, Yair Carmon, Simon Kornblith, et al. 2022. Model soups: averaging weights of multiple fine-tuned models improves accuracy without increasing inference time. In International Conference on Machine Learning, pages 23965-23998. PMLR.
|
| 339 |
+
Chang Xu, Dacheng Tao, and Chao Xu. 2013. A survey on multi-view learning. arXiv preprint arXiv:1304.5634.
|
| 340 |
+
Jiahui Yu, Zirui Wang, Vijay Vasudevan, Legg Yeung, Mojtaba Seyedhosseini, and Yonghui Wu. 2022. Coca: Contrastive captioners are image-text foundation models. arXiv preprint arXiv:2205.01917.
|
| 341 |
+
Renrui Zhang, Rongyao Fang, Peng Gao, Wei Zhang, Kunchang Li, Jifeng Dai, Yu Qiao, and Hongsheng Li. 2021. Tip-adapter: Training-free clip-adapter for better vision-language modeling. arXiv preprint arXiv:2111.03930.
|
| 342 |
+
Yi Zhang, Ce Zhang, Xueting Hu, and Zhihai He. 2023a. Unsupervised prototype adapter for vision-language models. arXiv preprint arXiv:2308.11507.
|
| 343 |
+
Yi Zhang, Ce Zhang, Zihan Liao, Yushun Tang, and Zhi-hai He. 2023b. Bdc-adapter: Brownian distance covariance for better vision-language reasoning. arXiv preprint arXiv:2309.01256.
|
| 344 |
+
Handong Zhao, Zhengming Ding, and Yun Fu. 2017. Multi-view clustering via deep matrix factorization. In Proceedings of the AAAI conference on artificial intelligence, volume 31.
|
| 345 |
+
Kecheng Zheng, Wei Wu, Ruili Feng, Kai Zhu, Jiawei Liu, Deli Zhao, Zheng-Jun Zha, Wei Chen, and Yu-jun Shen. 2023. Regularized mask tuning: Uncovering hidden knowledge in pre-trained vision-language models. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 11663-11673.
|
| 346 |
+
|
| 347 |
+
# A Supplementary Material
|
| 348 |
+
|
| 349 |
+
# A.1 Supplementary MS-COCO Performance
|
| 350 |
+
|
| 351 |
+
We supplement the MSA-Lo and zero-shot text retrieval results on MS-COCO dataset using both CLIP with ViT-B/16 and ViT-L/14. Specifically, we augment the image retrieval table (Tab.2 in the main draft) with MSA-Lo in Tab. 8, and we newly provide text retrieval results in Tab. 5. We also provide text retrieval ablation study in Tab. 6. We observe the consistent improvement compared with baselines and different ablated models and draw the similar conclusions as our main draft.
|
| 352 |
+
|
| 353 |
+
<table><tr><td colspan="7">MS-COCO Zero-Shot Text Retrieval</td></tr><tr><td>Backbone</td><td>CLIP</td><td>w/o MSA</td><td>V-MSA</td><td>T-MSA</td><td>MSA</td><td>MSA-Lo</td></tr><tr><td>ViT-B/16</td><td>51.7</td><td>53.5</td><td>53.5</td><td>54.5</td><td>54.9</td><td>54.7</td></tr><tr><td>ViT-L/14</td><td>56.1</td><td>56.7</td><td>57.8</td><td>59.2</td><td>59.5</td><td>59.4</td></tr></table>
|
| 354 |
+
|
| 355 |
+
Table 5: MSA zero-shot text retrieval evaluation of MS-COCO on CLIP with ViT-B/16 and ViT-L/14.
|
| 356 |
+
|
| 357 |
+
<table><tr><td colspan="5">MSA Ablation for MS-COCO Zero-Shot Text Retrieval</td></tr><tr><td>Backbone</td><td>MSA-L</td><td>MSA-L+M</td><td>MSA-L+S</td><td>MSA-L+M+S</td></tr><tr><td>ViT-B/16</td><td>53.7</td><td>54.5</td><td>54.5</td><td>54.9</td></tr><tr><td>ViT-L/14</td><td>57.8</td><td>59.1</td><td>59.0</td><td>59.5</td></tr></table>
|
| 358 |
+
|
| 359 |
+
# A.2 Implementation Details
|
| 360 |
+
|
| 361 |
+
We provide more implementation details for our adapter ensemble exploration. We run our experiments on 8 V100 GPUs. For bottleneck adapter used in our experiments, we consistently set 128 as hidden dimension. To maintain the near-identity initialization for finetuning the pretrained model, we initialize the values of weights using $0/1\mathrm{e}-3$ for means/variances values without bias for the bottleneck adapter. For the pyramid structure of our MSA, we initialize the sub-matrix, corresponding to the large-scale branch, as identity matrix and the other values using $0/1\mathrm{e}-3$ for means/variances. For LoRA structure in MSA-Lo, we add it parallel to the attention module for large-scale branch, and after the attention module for middle-scale and small-scale branches, setting 16 as low-rank hidden dimension. The outputs of three branches are added as an ensemble operation. In addition, we also use the ensemble strategy for the LoRA structure after FFN. Specifically, we use a shared matrix A and three different matrices B, and three outputs
|
| 362 |
+
|
| 363 |
+
are added together as an ensemble operation. For all backbones used in our experiments, we follow their original finetuning configurations to conduct our adapter ensemble finetuning, except for the available finetuning data and epochs (always 0.1M available data and 5 epochs in our study).
|
| 364 |
+
|
| 365 |
+
Herein, we also discuss the MSA-Lo implementation for the potential latency issue caused by ensemble operations. We simply use the LoRA structure after FFN as an example. Since several different B matrices need multiple forward computations, we concatenate them along with the feature dimension the achieve the parallel computation. In this way, multiple branches of the ensemble can be processed efficiently. The time consumption comparison of the FFN ensemble operation in one MSA-Lo block is shown in Tab. 7. "One-branch" means a typical LoRA baseline. "Three-branch" means the ensemble in three-time forward fashion. "Three-branch (parallel)" is the ensemble parallel implementation. Results are based on 10 runs average. We find leveraging on parallel implementation, the ensemble strategy can be achieved in an efficient fashion without too much additional latency cost.
|
| 366 |
+
|
| 367 |
+
Table 6: MSA ablation study by removing branches for different scales on zero-shot MS-COCO text retrieval.
|
| 368 |
+
|
| 369 |
+
<table><tr><td>One-branch</td><td>Three-branch</td><td>Three-branch (parallel)</td></tr><tr><td>1.34e-4</td><td>3.52e-4</td><td>1.58e-4</td></tr></table>
|
| 370 |
+
|
| 371 |
+
Table 7: Time consumption comparison of LoRA in one FFN block of MSA-Lo.
|
| 372 |
+
|
| 373 |
+
<table><tr><td colspan="7">MS-COCO Zero-Shot Image Retrieval</td></tr><tr><td>Backbone</td><td>CLIP</td><td>w/o MSA</td><td>V-MSA</td><td>L-MSA</td><td>MSA</td><td>MSA-Lo</td></tr><tr><td>ViT-B/16</td><td>32.7</td><td>34.5</td><td>35.2</td><td>34.3</td><td>35.2</td><td>35.2</td></tr><tr><td>ViT-L/14</td><td>35.3</td><td>35.9</td><td>38.7</td><td>37.2</td><td>38.8</td><td>38.6</td></tr></table>
|
| 374 |
+
|
| 375 |
+
Table 8: MSA zero-shot image retrieval evaluation of MS-COCO on ViT-B/16 and ViT-L/14CLIP.
|
| 376 |
+
|
| 377 |
+
# A.3 Backbone Generalization
|
| 378 |
+
|
| 379 |
+
Besides of the CLIP architecture, we further consider other backbones to validate the generalizability of the proposed adapter ensemble strategy. Specifically, SLIP (Mu et al., 2022) uses self-supervised learning to help vision-language pretraining. It further improves the cross-modal modeling capacity compared with CLIP. We follow its original paper to use a linear probing to evaluate image classification on Imagenet (Deng et al., 2009). We also use a 0.1M Imagenet subset
|
| 380 |
+
|
| 381 |
+
<table><tr><td colspan="5">Image classification on SLIP (ViT/B16)</td></tr><tr><td>Pretraining Data</td><td>Zero-shot</td><td>Linear</td><td>w/o MSA</td><td>w/ MSA</td></tr><tr><td>CC3M</td><td>23.0</td><td>47.5</td><td>51.0</td><td>51.4</td></tr><tr><td>CC12M</td><td>40.7</td><td>55.8</td><td>63.3</td><td>64.3</td></tr></table>
|
| 382 |
+
|
| 383 |
+
Table 9: Image classification results of SLIP based on CC3M and CC12M pretraining dataset. We compare our MSA with zero-shot, linear baselines and the ablated w/o MSA model. Our MSA shows the generalizability on SLIP backbone.
|
| 384 |
+
|
| 385 |
+
<table><tr><td colspan="5">Image classification results on Beit V2</td></tr><tr><td>Pretraining Data</td><td>Model</td><td>Linear</td><td>w/o MSA</td><td>w/ MSA</td></tr><tr><td rowspan="2">Imagenet1K</td><td>ViT-B</td><td>55.3</td><td>66.3</td><td>68.6</td></tr><tr><td>ViT-L</td><td>63.8</td><td>69.4</td><td>72.0</td></tr></table>
|
| 386 |
+
|
| 387 |
+
Table 10: Image classification results of Beit V2 using ViT-B and ViT-L backbones. We compare our MSA with zero-shot, linear baselines and the ablated w/o MSA model. Our MSA shows the generalizability on Beit V2 backbone.
|
| 388 |
+
|
| 389 |
+
to finetune the pretrained backbone 5 epochs for our ensemble strategy. Tab. 9 shows the comparisons of MSA ensemble with baselines on SLIP with different pretraining datasets (e.g., CC3M and CC12M (Changpinyo et al., 2021)). The zero-shot is evaluated by using prompt template while others using typical label prediction.
|
| 390 |
+
|
| 391 |
+
Beit V2 (Peng et al., 2022) is a backbone only for vision domain. Herein, we also include it to test the generalizability of our ensemble strategy on visual only task. We use a 0.1M Imagenet subset to finetune the pretrained backbone 5 epochs. Since the Beit V2 is pretrained in self-supervised fashion, it cannot perform zero-shot evaluation without finetuning. Similar to SLIP, we make a linear probing classifier as a baseline. Tab. 10 shows the comparisons of MSA ensemble with baselines on different backbones. We observe the proposed adapter ensemble is a general finetuning strategy for different backbones.
|
| 392 |
+
|
| 393 |
+
# A.4 More Visualizations of Feature Distribution
|
| 394 |
+
|
| 395 |
+
We show more feature distribution visualizations of our multi-scale attention (MSA) on different settings. The Regular setting finetunes and evaluates the pretrained model on Laion dataset using CLIP backbone. Since it is a more challenging setting and its performance gain is not as much as other settings, we do not observe significant feature
|
| 396 |
+
|
| 397 |
+
variations on this setting. Therefore, we mainly show Adaptation and Zero-shot settings for feature distribution visualization. Like our main draft, we show image and text feature distributions from models w/ and w/o MSA (each subfigure (a)), and image feature distributions of different scales (each subfigure (b)). Fig. 9 shows the zero-shot setting visualization on ViT-L/14 CLIP. Fig. 10 shows the adaptation setting visualization on ViT-B/16 CLIP. Fig. 11 shows the zero-shot setting visualization on ViT-B/16 CLIP. We find the adaptation setting shows significant feature variations, which indicates the features from different modalities become closer with each other and improve the retrieval performance.
|
| 398 |
+
|
| 399 |
+
# A.5 Retrieval Visualizations
|
| 400 |
+
|
| 401 |
+
# Retrieval Visualization
|
| 402 |
+
|
| 403 |
+
We show retrieval results to compare the models w/ and w/o MSA. In Fig. 7, MSA obtains the correct Recall@1 image retrieval in the first five samples but fails in the last. We observe compared with w/o MSA, MSA retrieval better matches with the query at different scales. For example, in the first example, MSA retrieves the image with correct cat object and street corner background while w/o MSA retrieves house and chair as background which are incorrect. In Fig. 8, MSA successes in the first five samples and fails in the last. Similarly, MSA matches the query with more details for text retrieval. For example, another standing woman on the edge of the image is captured by our method in the first example. The small zebra instead of giraffe is accurately attended in the second. The water background in both the second and third examples are captured by MSA but missed by w/o MSA.
|
| 404 |
+
|
| 405 |
+
We show more cross-modal retrieval visualizations on MS-COCO dataset using our model (w/ MSA) and w/o MSA. We show text retrieval visualizations in Fig. 12, where the image query is shown on the left and text retrieval with green color means the groundtruth retrieval. Our model obtains the correct results on Recall@1 in subfigure (a), (b), and (c), where our MSA captures more fine-grained patterns from different scales. For example, MSA finds the "brick" element in (b) and the "bathroom" element in (c) for cross-modal matching in a small scale but w/o MSA ignores them. w/o MSA derives the correct results on Recall@1 in subfigure (d), (e), and (f). However, MSA also finds reasonable re
|
| 406 |
+
|
| 407 |
+
trievals. For example, in (d), our MSA captures the "BMW" information which is shown in the middle of figure at a very small scale and provides the retrieval accordingly. Similarly, in (f), the fine-grained visual element "jet way" is considered by MSA for retrieval but w/o MSA ignores it. Fig. 13 and Fig. 14 show the image retrieval visualizations, where text query is shown on the top and image with green box means the groundtruth retrieval. In Fig. 13, our model (w/ MSA) obtains the correct retrieval on Recall@1 with more details. For example, in subfigure (a), our model captures the detailed color information of the clock tower and finds the most accurate retrieval while w/o MSA only finds it at Top3. In Fig. 14, w/o MSA derives the correct retrieval on Recall@1. However, our model also retrieve promising results at Top1 compared with the groundtruth. In addition, for all top five retrievals, our model generally obtains more reasonable results. For example, in subfigure (a), w/ MSA finds motor cycles in all five retrievals but w/o MSA misses this component at Top4.
|
| 408 |
+
|
| 409 |
+

|
| 410 |
+
A cat sitting on a street corner looking at the camera.
|
| 411 |
+
MSA:
|
| 412 |
+
w/o MSA:
|
| 413 |
+
|
| 414 |
+

|
| 415 |
+
An old style kitchen with baby blue cabinets.
|
| 416 |
+
MSA:
|
| 417 |
+
w/o MSA:
|
| 418 |
+
|
| 419 |
+

|
| 420 |
+
Figure 7: MS-COCO zero-shot image retrieval examples for ViT-B/16 CLIP backbone. MSA and w/o MSA represent if the model uses our multi-scale strategy. Caption queries are shown on the top and we show the Top1 image retrieval of both MSA and w/o MSA models. Our MSA obtains correct retrieval for the first five examples (in green) but fails at the last one (in red).
|
| 421 |
+
|
| 422 |
+

|
| 423 |
+
A cat in between two cars in a parking lot.
|
| 424 |
+
MSA:
|
| 425 |
+
|
| 426 |
+

|
| 427 |
+
w/o MSA:
|
| 428 |
+
|
| 429 |
+

|
| 430 |
+
A parked motorcycle next to a green tent.
|
| 431 |
+
MSA:
|
| 432 |
+
w/o MSA:
|
| 433 |
+
|
| 434 |
+

|
| 435 |
+
|
| 436 |
+

|
| 437 |
+
A kitten sitting in a skin with a green brush with green bristles.
|
| 438 |
+
MSA:
|
| 439 |
+
w/o MSA:
|
| 440 |
+
Close up of a white kitchen setup with a coffee maker on counter.
|
| 441 |
+
|
| 442 |
+

|
| 443 |
+
|
| 444 |
+

|
| 445 |
+
MSA:
|
| 446 |
+
w/o MSA:
|
| 447 |
+
|
| 448 |
+

|
| 449 |
+
|
| 450 |
+

|
| 451 |
+
MSA: A woman sitting on a bench and a women standing waiting for the bus.
|
| 452 |
+
w/o MSA: women is sitting on a stool on a sidewalk.
|
| 453 |
+
|
| 454 |
+

|
| 455 |
+
MSA: A giraffe and a zebra are on a grassy field by the water. w/o MSA: An adult and a younger giraffe are facing the same direction.
|
| 456 |
+
|
| 457 |
+

|
| 458 |
+
MSA: Person standing near the water with a red disc in hand. w/o MSA: A man has a frisbee in his hand and is standing up.
|
| 459 |
+
|
| 460 |
+

|
| 461 |
+
MSA: Urban downtown city center with a bicyclist and pedestrians.
|
| 462 |
+
|
| 463 |
+

|
| 464 |
+
w/o MSA: The passage between the modern buildings is used by bicycle riders.
|
| 465 |
+
MSA: A person on her cell phone in a large crowd of people.
|
| 466 |
+
w/o MSA: a young woman looking at her cell phone.
|
| 467 |
+
Figure 8: MS-COCO zero-shot text retrieval examples for ViT-B/16 CLIP backbone. MSA and w/o MSA represent if the model uses our multi-scale attention strategy. Image queries are shown on the top and we show the Top1 text retrieval of both MSA and w/o MSA models. Our MSA obtains correct retrieval for the first five examples (in green) but fails at the last one (in red).
|
| 468 |
+
|
| 469 |
+

|
| 470 |
+
MSA: A double decker tour bus with the logo "SS Transit".
|
| 471 |
+
w/o MSA: A purple and white city bus pulling up to the curb.
|
| 472 |
+
|
| 473 |
+

|
| 474 |
+
(a) Distribution visualization of model w/ and w/o MSA.
|
| 475 |
+
|
| 476 |
+

|
| 477 |
+
(b) Distribution visualization of different scales feature.
|
| 478 |
+
Figure 9: YFCC feature visualization on Zero-shot setting using ViT-L/14 CLIP.
|
| 479 |
+
|
| 480 |
+

|
| 481 |
+
(a) Distribution visualization of model w/ and w/o MSA.
|
| 482 |
+
|
| 483 |
+

|
| 484 |
+
(b) Distribution visualization of different scales feature.
|
| 485 |
+
Figure 10: YFCC feature visualization on Adaptation setting using ViT-B/16 CLIP.
|
| 486 |
+
|
| 487 |
+

|
| 488 |
+
(a) Distribution visualization of model w/ and w/o MSA.
|
| 489 |
+
Figure 11: YFCC feature visualization on Zero-shot setting using ViT-B/16 CLIP.
|
| 490 |
+
|
| 491 |
+

|
| 492 |
+
(b) Distribution visualization of different scales feature.
|
| 493 |
+
|
| 494 |
+

|
| 495 |
+
w/ MSA:
|
| 496 |
+
w/o MSA:
|
| 497 |
+
|
| 498 |
+
Top1: Some purple benches and a bird on it
|
| 499 |
+
Top2: A bird sitting on top of a park bench. Top3: A penguin bird standing on a beach section.
|
| 500 |
+
Top3: A nice bird standing on a bench gazing at. Top4: A person sitting on a bench near many birds
|
| 501 |
+
Top4: A person sitting on a bench near many birds. Top5: Man on park bench surrounded by some pigeons.
|
| 502 |
+
|
| 503 |
+
Top1: A person sitting on a bench near many birds.
|
| 504 |
+
Top2: A bird sitting on top of a park bench.
|
| 505 |
+
Top3: Some purple benches and a bird on it. Top4: A nice bird standing on a bench grazing
|
| 506 |
+
Top: A small bird sitting on the back of a wooden bench.
|
| 507 |
+
|
| 508 |
+
# (a)
|
| 509 |
+
|
| 510 |
+

|
| 511 |
+
w/MSA:
|
| 512 |
+
w/o MSA:
|
| 513 |
+
|
| 514 |
+
Top1: Lady standing in a retro pink and turquoise bathroom.
|
| 515 |
+
|
| 516 |
+
Top2: A lady is standing in pastel colored bathroom in front of the bathtub and there are
|
| 517 |
+
Christmas lights hanging up outside of the doorway. Top3: A lady dressed in khakis standing in a bathroom next to the sink
|
| 518 |
+
Top: Woman in high heels in a crumbling room.
|
| 519 |
+
Top5: A woman in a yellow bathroom is holding a camera.
|
| 520 |
+
|
| 521 |
+
Top1: A little blonde girl standing in front of a fridge.
|
| 522 |
+
Top2: A lady dressed in khakis standing in a bathroom next to the sink.
|
| 523 |
+
Top3: Woman in high heels in a crumbling room. Top4: Lady standing in a retro pink and turpvsis
|
| 524 |
+
Top4: Lady standing in a retro pink and turquoise bathroom. Top5: A woman in a yellow bathroom is holding a camera.
|
| 525 |
+
|
| 526 |
+
# (c)
|
| 527 |
+
|
| 528 |
+

|
| 529 |
+
w/MSA:
|
| 530 |
+
w/o MSA:
|
| 531 |
+
Figure 12: Text retrieval visualization on MS-COCO using w/ and w/o MSA models. Our model (w/ MSA) obtains the correct retrieval on Recall@1 in (a), (b), and (c). w/o MSA derives the correct retrieval on Recall@1 in (d), (e), and (f). Image query is shown on the left and text with green color means the groundtruth retrieval result.
|
| 532 |
+
|
| 533 |
+
Top1: A kitchen with hardwood floors and a sink and oven.
|
| 534 |
+
Top2: A kitchen that has a tile floor, a refrigerator, a microwave, and a toaster.
|
| 535 |
+
Top3: The small kitchen with the spacious counters is clean.
|
| 536 |
+
Top4: An unadorned kitchen with oven, sink, cabinets, microwave, wood floor, and a
|
| 537 |
+
window.
|
| 538 |
+
Top5: The small kitchen has large cabinets and two stoves.
|
| 539 |
+
|
| 540 |
+
Top1: An unadorned kitchen with oven, sink, cabinets, microwave, wood floor, and a
|
| 541 |
+
window. Top: The small kitchen has large cabinets and two stoves.
|
| 542 |
+
Top2: The small kitchen has large cabinets and two stove tops. Top3: The small kitchen with the spacious counters is clean.
|
| 543 |
+
Top4: A kitchen that has a tile floor, a refrigerator, a microwave, and a toaster.
|
| 544 |
+
Top5: A kitchen that has a floor, a refrigerator, a microw
|
| 545 |
+
|
| 546 |
+
# (e)
|
| 547 |
+
|
| 548 |
+

|
| 549 |
+
w/ MSA:
|
| 550 |
+
w/o MSA:
|
| 551 |
+
|
| 552 |
+
Top1: An interesting kitchen renovation with brick and wood.
|
| 553 |
+
Top2: A wood paneled kitchen with dining table and tiled floor. Top3: Wooden control counter top is a tiled kitchen.
|
| 554 |
+
Top3: Wooden central counter-top in a tiled kitchen. Top4: A very old fashioned kitchen with retro floor tile
|
| 555 |
+
Top5: Kitchen view with brick framework around the sink and by the oven.
|
| 556 |
+
|
| 557 |
+
Top1: Wooden central counter-top in a tiled kitchen.
|
| 558 |
+
Top2: A wood paneled kitchen with dining table and tiled floor. Top3: Kitchen with briefer frames around the risk and
|
| 559 |
+
Top3: Kitchen View with brick framework around the sink and by the oven. Top4: An interesting kitchen renovation with brick and wood.
|
| 560 |
+
Top5: A kitchen with a wooden floor and a microwave oven.
|
| 561 |
+
|
| 562 |
+
# (b)
|
| 563 |
+
|
| 564 |
+

|
| 565 |
+
w/MSA:
|
| 566 |
+
w/o MSA:
|
| 567 |
+
|
| 568 |
+
Top1: A BMW motorcycle is parked on display in this field.
|
| 569 |
+
Top2: A man looking at motorcycles in a field
|
| 570 |
+
Top3: People stand around an antique motorcycle in a grassy area.
|
| 571 |
+
Top4: A main looks at a motorcycle amongst others in a field. Top5: A World War Military Molecule on display at an event
|
| 572 |
+
Top3: A World War Military Motocycle on Display at an event
|
| 573 |
+
|
| 574 |
+
Top1: A man looking at motorcycles in a field.
|
| 575 |
+
Top2: People stand around an antique motorcycle in a grassy area.
|
| 576 |
+
Top3: A man looks at a motorcycle amongst others in a field Top4: A BMW motorcycle is parked on display in this field.
|
| 577 |
+
Top5: A group of people look at the dark green motorcycle parked on the grass.
|
| 578 |
+
|
| 579 |
+
# (d)
|
| 580 |
+
|
| 581 |
+

|
| 582 |
+
w/MSA:
|
| 583 |
+
w/o MSA:
|
| 584 |
+
|
| 585 |
+
Top1: View from gate of jet connected to jet way for passengers to board or deplane.
|
| 586 |
+
Top2: An airplane sits outside, ready at the airport.
|
| 587 |
+
Top3: A Malaysian airplane that is stationary on the runway.
|
| 588 |
+
Top4: A red and blue plan on the runway getting ready to get passengers
|
| 589 |
+
Top5: A person at an airport terminal with planed in view outside of the windows.
|
| 590 |
+
|
| 591 |
+
Top1: An airplane sits outside, ready at the airport.
|
| 592 |
+
Top2: A person at an airport terminal with planed in view outside of the windows.
|
| 593 |
+
Top3: View from gate of jet connected to jet way for passengers to board or deplane.
|
| 594 |
+
Top4: A red and blue plan on the runway getting ready to get passengers
|
| 595 |
+
|
| 596 |
+
# (f)
|
| 597 |
+
|
| 598 |
+
A large clock tower is yellow and white.
|
| 599 |
+
|
| 600 |
+

|
| 601 |
+
(a)
|
| 602 |
+
|
| 603 |
+
An elderly person in a kitchen cooking food.
|
| 604 |
+
|
| 605 |
+

|
| 606 |
+
(b)
|
| 607 |
+
|
| 608 |
+
An office kitchen with open windows and no food.
|
| 609 |
+
|
| 610 |
+

|
| 611 |
+
(c)
|
| 612 |
+
Figure 13: Image retrieval visualization on MS-COCO. We compare the models w/ and w/o MSA strategy. For these three samples, our model (w/ MSA) obtains the correct retrieval on Recall@1. Text query is shown on the top and image retrieval with green box means the groundtruth retrieval result.
|
| 613 |
+
|
| 614 |
+
Altered photograph of very shiny motor cycles in a field.
|
| 615 |
+
|
| 616 |
+

|
| 617 |
+
(a)
|
| 618 |
+
|
| 619 |
+
A display of vintage animal toys on the floor.
|
| 620 |
+
|
| 621 |
+

|
| 622 |
+
(b)
|
| 623 |
+
|
| 624 |
+
Close up of a white kitchen setup with a coffee maker on counter.
|
| 625 |
+
|
| 626 |
+

|
| 627 |
+
(c)
|
| 628 |
+
Figure 14: Image retrieval visualization on MS-COCO. We compare the models w/ and w/o MSA strategy. For these three samples, w/o MSA derives the correct retrieval on Recall@1. Text query is shown on the top and image retrieval with green box means the groundtruth retrieval result.
|
advancingvisionlanguagemodelswithadapterensemblestrategies/images.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9e768161a1a3ce07e068f8ee9a3bebe5a7e9d17c167b05c0801ec94edd4671ed
|
| 3 |
+
size 1314224
|
advancingvisionlanguagemodelswithadapterensemblestrategies/layout.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5c0490efd731c2655ceb086b4f5b22c20ac12b2e138c85b90796fd8113929b5f
|
| 3 |
+
size 690263
|
adversarialattacksonpartsofspeechanempiricalstudyintexttoimagegeneration/00d22e0d-0a6f-42b1-9bb4-f9d6cea5a1f9_content_list.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:40d8bc2bbc4a56abed91efc3594f7e8dd5799533be066550101ac997168f7afa
|
| 3 |
+
size 109248
|
adversarialattacksonpartsofspeechanempiricalstudyintexttoimagegeneration/00d22e0d-0a6f-42b1-9bb4-f9d6cea5a1f9_model.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:df9c5ea792e6d9a16bca7f6a47aaaf727ebf8755c5822e68d2206c7a2f6d73b4
|
| 3 |
+
size 129897
|
adversarialattacksonpartsofspeechanempiricalstudyintexttoimagegeneration/00d22e0d-0a6f-42b1-9bb4-f9d6cea5a1f9_origin.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2b1879510e411093eb7b5b153b38c743c09c1706873ad9335f5bf4e953967cca
|
| 3 |
+
size 13257129
|
adversarialattacksonpartsofspeechanempiricalstudyintexttoimagegeneration/full.md
ADDED
|
@@ -0,0 +1,462 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Adversarial Attacks on Parts of Speech: An Empirical Study in Text-to-Image Generation
|
| 2 |
+
|
| 3 |
+
G M Shahariar, Jia Chen, Jiachen Li, Yue Dong
|
| 4 |
+
|
| 5 |
+
University of California, Riverside
|
| 6 |
+
|
| 7 |
+
{gshah010, jiac, jiachen.li, yue.dong}@ucr.edu
|
| 8 |
+
|
| 9 |
+
# Abstract
|
| 10 |
+
|
| 11 |
+
Recent studies show that text-to-image (T2I) models are vulnerable to adversarial attacks, especially with noun perturbations in text prompts. In this study, we investigate the impact of adversarial attacks on different POS tags within text prompts on the images generated by T2I models. We create a high-quality dataset for realistic POS tag token swapping and perform gradient-based attacks to find adversarial suffixes that mislead T2I models into generating images with altered tokens. Our empirical results show that the attack success rate (ASR) varies significantly among different POS tag categories, with nouns, proper nouns, and adjectives being the easiest to attack. We explore the mechanism behind the steering effect of adversarial suffixes, finding that the number of critical tokens and content fusion vary among POS tags, while features like suffix transferability are consistent across categories. We have made our implementation publicly available at - https://github.com/shahariar-shibli/Adversarial-Attack-on-POS-Tags.
|
| 12 |
+
|
| 13 |
+
# 1 Introduction
|
| 14 |
+
|
| 15 |
+
Text-to-Image (T2I) generation models such as Stable Diffusion (Rombach et al., 2022; Podell et al., 2023), DALL-E2 (Ramesh et al., 2022), Imagen (Saharia et al., 2022), ediff-i (Balaji et al., 2022) have made steady progress in the field of image generation by bridging the semantic gap between textual descriptions and visual representations. Unlike traditional methods reliant solely on pixel manipulation, these models leverage multi-model alignments in latent spaces to interpret and synthesize complex visual content from textual prompts. Recent studies, such as Tang et al. (2023), have interpreted how cross-alignment from texts to images is transformed through text-image attribution analysis, demonstrating that different POS tags are well captured by cross-modal attention during synthesis.
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
|
| 19 |
+

|
| 20 |
+
|
| 21 |
+

|
| 22 |
+
|
| 23 |
+

|
| 24 |
+
|
| 25 |
+

|
| 26 |
+
|
| 27 |
+

|
| 28 |
+
|
| 29 |
+

|
| 30 |
+
Figure 1: Examples of successful adversarial attacks on Stable Diffusion covering different POS tags drawn from our dataset. The POS tokens targeted by adversarial suffixes are highlighted in red. In addition, we observe that the attack success rate (ASR) varies significantly across POS tag categories, with features like the number of critical tokens (defined in §5, non-critical tokens are highlighted in orange) being highly associated with ASR.
|
| 31 |
+
|
| 32 |
+

|
| 33 |
+
|
| 34 |
+

|
| 35 |
+
|
| 36 |
+
On the other hand, recent research shows that T2I models are vulnerable to adversarial perturbations in text prompts, such as inserting nonsensical words (Milliere, 2022), phrases (Maus et al., 2023), or irrelevant characters (Zhuang et al., 2023), which can significantly bias the generated images (Chefer et al., 2023; Salman et al., 2023). However, current adversarial attacks on T2I generation models, either manual heuristic-based methods (Zhuang et al., 2023; Gao et al., 2023; Maus et al., 2023) or automatic gradient-based approaches (Zhuang et al., 2023; Liang et al., 2023; Liu et al., 2023; Shahgir et al., 2023; Yang et al., 2024a,b; Du et al., 2024; Zhai et al., 2024), are specifically targeting entities
|
| 37 |
+
|
| 38 |
+
<table><tr><td>Research Paper</td><td>POS Tags to Attack</td><td>Data Source</td></tr><tr><td>Zhuang et al. (2023)</td><td>Noun</td><td>ChatGPT</td></tr><tr><td>Liu et al. (2023)</td><td>Noun</td><td>ImageNet-1K</td></tr><tr><td rowspan="2">Shahgir et al. (2023)</td><td rowspan="2">Noun</td><td>Manual</td></tr><tr><td>MS-COCO</td></tr><tr><td>Yang et al. (2024a)</td><td>Noun</td><td>MS-COCO</td></tr><tr><td>Yang et al. (2024b)</td><td>Noun</td><td>ChatGPT</td></tr><tr><td>Du et al. (2024)</td><td>Noun</td><td>ImageNet-1K</td></tr><tr><td>This work</td><td>Noun, Proper Noun, Adjective, Verb, Numeral, Adverb</td><td>MS-COCO</td></tr></table>
|
| 39 |
+
|
| 40 |
+
Table 1: Comparison of T2I adversarial attacks based on targeting parts of speech.
|
| 41 |
+
|
| 42 |
+
or objects (i.e., nouns) in text prompts, neglecting other parts of speech. In this paper, we aim to answer the following two research questions:
|
| 43 |
+
|
| 44 |
+
- Q1: Do adversarial attacks, particularly gradient-based attacks on T2I models, behave similarly when targeting different POS tag categories?
|
| 45 |
+
- Q2: Are there common or distinct features relevant to attack success rates (ASR) when targeting different POS tag categories under adversarial attacks?
|
| 46 |
+
|
| 47 |
+
To bridge the gap in analyzing attack mechanisms across different POS tag categories beyond nouns, we first created a dataset with realistic scenarios for swapping different POS tag categories with adversarial attacks. Figure 1 provides a few examples drawn from our dataset covering six POS tags from Tang et al. (2023): noun, adjective, verb, adverb, numeral, and proper noun, with adversarial suffixes that successfully mislead T2I models into generating images related to the targeted attribute. Creating such a dataset is non-trivial, as Shahgir et al. (2023) noted that ASR to T2I models might be affected by internal bias rather than the attack itself; we tried to minimize such biases when creating the dataset. To the best of our knowledge, there is currently no dataset available for analyzing adversarial attacks on POS tags other than nouns (refer to Table 1).
|
| 48 |
+
|
| 49 |
+
We conduct targeted adversarial attacks over POS tag categories with a gradient-based token searching algorithm specifically designed for T2I models to effectively navigate the larger vocabulary size of the T2I text encoder (Shahgir et al., 2023). The attack objective is to create an adversarial prompt that causes a target POS token to appear in the generated image while ensuring the original POS token from the input prompt does
|
| 50 |
+
|
| 51 |
+
not. We observe that the ASR differs significantly across different POS tag categories. Nouns, proper nouns, and adjectives are the easiest to attack, with increasing difficulties, while the other three categories, with the same gradient-based attack, offer almost no success, whether in restricted (preventing the target token's POS tag attribute from appearing in the adversarial suffix) or unrestricted settings.
|
| 52 |
+
|
| 53 |
+
This observation led us to further investigate whether there are features associated with these differences in ASR across POS categories. Through extensive experiments, we discovered a correlation between the number of critical tokens in adversarial suffixes and the attack success rate across different POS categories. Critical tokens are those whose removal from the adversarial suffix renders the attack unsuccessful.
|
| 54 |
+
|
| 55 |
+
Additionally, the results from our ablation study reveal that adversarial suffixes, while steering the generation of target attributes, often fail to completely remove the original attribute. For example, when attempting to change a purple grape to a green one using adversarial suffixes, the resulting image often shows a mixed color. In contrast, with noun attacks, both objects can be generated, whereas with verbs, it is difficult to mix or generate both original and swapped tokens. This varying ease of content fusion across POS categories may also contribute to the differences in ASR.
|
| 56 |
+
|
| 57 |
+
Furthermore, we identified a general feature shared across different POS categories: the transferability of the attack suffix. Similar to nouns, the adversarial suffixes found are universally transferable to other input prompts with the same attributes. This means an adversarial suffix can transform multiple input prompts with different attributes into the same target attributes in the generated images. For instance, we found that the same adversarial suffix targeting a 'blue' cup can steer the model to generate images of a blue cup across multiple input prompts with different original colors (e.g., red, yellow, orange).
|
| 58 |
+
|
| 59 |
+
# 2 Related Work
|
| 60 |
+
|
| 61 |
+
Text-to-Image Diffusion Models. Nichol et al. (2021) formalized the initial text-to-image (T2I) diffusion model (GLIDE) that substituted class labels with text in class-conditioned diffusion models (i.e. Ablated Diffusion Models (Dhariwal and Nichol, 2021)). The authors explored two types of text conditioning methods: classifier guidance
|
| 62 |
+
|
| 63 |
+
and classifier-free guidance (CFG). Sahara et al. (2022) proposedImagen by following the classifier-free guidance (CFG) of GLIDE for T2I generation. They utilized pre-trained large language models (LLMs) as the text encoder and found that scaling up language models is more efficient in improving sample fidelity and aligning images with text. Ramesh et al. (2022) created DALL-E2, a T2I generation model capable of sequentially generating images using text embeddings to guide the process. They achieved this by training a generative diffusion decoder to reverse the image encoding process of CLIP (Radford et al., 2021). Rombach et al. (2022) developed the Latent Diffusion Model (LDM) by incorporating denoising methods within the latent space of pre-trained autoencoders and improving the U-Net architecture with the cross-attention mechanism. Stability AI has utilized the LDM framework to create and introduce a variety of text-to-image diffusion models called the Stable Diffusion series.
|
| 64 |
+
|
| 65 |
+
Adversarial Attacks on T2I Models. Existing research on adversarial attacks on T2I models primarily falls into two categories: query or heuristic-based and gradient-based. Within the first category, recent studies have explored the excessive sensitivity of T2I diffusion models to minor changes in text prompts. Maus et al. (2023) introduced a query-based attack that discovers prepended prompts capable of causing T2I diffusion models to generate specific image categories. Zhuang et al. (2023) targeted the text encoder of diffusion models by appending extra nonsensical characters to the input prompt using a genetic algorithm. Gao et al. (2023) first identified keywords based on their impact on the generation distribution and then applied character-level substitutions, such as typos, glyphs, and phonetic variations. In the second category, there has been a recent increase in gradient-based adversarial attacks targeting the text encoder of T2I models. Liu et al. (2023) introduced a gradient-guided optimization process to refine a continuous token embedding, using gradients to navigate the prompt space and identify failure cases. Yang et al. (2024a) explored a focused targeted attack that adds target objects while removing original ones, and developed MMP-Attack, which incorporates multimodal features. Du et al. (2024) proposed Autoattack on Text-to-image Models (ATM), which automatically generates attack prompts that resemble clean prompts by replacing or adding words. Shahgir et al. (2023) applied gradient-based to
|
| 66 |
+
|
| 67 |
+
ken perturbation methods to replace entities in the prompt with adversarial suffix tokens. We adopt the gradient attack proposed by (Shahgir et al., 2023) because it aligns with our attack objectives and demonstrates strong performance in targeting nouns.
|
| 68 |
+
|
| 69 |
+
# 3 Dataset Creation
|
| 70 |
+
|
| 71 |
+
In this section, we outline the procedure for constructing our dataset. We first specify the dataset source and then describe the steps involved in its construction.
|
| 72 |
+
|
| 73 |
+
Data Collection. The first obstacle we encountered in evaluating adversarial attacks across different POS categories beyond nouns was that there was no existing dataset for fair comparison. Table 1 compares existing adversarial attack datasets by size, parts of speech covered, and data sources. To construct our dataset, we chose MS-COCO (Lin et al., 2014) as the data source for its diverse and complex captions making it suitable for testing the robustness of SD. In the train split of MS-COCO, each image has five captions. We collected only the first caption among the five resulting in 118,287 rows.
|
| 74 |
+
|
| 75 |
+
Input Prompts Selection. We identified the POS tags in each caption from the initially collected data using the NLTK library (Bird, 2006) and a pretrained POS tagging model (Sajjad et al., 2022). We only focused on six parts of speech tags: noun, verb, adverb, adjective, numeral, and proper noun. For each POS tag, we then randomly selected 20 unique captions, each containing at least one word from the corresponding POS tag, to be used as input prompts.
|
| 76 |
+
|
| 77 |
+
Target Prompts Generation. For each input prompt of every POS tag, we generated five target prompts, resulting in 100 prompt pairs per POS tag. Each input and target prompt differed by only one word, with the target words chosen from a pool of candidate words. The process of generating target prompts starts by extracting the POS-tagged word from the input prompt using the same NLTK library and pre-trained POS tagging model employed during the input prompt selection. Then, we compile a set of candidate words by gathering other words of the same POS category, identifying antonyms to introduce variety, [MASK] prediction to acquire the top-5 words, and exploring the CLIP token embedding space to find the top-k distant neighbors of the word. To extract antonyms, we use the
|
| 78 |
+
|
| 79 |
+
NLTK library and the WordNet database (Fellbaum, 2010). For [MASK] prediction, we employ BERT (Devlin et al., 2019) as a masked language model. To identify the farthest neighbor tokens in the vocabulary space, we calculate the cosine similarity between the extracted input word embedding and the embeddings of other tokens in the vocabulary, selecting the top 100 tokens with the lowest cosine similarity scores. These candidate words are then filtered to ensure they retain the same POS while removing synonyms, subwords, and substrings to maintain relevance and avoid redundancy. Using these filtered candidate words, we then generate ten candidate prompts ranked highest through [MASK] prediction probabilities. These prompts are subsequently ranked based on their perplexity scores, which measure the fluency and coherence of the prompts. The perplexity score is calculated using the GPT-2 model (Radford et al., 2019). Finally, the five prompts with the lowest perplexity scores, indicating the highest quality, are selected as the final target prompts. We repeat this process for each of the six POS tags, resulting in a total of 600 prompt pairs.
|
| 80 |
+
|
| 81 |
+
Annotator Recruitment. Our study involves two annotation tasks: dataset annotation and attack success evaluation. For these tasks, we chose two annotators with expertise and research experience in vision and language-related tasks. We chose them from a group of five candidates based on their trustworthiness scores (Price et al., 2020), which were determined through an assessment. We presented them with 30 image-text pairs and asked whether the image accurately reflected the text description (Yes/No). From our dataset, we randomly chose 20 text prompts and generated one image per prompt using SD. In addition, we created 10 text prompts with the help of ChatGPT using the prompt "Generate 10 simple scenes for text-to-image generative model" and then using SD generated one image per prompt. These 10 image-text pairs served as control samples, which were unknown to the participants in advance. Upon completion of the task, we assessed the number of correctly labeled control samples for each candidate. Candidates who achieved a trustworthiness score exceeding $90\%$ were selected as annotators.
|
| 82 |
+
|
| 83 |
+
Dataset Annotation. We assigned one annotator the task of assessing the meaningfulness of the generated target prompts. The annotator was provided with 600 prompt pairs. For each prompt, we also presented the annotator with 10 candidate tar
|
| 84 |
+
|
| 85 |
+
get words generated using ChatGPT. We used the prompt "Replace [MASK] with the most probable 10 words in the following text: " to generate candidate target words by ChatGPT. If the target prompt generated from our pipeline appeared meaningful and the annotator considered it visually representable, we instruct the annotator to retain it; otherwise, we ask to replace the corresponding word with an alternative from the pool of ChatGPT-generated words. Out of the 600 prompt pairs, the annotator opted to replace 97 target prompts.
|
| 86 |
+
|
| 87 |
+
# 4 Experiment
|
| 88 |
+
|
| 89 |
+
In this section, we outline the gradient-based adversarial attack method, describe the experimental setup, and report the results to assess the effectiveness of the attack.
|
| 90 |
+
|
| 91 |
+
# 4.1 Attack Method
|
| 92 |
+
|
| 93 |
+
Gradient-based attacks on Stable Diffusion (Zhuang et al., 2023; Shahgir et al., 2023; Yang et al., 2024a,b; Du et al., 2024) utilize the gradient information to perturb the input prompt in a way that maximizes the divergence from the intended output, effectively manipulating the image synthesis process. While previous studies have predominantly focused on nouns, our analysis extends this approach to other parts of speech by applying the gradient-based attack framework proposed by (Shahgir et al., 2023). The process of such an attack on T2I models generally starts with an initial prompt, which is modified iteratively to create an adversarial prompt that maximizes a predefined score function. This involves embedding the target prompt and the adversarial prompt using a token embedder and processing them through a text encoder. The core mechanism focuses on creating multiple candidate prompts by replacing tokens and computing the top-k token candidates. The best candidate prompt, which maximizes the score function, is selected, and the gradient of the loss function concerning the adversarial prompt is used to iteratively refine the prompt. This iterative optimization adjusts the adversarial prompt to gradually increase the discrepancy between the model's output for the target prompt and the adversarial prompt, effectively fooling the T2I generation model. Further details of the attack are provided in Appendix B. We conducted the targeted attack under two distinct settings: with and without restrictions. In the unrestricted setting, we
|
| 94 |
+
|
| 95 |
+
allow the adversarial prompt to include the target token or its sub-tokens as suffix tokens. However, in the restricted attack scenario, we confine the appearance of the target token within the adversarial prompt by constraining all possible substrings of the target token.
|
| 96 |
+
|
| 97 |
+
# 4.2 Experimental Setup
|
| 98 |
+
|
| 99 |
+
We followed the setup of Shahgir et al. (2023) and conducted the attack five times for each pair, with 100 steps per run, employing 10 adversarial tokens. For each step, we selected the top 256 tokens as candidate tokens and generated 512 new prompts by randomly substituting tokens using these candidates. Subsequently, we generated seven images per attack, resulting in the evaluation of a total of 21,000 generated images (600 pairs, 5 runs, and 7 images per run). During image generation, we set the resolution to $512 \times 512$ , the number of inference steps to 50, and the scale of classifier-free guidance to 7.5. As the victim model, we utilized Stable Diffusion v1.5 (SD v15) for both image generation and performance assessment, leveraging a pre-trained CLIP model trained on a dataset comprising text-image pairs. All experiments (attack execution, evaluation, and image generation) were conducted using a single Nvidia RTX 3090 GPU, totaling approximately 600 GPU hours. The execution time to attack a single input-target prompt pair is approximately 8 minutes.
|
| 100 |
+
|
| 101 |
+
# 4.3 Evaluation Metrics
|
| 102 |
+
|
| 103 |
+
Attack Success Rate. We consider an attack successful if the image generated by the adversarial prompt matches the target text; otherwise, we consider it unsuccessful. Since we generate 7 images per adversarial prompt, to measure the attack success rate (ASR), we consider the attack as successful if at least 4 images have a higher matching score than a threshold. Following (Shahgir et al., 2023), we set this threshold value at 3.41. We determine the matching score by calculating the difference between the CLIP score of the input prompt and the generated image, and the CLIP score of the target text and the generated image. CLIP score measures the cosine similarity between the visual CLIP embedding of an image and the textual CLIP embedding of a text. For each input-target prompt pair, we run the attack five times, generating five adversarial prompts, and consider the attack successful if at least one of them succeeds.
|
| 104 |
+
|
| 105 |
+
Semantic Shift Rate. For a quantitative measure
|
| 106 |
+
|
| 107 |
+
to evaluate the efficacy of adversarial suffix tokens, we utilized SemSR (Semantic Shift Rate) (Zhai et al., 2024) which measures the semantics between a generated image and a text prompt. SemSR utilizes CLIP's multi-modal embedding space and computes the similarity in semantics between a generated image and a prompt using cosine similarity. This metric quantifies the displacement in the vector space of the generated image after appending adversarial suffix tokens compared to the image generated using the input prompt. Since the amount of deviation necessary to attain diverse target semantics differs, it is adjusted by the maximum deviation. The SemSR equation is provided below:
|
| 108 |
+
|
| 109 |
+
$$
|
| 110 |
+
S e m S R = \frac {C S \left(E _ {I _ {a}} , E _ {P _ {a}}\right) - C S \left(E _ {I _ {i}} , E _ {P _ {i}}\right)}{C S \left(E _ {I _ {t}} , E _ {P _ {t}}\right) - C S \left(E _ {I _ {i}} , E _ {P _ {i}}\right)} \tag {1}
|
| 111 |
+
$$
|
| 112 |
+
|
| 113 |
+
where $CS$ denotes CLIP_Score, $I_{a}$ represents the generated image from the adversarial prompt $P_{a}$ , $I_{i}$ denotes the generated image from the input prompt $P_{i}$ , and $I_{t}$ denotes the generated image from the target prompt $P_{t}$ . For a single input-target prompt pair, we measure the average of SemSR scores over five runs.
|
| 114 |
+
|
| 115 |
+
# 4.4 Results
|
| 116 |
+
|
| 117 |
+
In Figure 11, we showcase a few examples of images generated through both the unrestricted and restricted attack methods. Table 2 displays the average attack success rate (ASR) and average semantic shift rate (SemSR) over all the prompt pairs for each POS tag under both attack conditions. Below, we present both quantitative analysis and human evaluation of our experiments.
|
| 118 |
+
|
| 119 |
+
<table><tr><td rowspan="2">POS Tag</td><td colspan="2">Unrestricted Attack</td><td colspan="2">Restricted Attack</td></tr><tr><td>ASR</td><td>SemSR</td><td>ASR</td><td>SemSR</td></tr><tr><td>Noun</td><td>0.65</td><td>1.4394</td><td>0.51</td><td>1.3884</td></tr><tr><td>Proper Noun</td><td>0.40</td><td>0.8955</td><td>0.31</td><td>0.8606</td></tr><tr><td>Adjective</td><td>0.29</td><td>2.0929</td><td>0.24</td><td>1.1181</td></tr><tr><td>Verb</td><td>0.15</td><td>1.5963</td><td>0.12</td><td>1.9121</td></tr><tr><td>Numeral</td><td>0.13</td><td>1.9246</td><td>0.11</td><td>1.5943</td></tr><tr><td>Adverb</td><td>0.03</td><td>0.9313</td><td>0.01</td><td>1.0077</td></tr></table>
|
| 120 |
+
|
| 121 |
+
Table 2: Average Attack Success Rate (ASR) and average Semantic Shift Rate (SemSR) of both unrestricted and restricted attack on each POS Tag. The higher the values, the better. The highest values are bold marked.
|
| 122 |
+
|
| 123 |
+
Quantitative Evaluation. Table 2 presents the ASR and SemSR metrics, which are the average values across 100 data points for each POS tag.
|
| 124 |
+
|
| 125 |
+
<table><tr><td rowspan="2">POS Tag</td><td colspan="2">Unrestricted Attack</td><td colspan="2">Restricted Attack</td></tr><tr><td>Input</td><td>Target</td><td>Input</td><td>Target</td></tr><tr><td>Noun</td><td>0.13</td><td>0.87</td><td>0.27</td><td>0.73</td></tr><tr><td>Proper Noun</td><td>0.47</td><td>0.53</td><td>0.53</td><td>0.47</td></tr><tr><td>Adjective</td><td>0.67</td><td>0.33</td><td>0.53</td><td>0.47</td></tr><tr><td>Verb</td><td>0.73</td><td>0.27</td><td>0.67</td><td>0.20</td></tr><tr><td>Numeral</td><td>0.20</td><td>0.13</td><td>0.20</td><td>0.13</td></tr><tr><td>Adverb</td><td>0.93</td><td>0.07</td><td>0.87</td><td>0</td></tr></table>
|
| 126 |
+
|
| 127 |
+
Table 3: Human evaluation results on the matching of input and target text with the generated images for each POS tag in both unrestricted and restricted settings.
|
| 128 |
+
|
| 129 |
+
Higher ASR and SemSR values indicate better performance. From the table, we observe that in the case of the unrestricted attack, both ASR and SemSR surpass those of the restricted attack except for verb and adverb POS tags. This suggests that allowing the target token to be part of the concatenated adversarial suffix tokens leads to greater success in adversarial attacks. Clearly, the unrestricted attack excels in producing images containing the target POS token instead of the input POS token. We also observe that in both the restricted and unrestricted attacks, nouns demonstrate higher ASR values compared to other POS tags, implying their greater vulnerability to adversarial attacks. Proper nouns and adjectives show moderate success rates, while verbs and numerals exhibit lower success rates. Adverbs, on the other hand, have the lowest success rates in both types of attacks, indicating their higher resistance to adversarial manipulation. SemSR values quantify the semantic disparity between a text and its corresponding generated image caused by an adversarial attack. Higher SemSR values signify substantial semantic shifts. By analyzing SemSR values, we find that attacking nouns and adjectives is comparatively simpler, whereas adverbs present greater difficulty. This suggests that nouns and adjectives undergo more significant semantic alterations, while adverbs experience the least. Moreover, SemSR values remain relatively stable across various POS tags for both unrestricted and restricted attacks. However, with unrestricted attack, adjectives exhibit the greatest semantic shifts, which is not the case with restricted attack. Numerals consistently show the second-highest semantic changes across both attack types.
|
| 130 |
+
|
| 131 |
+
Human Evaluation. We evaluate the attack's effectiveness with the assistance of two annotators. We randomly choose 15 prompt pairs for each POS tag,
|
| 132 |
+
|
| 133 |
+
amounting to a total of 90 prompt pairs for both unrestricted and restricted attack settings. Each prompt pair is presented with 7 images to the annotators (as 7 images were generated per run in our experiments), who then assess whether at least 4 images closely align with either the target prompt or the input prompt (Yes/No). We collect evaluations from the annotators using a Google Form (Appendix J), which includes the generated image and two checkboxes for the input text and target text. We determine the score of an annotator by the number of prompt pairs they classify as a match. Since there are two evaluators, we calculate the average of their scores and present the results in Table 3. The table indicates that annotators agree that verbs, adverbs, and numerals are more resistant to adversarial attacks. In the case of numerals, the annotators reported that the majority of the postattack generated images do not align with either the target or the input prompts. We observe that unrestricted attack tends to generate images that more closely match the target prompt than the restricted attack. We used Cohen's Kappa $(\kappa)$ metrics (Cohen, 1960) to measure annotator agreement on target text-image matching, obtaining scores of 0.796 for unrestricted and 0.745 for restricted settings, which indicate a high degree of agreement.
|
| 134 |
+
|
| 135 |
+
From Table 2 and 3, we observe that the average ASR shows a strong positive correlation with human evaluation of target text-image matching in both the unrestricted setting (Pearson $= 0.988$ and Spearman $= 1.00$ ) and the restricted setting (Pearson $= 0.980$ and Spearman $= 0.986$ ). On the other hand, the average SemSR exhibits a very weak negative correlation with human evaluation in both unrestricted attack scenario (Pearson $= -0.126$ and Spearman $= -0.143$ ), and restricted attack scenario (Pearson $= -0.176$ and Spearman $= -0.087$ ). Given that the average ASR has higher correlations with human judgment in both settings, it is more reliable than average SemSR for evaluating the success of attacking POS tags. Therefore, we use ASR to evaluate attack success in all subsequent sections.
|
| 136 |
+
|
| 137 |
+
# 5 Attack Success Mechanism
|
| 138 |
+
|
| 139 |
+
In this section, we explore the mechanism behind the steering effect of adversarial suffixes. We identify (a) features that vary across POS categories and explain differences in attack success rates (ASR), such as the number of critical tokens and content fusion, and (b) features that are consistent across
|
| 140 |
+
|
| 141 |
+
<table><tr><td rowspan="2">POS Tag</td><td colspan="3">Unrestricted</td><td colspan="3">Restricted</td></tr><tr><td>Number of Successful Attack</td><td>Avg no. of critical tokens</td><td>Avg ASR by removing critical tokens</td><td>Number of Successful Attack</td><td>Avg no. of critical tokens</td><td>Avg ASR by removing critical tokens</td></tr><tr><td>Noun</td><td>65</td><td>7.800</td><td>0.195</td><td>51</td><td>8.902</td><td>0.136</td></tr><tr><td>Proper Noun</td><td>40</td><td>8.175</td><td>0.175</td><td>31</td><td>8.935</td><td>0.115</td></tr><tr><td>Adjective</td><td>29</td><td>7.862</td><td>0.173</td><td>24</td><td>8.960</td><td>0.111</td></tr><tr><td>Verb</td><td>15</td><td>8.200</td><td>0.166</td><td>12</td><td>9.000</td><td>0.076</td></tr><tr><td>Numeral</td><td>13</td><td>8.615</td><td>0.150</td><td>11</td><td>9.180</td><td>0.034</td></tr><tr><td>Adverb</td><td>3</td><td>9.000</td><td>0.078</td><td>1</td><td>10.000</td><td>0</td></tr></table>
|
| 142 |
+
|
| 143 |
+
Table 4: Comparison of the average attack success rates (ASR) by removing critical tokens across different POS tags, under all unrestricted and restricted successful attack examples.
|
| 144 |
+
|
| 145 |
+
different POS categories and do not explain variations in ASR rates, but provide general insights such as suffix transferability.
|
| 146 |
+
|
| 147 |
+
Correlation between the number of critical tokens in adversarial suffixes and ASR. A successful attack demonstrates that appending an adversarial suffix to an input prompt effectively shifts the text embedding toward the target prompt, highlighting the significant role of the suffix tokens. To investigate, we tokenized several adversarial suffixes, generated an image for each token to isolate their contributions, and found that some tokens generate images associated with the target POS token. This observation led us to identify the most contributing tokens within adversarial suffixes. We define "critical tokens" as those whose removal causes the attack to fail. To determine critical tokens in
|
| 148 |
+
|
| 149 |
+

|
| 150 |
+
Figure 2: Average length of critical tokens across different POS tags in unrestricted and restricted settings. Exponential trend lines are included for both settings to highlight the general pattern.
|
| 151 |
+
|
| 152 |
+
a suffix, we generated all possible combinations of replacing suffix tokens with <lendoftext> token. For each combination, we generated an image and queried the pre-trained vision-language model
|
| 153 |
+
|
| 154 |
+
BLIP $^1$ (Li et al., 2022) to check if the generated image matched the target prompt. We identified the combination with the fewest tokens replaced by $<\text{lendoftext}|$ and considered those tokens as critical since their absence leads to an unsuccessful attack. Tokens not replaced by $<\text{lendoftext}|$ were considered non-critical.
|
| 155 |
+
|
| 156 |
+
We present the average number of critical tokens across all POS tags in Table 4 and compare the lengths of critical tokens in Figure 2. The number of critical tokens is generally higher across POS categories in both attack settings. However, the restricted setting shows significantly higher numbers of critical tokens, as the absence of the target word necessitates other tokens to compensate and maintain the attack's effectiveness. We find that adverbs, numerals, and verbs are more resistant to adversarial attacks due to their dependency on the high number of critical tokens in the suffixes. This prompted us to explore whether every critical token within a suffix contributes equally to the attack's success. Therefore, removing some or all critical tokens from the suffixes should notably decrease the ASR. To test this in both settings, we removed critical tokens from the suffixes in all possible combinations while keeping the non-critical tokens unchanged. We then calculated the ASR for each combination by querying BLIP and took the average. We find that the ASR significantly decreases across POS categories. Table 4 shows that adverbs, numerals, and verbs are the hardest to attack due to their reliance on a higher number of critical tokens, resulting in a significantly lower ASR when these tokens are removed. However, nouns, proper nouns, and adjectives are relatively
|
| 157 |
+
|
| 158 |
+
easier to attack. Despite having a substantial number of critical tokens, the ASR for these categories remains moderately high when critical tokens are removed but still shows a significant drop. For instance, in the unrestricted setting, the attack success rate drops from 65 (total successful attacks) to around 13 $(0.195 * 65)$ when critical tokens are removed. Thus, we conclude that the number of critical tokens in adversarial suffixes is highly associated with ASR. Some POS tags are harder to attack because the attack algorithm must find adversarial suffixes with a higher number of critical tokens.
|
| 159 |
+
|
| 160 |
+
Ease of Content Fusion. We observe that while adversarial suffixes steer the generation of target attributes, they often fail to completely remove the original token. This results in images generated by the Stable Diffusion containing both the input and target attributes, a phenomenon we refer to as content fusion. We found that content fusion across different POS categories decreases with decreasing ASR. For example, when attempting to change a noun like "car" to "motorcycle", the resulting image often contains both the car and the motorcycle. For a proper noun, changing a "Santa costume" to a "Halloween costume" might result in a Santa costume with Halloween-themed colors. With adjectives, trying to change a "white swan" to a "black swan" can lead to an image of a swan that is both black and white. We showcase examples of adjective fusion in Appendix I. In contrast, verbs are harder to mix or generate together; for instance, it is difficult to create an image where a person is both standing and lying down. Similarly, in the case of numerals, attempting to change "three apples" to "five apples" often fails to produce an image with both three and five apples. With adverbs, changing "running quickly" to "running slowly" does not result in an image that simultaneously depicts both quick and slow running. We posit that this varying ease of content fusion is due to the number of critical tokens associated with ASR. In categories like nouns, proper nouns, and adjectives, where the number of critical tokens is relatively lower, fusion is easier. However, in categories with a higher number of critical tokens, such as verbs, numerals, and adverbs, fusion is not possible.
|
| 161 |
+
|
| 162 |
+
Suffix Transferability. We discovered a common feature across different POS categories: the transferability of adversarial suffixes. We observed that the identified adversarial suffixes can universally transfer to other input prompts within the same
|
| 163 |
+
|
| 164 |
+
POS tag. This indicates that a single adversarial suffix can convert various input prompts with distinct attributes into images with the same target attributes. For example, an adversarial suffix targeting the noun "motorcycle" can prompt the model to generate motorcycle images from diverse noun prompts like "plane", "car", and "bird". We present some examples in Appendix G (Figure 10). Additionally, to explain why such universal transferability works, we demonstrate by following the approach of (Du et al., 2024) that the adversarial suffix alone can dictate the output of the Stable Diffusion by steering the generated image toward the target prompt. At first, we divide a successful adversarial prompt into two segments: the input prompt and the adversarial suffix. Then we extract text embeddings of both the input prompt and the suffix separately. This step ensures that each segment is processed into its own embedding without influence from the other segment. The embeddings of the input prompt and the suffix are then concatenated. Concatenation $(\oplus)$ means joining these two embeddings into a single combined embedding that the Stable Diffusion will use for image generation. We observe that the final image generated by Stable Diffusion using the concatenated text embedding matches the target prompt. We repeat this procedure for all successful attack examples and find consistent results across all POS tags. Further details can be found in Appendix G.
|
| 165 |
+
|
| 166 |
+
# 6 Conclusion
|
| 167 |
+
|
| 168 |
+
In this study, we evaluate a gradient-based adversarial attack aimed at six POS tags within text prompts in both unrestricted and restricted attack strategies. We assess the impact of these attacks on the Stable Diffusion, revealing valuable insights into the factors contributing to their success. Our findings reveal that nouns, proper nouns, and adjectives are particularly vulnerable to perturbation, resulting in adversarial image generation. However, we see that verbs, adverbs, and numerals exhibit a higher level of resilience against adversarial attack, exerting minimal influence on the visual output generated by the Stable Diffusion. We hypothesize that the number of critical tokens in an adversarial suffix and the ease of content fusion are primarily responsible for such resilience against attacks. We believe these findings will be valuable for enhancing the robustness of T2I generation systems.
|
| 169 |
+
|
| 170 |
+
# 7 Limitations
|
| 171 |
+
|
| 172 |
+
We utilized the Stable Diffusion model for the gradient-based attack. It is important to note that the attack approach might not generalize effectively to other closed-source T2I generation models likeImagen (Saharia et al., 2022) or DALL-E2 (Ramesh et al., 2022), owing to differences in architecture, text encoder, and training data. Moreover, the metrics utilized in this study to assess the attack may not fully capture the visual plausibility or semantic accuracy of images after the attack. We evaluated the attack only on six specific POS tags, which may not encompass all possible scenarios, such as prepositions, conjunctions, interjections, articles, and determiners. Furthermore, the approach relies on appending suffix tokens to the original prompt, which may not always be the most optimal method for manipulating the image generation process, considering the T2I model's sensitivity to the order of tokens. As the appended adversarial suffix tokens may lack meaning, the resulting adversarial prompt found by the attack methods exhibits reduced naturalness.
|
| 173 |
+
|
| 174 |
+
# References
|
| 175 |
+
|
| 176 |
+
Yogesh Balaji, Seungjun Nah, Xun Huang, Arash Vahdat, Jiaming Song, Qinsheng Zhang, Karsten Kreis, Miika Aittala, Timo Aila, Samuli Laine, et al. 2022. ediff-i: Text-to-image diffusion models with an ensemble of expert denoisers. arXiv preprint arXiv:2211.01324.
|
| 177 |
+
Steven Bird. 2006. NLTK: The Natural Language Toolkit. In Proceedings of the COLING/ACL 2006 Interactive Presentation Sessions, pages 69-72, Sydney, Australia. Association for Computational Linguistics.
|
| 178 |
+
Hila Chefer, Yuval Alaluf, Yael Vinker, Lior Wolf, and Daniel Cohen-Or. 2023. *Attend-and-excite: Attention-based semantic guidance for text-to-image diffusion models*. ACM Transactions on Graphics (TOG), 42(4):1-10.
|
| 179 |
+
Mehdi Cherti, Romain Beaumont, Ross Wightman, Mitchell Wortsman, Gabriel Ilharco, Cade Gordon, Christoph Schuhmann, Ludwig Schmidt, and Jenia Jitsev. 2023. Reproducible scaling laws for contrastive language-image learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2818-2829.
|
| 180 |
+
Jacob Cohen. 1960. A coefficient of agreement for nominal scales. Educational and psychological measurement, 20(1):37-46.
|
| 181 |
+
|
| 182 |
+
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2019. BERT: Pre-training of deep bidirectional transformers for language understanding. 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 4171-4186, Minneapolis, Minnesota. Association for Computational Linguistics.
|
| 183 |
+
Prafulla Dhariwal and Alexander Nichol. 2021. Diffusion models beat gans on image synthesis. Advances in neural information processing systems, 34:8780-8794.
|
| 184 |
+
Chengbin Du, Yanxi Li, Zhongwei Qiu, and Chang Xu. 2024. Stable diffusion is unstable. Advances in Neural Information Processing Systems, 36.
|
| 185 |
+
Christiane Fellbaum. 2010. Wordnet. In Theory and applications of ontology: computer applications, pages 231-243. Springer.
|
| 186 |
+
Hongcheng Gao, Hao Zhang, Yinpeng Dong, and Zhijie Deng. 2023. Evaluating the robustness of text-to-image diffusion models against real-world attacks. arXiv preprint arXiv:2306.13103.
|
| 187 |
+
Junnan Li, Dongxu Li, Caiming Xiong, and Steven Hoi. 2022. Blip: Bootstrapping language-image pretraining for unified vision-language understanding and generation. In International conference on machine learning, pages 12888-12900. PMLR.
|
| 188 |
+
Chumeng Liang, Xiaoyu Wu, Yang Hua, Jiaru Zhang, Yiming Xue, Tao Song, Zhengui Xue, Ruhui Ma, and Haibing Guan. 2023. Adversarial example does good: Preventing painting imitation from diffusion models via adversarial examples. In Proceedings of the 40th International Conference on Machine Learning, volume 202 of Proceedings of Machine Learning Research, pages 20763-20786. PMLR.
|
| 189 |
+
Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dólar, and C Lawrence Zitnick. 2014. Microsoft coco: Common objects in context. In Computer Vision-ECCV 2014: 13th European Conference, Zurich, Switzerland, September 6-12, 2014, Proceedings, Part V 13, pages 740-755. Springer.
|
| 190 |
+
Qihao Liu, Adam Kortylewski, Yutong Bai, Song Bai, and Alan Yuille. 2023. Discovering failure modes of text-guided diffusion models via adversarial search. In The Twelfth International Conference on Learning Representations.
|
| 191 |
+
Natalie Maus, Patrick Chao, Eric Wong, and Jacob Gardner. 2023. Black box adversarial prompting for foundation models. arXiv preprint arXiv:2302.04237.
|
| 192 |
+
Raphael Milliere. 2022. Adversarial attacks on image generation with made-up words. arXiv preprint arXiv:2208.04135.
|
| 193 |
+
|
| 194 |
+
Alex Nichol, Prafulla Dhariwal, Aditya Ramesh, Pranav Shyam, Pamela Mishkin, Bob McGrew, Ilya Sutskever, and Mark Chen. 2021. Glide: Towards photorealistic image generation and editing with text-guided diffusion models. arXiv preprint arXiv:2112.10741.
|
| 195 |
+
Dustin Podell, Zion English, Kyle Lacey, Andreas Blattmann, Tim Dockhorn, Jonas Müller, Joe Penna, and Robin Rombach. 2023. Sdxl: Improving latent diffusion models for high-resolution image synthesis. arXiv preprint arXiv:2307.01952.
|
| 196 |
+
Ilan Price, Jordan Gifford-Moore, Jory Fleming, Saul Musker, Maayan Roichman, Guillaume Sylvain, Nithum Thain, Lucas Dixon, and Jeffrey Sorensen. 2020. Six attributes of unhealthy conversation. arXiv preprint arXiv:2010.07410.
|
| 197 |
+
Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. 2021. Learning transferable visual models from natural language supervision. In International conference on machine learning, pages 8748-8763. PMLR.
|
| 198 |
+
Alec Radford, Jeff Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. 2019. Language models are unsupervised multitask learners.
|
| 199 |
+
Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. 2022. Hierarchical text-conditional image generation with clip latents. arXiv preprint arXiv:2204.06125, 1(2):3.
|
| 200 |
+
Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. 2022. High-resolution image synthesis with latent diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 10684-10695.
|
| 201 |
+
Chitwan Sahara, William Chan, Saurabh Saxena, Lala Li, Jay Whang, Emily L Denton, Kamyar Ghasemipour, Raphael Gontijo Lopes, Burcu Karagol Ayan, Tim Salimans, et al. 2022. Photorealistic text-to-image diffusion models with deep language understanding. Advances in neural information processing systems, 35:36479-36494.
|
| 202 |
+
Hassan Sajjad, Nadir Durrani, Fahim Dalvi, Firoj Alam, Abdul Khan, and Jia Xu. 2022. Analyzing encoded concepts in transformer language models. In Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 3082-3101, Seattle, United States. Association for Computational Linguistics.
|
| 203 |
+
Hadi Salman, Alaa Khaddaj, Guillaume Leclerc, Andrew Ilyas, and Aleksander Madry. 2023. Raising the cost of malicious ai-powered image editing. arXiv preprint arXiv:2302.06588.
|
| 204 |
+
|
| 205 |
+
Haz Sameen Shahgir, Xianghao Kong, Greg Ver Steeg, and Yue Dong. 2023. Asymmetric bias in text-to-image generation with adversarial attacks. arXiv preprint arXiv:2312.14440.
|
| 206 |
+
Raphael Tang, Linqing Liu, Akshit Pandey, Zhiying Jiang, Gefei Yang, Karun Kumar, Pontus Stenetorp, Jimmy Lin, and Ferhan Ture. 2023. What the DAAM: Interpreting stable diffusion using cross attention. In Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 5644-5659, Toronto, Canada. Association for Computational Linguistics.
|
| 207 |
+
Laurens Van der Maaten and Geoffrey Hinton. 2008. Visualizing data using t-sne. Journal of machine learning research, 9(11).
|
| 208 |
+
Dingcheng Yang, Yang Bai, Xiaojun Jia, Yang Liu, Xiaochun Cao, and Wenjian Yu. 2024a. Cheating suffix: Targeted attack to text-to-image diffusion models with multi-modal priors. arXiv preprint arXiv:2402.01369.
|
| 209 |
+
Yuchen Yang, Bo Hui, Haolin Yuan, Neil Gong, and Yinzhi Cao. 2024b. Sneakyprompt: Jailbreaking text-to-image generative models. In 2024 IEEE Symposium on Security and Privacy (SP), pages 123-123. IEEE Computer Society.
|
| 210 |
+
Shengfang Zhai, Weilong Wang, Jiajun Li, Yinpeng Dong, Hang Su, and Qingni Shen. 2024. Discovering universal semantic triggers for text-to-image synthesis. arXiv preprint arXiv:2402.07562.
|
| 211 |
+
Haomin Zhuang, Yihua Zhang, and Sijia Liu. 2023. A pilot study of query-free adversarial attack against stable diffusion. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2384-2391.
|
| 212 |
+
Andy Zou, Zifan Wang, J Zico Kolter, and Matt Fredrikson. 2023. Universal and transferable adversarial attacks on aligned language models. arXiv preprint arXiv:2307.15043.
|
| 213 |
+
|
| 214 |
+
# Appendix
|
| 215 |
+
|
| 216 |
+
# A Preliminaries of Stable Diffusion
|
| 217 |
+
|
| 218 |
+
Stable diffusion is a latent diffusion model comprising three key components: a Variational Autoencoder (VAE), a UNet, and a CLIP text encoder (Radford et al., 2021) for conditioning. The VAE consists of an encoder $E$ and a decoder $D$ where the encoder compresses an image $y$ into a lower-dimensional latent space representation $E(y)$ , while the decoder reconstructs the image from the latent space $\bar{y} = D(E(y))$ . During the T2I generation process, at first CLIP tokenizer tokenizes a text prompt into a sequence of tokens $W = \{w_{1}, w_{2}, \dots, w_{n}\}$ , ensuring uniform length by
|
| 219 |
+
|
| 220 |
+

|
| 221 |
+
Figure 3: Schematic view of the POS-Attack pipeline. At first, hidden state representations from the CLIP text encoder using input and target token embeddings are extracted. Then, we compute loss, take gradients, and select the top-k candidate tokens for substitution. Next, we create several candidate prompts by randomly replacing multiple tokens from the pool. The candidate prompt maximizing a score function is chosen for the next optimization step.
|
| 222 |
+
|
| 223 |
+
padding or truncating sequences to 77 tokens for computational ease. Each token is then converted into a text representation $W_{emb}$ using the text encoder of CLIP. CLIP comprises both an image encoder and a text encoder, each responsible for encoding an image and its corresponding text description into representations that closely align with one another. As a result, the text representation $W_{emb}$ generated by CLIP's text encoder for a given text prompt is expected to contain relevant information about the images described in the prompt. Next, a random latent image representation $I_0$ , drawn from a Gaussian distribution is created, and noise is gradually eliminated to get a noise-free representation $E(y) = I_{emb}$ through a reverse diffusion process. Guided by the latent text embedding $W_{emb}$ , a UNet neural network $U(I_0, W_{emb}, t)$ employs a cross-attention mechanism to predict and eliminate noise from the latent space $E(y)$ at each time step $t$ . The level of noise reduction is regulated by a scheduler, progressively refining image quality. Finally, the VAE decoder $D$ upscales the latent image $E(y)$ back into pixel space, resulting in a high-resolution image $\bar{y}$ .
|
| 224 |
+
|
| 225 |
+
# B Details of Adversarial Attack
|
| 226 |
+
|
| 227 |
+
Adversarial Prompt Generation. We start the process by considering the input prompt as the adversarial prompt. Subsequently, we extract the embeddings for both the adversarial prompt tokens and the target prompt tokens. These embeddings
|
| 228 |
+
|
| 229 |
+

|
| 230 |
+
Figure 4: Examples of vulnerabilities revealed by SD model with prompts containing adverbs and proper nouns.
|
| 231 |
+
|
| 232 |
+

|
| 233 |
+
|
| 234 |
+
are then fed into the CLIP text encoder to obtain the final hidden state representations. Following this, we compute the loss using a loss function and calculate gradients with respect to one hot token vector to determine the top-k candidate tokens for substitution. Then, we generate several candidate prompts by randomly replacing multiple tokens of the initial adversarial prompt from the pool of candidate tokens. The candidate prompt that maximizes the score function is chosen as the adversarial prompt for the subsequent optimization step. This iterative process continues for a set number of iterations until a final adversarial prompt is obtained. Notably, this attack method relies only on the text encoder and does not necessitate access to the image generation model. An illustration of the adversarial attack is depicted in Figure 3. From the adversary's viewpoint, the concatenated suffix tokens in the adversarial prompt should be nonsensical to humans yet encode specific semantics predetermined by the adversary.
|
| 235 |
+
|
| 236 |
+
Loss Function. The attack focuses on manipulating the CLIP embedding space to optimize a score function, which quantifies how much the adversarial token embeddings at an intermediate optimization stage deviate towards the target token embeddings using cosine similarity. The objective is to steer away from the embeddings of input tokens and progressively approach those of the target tokens by discovering more effective adversarial tokens. This process of maximizing the score function is similar to Shahgir et al. (2023). To compute the loss, we adopt the negated score function. Maximizing the score is equivalent to minimizing the loss.
|
| 237 |
+
|
| 238 |
+
Gradient-based Search. The attack employs an effective greedy coordinated gradient-based search algorithm (Zou et al., 2023), utilizing the loss function discussed above. At each optimization step, the algorithm selects $k$ tokens with the highest negative loss and computes gradients with respect to
|
| 239 |
+
|
| 240 |
+

|
| 241 |
+
Figure 5: Examples of vulnerabilities revealed by SD model with numerals. Each row contains 10 images with numerals one to ten from left to right sequentially. The first row contains ten images of the prompt “_ bears lying in the field” where __ is replaced by “one” to “ten” serially. Similarly, the second, third, and fourth rows contain prompts “_ birds looking around while on the ground”, “_ cows eating grass” and “_ sheep roaming in the field”.
|
| 242 |
+
|
| 243 |
+
the one-hot token vectors to identify a promising set of candidates for replacing adversarial suffix token positions. New candidate prompts are generated by randomly replacing multiple token positions using the pool of token candidates, repeating this process $T$ times. Following the approach of Shahgir et al. (2023), we initially replace all tokens and then gradually reduce the replacement rate to $20\%$ .
|
| 244 |
+
|
| 245 |
+
# C Vulnerabilities Observed across POS Tags
|
| 246 |
+
|
| 247 |
+
In this section, we present some vulnerabilities observed on Stable Diffusion across a few POS tags. We noticed that the SD model inherently faces difficulty generating images from prompts that include numerals. Specifically, the model struggles to produce images with a precise count of identical objects. For instance, if the prompt is to generate an image of five birds, the SD model will fail to create exactly five birds and instead produce images with a random number of birds, such as three, four, or more than five. Examples of this issue are shown in Figure 5. Images generated by the model using prompts where the adverb tokens have shared linguistic structures, close semantic representation in the feature space, and unrelated to emotions generally have minimal impact on visual output. We show such an example in Figure 4(a). In this example, substituting "beautifully" with "partly" in
|
| 248 |
+
|
| 249 |
+
the prompt “a bench that is beautifully shaded by a tree” results in close perplexity<sup>2</sup> scores for the first (128.18) and second prompts (123.49). exhibit little difference. Furthermore, we observed that the SD model struggles to generate images involving logos, such as those of Microsoft, Disney, or Google. As shown in Figure 4(b), instead of producing accurate images, the model generates images with misspelled words as logos.
|
| 250 |
+
|
| 251 |
+
# D Impact of Semantic Distance on Attack Success
|
| 252 |
+
|
| 253 |
+
In this section, we examine why certain POS tags are easier to attack by considering the impact of semantic distance. To explore this, we plotted text embeddings of all the data across six POS tags from the dataset in Figure 6 using t-Distributed Stochastic Neighbor Embedding (t-SNE) (Van der Maaten and Hinton, 2008). Nouns, proper nouns, and adjectives show clear clustering with visible distances between markers, indicating considerable differences in their text embeddings. This distance allows the gradient algorithm to minimize the gap from input to target, making attacks on these POS tags easier. However, for numerals, verbs, and adverbs, the markers are very close or even overlapping, indicating that the input and target prompts have similar semantic representations. This prox
|
| 254 |
+
|
| 255 |
+

|
| 256 |
+
Noun
|
| 257 |
+
|
| 258 |
+

|
| 259 |
+
Proper Noun
|
| 260 |
+
|
| 261 |
+

|
| 262 |
+
Adjective
|
| 263 |
+
|
| 264 |
+

|
| 265 |
+
Verb
|
| 266 |
+
|
| 267 |
+

|
| 268 |
+
Numeral
|
| 269 |
+
|
| 270 |
+

|
| 271 |
+
Adverb
|
| 272 |
+
Figure 6: Visual representation of text embeddings of all input-target prompt pairs across six POS tags in 2D space. Blue marker is for input prompt, yellow indicates target prompt, green for inherent bias inducing prompt, and red for prompt where the target word is removed.
|
| 273 |
+
|
| 274 |
+
imity hampers the algorithm's ability to optimize the distance gap, leading to lower attack success rates.
|
| 275 |
+
|
| 276 |
+

|
| 277 |
+
a purple cup on a table.76 ia
|
| 278 |
+
|
| 279 |
+

|
| 280 |
+
a purple cup on a table. $\backslash 1$ v46
|
| 281 |
+
|
| 282 |
+

|
| 283 |
+
a purple cup on a table. m w d 46? y $^ \text{念}$ -# $\backslash \langle q4c02\rangle$
|
| 284 |
+
purple $\rightarrow$ yellow
|
| 285 |
+
Figure 7: Examples of adversarial attack on Adjective using ASCII/non-alphabetic characters.
|
| 286 |
+
|
| 287 |
+

|
| 288 |
+
a purple cup on a table. $ 4 x 8$18 > 5 > 8 v/s)%y &/.3$; 4 x 818, d! $4, o (m $8 y $7x);
|
| 289 |
+
|
| 290 |
+
# E Attack using ASCII/non-alphabetic characters
|
| 291 |
+
|
| 292 |
+
We evaluated the adversarial attack by limiting it to adding only ASCII or non-alphabetic characters at the end of the input prompt. However, these
|
| 293 |
+
|
| 294 |
+
attempts were unsuccessful. We conducted experiments by adding 5, 20, and 50 adversarial characters to a text prompt containing an adjective token, yet there was no alteration in the resulting image. In all three scenarios, we noticed that even with the addition of characters, the SD continued to generate images identical to those generated from the original input prompt. We present a few examples in Figure 7.
|
| 295 |
+
|
| 296 |
+
# F Attack Transferability
|
| 297 |
+
|
| 298 |
+
We employed Stable Diffusion v1-5, utilizing CLIP ViT-L/14 (Radford et al., 2021) as the pre-trained text encoder, for both unrestricted and restricted attack methods. Our investigation reveals that adversarial suffixes generated with this version of SD are ineffective when applied to Stable Diffusion v2-1, which uses a different pre-trained text encoder, OpenCLIP-ViT/H (Cherti et al., 2023). However, we note that the attacks successfully transfer to Stable Diffusion v1-4. Examples generated using SD v1-4 are presented in Figure 8.
|
| 299 |
+
|
| 300 |
+

|
| 301 |
+
a very cute teddy bear holding a pen. Brigitte entire biblidar burden goodreads muhinstrutor spinrilla
|
| 302 |
+
white $\longrightarrow$ black
|
| 303 |
+
|
| 304 |
+

|
| 305 |
+
pen $\longrightarrow$ book
|
| 306 |
+
a young boy wearing a batman costume while riding a skateboard, packaged uclashaggy drew superman paired superman you explore selfcare
|
| 307 |
+
curly $\longrightarrow$ thick
|
| 308 |
+
|
| 309 |
+

|
| 310 |
+
batman $\longrightarrow$ superman
|
| 311 |
+
floating $\longrightarrow$ flying
|
| 312 |
+
black duck floating in a wavy pond. airborne landing three novice konrobin livery
|
| 313 |
+
three $\longrightarrow$ two
|
| 314 |
+
|
| 315 |
+

|
| 316 |
+
a white swan on a lake. black sements gaga tiazelle shares zalbraving scratches water
|
| 317 |
+
Figure 8: Some examples of successful attack on Stable Diffusion v1-4.
|
| 318 |
+
|
| 319 |
+

|
| 320 |
+
a white curly-haired dog standing in a hallway. X urged forestation montyalistair maltese hallelbulldogs notices generate
|
| 321 |
+
three birds are looking around while on the ground. partnership rivals moulin 3 angled exchanges bharatscoring blueslyrix
|
| 322 |
+
|
| 323 |
+

|
| 324 |
+
|
| 325 |
+

|
| 326 |
+
a white swan on a lake.
|
| 327 |
+
(a) Input prompt
|
| 328 |
+
|
| 329 |
+

|
| 330 |
+
black sements gaga tiazzle shares
|
| 331 |
+
zalbraving scratches water
|
| 332 |
+
(b) suffix
|
| 333 |
+
|
| 334 |
+

|
| 335 |
+
(c) Image after concatenation
|
| 336 |
+
|
| 337 |
+

|
| 338 |
+
|
| 339 |
+

|
| 340 |
+
|
| 341 |
+

|
| 342 |
+
(d) DAAM heatmap on suffix
|
| 343 |
+
|
| 344 |
+

|
| 345 |
+
|
| 346 |
+

|
| 347 |
+
(e) Input prompt
|
| 348 |
+
|
| 349 |
+

|
| 350 |
+
coz ravens kbs yourself >>>> sportscenter crow reminded):
|
| 351 |
+
(f) suffix
|
| 352 |
+
|
| 353 |
+

|
| 354 |
+
(g) Image after concatenation
|
| 355 |
+
|
| 356 |
+

|
| 357 |
+
Figure 9: Examples demonstrating how the adversarial suffix independently dictates the SD model's output.
|
| 358 |
+
|
| 359 |
+

|
| 360 |
+
(h) DAAM heatmap on suffix
|
| 361 |
+
|
| 362 |
+

|
| 363 |
+
|
| 364 |
+

|
| 365 |
+
|
| 366 |
+
using the concatenated text embedding. As the suffix tokens are largely nonsensical, we employed DAAM (Tang et al., 2023) to generate word attribution heatmap in order to delineate which suffix words correspond to which portion of the suffix image, as shown in Figure 9(d). Similarly, we repeat the procedure for the restricted setting in Figure $9(\mathrm{e - g})$
|
| 367 |
+
|
| 368 |
+

|
| 369 |
+
A big plane gets ready to take off. motorcycle generating ur according bike
|
| 370 |
+
|
| 371 |
+

|
| 372 |
+
A big car gets ready to take off. motorcycle generating ur according y bike imaginefriday street cruiser
|
| 373 |
+
|
| 374 |
+

|
| 375 |
+
A big bird gets ready to take off. motorcycle generating ur according bike imaginefriday street cruiser
|
| 376 |
+
|
| 377 |
+

|
| 378 |
+
A dog on a Santa hat on a pillow tbd halloween becomes rivals grandstand helmets becomes pumpkin aided xj
|
| 379 |
+
|
| 380 |
+

|
| 381 |
+
A dog on a Floppy hat on a pillow. tbd hallowen becomes rivals grandstand helmets becomes pumpkin aided xj
|
| 382 |
+
|
| 383 |
+

|
| 384 |
+
A dog on a Cowboy hat on a pillow. tbd hallowes becomes rivals grandstand helmets becomes pumpkin aided xi
|
| 385 |
+
|
| 386 |
+

|
| 387 |
+
A cat napping inside of a largeplanter. manish iness ' birthdayhis courageous gazing ’ studying
|
| 388 |
+
|
| 389 |
+

|
| 390 |
+
A cat jumping inside of a large planter: manish inness ' birthday his courageous gazing ' studying
|
| 391 |
+
|
| 392 |
+

|
| 393 |
+
A cat running inside of a large planter. manish iness $^\ddagger$ birthday his courageous gazing $\ddagger$ studying
|
| 394 |
+
|
| 395 |
+

|
| 396 |
+
A purple cup on a table.
|
| 397 |
+
manuscript potted oh
|
| 398 |
+
fortunes discusses turquoscreen
|
| 399 |
+
dell mods
|
| 400 |
+
|
| 401 |
+

|
| 402 |
+
A green cup on a table.
|
| 403 |
+
manuscript potted oh
|
| 404 |
+
nes discusses turquoscreen
|
| 405 |
+
dell mods
|
| 406 |
+
Figure 10: Examples of adversarial suffix transferability. The top two rows are the examples of noun and proper noun POS tags in unrestricted settings where the target words are "motorcycle" and "Halloween" respectively. The last two rows correspond to the examples of verb and adjective POS tags in restricted settings where the target words are "watching" and "blue" respectively.
|
| 407 |
+
|
| 408 |
+

|
| 409 |
+
A yellow cup on a table. manuscript potted ohunes discusses turquoscreen dell modis
|
| 410 |
+
|
| 411 |
+
# G Examples of Suffix Transferability
|
| 412 |
+
|
| 413 |
+
We provide a successful attack example in Figure 9 where the input and target prompts are "a white swan on a lake." and "a black swan on a lake." respectively. Figure 9(a - d) represents the unrestricted setting. Figure 9(a) and 9(b) represent the images generated by the SD model using the text embedding of the input prompt and the suffix respectively while 9(c) is the final image generated
|
| 414 |
+
|
| 415 |
+

|
| 416 |
+
Figure 11: Few examples of successful attacks on out-of-dataset instances for each POS tag.
|
| 417 |
+
|
| 418 |
+
# I Some Examples of Adjective Color Fusion
|
| 419 |
+
|
| 420 |
+

|
| 421 |
+
Figure 12: Examples of adversarial suffix found by the adversarial attack responsible for fusion of color adjectives.
|
| 422 |
+
|
| 423 |
+
# Match Text Description in Image
|
| 424 |
+
|
| 425 |
+

|
| 426 |
+
|
| 427 |
+
Not shared
|
| 428 |
+
|
| 429 |
+
* Indicates required question
|
| 430 |
+
|
| 431 |
+

|
| 432 |
+
|
| 433 |
+
Are there at least 4 images that match the prompt = " A rose that is laying down on a bed."?
|
| 434 |
+
|
| 435 |
+

|
| 436 |
+
|
| 437 |
+

|
| 438 |
+
|
| 439 |
+

|
| 440 |
+
|
| 441 |
+
Yes
|
| 442 |
+
|
| 443 |
+

|
| 444 |
+
Figure 13: An overview of the human evaluation template.
|
| 445 |
+
|
| 446 |
+
No
|
| 447 |
+
|
| 448 |
+
Are there at least 4 images that match the prompt = "A rose that is laying down on * a grave."?
|
| 449 |
+
|
| 450 |
+

|
| 451 |
+
|
| 452 |
+

|
| 453 |
+
|
| 454 |
+
Yes
|
| 455 |
+
|
| 456 |
+

|
| 457 |
+
|
| 458 |
+
No
|
| 459 |
+
|
| 460 |
+
Next
|
| 461 |
+
|
| 462 |
+
Clear form
|
adversarialattacksonpartsofspeechanempiricalstudyintexttoimagegeneration/images.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3e5410765cb2a061d55be868e41db146242a7c38aab6c8a8d4510d32b8d25721
|
| 3 |
+
size 1509494
|
adversarialattacksonpartsofspeechanempiricalstudyintexttoimagegeneration/layout.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6ccc2a6bbbc6dd179a6190c06983d7160f0187b00c3e61bea43af2baeb095fea
|
| 3 |
+
size 522848
|
adversarialmathwordproblemgeneration/d968ab76-b420-4619-93ae-b6a1e4ac5f39_content_list.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8bab23054edad5f80b7dd2d05aea6093a105914f5f5460a76a3294b2429dccf5
|
| 3 |
+
size 111543
|
adversarialmathwordproblemgeneration/d968ab76-b420-4619-93ae-b6a1e4ac5f39_model.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2d3a1cbd468706013856816e6249a5d53bd767acc0654ab6095db46eace855a0
|
| 3 |
+
size 134915
|
adversarialmathwordproblemgeneration/d968ab76-b420-4619-93ae-b6a1e4ac5f39_origin.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2dec1707993c64df84ed0218003b544b48587b73253e85e4fc06856aa99ec6ee
|
| 3 |
+
size 2736356
|
adversarialmathwordproblemgeneration/full.md
ADDED
|
@@ -0,0 +1,427 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Adversarial Math Word Problem Generation
|
| 2 |
+
|
| 3 |
+
Roy Xie Chengxuan Huang Junlin Wang Bhuwan Dhingra
|
| 4 |
+
|
| 5 |
+
Duke University
|
| 6 |
+
|
| 7 |
+
{ruoyu.xie, jonathan.huang, junlin.wang2}@duke.edu {bdhingra}@cs.duke.edu
|
| 8 |
+
|
| 9 |
+
# Abstract
|
| 10 |
+
|
| 11 |
+
Large language models (LLMs) have significantly transformed the educational landscape. As current plagiarism detection tools struggle to keep pace with LLMs' rapid advancements, the educational community faces the challenge of assessing students' true problem-solving abilities in the presence of LLMs. In this work, we explore a new paradigm for ensuring fair evaluation—generating adversarial examples which preserve the structure and difficulty of the original questions aimed for assessment, but are unsolvable by LLMs. Focusing on the domain of math word problems, we leverage abstract syntax trees to structurally generate adversarial examples that cause LLMs to produce incorrect answers by simply editing the numeric values in the problems. We conduct experiments on various open- and closed-source LLMs, quantitatively and qualitatively demonstrating that our method significantly degrades their math problem-solving ability. We identify shared vulnerabilities among LLMs and propose a cost-effective approach to attack high-cost models. Additionally, we conduct automatic analysis to investigate the cause of failure, providing further insights into the limitations of LLMs.<sup>1</sup>
|
| 12 |
+
|
| 13 |
+
# 1 Introduction
|
| 14 |
+
|
| 15 |
+
Recent advances in large language models (LLMs) have revolutionized the world of education, primarily due to the great improvements in their natural language generation and problem-solving capabilities. This has transformed how students access information and complete assignments, raising significant concerns among educators in accurately evaluating students' true problem-solving abilities with the presence of such powerful tools (OpenAI, 2023; Kung et al., 2023; Callanan et al., 2023). While efforts like plagiarism detection exist (Kirchenbauer
|
| 16 |
+
|
| 17 |
+
et al., 2023; Mitchell et al., 2023), their effectiveness in identifying LLM-generated content is limited (Liang et al., 2023; Chaka, 2023), underscoring the need for more advanced anti-plagiarism methods to match LLM advancements.
|
| 18 |
+
|
| 19 |
+
At the same time, adversarial attacks on LLMs have gained more attention due to increased awareness of the potential risks associated with LLMs. Most work on adversarial attacks focuses on developing prompts to elicit specific outputs from LLMs (Zhang et al., 2020; Zou et al., 2023; Carlini et al., 2023) Recent work suggests that even the most powerful aligned LLMs are vulnerable to such attacks (Zou et al., 2023; Carlini et al., 2023). Hence, we might expect that as LLMs become stronger, detecting their outputs will become more difficult, but adversarial examples may still persist (Ilyas et al., 2019; Wei et al., 2023).
|
| 20 |
+
|
| 21 |
+
To this end, we introduce a new paradigm for generating homework assignments that LLMs cannot solve by utilizing adversarial attacks. We focus on math word problems (MwPs), which present a unique and challenging intersection of language and mathematics. In this work, we ask the question: "Can LLMs still solve an MwP after changing its numeric values?" We aim to create MwPs that LLMs are unable to solve while maintaining the original difficulty and coherence of the problems. Our aim is not just to challenge LLMs but to do so in a way that reflects real-world educational standards to ensure the MwPs remain educationally valuable and relevant.
|
| 22 |
+
|
| 23 |
+
While conceptually simple, doing this automatically is challenging as directly modifying numbers in the problem could lead to nonsensical problems. For example, consider the problem "A class has 6 male students and half as many female students. How many students in total?" Directly change the number of male students from 6 to 5 (or any odd numbers) without checking its intermediate computational steps might result in "2.5 female students,"
|
| 24 |
+
|
| 25 |
+

|
| 26 |
+
Figure 1: Method Overview: Given a MWP that an LLM can correctly solve, our method first transforms it into Python code. The Python code then is converted into an AST representation, which is used to generate adversarial problems by modifying the numeric values in a controllable manner. We place constraints on the nodes of the AST to ensure that the modified problem maintains the same difficulty level as the original problem. Despite this, we find that the resulting adversarial examples cause LLMs to predict incorrect answers.
|
| 27 |
+
|
| 28 |
+
which is not only illogical but also introducing fraction to the problem, which might change the indented difficulty. Similarly, changing the number from 6 to 624 might make the problem unrealistic and much harder for students. To generate meaningful and coherent problem variations, it is essential to consider the logical implications of number modifications and ensure that the resulting problem remains plausible and solvable. We further discuss the importance of educational constraints in §3.2.
|
| 29 |
+
|
| 30 |
+
To effectively generate modifications in large scale to assess the robustness of LLMs also requires: (i) The answer to the altered problem changes must be recomputed automatically; and (ii) Preserving the difficulty and validity of the modified problem requires us to ensure that all the intermediate calculations in the new problem are consistent with the original problem. To tackle these challenges, we first convert MwPs to a code representation and leverage abstract syntax trees (ASTs) to map each calculation step into a node. We then define educational constraints for each node to ensure all the desired properties are preserved for the generated new problem.
|
| 31 |
+
|
| 32 |
+
In this work, we evaluate several LLMs and demonstrate the effectiveness of our method by achieving a significant attack success rate (ASR). Our approach outperforms the previous rephrasing attack by an average of $62\%$ ASR. We investigate universal attacks and attack transferability, proposing a cost-effective approach to attack high-cost models (e.g., GPT-4) by reducing API request calls by $90\%$ while achieving high performance. We conduct human evaluations to verify that our generated problems indeed preserve the original coherence and difficulty. Furthermore, we perform a
|
| 33 |
+
|
| 34 |
+
regression analysis and find that our adversarial examples exploit different weaknesses of each model, offering valuable insights into LLM's limitation.
|
| 35 |
+
|
| 36 |
+
# 2 Background and Related Work
|
| 37 |
+
|
| 38 |
+
Fair Evaluation for Educational Purpose As LLMs become more adept at generating human-like text, it becomes increasingly difficult to distinguish between student-and machine-generated content (Chaka, 2023; Liang et al., 2023), which poses significant challenges for educational institutions in ensuring fair evaluation of student work (Yan et al., 2024). This issue also extends beyond traditional written assignments, as LLMs can now provide detailed solutions to complex problems across various disciplines (Abedi et al., 2023). Consequently, educators must develop new strategies to assess student understanding and maintain the integrity of the evaluation process (Liu et al., 2023).
|
| 39 |
+
|
| 40 |
+
LLMs Math-solving Ability Our work also closely relates to LLM's math reasoning ability (Yu et al., 2023; Xu et al., 2023). Studies found that LLMs can significantly improve their math-solving ability through prompt engineering (Yu et al., 2023; Imani et al., 2023a), such as chain-of-thought (CoT) (Wei et al., 2022). Converting the MwPs' solving steps into symbolic representations can also improves LLM's performance (Li et al., 2023; He-Yueya et al., 2023; Gao et al., 2023).
|
| 41 |
+
|
| 42 |
+
Adversarial Attacks on MwPs Adversarial attacks on LLMs involve modifying prompts to al
|
| 43 |
+
|
| 44 |
+
ter their behavior (Zhang et al., 2020; Zou et al., 2023; Carlini et al., 2023). In this work, we modify MwPs to cause LLMs to output incorrect answers. Bubeck et al. (2023) conducted limited memorization tests on MwPs by randomly changing numeric values, suggesting that state-of-the-art LLMs do not solely rely on memorization but apply general solution methods. However, their study's sample size was relatively small, and we demonstrate that modifying numbers in MwPs causes LLMs to fail on a larger scale. On the other hand, Zhou et al. (2023) rephrased MwPs by changing words while preserving numeric values. This approach risks altering the original context and introducing inconsistencies and problematic content (see Appendix B), requiring extensive human validation. Therefore, we focus on altering the numerical values in this work and preserve the underlying logic.
|
| 45 |
+
|
| 46 |
+
# 3 Methodology
|
| 47 |
+
|
| 48 |
+
MwPs are presented in natural language, which creates challenges for systematic structural and syntactic modifications. In this section, we describe our approach to generating adversarial MwPs. An overview of our method can be found in Figure 1. We denote an original problem-answer pair as $p = (x,y)$ , where $x$ is a sequence of tokens $x_{1},\ldots ,x_{n}$ in the problem and $y$ is its ground-truth answer. We define $G$ as a ground-truth function that computes the correct answer for a math problem and $F$ as a function which maps the elements of a sequence as: $F(\tilde{x}_i)\sim \mathbb{R}$ (i.e., a random real number) if $x_{i}$ is numeric and $F(\tilde{x}_i) = x_i$ otherwise. We denote the set of all possible adversarial modifications to it as:
|
| 49 |
+
|
| 50 |
+
$$
|
| 51 |
+
A (x, y) = \left\{\left(\tilde {x}, \tilde {y}\right): \tilde {x} _ {i} \in F (x), \tilde {y} = G (\tilde {x}) \right\}. \tag {1}
|
| 52 |
+
$$
|
| 53 |
+
|
| 54 |
+
$A(x,y)$ will also consist of many unnatural and difficult problems, hence later in $\S 3.2$ we will introduce filtering constraints for selecting the adversarial examples that preserve difficulty.
|
| 55 |
+
|
| 56 |
+
# 3.1 Mapping From MWPs to Code to Tree
|
| 57 |
+
|
| 58 |
+
To structurally modify MwPs, we first use GPT-4 to generate the Python code that reflects the solution steps given the problem and its final answer. Next, we utilize the AST, a tree structure for programming language code, to convert the generated
|
| 59 |
+
|
| 60 |
+
Python code into a tree representation for controllable new problem generation. We build the ASTs by traversing through the Python code and constructing nodes corresponding to each statement. The final print statement that outputs the answer is the root of the tree. Each AST has mainly two types of nodes: operation nodes, which carry out the operations in the tree and are the non-leaf nodes, and variable nodes, which correspond to the numeric values from the problem and are the leaf nodes. We discuss the nodes in ASTs in detail in Appendix C and conduct analysis on the quality of generated Python code and ASTs in §5.
|
| 61 |
+
|
| 62 |
+
# 3.2 Adversarial Example Generation
|
| 63 |
+
|
| 64 |
+
In an adversarial setting, attackers can perform multiple rounds of attack on the system, and any successful attack signifies the possible flaws of the system (Carlini and Wagner, 2017). Similarly, we generate adversarial examples which are different versions of the original MwPs to attack LLMs. Examples can be found in Table 6.
|
| 65 |
+
|
| 66 |
+
Educational Context It's essential to maintain the original difficulty and coherence of the MwPs despite changes in their numeric values. For instance, changing one-digit multiplication to four-digit multiplication significantly alters the problem's complexity. To maintain mathematical logic intact, the order of magnitude of numbers in the problem should also remain unchanged. For example, changing a problem from "Jack ate 2 out of a total of 5 apples" to "Jack ate 5 out of a total of 2 apples" not only introduces the concept of negative numbers but also alters the problem's logical structure and coherency. Such modifications can create unrealistic scenarios, potentially confusing students and leading to ineffective learning experiences (Vilenius-Tuohimaa et al., 2008).
|
| 67 |
+
|
| 68 |
+
Filtering Constraints To minimize the difference between the original MWP and its adversarial counterpart while adhering to the educational context, we define a set of Boolean constraints for each node in the AST to control the generation quality. Given the original node value $h$ and its new value $h'$ , a newly generated problem is valid if and only if $h'$ satisfies the same set of constraints that $h$ has, for all nodes. A list of node constraints is:
|
| 69 |
+
|
| 70 |
+
- Positivity: if $h$ is positive, then $h'$ should be positive. This constraint avoids generating phrases like "get 5 apples from 2" since this would produce a negative node.
|
| 71 |
+
|
| 72 |
+
- Integer: if $h$ is an integer, then $h'$ should remain an integer. This ensures that phrases like "the first half of 3 people" wouldn't appear, since the original problem likely has an integer value in the intermediate node.
|
| 73 |
+
- Proper Fraction: if $h$ is between 0 and 1, then $h'$ should be between 0 and 1. This prevents phrases such as "John eats 4/3 of his chimichanga" and "the bucket is filled till 150% full" from being produced since the generated problems wouldn't make logical sense for many problems when a number is no longer a proper fraction.
|
| 74 |
+
|
| 75 |
+
Constrictive Generation Methods The node constraints ensure the adversarial examples are valid in the numerical sense; instances that don't make logical sense like "28-hour work day", which is not common, can still be generated. Different values for the variable nodes can also lead to vastly different difficulty levels, as $h'$ can be significantly larger than $h$ . To mitigate this, we propose three generation methods to distinguish generated adversarial examples with different levels of difficulty. We decompose the values $h \approx a \times 10^b$ , where $a$ is an integer that is not divisible by 10 and with at most $c$ digits. Depending on the numbers $h$ , $a$ , and $b$ , the generation methods are defined as follows:
|
| 76 |
+
|
| 77 |
+
- M1 Free Generation: Allowing the generated problem to have a wide range of numbers with minimal constraints, with each $h'$ to be $a' \times 10^b$ . Regardless of the value of $a$ , $a'$ is drawn from a uniform distribution between 1 and $10^c$ . If the variable node $v$ is a divisor of a division node, then $a'$ is drawn from a uniform distribution between 1 and $\left\lfloor 10^{c/2} \right\rfloor$ .
|
| 78 |
+
- $M2$ Count of Digits: Constraining the generated value $h'$ has the same number of digits as $h$ . For example, for $h = 100$ , some possible $h'$ are 942, 589, or 264. This ensures $h'$ is always within a reasonable range relative to $h$ and maintains similar problem difficulty levels. For more variability, $h'$ can range from 1 to 99 if $h$ has only one digit. For decimal variable values like $h = 1.25$ , we use $a = 125$ to generate numbers like $a' = 473$ , then convert them back to $h' = 4.73$ .
|
| 79 |
+
- $M3$ Count of Scientific Numbers: Constraining the new value shares a similar scientific digit count and is within a similar range to the original value. For example, for $h = 1500$ , $h' \sim \text{Pois}(h)$ can be 1700, 800, 1200, where Pois is the Poisson distribution. The rationale is that larger numbers do not result in more difficult problems, but more
|
| 80 |
+
|
| 81 |
+
scientific numbers do. An example would be comparing the numbers 150,000 and 172,568.
|
| 82 |
+
|
| 83 |
+
$M3$ is the most restrictive generation, followed by $M2$ , and $M1$ is the least restrictive:
|
| 84 |
+
|
| 85 |
+
$$
|
| 86 |
+
M 1 (A (x, y)) \supseteq M 2 (A (x, y)) \supseteq M 3 (A (x, y)). \tag {2}
|
| 87 |
+
$$
|
| 88 |
+
|
| 89 |
+
The more restrictive a method is, the closer the difficulty levels and coherence remain between an adversarial example and its original version. Thus, we use $M3$ as our main generation method since it ensures that adversarial examples adhere to all constraints, maintaining original difficulty and coherence. While $M1$ and $M2$ generations may not fit the educational context, we aim to study LLMs' math-solving abilities by simply altering numeric values. We discuss how different methods impact model performance in §4.2. We present detailed descriptions of each generation method in Appendix D and their generated examples in Table 6.
|
| 90 |
+
|
| 91 |
+
# 4 Experiments and Results
|
| 92 |
+
|
| 93 |
+
In this section, we present multiple experiments and demonstrate the effectiveness of our method on attacking various LLMs.
|
| 94 |
+
|
| 95 |
+
# 4.1 Experimental Setup
|
| 96 |
+
|
| 97 |
+
Datasets We generate problem variants from GSM8K (Cobbe et al., 2021) and MultiArith (Roy and Roth, 2015). Both datasets are commonly used for evaluating LLMs' mathematical capabilities, and MultiArith is sourced directly from math worksheets used by elementary school students to practice math problems (Roy et al., 2015).
|
| 98 |
+
|
| 99 |
+
Models We conduct experiments on the following open-source models: MetaMath 7B, 70B (Yu et al., 2023), Mistral 7B (Jiang et al., 2023), Llama 3 8B (Meta, 2024), Llama 2 13B (Touvron et al., 2023), WizardMath 13B (Xu et al., 2023), Vicuna 13B (Chiang et al., 2023), and CodeLlama (Roziere et al., 2023). Additional, we evaluate two closed-source models: GPT-4 (OpenAI, 2023) and GPT-3.5 (OpenAI, 2022). The model selection was largely based on the LLMs' math-solving ability. Our intention is to evaluate a wide range of LLM performances, including the math-tuned LLMs such as MetaMath and WizardMath, popular
|
| 100 |
+
|
| 101 |
+
<table><tr><td rowspan="3">Model</td><td colspan="7">MultiArith</td><td colspan="7">GSM8K</td></tr><tr><td colspan="3">M3</td><td colspan="2">M2</td><td colspan="2">M1</td><td colspan="2">M3</td><td colspan="2">M2</td><td colspan="2">M1</td><td></td></tr><tr><td>OA</td><td>AA</td><td>ASR</td><td>AA</td><td>ASR</td><td>AA</td><td>ASR</td><td>OA</td><td>AA</td><td>ASR</td><td>AA</td><td>ASR</td><td>AA</td><td>ASR</td></tr><tr><td>Mistral 7B</td><td>37.0</td><td>0.0</td><td>100.0</td><td>0.0</td><td>100.0</td><td>0.0</td><td>100.0</td><td>29.0</td><td>0.0</td><td>100.0</td><td>0.0</td><td>100.0</td><td>0.0</td><td>100.0</td></tr><tr><td>MetaMath 7B</td><td>100.0</td><td>74.0</td><td>26.0</td><td>10.0</td><td>90.0</td><td>0.0</td><td>100.0</td><td>95.0</td><td>28.0</td><td>71.0</td><td>9.0</td><td>91.0</td><td>0.0</td><td>100.0</td></tr><tr><td>Llama 3 8B</td><td>17.0</td><td>0.0</td><td>100.0</td><td>0.0</td><td>100.0</td><td>0.0</td><td>100.0</td><td>21.0</td><td>0.0</td><td>100.0</td><td>0.0</td><td>100.0</td><td>0.0</td><td>100.0</td></tr><tr><td>Llama 2 13B</td><td>12.0</td><td>0.0</td><td>100.0</td><td>0.0</td><td>100.0</td><td>0.0</td><td>100.0</td><td>10.0</td><td>0.0</td><td>100.0</td><td>0.0</td><td>100.0</td><td>0.0</td><td>100.0</td></tr><tr><td>WizardMath 13B</td><td>89.0</td><td>20.0</td><td>78.0</td><td>5.0</td><td>94.0</td><td>0.0</td><td>100.0</td><td>89.0</td><td>11.0</td><td>88.0</td><td>2.0</td><td>98.0</td><td>0.0</td><td>100.0</td></tr><tr><td>Vicuna 13B</td><td>76.0</td><td>4.0</td><td>95.0</td><td>1.0</td><td>99.0</td><td>0.0</td><td>100.0</td><td>60.0</td><td>0.0</td><td>100.0</td><td>0.0</td><td>100.0</td><td>0.0</td><td>100.0</td></tr><tr><td>CodeLlama 34B</td><td>11.0</td><td>0.0</td><td>100.0</td><td>0.0</td><td>100.0</td><td>0.0</td><td>100.0</td><td>6.0</td><td>0.0</td><td>100.0</td><td>0.0</td><td>100.0</td><td>0.0</td><td>100.0</td></tr><tr><td>MetaMath 70B</td><td>99.0</td><td>86.0</td><td>13.0</td><td>30.0</td><td>70.0</td><td>0.0</td><td>100.0</td><td>98.0</td><td>50.0</td><td>49.0</td><td>17.0</td><td>83.0</td><td>0.0</td><td>100.0</td></tr><tr><td>GPT-3.5</td><td>97.0</td><td>74.0</td><td>24.0</td><td>47.0</td><td>52.0</td><td>0.0</td><td>100.0</td><td>91.0</td><td>52.0</td><td>43.0</td><td>31.0</td><td>66.0</td><td>0.0</td><td>100.0</td></tr><tr><td>Average</td><td>60.0</td><td>28.7</td><td>70.7</td><td>10.3</td><td>78.3</td><td>0.0</td><td>100.0</td><td>55.4</td><td>15.9</td><td>83.4</td><td>6.6</td><td>93.1</td><td>0.0</td><td>100.0</td></tr></table>
|
| 102 |
+
|
| 103 |
+
open-source LLMs such as Llama 3 and Mistral, and the API-based GPT models.
|
| 104 |
+
|
| 105 |
+
Metrics We follow the previous adversarial attack literature to measure the attacks, which looks for at least one perturbation that fools the model (Croce et al., 2020; Pruthi et al., 2019; Jia and Liang, 2017). A problem is considered incorrect if it has at least one incorrect variation, also known as an adversarial example. Given a set of original problem-answer pairs $P$ and a LLM $L$ , we define:
|
| 106 |
+
|
| 107 |
+
- Original Accuracy (OA): the accuracy of $L$ on the original problems,
|
| 108 |
+
|
| 109 |
+
$$
|
| 110 |
+
\mathrm {O A} (L) = \frac {\sum_ {(x , y) \in P} 1 \{L (x) = y \}}{| P |}. \tag {3}
|
| 111 |
+
$$
|
| 112 |
+
|
| 113 |
+
- Attack Accuracy (AA): given an indicator function $I_{xy}$ :
|
| 114 |
+
|
| 115 |
+
$$
|
| 116 |
+
I _ {x y} = 1 \left[ \forall (\tilde {x}, \tilde {y}) \in A (x, y): L (\tilde {x}) = \tilde {y} \right], \tag {4}
|
| 117 |
+
$$
|
| 118 |
+
|
| 119 |
+
$L$ 's accuracy on the adversarial examples:
|
| 120 |
+
|
| 121 |
+
$$
|
| 122 |
+
\mathrm {A A} (L) = \frac {\sum_ {(x , y) \in P} I _ {x y}}{| P |}. \tag {5}
|
| 123 |
+
$$
|
| 124 |
+
|
| 125 |
+
- Attack Success Rate (ASR): relative decrease in accuracy due to adversarial modifications,
|
| 126 |
+
|
| 127 |
+
$$
|
| 128 |
+
\operatorname {A S R} (L) = \frac {\operatorname {O A} (L) - \operatorname {A A} (L)}{\operatorname {O A} (L)}. \tag {6}
|
| 129 |
+
$$
|
| 130 |
+
|
| 131 |
+
Baseline As a baseline, we evaluate a common rephrasing approach focusing on modifying words within MwPs. Zhou et al. (2023) freeze the logical entities and iteratively swap each unfrozen token with similar tokens that cause LLMs to fail. They then validate the adversarial example with human manual checking. Zhou et al. (2023) created the
|
| 132 |
+
|
| 133 |
+
RobustMath dataset, which includes 214 original problems from a combination of GSM8K and MultiArith with their 300 rephrased versions. We report the results in Appendix E, observing ASR for 4 out of the 7 models; however, some models even show improved accuracy given these adversarial examples, suggesting that such attacks may not generalize well across different LLMs.
|
| 134 |
+
|
| 135 |
+
# 4.2 Our Attacks
|
| 136 |
+
|
| 137 |
+
Problem Variation Generation We set the number of attempts to generate problem variants to be 30,000 and present the average number of generation per problem for each $M$ in Appendix H. While on average each problem generates over a thousand variants, it is worth noting that the actual number of possible generations varies based on the original values and the number of variable nodes in a problem.<sup>8</sup> Given this reason and cost considerations, in this work we randomly select 100 random problems from MultiArith and GSM8K and generate 100 variants for each selected problem in each $M$ . Despite the seemingly small number of selected problems, the total data points are up to 60,000.<sup>9</sup>
|
| 138 |
+
|
| 139 |
+
Table 1: Main Attacks: Performance of three different generation methods. Simply changing numeric values consistently cause performance drop across all LLMs, even with the most restrictive generation method.
|
| 140 |
+
|
| 141 |
+
<table><tr><td>Models</td><td>Avg. (%) ↓</td></tr><tr><td>CodeLlama 34B</td><td>91.8</td></tr><tr><td>Llama 2 13B</td><td>91.6</td></tr><tr><td>Llama 3 8B</td><td>78.3</td></tr><tr><td>Mistral 7B</td><td>70.5</td></tr><tr><td>Vicuna 13B</td><td>50.3</td></tr><tr><td>WizardMath 13B</td><td>21.0</td></tr><tr><td>MetaMath 7B</td><td>15.2</td></tr><tr><td>MetaMath 70B</td><td>7.9</td></tr><tr><td>GPT-3.5</td><td>6.9</td></tr></table>
|
| 142 |
+
|
| 143 |
+
Table 2: Incorrect Variants: The average percentage of incorrect variants per problem for each model in $M3$ . Appendix F shows detailed count distributions.
|
| 144 |
+
|
| 145 |
+
<table><tr><td rowspan="2">Model</td><td colspan="3">RobustMath</td><td colspan="4">Ours (M3)</td></tr><tr><td>OA</td><td>AA</td><td>ASR</td><td>OA</td><td>AA</td><td>ASR</td><td>Δ ASR</td></tr><tr><td>Mistral 7B</td><td>10.3</td><td>18.7</td><td>0.0</td><td>33.0</td><td>0.0</td><td>100.0</td><td>+100.0</td></tr><tr><td>MetaMath 7B</td><td>91.1</td><td>79.3</td><td>13.0</td><td>97.5</td><td>51.0</td><td>48.5</td><td>+35.5</td></tr><tr><td>Llama 3 8B</td><td>22.0</td><td>30.0</td><td>0.0</td><td>19.0</td><td>0.0</td><td>100.0</td><td>+100.0</td></tr><tr><td>Llama 2 13B</td><td>2.3</td><td>8.3</td><td>0.0</td><td>11.0</td><td>0.0</td><td>100.0</td><td>+100.0</td></tr><tr><td>WizardMath 13B</td><td>71.0</td><td>70.3</td><td>1.0</td><td>89.0</td><td>15.5</td><td>82.6</td><td>+81.6</td></tr><tr><td>Vicuna 13B</td><td>46.3</td><td>51.7</td><td>0.0</td><td>68.0</td><td>2.0</td><td>97.5</td><td>+97.5</td></tr><tr><td>CodeLlama 34B</td><td>31.3</td><td>10.3</td><td>67.1</td><td>8.5</td><td>0.0</td><td>100.0</td><td>+32.9</td></tr><tr><td>MetaMath 70B</td><td>93.0</td><td>82.7</td><td>11.1</td><td>98.5</td><td>68.0</td><td>31.1</td><td>+20.0</td></tr><tr><td>GPT-3.5</td><td>91.1</td><td>75.7</td><td>16.9</td><td>94.0</td><td>63.0</td><td>33.3</td><td>+16.4</td></tr><tr><td>Average</td><td>51.0</td><td>47.4</td><td>12.1</td><td>57.6</td><td>22.2</td><td>77.0</td><td>+62.0</td></tr></table>
|
| 146 |
+
|
| 147 |
+
Main Attacks We report the model performance from all $M$ s in Table 1.10 Ranging from the most lenient method, $M1$ , where the numbers could be fairly wild, to the most stringent one, $M3$ , we observe a consistent performance drop across all models, even strong ones (e.g., math-tuned, larger size, or API-based). For the most original-problem-like generation, $M3$ , weak models (e.g., smaller size or general-purpose) fail to generate any correct answers. Table 2 offers a different perspective by focusing on the average percentage of incorrect variants per model. The result is highly correlated with the reported ASR, with GPT-3.5 and MetaMath being the most robust and CodeLLama and LLama 2 the least. These insights add additional value to our evaluation, showing the vulnerability of the model in individual problem variants. Furthermore, comparing $M3$ with rephrasing attacks in the Table 3, our method significantly outperforms the baseline, resulting in a 62 ASR point improvement on average. We also analyze how ASR changes given different numbers of attacks in Appendix J. Interestingly, for several models, just 10 attacks are enough to significantly degrade performance.
|
| 148 |
+
|
| 149 |
+
Table 3: Comparison Result: We calculate the average of each metric from both datasets and compare the result with rephrasing attack, RobustMath. Our method significantly outperforms the baseline in every model, with an average improvement of 62 ASR points.
|
| 150 |
+
|
| 151 |
+
<table><tr><td>Model</td><td>Ct.</td><td>M3 (%)</td><td>M2 (%)</td><td>M1 (%)</td></tr><tr><td>Mistral 7B</td><td>1</td><td>100.0</td><td>100.0</td><td>100.0</td></tr><tr><td>MetaMath 7B</td><td>2</td><td>70.0</td><td>90.0</td><td>100.0</td></tr><tr><td>Llama 3 8B</td><td>3</td><td>67.0</td><td>87.0</td><td>100.0</td></tr><tr><td>Llama 2 13B</td><td>4</td><td>67.0</td><td>87.0</td><td>100.0</td></tr><tr><td>WizardMath 13B</td><td>5</td><td>49.0</td><td>80.0</td><td>100.0</td></tr><tr><td>Vicuna 13B</td><td>6</td><td>44.0</td><td>77.0</td><td>100.0</td></tr><tr><td>CodeLlama 34B</td><td>7</td><td>19.0</td><td>65.0</td><td>99.0</td></tr><tr><td>MetaMath 70B</td><td>8</td><td>9.0</td><td>49.0</td><td>87.0</td></tr><tr><td>GPT-3.5</td><td>9</td><td>9.0</td><td>46.0</td><td>83.0</td></tr></table>
|
| 152 |
+
|
| 153 |
+
<sup>10</sup>We do not run the full dataset against GPT-4 due to cost considerations. Instead, we propose a cost-effective approach to query expensive models in Efficient Attacks section.
|
| 154 |
+
|
| 155 |
+
Universal Attacks Following the previous adversarial attack literature, we investigate whether there are adversarial examples exist in all LLMs, also known as universal attacks (Zou et al., 2023; Moosavi-Dezfooli et al., 2017). We count the number of adversarial examples from each model and calculated the percentage of common ones among them. We report the results on Table 4 and observe a clear pattern of decreasing universal attacks with an increased number of models. This suggests that while all models are vulnerable to some degree of universal attacks, the percentage of such attacks decreases as more and diverse models are considered. We also observe that universal attacks varies significantly across different $M_{\mathrm{s}}$ with $M3$ having the lowest number of universal attacks.
|
| 156 |
+
|
| 157 |
+
Table 4: Universal Attack: Universal attacks are shared among a number of models. Increasing the count of models being considered decreases the universal attacks, with $M3$ consistently showing the lowest percentages.
|
| 158 |
+
|
| 159 |
+
<table><tr><td>Models</td><td>Req Call</td><td>Cost ($)</td><td>ASR</td><td>Req Δ (%)</td></tr><tr><td>MetaMath 7B</td><td>1,389</td><td>10.7</td><td>8.0</td><td>72.2</td></tr><tr><td>WizardMath 13B</td><td>1,745</td><td>8.8</td><td>6.0</td><td>65.1</td></tr><tr><td>MetaMath 70B</td><td>672</td><td>4.3</td><td>8.0</td><td>86.6</td></tr><tr><td>GPT-3.5</td><td>456</td><td>2.8</td><td>10.0</td><td>90.9</td></tr><tr><td>Target: GPT-4</td><td>5,000</td><td>29.3</td><td>10</td><td>-</td></tr></table>
|
| 160 |
+
|
| 161 |
+
Table 5: Efficient Attack: A targeted approach to attack high-cost models. We leverage adversarial examples from cheaper models to attack GPT-4, achieving the same ASR while reducing up to $90\%$ request calls.
|
| 162 |
+
|
| 163 |
+
Efficient Attacks Scaling up the number of attacks leads to a consistent performance drop for all models. However, this may not be feasible for API-based models like GPT-4 due to request limits and high costs. The cost barrier is particularly relevant for educational institutions working with limited resources. To address this, we propose an efficient attack method for API-based models by using adversarial examples in a targeted manner. The idea is simple: we attack model $A$ (target model, GPT-4 in our case), with adversarial examples from a cheaper model $B$ (e.g., open-source, lower API cost). We select 50 problems along with their 100
|
| 164 |
+
|
| 165 |
+
variations and run them against GPT-4, comparing the results with attacking GPT-4 using 50 adversarial examples from a cheaper model. Note that for some models, there are no correct responses, even with $M3$ . Therefore, we only compare $M3$ with the models that have correct answers. We compare the results in Table 5 and observe a significant request reduction while achieving similar ASR.
|
| 166 |
+
|
| 167 |
+
# 5 Analysis and Discussion
|
| 168 |
+
|
| 169 |
+
In this section, we conduct analysis to better understand our generation methods and the mathematical capabilities of LLMs.
|
| 170 |
+
|
| 171 |
+
Validation Through Human Evaluation We conduct a human evaluation to ensure the validity of our generated problems. We randomly select 30 problems that GPT-3.5 failed on for GSM8K and select 2 adversarial examples from each problem. Three evaluators are asked to assess (i) correctness: whether the answer to the modified problem is correct; (ii) coherence: whether the problem is contextually coherent; and (iii) similarity: whether the newly generated problem's difficulty level matches the original. Evaluators make binary decisions to determine if the criteria are met, and Figure 2 shows the average scores. Overall, all evaluators agree on correctness. $M3$ scores highly across all metrics, indicating it preserves the original problem's coherence and difficulty. Coherence and similarity scores for $M2$ and $M3$ are relatively low, suggesting their perturbations might not be useful in an educational context.
|
| 172 |
+
|
| 173 |
+

|
| 174 |
+
Figure 2: Human Evaluation: The average score from three annotators. $M3$ achieves the highest scores across all metrics, indicating our best generation method correctly generates contextually coherent problems that preserve original difficulty.
|
| 175 |
+
|
| 176 |
+
Transferability Following the previous work (Zou et al., 2023; Zhou et al., 2023), we investigate the transferability of adversarial examples
|
| 177 |
+
|
| 178 |
+
among the models. Specifically, We attack model $A$ with the adversarial examples from model $B$ and calculate the number of common adversarial examples between these two models. We present $M3$ result in the Figure 3. We observe that weaker models exhibit a high percentage of transferability, indicating a strong vulnerability correlation among them. On the other hand, strong models such as MetaMath 70B and GPT-3.5 tend to have a lower transferability rate. While it might suggest a form of resistance to adversarial examples that affect other models, it is not a measure of robustness as it could be that those models fail on entirely different examples. This finding suggests that certain LLMs might struggle with particular numbers or patterns. To further understand these phenomena, we conduct regression analysis as shown below.
|
| 179 |
+
|
| 180 |
+

|
| 181 |
+
Figure 3: Transferability: We present the adversarial example transferability $(\%)$ among all models by comparing each model against all other models. Compared to the math-tuned and production models, the weaker models such as LLaMa2 13B exhibit significant vulnerability and a strong correlation among them.
|
| 182 |
+
|
| 183 |
+
Regression Feature Analysis To gain deeper insights into the limitations of LLMs on MwPs, we conduct a regression analysis investigating the relationships between various features of the problems and the correctness of the models' predictions. We construct a set of 51 input features from 20,000 $M3$ generated problems, including features such as operation counts, answer value ranges, and node counts in the problem's AST. By examining the coefficients of these features in predicting model correctness (see Table 8 and Figure 8 in the Appendix), we uncover interesting patterns that shed light on the limitations of LLMs:
|
| 184 |
+
|
| 185 |
+
- Varying Vulnerabilities Across Models We find that the most positively and negatively correlated
|
| 186 |
+
|
| 187 |
+
features vary considerably across models, suggesting that our adversarial examples exploit distinct vulnerabilities. For instance, models exhibit divergent performance on problems with different answer value ranges. Mistral 7B and WizardMath 13B perform relatively well on problems with smaller answer values (e.g., in the range of [2, 8) and [8, 32)), while MetaMath 7B and Vicuna 13B show better performance on problems with answer values in the range of [32, 128). This observation hints that different models may have learned to specialize in problems with specific ranges, possibly due to variations in the distributions of their pre-training data (Srivatsa and Kochmar, 2024).
|
| 188 |
+
|
| 189 |
+
- Complexity and Operation Types We observe that problems involving division and a higher number of operations tend to be more challenging for most LLMs (see Figure 8 in the Appendix for visualizations). For instance, problems requiring multiple division operations or a combination of different operations (e.g., addition, subtraction, multiplication, and division) are more likely to result in incorrect predictions. This aligns with the intuition that complex problems requiring more mathematical operations are generally more difficult for LLMs to solve (Imani et al., 2023b).
|
| 190 |
+
- Tokenization Choices and Numerical Reasoning: Recent research has also highlighted the impact of tokenization choices on LLMs' numerical reasoning capabilities (Singh and Strouse, 2024). Our experiments reveal similar patterns, with Llama-based models tokenizing each digit individually, while GPT-3.5 and GPT-4 encode every three digits into a single token. This difference in tokenization may contribute to the observed consistent performance of GPT-3.5 to the number of tokens in the answer compared to the Llama-based models.
|
| 191 |
+
|
| 192 |
+
# Why LLMs suffer From Such Simple Attacks?
|
| 193 |
+
|
| 194 |
+
While LLMs can be trained on vast amounts of math data, they may not have an inherent grasp of the underlying mathematical concepts and reasoning steps (Saxton et al., 2019; Lample and Charton, 2019). Instead, they likely rely on pattern and statistical associations learned from the training data to make predictions (Bender et al., 2021), which is also known as memorization (Carlini et al., 2022). Modifying the numbers in a problem may disrupt these learned patterns, causing the models to make errors. This is evidenced by the significant perfor
|
| 195 |
+
|
| 196 |
+
mance drops observed in models like WizardMath (89% to 20%) and Vicuna (76% to 4%) when presented with adversarial examples (Table 1). Furthermore, test data contamination could also play a role - if the training corpus contains the test data, the models may be able to answer the original questions correctly but struggle to generalize to even subtle variations (Balloccu et al., 2024).
|
| 197 |
+
|
| 198 |
+
Generated Python Code and ASTs Analysis To ensure that the generated Python code is valid and can be correctly converted into ASTs, we manually examined 200 Python code and ASTs pairs from GSM8K and MultiArith, respectively. We identify the four types of errors:
|
| 199 |
+
|
| 200 |
+
- Incorrect answers or code: The generated code produces incorrect answers or contains logical errors that deviate from the problem statement.
|
| 201 |
+
- Use of unsupported constructs: The code includes loops, conditional and comparison statements, or user-defined functions, which are not supported by our AST conversion process.
|
| 202 |
+
- Complex expressions: The code contains expressions that are difficult to convert into ASTs, such as $x = y // z + (y \% z > 0)$ .
|
| 203 |
+
- Number misalignment: The same number appears multiple times in the code or the problem, leading to inconsistencies between the generated code and the problem statement.
|
| 204 |
+
|
| 205 |
+
Encouragingly, we find that $96.5\%$ and $92.5\%$ of the generated ASTs for GSM8K and MultiArith, respectively, are valid and free from these errors. We discuss this process in more details in the Appendix I. The high percentage of valid code and ASTs pair indicates that our code generation approach is indeed reliable.
|
| 206 |
+
|
| 207 |
+
# 6 Conclusion
|
| 208 |
+
|
| 209 |
+
We introduce a novel method to generate adversarial MwPs using ASTs. Our approach effectively challenges the mathematical problem-solving abilities of LLMs while maintaining the original difficulty and coherence of the problems. The generated adversarial examples significantly degrade the performance of both open- and closed-source LLMs, surpassing previous attacks by an average of $62\%$ ASR. We validate our adversarial examples through human evaluation and investigate universal attacks and transferability, proposing a cost-effective method to attack high-cost API-based models with up to a $90\%$ reduction in requests.
|
| 210 |
+
|
| 211 |
+
Automatic regression analyses reveal distinct weaknesses of different models when solving MwPs. Our work contributes to the development of fair and robust educational tools, ensuring ethically sound evaluations and promoting the responsible use of LLMs in education.
|
| 212 |
+
|
| 213 |
+
# 7 Limitations
|
| 214 |
+
|
| 215 |
+
This work has not empirically validated the correlation between the complexity of generated problems and the actual difficulty perceived by human students. Further investigation is needed to establish this correlation.
|
| 216 |
+
|
| 217 |
+
As a proof of concept, our method demonstrates the feasibility of generating meaningful and useful adversarial examples to LLMs, at least at the difficulty levels represented by the GSM8K and Multi-Arith datasets. However, it may not generalize well to math problems with significantly different types or difficulty levels. For example, very simple arithmetic problems (e.g., $3 + 2 = ?$ ) might never have a successful attack on LLMs specifically trained for math, while advanced problems requiring proofs or concepts without numeric manipulation (e.g., prove newton's binomial theorem) may not be suitable for our code generation procedure. As LLMs continue to improve, it is possible that they may become more robust, which is a challenge faced by all adversarial attack methods in general. We plan to address these limitations in future work by exploring a wider range of math problems and investigating other attack vectors as LLMs evolve.
|
| 218 |
+
|
| 219 |
+
# 8 Ethics Statement
|
| 220 |
+
|
| 221 |
+
While our primary intention is to address concerns about academic dishonesty, we acknowledge that our strategy might also lead to potential exacerbating educational inequality. By designing math problems specifically to be unsolvable by LLMs, the educators without access to resources, training, or the necessary tools could be placed at a disadvantage. This approach risks amplifying the disparities between institutions or individuals with differing levels of technological access.
|
| 222 |
+
|
| 223 |
+
# 9 Acknowledgements
|
| 224 |
+
|
| 225 |
+
We thank Sandy Yeung and Jack Goffinet for helpful discussions. We also thank anonymous reviewers for their insightful feedback. This work was supported in part by the NSF Graduate Research Fellowship and the Learning Engineering
|
| 226 |
+
|
| 227 |
+
Virtual Institute, funded by leading education philanthropists and organizations through Grant G-23-2137070 to the University of Florida and its partner institutions. The opinions expressed are those of the authors and do not represent the views of the University of Florida, the partner institutions, or those of the philanthropists and organizations.
|
| 228 |
+
|
| 229 |
+
# References
|
| 230 |
+
|
| 231 |
+
Mahyar Abedi, Ibrahim Alshybani, Muhammad Rubayat Bin Shahadat, and Michael Murillo. 2023. Beyond traditional teaching: The potential of large language models and chatbots in graduate engineering education. *Qeios*.
|
| 232 |
+
Simone Balloccu, Patrícia Schmidtová, Mateusz Lango, and Ondrej Dušek. 2024. Leak, cheat, repeat: Data contamination and evaluation malpractices in closed-source llms. arXiv preprint arXiv:2402.03927.
|
| 233 |
+
Emily M. Bender, Timnit Gebru, Angelina McMillan-Major, and Shmargaret Shmitchell. 2021. On the dangers of stochastic parrots: Can language models be too big? In Proceedings of the 2021 ACM Conference on Fairness, Accountability, and Transparency, FAccT '21, page 610-623, New York, NY, USA. Association for Computing Machinery.
|
| 234 |
+
Sebastien Bubeck, Varun Chandrasekaran, Ronen Eldan, Johannes Gehrke, Eric Horvitz, Ece Kamar, Peter Lee, Yin Tat Lee, Yuanzhi Li, Scott Lundberg, et al. 2023. Sparks of artificial general intelligence: Early experiments with gpt-4. arXiv preprint arXiv:2303.12712.
|
| 235 |
+
Ethan Callanan, Amarachi Mbakwe, Antony Papadimitriou, Yulong Pei, Mathieu Sibue, Xiaodan Zhu, Zhiqiang Ma, Xiaomo Liu, and Sameena Shah. 2023. Can gpt models be financial analysts? an evaluation of chatgpt and gpt-4 on mock cfa exams. arXiv preprint arXiv:2310.08678.
|
| 236 |
+
Nicholas Carlini, Daphne Ippolito, Matthew Jagielski, Katherine Lee, Florian Tramer, and Chiyuan Zhang. 2022. Quantifying memorization across neural language models. arXiv preprint arXiv:2202.07646.
|
| 237 |
+
Nicholas Carlini, Milad Nasr, Christopher A Choquette-Choo, Matthew Jagielski, Irena Gao, Anas Awadalla, Pang Wei Koh, Daphne Ippolito, Katherine Lee, Florian Tramer, et al. 2023. Are aligned neural networks adversarially aligned? arXiv preprint arXiv:2306.15447.
|
| 238 |
+
Nicholas Carlini and David Wagner. 2017. Towards evaluating the robustness of neural networks. In 2017 IEEE symposium on security and privacy (sp), pages 39-57. Ieee.
|
| 239 |
+
Chaka Chaka. 2023. Detecting ai content in responses generated by chatgpt, youchat, and chatsonic: The case of five ai content detection tools. Journal of Applied Learning and Teaching, 6(2).
|
| 240 |
+
|
| 241 |
+
Wei-Lin Chiang, Zhuohan Li, Zi Lin, Ying Sheng, Zhanghao Wu, Hao Zhang, Lianmin Zheng, Siyuan Zhuang, Yonghao Zhuang, Joseph E Gonzalez, et al. 2023. Vicuna: An open-source chatbot impressing gpt-4 with $90\%$ * chatgpt quality. See https://vicuna.lmsys.org (accessed 14 April 2023).
|
| 242 |
+
Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Mark Chen, Heewoo Jun, Lukasz Kaiser, Matthias Plappert, Jerry Tworek, Jacob Hilton, Reiichiro Nakano, et al. 2021. Training verifiers to solve math word problems. arXiv preprint arXiv:2110.14168.
|
| 243 |
+
Francesco Croce, Maksym Andriushchenko, Vikash Sehwag, Edoardo Debenedetti, Nicolas Flammarion, Mung Chiang, Prateek Mittal, and Matthias Hein. 2020. Robustbench: a standardized adversarial robustness benchmark. arXiv preprint arXiv:2010.09670.
|
| 244 |
+
Luyu Gao, Aman Madaan, Shuyan Zhou, Uri Alon, Pengfei Liu, Yiming Yang, Jamie Callan, and Graham Neubig. 2023. Pal: Program-aided language models. In International Conference on Machine Learning, pages 10764–10799. PMLR.
|
| 245 |
+
Joy He-Yueya, Gabriel Poesia, Rose E Wang, and Noah D Goodman. 2023. Solving math word problems by combining language models with symbolic solvers. arXiv preprint arXiv:2304.09102.
|
| 246 |
+
Andrew Ilyas, Shibani Santurkar, Dimitris Tsipras, Logan Engstrom, Brandon Tran, and Aleksander Madry. 2019. Adversarial examples are not bugs, they are features. Advances in neural information processing systems, 32.
|
| 247 |
+
Shima Imani, Liang Du, and Harsh Shrivastava. 2023a. Mathprompter: Mathematical reasoning using large language models. In Proceedings of the The 61st Annual Meeting of the Association for Computational Linguistics: Industry Track, ACL 2023, Toronto, Canada, July 9-14, 2023, pages 37-42. Association for Computational Linguistics.
|
| 248 |
+
Shima Imani, Liang Du, and Harsh Shrivastava. 2023b. Mathprompt: Mathematical reasoning using large language models. arXiv preprint arXiv:2303.05398.
|
| 249 |
+
Robin Jia and Percy Liang. 2017. Adversarial examples for evaluating reading comprehension systems. arXiv preprint arXiv:1707.07328.
|
| 250 |
+
Albert Q Jiang, Alexandre Sablayrolles, Arthur Mensch, Chris Bamford, Devendra Singh Chaplot, Diego de las Casas, Florian Bressand, Gianna Lengyel, Guillaume Lample, Lucile Saulnier, et al. 2023. Mistral 7b. arXiv preprint arXiv:2310.06825.
|
| 251 |
+
John Kirchenbauer, Jonas Geiping, Yuxin Wen, Jonathan Katz, Ian Miers, and Tom Goldstein. 2023. A watermark for large language models. arXiv preprint arXiv:2301.10226.
|
| 252 |
+
|
| 253 |
+
Tiffany H Kung, Morgan Cheatham, Arielle Medenilla, Czarina Sillos, Lorie De Leon, Camille Elepano, Maria Madriaga, Rimel Aggabao, Giezel DiazCandido, James Maningo, et al. 2023. Performance of chatgpt on usmle: Potential for ai-assisted medical education using large language models. PLoS digital health, 2(2):e0000198.
|
| 254 |
+
Guillaume Lample and François Charton. 2019. Deep learning for symbolic mathematics. arXiv preprint arXiv:1912.01412.
|
| 255 |
+
Chengshu Li, Jacky Liang, Andy Zeng, Xinyun Chen, Karol Hausman, Dorsa Sadigh, Sergey Levine, Li Fei-Fei, Fei Xia, and Brian Ichter. 2023. Chain of code: Reasoning with a language model-augmented code emulator. arXiv preprint arXiv:2312.04474.
|
| 256 |
+
Weixin Liang, Mert Yuksekgonul, Yining Mao, Eric Wu, and James Zou. 2023. Gpt detectors are biased against non-native english writers. arXiv preprint arXiv:2304.02819.
|
| 257 |
+
Ming Liu, Yiling Ren, Lucy Michael Nyagoga, Francis Stonier, Zhongming Wu, and Liang Yu. 2023. Future of education in the era of generative artificial intelligence: Consensus among chinese scholars on applications of chatgpt in schools. Future in Educational Research, 1(1):72-101.
|
| 258 |
+
Meta. 2024. Llama 3 model card.
|
| 259 |
+
Eric Mitchell, Yoonho Lee, Alexander Khazatsky, Christopher D Manning, and Chelsea Finn. 2023. Detectgpt: Zero-shot machine-generated text detection using probability curvature. arXiv preprint arXiv:2301.11305.
|
| 260 |
+
Seyed-Mohsen Moosavi-Dezfooli, Alhussein Fawzi, Omar Fawzi, and Pascal Frossard. 2017. Universal adversarial perturbations. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1765-1773.
|
| 261 |
+
OpenAI. 2022. Chatgpt: Optimizing language models for dialogue. Accessed: 2023-01-10.
|
| 262 |
+
OpenAI. 2023. Gpt-4 technical report. ArXiv, abs/2303.08774.
|
| 263 |
+
Danish Pruthi, Bhuwan Dhingra, and Zachary C Lipton. 2019. Combating adversarial misspellings with robust word recognition. arXiv preprint arXiv:1905.11268.
|
| 264 |
+
Subhro Roy and Dan Roth. 2015. Solving general arithmetic word problems. In Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing, pages 1743-1752, Lisbon, Portugal. Association for Computational Linguistics.
|
| 265 |
+
Subhro Roy, Tim Vieira, and Dan Roth. 2015. Reasoning about quantities in natural language. Transactions of the Association for Computational Linguistics, 3:1-13.
|
| 266 |
+
|
| 267 |
+
Baptiste Roziere, Jonas Gehring, Fabian Gloeckle, Sten Sootla, Itai Gat, Xiaqing Ellen Tan, Yossi Adi, Jingyu Liu, Tal Remez, Jérémy Rapin, et al. 2023. Code llama: Open foundation models for code. arXiv preprint arXiv:2308.12950.
|
| 268 |
+
David Saxton, Edward Grefenstette, Felix Hill, and Pushmeet Kohli. 2019. Analysing mathematical reasoning abilities of neural models. arXiv preprint arXiv:1904.01557.
|
| 269 |
+
Aaditya K Singh and DJ Strouse. 2024. Tokenization counts: the impact of tokenization on arithmetic in frontier lms. arXiv preprint arXiv:2402.14903.
|
| 270 |
+
Kv Aditya Srivatsa and Ekaterina Kochmar. 2024. What makes math word problems challenging for LLMs? In Findings of the Association for Computational Linguistics: NAACL 2024, pages 1138-1148, Mexico City, Mexico. Association for Computational Linguistics.
|
| 271 |
+
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.
|
| 272 |
+
Piia Maria Vilenius-Tuohimaa, Kaisa Aunola, and Jari-Erik Nurmi. 2008. The association between mathematical word problems and reading comprehension. Educational Psychology, 28(4):409-426.
|
| 273 |
+
Alexander Wei, Nika Haghtalab, and Jacob Steinhardt. 2023. Jailbroken: How does llm safety training fail? arXiv preprint arXiv:2307.02483.
|
| 274 |
+
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.
|
| 275 |
+
Can Xu, Qingfeng Sun, Kai Zheng, Xiubo Geng, Pu Zhao, Jiazhan Feng, Chongyang Tao, and Daxin Jiang. 2023. Wizardlm: Empowering large language models to follow complex instructions. arXiv preprint arXiv:2304.12244.
|
| 276 |
+
Lixiang Yan, Lele Sha, Linxuan Zhao, Yuheng Li, Roberto Martinez-Maldonado, Guanliang Chen, Xinyu Li, Yueqiao Jin, and Dragan Gasevic. 2024. Practical and ethical challenges of large language models in education: A systematic scoping review. British Journal of Educational Technology, 55(1):90-112.
|
| 277 |
+
Longhui Yu, Weisen Jiang, Han Shi, Jincheng Yu, Zhengying Liu, Yu Zhang, James T Kwok, Zhenguo Li, Adrian Weller, and Weiyang Liu. 2023. Metamath: Bootstrap your own mathematical questions for large language models. arXiv preprint arXiv:2309.12284.
|
| 278 |
+
|
| 279 |
+
Wei Emma Zhang, Quan Z Sheng, Ahoud Alhazmi, and Chenliang Li. 2020. Adversarial attacks on deep-learning models in natural language processing: A survey. ACM Transactions on Intelligent Systems and Technology (TIST), 11(3):1-41.
|
| 280 |
+
Zihao Zhou, Qiufeng Wang, Mingyu Jin, Jie Yao, Jianan Ye, Wei Liu, Wei Wang, Xiaowei Huang, and Kaizhu Huang. 2023. Mathattack: Attacking large language models towards math solving ability. arXiv preprint arXiv:2309.01686.
|
| 281 |
+
Andy Zou, Zifan Wang, J Zico Kolter, and Matt Fredrikson. 2023. Universal and transferable adversarial attacks on aligned language models. arXiv preprint arXiv:2307.15043.
|
| 282 |
+
|
| 283 |
+
# A Prompt Templates
|
| 284 |
+
|
| 285 |
+
# A.1 Code Generation Prompt
|
| 286 |
+
|
| 287 |
+
Write a Python script that contains a step-by-step solution for a given math problem and its answer. Start the script by defining variables corresponding to the quantities mentioned in the problem. Print the final answer at the end of the script. Do not use if-else statements, floor divisions, and loops to solve the problem.
|
| 288 |
+
|
| 289 |
+
Given problem: {problem}
|
| 290 |
+
|
| 291 |
+
Answer: {answer}
|
| 292 |
+
|
| 293 |
+
Python script:
|
| 294 |
+
|
| 295 |
+
# A.2 Zero-shot CoT
|
| 296 |
+
|
| 297 |
+
Solve a math problem. The solution ends with "the answer is (a number)" like "the answer is 1".
|
| 298 |
+
|
| 299 |
+
Question: {problem}
|
| 300 |
+
|
| 301 |
+
Answer: Let's think step by step.
|
| 302 |
+
|
| 303 |
+
# B A Rephrasing Attack Example
|
| 304 |
+
|
| 305 |
+
A plane travels 1200 miles in 3 hours. At the same rate, how many additional hours would it take to travel an additional 2000 miles?
|
| 306 |
+
|
| 307 |
+
A helicopter travels 1200 miles in 3 hours. At the same rate, how many additional hours would it take to travel an additional 2000 miles?
|
| 308 |
+
|
| 309 |
+
Figure 4: A rephrasing attack example from Zhou et al. (2023). The left side shows the original problem, and the right side is the rephrased version. Although planes and helicopters are conceptually similar, the maximum flying distance for a helicopter is usually between 300 to 400 miles. The rephrasing introduces a subtle and incorrect factual error into the problem, which could be hard to detect at times.
|
| 310 |
+
|
| 311 |
+
# C AST Nodes
|
| 312 |
+
|
| 313 |
+
With the two main types of nodes, we further distinguish them into following nodes:
|
| 314 |
+
|
| 315 |
+
- Binary operation node: A node consists of two operands (nodes) and one main operation.
|
| 316 |
+
- Unary operation node: A node consists of only one operand and one main operation.
|
| 317 |
+
- Variable node: Represents the corresponding variable and its value from the problem. The set of variable nodes will be represented by $V = \{v_{1},\ldots ,v_{n}\} \subset S$ , where $S$ represents the full tree.
|
| 318 |
+
- Constant node: A special type of variable node, where the number appearing in the code does not correspond to any number in the problem. For example, a problem mentioning "one year" implies a number of "365" days in the code.
|
| 319 |
+
|
| 320 |
+
We associate the number in the original question with the variable node so that a change in the variable node will also change the number in the question. If a number appears multiple times in the code and the problem, then we associate them based on the specific procedures described in Section I.4.
|
| 321 |
+
|
| 322 |
+
# D Generation Details
|
| 323 |
+
|
| 324 |
+
In this section, we describe the generation detail for new numbers in each generation method. Each variable node in an AST generates a new number $val(v') = p'$ by following Algorithm 2, which takes the AST $S$ , a maximum number of attempts $N$ , a maximum number of scientific digits $c$ , the set of Boolean constraints $C$ , and the desired generation $M$ method as inputs. It produces $m$ sets of new problems $W' = \{V_1', \ldots, V_m'\}$ that satisfy the given node constraints defined in §3.2. A newly generated adversarial example is valid if all nodes have their given constraints satisfied. Unless otherwise stated, we use $N = 30,000$ and $c = 6$ for all experiments.
|
| 325 |
+
|
| 326 |
+
Algorithm 1: Number Generation Based on Method
|
| 327 |
+
Input: $v_{i}, M, c$
|
| 328 |
+
Output: $v_{i}^{\prime}$
|
| 329 |
+
Let $a_{i} \times 10_{i}^{b} \approx h = val(v_{i})$ , where $a_{i}$ is an integer that is not divisible by 10 and has at most $c$ scientific digits.
|
| 330 |
+
if $M = \mathbf{M1}$ then
|
| 331 |
+
if $v_{i}$ is a divisor for a division node then
|
| 332 |
+
$a_{i}^{\prime} \sim \mathrm{Uniform}(1, 10^{c/2})$
|
| 333 |
+
else
|
| 334 |
+
$a_{i}^{\prime} \sim \mathrm{Uniform}(1, 10^{c})$
|
| 335 |
+
else if $M = \mathbf{M2}$ then
|
| 336 |
+
Let $d$ be the number of digits $val(v_{i})$ has.
|
| 337 |
+
if $d = 1$ then
|
| 338 |
+
$a_{i}^{\prime} \sim \mathrm{Uniform}(1, 99)$
|
| 339 |
+
else
|
| 340 |
+
$a_{i}^{\prime} \sim \mathrm{Uniform}(10^{d-1}, 10^{d}-1)$ $b \gets 0$ if $b > 0$ else $b$
|
| 341 |
+
else if $M = \mathbf{M3}$ then
|
| 342 |
+
if $1 \leq a_{i} \leq 9$ then
|
| 343 |
+
$a_{i}^{\prime} \sim \mathrm{Uniform}(1, 9)$
|
| 344 |
+
else
|
| 345 |
+
$a_{i}^{\prime} \sim \mathrm{Pois}(a_{i})$ $val(v_{i}^{\prime}) \gets a_{i}^{\prime} \times 10^{b}$
|
| 346 |
+
return $v_{i}^{\prime}$
|
| 347 |
+
|
| 348 |
+
Algorithm 2: Problems Generation
|
| 349 |
+
Input: $S = \{s_1,\dots ,s_u\} ,V = \{v_1,\dots ,v_n\} \subset S,N,c,C,M$
|
| 350 |
+
Output: $W^{\prime} = \{V_{1}^{\prime},\ldots ,V_{m}^{\prime}\}$ , where $V_{j}^{\prime} = \{v_{1}^{\prime},\dots ,v_{n}^{\prime}\}$
|
| 351 |
+
attempts $\leftarrow 0,j\gets 1$ $W^{\prime} = \emptyset$
|
| 352 |
+
while attempts $< N$ do
|
| 353 |
+
$V_{j}^{\prime} = \emptyset$
|
| 354 |
+
for $v_{i}\in V$ do Obtain $v_{i}^{\prime}$ from Algorithm 1 with input $v_{i}$ $M$ , and $c$ $V_{j}^{\prime}\gets V_{j}^{\prime}\cup \{v_{i}^{\prime}\}$
|
| 355 |
+
attempts $\leftarrow$ attempts + 1
|
| 356 |
+
$S^{\prime}\gets S$
|
| 357 |
+
Apply the new sequence of values from the variable nodes $V_{j}^{\prime}$ to $S^{\prime}$
|
| 358 |
+
accept $\leftarrow$ True
|
| 359 |
+
for each node $s_k^\prime$ in $S^{\prime}$ do if $\exists C_i\in C,C_i(s_k)\Rightarrow C_i(s_k^{\prime})$ then accept $\leftarrow$ False
|
| 360 |
+
if accept then $W^{\prime}\gets W^{\prime}\cup \{V_{j}^{\prime}\}$ $j\gets j + 1$
|
| 361 |
+
return $W^{\prime}$
|
| 362 |
+
|
| 363 |
+
<table><tr><td>Method</td><td>Question</td><td>Answer</td></tr><tr><td>Original</td><td>Mary does her grocery shopping on Saturday. She does her shopping only at a specific store where she is allowed a credit of $100, which must be paid in full before her next shopping trip. That week she spent the full credit limit and paid $15 of it on Tuesday and $23 of it on Thursday. How much credit will Mary need to pay before her next shopping trip?</td><td>62</td></tr><tr><td>M3</td><td>Mary does her grocery shopping on Saturday. She does her shopping only at a specific store where she is allowed a credit of $80, which must be paid in full before her next shopping trip. That week she spent the full credit limit and paid $12 of it on Tuesday and $19 of it on Thursday. How much credit will Mary need to pay before her next shopping trip?</td><td>49</td></tr><tr><td>M2</td><td>Mary does her grocery shopping on Saturday. She does her shopping only at a specific store where she is allowed a credit of $432, which must be paid in full before her next shopping trip. That week she spent the full credit limit and paid $91 of it on Tuesday and $76 of it on Thursday. How much credit will Mary need to pay before her next shopping trip?</td><td>265</td></tr><tr><td>M1</td><td>Mary does her grocery shopping on Saturday. She does her shopping only at a specific store where she is allowed a credit of $56347, which must be paid in full before her next shopping trip. That week she spent the full credit limit and paid $54731 of it on Tuesday and $1566 of it on Thursday. How much credit will Mary need to pay before her next shopping trip?</td><td>50</td></tr><tr><td>Original</td><td>A birdwatcher records the number of birds he sees each day. One Monday he sees 70 birds. On Tuesday he sees half as many birds as he did on Monday. On Wednesday he sees 8 more birds than he did on Tuesday. How many total birds did the birdwatcher see from Monday to Wednesday?</td><td>148</td></tr><tr><td>M3</td><td>A birdwatcher records the number of birds he sees each day. One Monday he sees 80 birds. On Tuesday he sees half as many birds as he did on Monday. On Wednesday he sees 2 more birds than he did on Tuesday. How many total birds did the birdwatcher see from Monday to Wednesday?</td><td>162</td></tr><tr><td>M2</td><td>A birdwatcher records the number of birds he sees each day. One Monday he sees 26 birds. On Tuesday he sees half as many birds as he did on Monday. On Wednesday he sees 39 more birds than he did on Tuesday. How many total birds did the birdwatcher see from Monday to Wednesday?</td><td>91</td></tr><tr><td>M1</td><td>A birdwatcher records the number of birds he sees each day. One Monday he sees 57010 birds. On Tuesday he sees half as many birds as he did on Monday. On Wednesday he sees 86391 more birds than he did on Tuesday. How many total birds did the birdwatcher see from Monday to Wednesday?</td><td>200411</td></tr></table>
|
| 364 |
+
|
| 365 |
+
Table 6: Examples of questions generated by the three generation methods.
|
| 366 |
+
|
| 367 |
+
# E Rephrasing Attack Performance
|
| 368 |
+
|
| 369 |
+
<table><tr><td>Model</td><td>OA</td><td>AA</td><td>ASR</td></tr><tr><td>Mistral 7B</td><td>10.3</td><td>18.7</td><td>0.0</td></tr><tr><td>MetaMath 7B</td><td>91.1</td><td>79.3</td><td>13.0</td></tr><tr><td>Llama 3 8B</td><td>22.0</td><td>30.0</td><td>0.0</td></tr><tr><td>Llama-2 13B</td><td>2.3</td><td>8.3</td><td>0.0</td></tr><tr><td>WizardMath 13B</td><td>71.0</td><td>70.3</td><td>1.0</td></tr><tr><td>Vicuna 13B</td><td>46.3</td><td>51.7</td><td>0.0</td></tr><tr><td>CodeLlama 34B</td><td>31.3</td><td>10.3</td><td>67.1</td></tr><tr><td>MetaMath 70B</td><td>93.0</td><td>82.7</td><td>11.1</td></tr><tr><td>GPT-3.5</td><td>91.1</td><td>75.7</td><td>16.9</td></tr></table>
|
| 370 |
+
|
| 371 |
+
Table 7: While rephrasing the problem results in lower accuracy for 4 out of 7 models, a few models show improved accuracy with the rephrased version. This suggests that rephrasing the MwPs may not generalize effectively across different LLMs.
|
| 372 |
+
|
| 373 |
+
# F Incorrect Variant Count Distribution
|
| 374 |
+
|
| 375 |
+

|
| 376 |
+
Figure 5: We present the distribution of incorrect adversarial examples in different buckets. For strong models (e.g., GPT-3.5-Turbo, MetaMath 70B), around half of the problems have zero incorrect adversarial examples, while for weaker models (e.g., Llama-2 13B, CodeLlama 34B), most problems have more than 90 incorrect adversarial examples.
|
| 377 |
+
|
| 378 |
+
# G Evaluation Metrics
|
| 379 |
+
|
| 380 |
+
The Attack Success Rate (ASR) is a key metric in adversarial attack research and measures the effectiveness of an attack in causing the model to fail. Specifically, ASR quantifies how much a model's accuracy drops when subjected to adversarial examples. In line with the standard practices in adversarial attack literature, we focus on identifying at least one modified problem that successfully fools the model.
|
| 381 |
+
|
| 382 |
+
Our choice of ASR as the main evaluation metric is grounded in its relevance to the real-world scenario, where an attacker typically only needs one successful perturbation to compromise a system. In adversarial attack literature, particularly in fields such as computer vision and NLP, ASR is a widely adopted standard for evaluating model robustness. For example, RobustBench (Croce et al., 2020), a widely-used benchmark for evaluating model robustness, defines robust accuracy as the model's accuracy on the most adversarial example within all possible perturbations (see Equation (1) in the paper). Similarly, Pruthi et al. (2019) measure attack success based on the model's performance on the worst-case adversary (see Equation (2) in the paper). Furthermore, the AddSent attack proposed by Jia and Liang (2017) picks the worst adversary out of a human-chosen set. These approaches align with our ASR metric's underlying principle: a model is considered robust only if it correctly handles all semantics-preserving perturbations. In addition to ASR, we also report the average percentage of incorrect variants per model in Table 2.
|
| 383 |
+
|
| 384 |
+
# H Number of Generation
|
| 385 |
+
|
| 386 |
+

|
| 387 |
+
Figure 6: With 30,000 attempts for each given constraint, we calculate the average number of adversarial examples generated for each problem.
|
| 388 |
+
|
| 389 |
+
# I Code Analysis
|
| 390 |
+
|
| 391 |
+
# I.1 Incorrect Answer from the Dataset
|
| 392 |
+
|
| 393 |
+
Given the execution steps in code are almost always deterministic, we are able to identify this error effectively. There are also instances where the dataset-provided answers might be wrong. An example of such an instance is the following question from the MultiArith dataset: "Paige's team won their dodgeball game and scored 41 points total. If Paige scored 11 of the points and everyone else scored 6 points each, how many players were on her team?", which the dataset provided 5 as the answer. However, the correct answer should be 6, as Paige is on the team as well. The code provided by GPT-4 counted Paige to the team. To automatically detect such instances, the value of the final answer node will be compared to the answer given by the dataset, and the question will be filtered out for further generations of problems if the two answers don't match. In total, we found only $1\%$ and $2.5\%$ generated codes have incorrect logic or answers in GSM8K and MultiArith, respectively.
|
| 394 |
+
|
| 395 |
+
# I.2 Incorrect Answer from GPT-4
|
| 396 |
+
|
| 397 |
+
Similarly, there are also instances where GPT-4 generated codes that provided the wrong answer to the given question. One such question is from the GSM8K dataset: "Jen decides to travel to 3 different countries. He has to pay $400 for the supplies he needs, in total. The tickets for travel cost, in total, 50% more than the supplies. How much does travel cost?" The correct answer should be \(400 + 400 \times 1.5 = 1000$ , but the code generated by GPT-4 outputted \)600. Similar to the previous error, instances where the code outputs the wrong answers will be detected by comparing them to answers given by the dataset, and the instances will be discarded from generating math problems.
|
| 398 |
+
|
| 399 |
+
# I.3 Contains Control Flow Statements
|
| 400 |
+
|
| 401 |
+
Although specified in the prompt, GPT-4 might generate codes that include control flow statements (including "if", "for", and "while" statements). Codes that contain control flow statements are considered errors and discarded because the codes are usually only applicable to the original instance of the question. Furthermore, the code might not halt for some combinations of numbers, resulting in no answers associated with the generated instances.
|
| 402 |
+
|
| 403 |
+
# I.4 Number Misalignment
|
| 404 |
+
|
| 405 |
+
To ensure the correct generation of new questions, numbers in the original question need to be associated with numbers in the code. Given the sequence of numbers in the question $(q_{1},\ldots ,q_{n})$ and the sequence of numbers in the code $(c_{1},\ldots ,c_{m})$ , the goal of grounding is to associate $q_{i}$ to the correct $c_{j}$ in the code. For distinct $q_{i}$ 's, such pairing is trivial. However, there are instances where some numbers appear multiple times in the question or the code, where a strategy for grounding is needed. Let $C_q(q_i)$ be the count of
|
| 406 |
+
|
| 407 |
+
$q_{i}$ in the question, and let $C_c(c_i)$ be the count of $c_{i}$ in the code. The strategy will be broken down into several scenarios:
|
| 408 |
+
|
| 409 |
+
1. If there is a number $q_i$ , such that $C_q(q_i) < C_c(q_i)$ , then the question will be discarded for further problem generations. The reason to discard this kind of problem is that the relation between the numbers can be very convoluted. One number in the question might correspond to zero, one, or many numbers in the code, and finding the correct correspondence requires human evaluation.
|
| 410 |
+
|
| 411 |
+
2. There is a number qi, such that Cq(qi) > 1 and Cq(qi) = Cc(qi). Similar to the previous scenario, one number in the question can correspond to zero, one, or many numbers in the code. However, after some manual inspection, we find that most questions under this scenario have a one-to-one correspondence between the numbers in the questions and the codes. Therefore, we have devised a method to ensure that the right correspondence of numbers can be retrieved. Given that the number appears Cq(qi) times in the question and the code, we constructed Cq(qi)! pairs of one-to-one correspondences to the numbers from the syntax tree to the question. Then, random numbers are generated to combine the equivalences of correspondences. For example, given that the question is "Mary has 5 apples and 5 oranges, how many fruits does Mary have?". Although the two "5"s correspond to different representations in the question, due to the communicative nature of addition, the two "5"s are interchangeable in the syntax tree. Thus, the two pairs of correspondence for this question can be combined, and there is no ambiguity in the grounding. After the correspondences are combined, one valid sequence of numbers for the question is randomly generated for the code that ensures that all correspondences of the syntax tree output different answers. Then, this version of the question is asked to GPT-4 to obtain the answer to the question. The correspondence that has the same answer will be used, and if no correspondence has the correct answer, the question will be discarded. An example of this type of question is: "The pizzeria sells small pizzas for $2 and large pizzas for $8. They sold $40 in pizzas. If they sold 8 small pizzas, how many large pizzas did they sell?" One valid and distinguishing sequence of numbers for the question is (2,3,31,5), which will result in different answers 5 and 7.
|
| 412 |
+
|
| 413 |
+
3. There is a number $c_{i}$ , such that $C_{q}(c_{i}) > C_{c}(c_{i})$ . Similar to the reasoning for the first case, these kinds of questions are eliminated for problem generations.
|
| 414 |
+
|
| 415 |
+
# J Number of Attacks
|
| 416 |
+
|
| 417 |
+

|
| 418 |
+
Figure 7: We report the model performance given various number of attacks. For several models, only 10 attacks are enough to degrade the performance.
|
| 419 |
+
|
| 420 |
+
# K Feature Analysis
|
| 421 |
+
|
| 422 |
+
<table><tr><td>Features</td><td>MetaMath 7B</td><td>Vicuna 13b</td><td>CodeLlama 34b</td><td>GPT-3.5</td></tr><tr><td>Addition Count</td><td>-0.0032</td><td>0.0080</td><td>-0.0146</td><td>0.0098</td></tr><tr><td>Divide Count</td><td>-0.0648</td><td>-0.1137</td><td>0.0142</td><td>-0.0804</td></tr><tr><td>Minus Count</td><td>-0.0187</td><td>0.0040</td><td>-0.0254</td><td>-0.0195</td></tr><tr><td>Multiply Count</td><td>-0.0328</td><td>0.0214</td><td>0.0031</td><td>-0.0520</td></tr><tr><td>Constant Count</td><td>0.0923</td><td>0.0782</td><td>0.0027</td><td>0.1559</td></tr><tr><td>Variable [8, 32)</td><td>0.0011</td><td>-0.0142</td><td>-0.0100</td><td>0.0117</td></tr><tr><td>Answer [2, 8)</td><td>0.2215</td><td>0.1377</td><td>0.0632</td><td>-0.0736</td></tr><tr><td>Answer [8, 32)</td><td>0.2437</td><td>0.1104</td><td>0.0215</td><td>-0.0787</td></tr><tr><td>Answer [32, 128)</td><td>0.2610</td><td>0.1670</td><td>0.0183</td><td>-0.0508</td></tr><tr><td>Answer [128, 512)</td><td>0.2267</td><td>0.0998</td><td>-0.0259</td><td>-0.0726</td></tr><tr><td>Answer [512, 2048)</td><td>0.0076</td><td>0.0864</td><td>-0.0380</td><td>-0.0343</td></tr><tr><td>Answer [2048, 8192)</td><td>-0.1987</td><td>-0.0775</td><td>-0.0434</td><td>0.0336</td></tr><tr><td>Convert to Int</td><td>0.2400</td><td>0.1664</td><td>0.0470</td><td>0.2476</td></tr><tr><td>Operation Count</td><td>-0.1196</td><td>-0.0804</td><td>-0.0227</td><td>-0.1421</td></tr><tr><td>Variable Count</td><td>0.0722</td><td>0.0254</td><td>0.0074</td><td>0.0939</td></tr><tr><td>Constant</td><td>0.2840</td><td>0.1840</td><td>0.0328</td><td>0.3919</td></tr><tr><td>Features</td><td>Llama 2 13b</td><td>MetaMath 70B</td><td>Mistral 7B</td><td>WizardMath 13B</td></tr><tr><td>Addition Count</td><td>-0.0163</td><td>-0.0287</td><td>0.0102</td><td>-0.0118</td></tr><tr><td>Divide Count</td><td>0.0523</td><td>0.0135</td><td>0.0134</td><td>-0.0423</td></tr><tr><td>Minus Count</td><td>-0.0152</td><td>-0.0271</td><td>0.0097</td><td>-0.0137</td></tr><tr><td>Multiply Count</td><td>-0.0248</td><td>-0.0473</td><td>-0.0422</td><td>-0.0369</td></tr><tr><td>Constant Count</td><td>-0.0051</td><td>0.1136</td><td>0.0478</td><td>0.0958</td></tr><tr><td>Variable [8, 32)</td><td>-0.0349</td><td>0.0286</td><td>-0.0383</td><td>0.0266</td></tr><tr><td>Answer [2, 8)</td><td>0.0205</td><td>0.0588</td><td>0.1006</td><td>0.1448</td></tr><tr><td>Answer [8, 32)</td><td>0.0256</td><td>0.0930</td><td>0.1065</td><td>0.1199</td></tr><tr><td>Answer [32, 128)</td><td>-0.0011</td><td>0.1186</td><td>0.0479</td><td>0.1234</td></tr><tr><td>Answer [128, 512)</td><td>-0.0006</td><td>0.1506</td><td>0.0325</td><td>0.0964</td></tr><tr><td>Answer [512, 2048)</td><td>-0.0186</td><td>0.0771</td><td>-0.0106</td><td>-0.0637</td></tr><tr><td>Answer [2048, 8192)</td><td>-0.0242</td><td>0.0105</td><td>-0.0008</td><td>-0.1885</td></tr><tr><td>Convert to Int</td><td>-0.0435</td><td>0.1771</td><td>-0.0894</td><td>0.0498</td></tr><tr><td>Operation Count</td><td>-0.0040</td><td>-0.0895</td><td>-0.0089</td><td>-0.1047</td></tr><tr><td>Variable Count</td><td>0.0217</td><td>0.1068</td><td>0.0238</td><td>0.0795</td></tr><tr><td>Constant</td><td>0.0205</td><td>0.3100</td><td>0.0805</td><td>0.2800</td></tr></table>
|
| 423 |
+
|
| 424 |
+
Table 8: Coefficients of regression analysis on selected features for each model. Positive coefficients indicate that the model performs better on problems with the corresponding feature, while negative coefficients indicate the opposite. The most positive and negative correlation coefficients for each model are **bolded**, and the second most positive and negative correlation coefficients are **underlined**. We observe that the most positively and negatively correlated features vary across different models, suggesting that our adversarial examples exploit different weaknesses of each model. For example, Mistral 7B and WizardMath 13B perform relatively well on problems with smaller answer values (e.g., in the range of [2, 8) and [8, 32)), while MetaMath 7B and Vicuna 13B show better performance on problems with answer values in the range of [32, 128). The observation matches the accuracy shown in Figure 8. Note that coefficients should not be compared across LLMs, only with other features within the same model. A more suited metric to compare between LLMs is accuracy, such as Table 1 and Figure 7.
|
| 425 |
+
|
| 426 |
+

|
| 427 |
+
Figure 8: The accuracy of LLMs is plotted against five relevant features when tasked with all questions generated by $M3$ . The top left graph shows the accuracy of models against problems with various counts of multiplications, and the top right graph compares problems with various counts of all operations, including both binary and unary operations. The middle left graph shows the accuracy against token counts of the final answer, and the middle right graph shows the accuracy against the count of nodes in the generated AST. The bottom two graphs show the accuracy of models with different ranges of generated numbers and the range of final answers.
|
adversarialmathwordproblemgeneration/images.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:392ea0a1644ad5ca20b29a85f2d07ed017aa4cdef28e811b45b8fd1ee82d48a0
|
| 3 |
+
size 1081095
|
adversarialmathwordproblemgeneration/layout.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bea2ec1b3f054ac56bbd09ca08dd9bbcaaf10a269183f54ca9ffd49288f47da8
|
| 3 |
+
size 566581
|
afriinstructinstructiontuningofafricanlanguagesfordiversetasks/b5c2b468-50bb-4ce9-8d25-3b475d651c30_content_list.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9140d8ca35ccb87f7cf764a6261c9518bd2a7fc1eee05b1a79718c523f73b1bd
|
| 3 |
+
size 110314
|
afriinstructinstructiontuningofafricanlanguagesfordiversetasks/b5c2b468-50bb-4ce9-8d25-3b475d651c30_model.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ced1dbcf028f1f011d655aab49ffc3a42b17708bec676c59ef243caebf33e89a
|
| 3 |
+
size 138019
|