Robust LLM Data Selection via Content-Invariant Gradient Attribution
Authors: Jia Gu, Liang Pang, Huawei Shen
Organizations: Institute of Computing Technology, Chinese Academy of Sciences, Beijing, China · University of Chinese Academy of Sciences, Beijing, China
Gradient-based data attribution has become an important tool for high-quality data selection in the instruction fine-tuning of large language models (LLMs), as it estimates the contribution of training examples through their influence on model optimization. However, we find that existing global gradient attribution methods suffer from surface-form bias: minor changes to semantically irrelevant details, such as wording or formatting, can produce highly inconsistent attribution scores even when the underlying content remains unchanged. To address this issue, we propose Content-Invariant Gradient Attribution (CIGA), a robust framework for instruction data selection. CIGA first identifies layers whose gradients are both influential for attribution and stable under semantics-preserving surface-form perturbations, thereby reducing formatting noise in gradient features. It then dynamically fuses these attribution signals with semantic representations of the input, combining optimization-level influence with content-level information. Extensive experiments across multiple benchmarks show that CIGA produces more stable rankings under surface-form perturbations while preserving downstream capabilities and improving average performance. CIGA also reduces attribution cost, offering a robust and efficient approach to data selection for LLM instruction tuning.
Figures & tables
Figure 1: Global-gradient attribution can be sensitive to semantically irrelevant surface details: minor wording or formatting changes produce different gradient representations and low-overlap selected subsets.
Figure 2: Overview of CIGA: (1) warm-up fine-tuning; (2) consistent influential layer selection across prompt variants; (3) task-adaptive fusion of gradient and semantic rankings; and (4) Top- k% selection and retraining.
Test
LESS
TracIn
CIGA
LLaMA-2-7B
TyDiQA
41.40
36.75
42.40
MMLU
62.16
58.50
76.04
BBH
68.94
69.86
71.92
GSM8K
46.07
51.96
52.00
HellaSwag
22.64
28.24
49.29
Table 1: Mean pairwise Jaccard similarity (%) across five semantics-preserving surface-form variants. Higher values indicate greater selection consistency.
Method
LLaMA-2-7B
Qwen3-4B-Base
TyDiQA
MMLU
BBH
GSM
Hella
ΔRand
TyDiQA
MMLU
BBH
GSM
Hella
ΔRand
Reference Baselines
Full
50.77 (0.3)
47.14 (0.2)
43.80 (0.8)
25.17 (1.0)
74.15 (0.3)
+2.48
66.34 (0.4)
72.89 (0.3)
68.52 (0.9)
78.09 (1.1)
70.40 (0.3)
-1.12
Random
49.54 (0.5)
45.51 (0.4)
41.85 (0.6)
17.29 (1.6)
74.47 (0.4)
-
73.16 (0.5)
73.01 (0.4)
67.13 (1.3)
78.01 (0.9)
70.52 (0.4)
-
Heuristic & Semantic Methods
Cos
48.31 (0.4)
46.06 (0.3)
40.93 (1.0)
21.91 (0.7)
74.52 (0.3)
+0.62
72.23 (1.4)
73.23 (0.3)
67.41 (1.1)
78.85 (1.0)
70.69 (0.3)
+0.11
Table 2: Performance comparison across test datasets (%). ΔRand is the average improvement over Random, and parentheses report standard deviations over three runs. ∗ marks a significant improvement of CIGA over Random ( p<0.05 ) on the corresponding task or macro-average. Bold marks the best result among selection methods (excluding Full and Random), and underline marks performance surpassing Full.
Model
Method
Jaccard
Downstream Avg
LLaMA-2-7B
CIGA-G
56.44
47.15
CIGA
58.33
47.84
Qwen3-4B-Base
CIGA-G
46.96
73.26
CIGA
48.68
73.40
Table 3: Component ablation in selection consistency and downstream performance (%).
Figure 3: Selected consistent influential layers across tasks. Shaded regions denote the middle layers of each model.
Model
Layers ( k )
TyDiQA
MMLU
BBH
GSM
Hella
Avg
LLaMA-2-7B
3
+0.10
− 0.01
− 0.19
+0.23
− 0.17
− 0.01
5
+0.67
+0.06
+0.18
+0.15
− 0.11
+0.19
Qwen3-4B-Base
3
+0.67
+0.12
0.00
− 0.22
− 0.10
+0.09
5
+1.04
+0.08
− 0.09
+0.08
− 0.02
+0.22
Table 4: Effect of the number of attribution layers on downstream performance (%). Layers are ranked by Slci . Values are differences from the single-layer setting ( k=1 ) measured in the same runs.
Model
Downstream Avg
Jaccard
n=3
n=4
n=3
n=4
Qwen3-4B-Base
− 0.37
− 0.19
− 3.09
− 0.95
LLaMA-2-7B
− 0.09
− 0.35
− 1.96
− 0.08
Table 5: Number of surface-form variants (%). Values are differences from the default setting ( n=5 ).
Stage
Complexity
CIGA
LESS
Warm-up
O(∣Dwarmup∣⋅N)
1 Hour
4 Hours
Grad-Score
O(∣D∣⋅N)
20 Hours
70 Hours
Layer Selection
O(mL∣Dval∣dg)
5 Min
–
Sem-Score
O(∣D∣∣Dval∣ds)
6 Min
–
Data Selection
O(∣D∣∣Dval∣dg)
< 1 Min
< 1 Min
Total
21.4 Hours
74.1 Hours
Table 6: Computational cost of the data-selection pipeline. L and m denote the numbers of layers and surface-form variants; dg and ds denote the gradient and semantic feature dimensions.
Figure 4: Comparison of gradient distributions via t-SNE.
Figure 5: Relationship between the consistent influential score and downstream performance across layers.
Appendix figures & tables7 assets
Supplementary material from the paper’s appendix.
Appendix
Dataset
Volume
Primary Content Domain
FLAN v2 ( Longpre et al., 2023 )
100000
Zero shot and few shot NLP tasks
CoT ( Wei et al., 2022 )
100000
Step by step logical deduction
Alpaca GPT4 ( Peng et al., 2023 )
52002
High quality general instructions
Dolly ( Conover et al., 2023 )
15011
Human generated conversational records
OASST1 ( Köpf et al., 2023 )
55668
Multi turn dialogue sequences
GSM8K ( Cobbe et al., 2021 )
7473
Grade school mathematical reasoning
Appendix
Table 7: Overview of the candidate training datasets, including their approximate volume and primary content focus.
Dataset
Template
Content
TyDiQA
Template 0
Answer the following question based on the information in the given passage. Passage: {C} \nQuestion: {Q} \nAnswer: {A}
Template 1
Read the text below and provide a answer to the query. Text: {C} \nQ: {Q} \nA: {A}
Template 2
Given the background context, please extract the answer. Context: {C} \nQuery: {Q} \nResponse: {A}
Table 8: Details of prompt variant templates across different benchmark datasets.
Figure 6: Sensitivity analysis of the variance penalty coefficient α in the CIGA layer selection mechanism.
Figure 7: Sensitivity analysis of the SNR sensitivity γ in dynamic feature fusion.
Hyperparameter
Value
TydiQA
MMLU
BBH
GSM8K
HellaSwag
Avg
Variance Penalty ( α )
0.1
54.32
45.77
41.20
17.66
74.62
46.71
0.4
54.32
47.46
41.20
17.66
74.54
47.04
0.7
56.17
47.46
41.39
19.64
74.54
47.84
1.0
54.77
47.46
37.78
19.64
74.54
46.84
Fusion Coefficient ( γ )
1
56.14
47.45
41.20
19.18
74.47
47.69
1/2
56.14
47.29
40.93
19.11
74.41
47.58
Appendix
Table 9: Performance metrics (%) under different configurations of hyperparameter α and γ .
Figure 8: Selection-ratio ablation on Qwen3-4B-Base. Scores are reported in percent. The dotted line marks the default 5% ratio; panels use task-specific y-axis ranges.
Method
Text (Validation Example / Selected Training Sample)
Eval Data
BBH (Boolean Expressions) : [User]: Evaluate the result of a random Boolean expression. Q: not ( ( not not True ) ) is [Assistant]: Let’s think step by step. Remember that (i) expressions inside brackets are always evaluated first and that (ii) the order of operations from highest priority to lowest priority is "not", "and", "or", respectively. We first simplify this expression "Z" as follows… [… Deduction steps truncated …] …So the answer is False.
Cos
dolly_2928 : [User]: Given these two sets of instructions, will you end up at the same end point if you started at the same beginning point? First instructions: 1) Take 2 steps forward… [Assistant]: Yes, you will end up at the same point for both sets of instructions…
LESS
oasst1_15234 : [User]: If you have a 3 gallon cylindrical shaped jug and a 5 gallon… [Assistant]: The correct procedure to end up with exactly 4 gallons in the 5 gallon jug is: b… [User]: i dont understand, can you explain it to me like I was like 5? [Assistant]: My apologies if that was confusing. I have realized that my previous answer was incorrect…
TracIn
oasst1_15229 : [User]: If you have a 3 gallon cylindrical shaped jug and a 5 gallon… [Assistant]: The correct answer is: “e. None of the above” .
CIGA
oasst1_15233 : [User]: If you have a 3 gallon cylindrical shaped jug and a 5 gallon… [Assistant]: The correct procedure to end up with exactly 4 gallons in the 5 gallon jug is: b. Fill 3 gallon jug. Pour it all into the 5 gallon jug twice Here’s the explanation: 1. Fill the 3 gallon jug with water. 2. Pour all 3 gallons from the 3 gallon jug into the 5 gallon jug…
Appendix
Table 10: Top-1 selected training samples by different methods for the BBH evaluation task.
Data attribution methods using gradient similarity are widely used to analyze and select training data for large language models, but what gradient similarity actually measures is debated. Some interpret it as identifying task-relevant skills, while other work reports that surface form is the main factor. We resolve this debate for supervised fine-tuning examples by varying task and answer format independently. Specifically, we render benchmarks in different answer formats, such that datasets can share a task without a format or a format without a task. We find that gradient alignment follows the answer format, as benchmark pairs sharing an answer format align strongly (disattenuated cosine near 0.4), while same benchmarks rendered with different answer format classes show no alignment (near 0.0). We demonstrate that this ordering holds from the earliest pretraining checkpoints through post-training, and across model scales and families. We then analyze the released selections of LESS, a gradient-based data selection method for instruction tuning, and find that each target's selections over-represent the target's own answer format. Hence, we demonstrate that gradient-based attribution methods track format similarity more than task semantics, meaning that such methods, as well as the semantic interpretation of the gradient, should be tested on data where answer format and task vary independently for greater robustness and reliability.
Large Language Models (LLMs) are increasingly deployed across diverse applications, raising critical questions for governance, accountability, and data provenance. Understanding which training data most influenced a model's output remains a fundamental open problem. We address this challenge through training data attribution (TDA) for auto-regressive LLMs by expanding upon the inverse formulation: How would training data be affected if the model had seen the generated output during training? Our method perturbs the base model using bidirectional gradient optimization (gradient ascent and descent) on a generated text sample and measures the resulting change in loss across training samples. Our framework supports attribution at arbitrary data granularity, enabling both factual and stylistic attribution. We evaluate our method against baselines on pretrained models with known datasets, and show that it outperforms previous work on influence metrics, thereby enhancing model interpretability, an essential requirement for accountable AI systems.
Frédéric Berdoz, Luca A. Lanzendörfer, Kaan Bayraktar +1
With Large Language Model (LLM) pre-training and fine-tuning shifting its focus from data volume to data quality, quality data selection has emerged as a critical research topic. Existing online data selection methods for LLM training are typically "batch-constrained", limiting optimization to local utility within random batches. To overcome this, we propose GAIA (Global Adaptive Instruction tuning via GAussian processes), a framework that formulates data valuation as a global estimation process. GAIA employs Gaussian Process regression to model continuous utility manifolds across the semantic space, utilizing an adaptive strategy fusion mechanism to dynamically prioritize high-utility samples. By casting the strategy-posterior update as an instance of the classical fixed-share Hedge framework for tracking the best expert, we inherit a dynamic-regret guarantee that characterizes GAIA's robustness under non-stationary quality scores during training. Empirical evaluations on three datasets demonstrate that GAIA significantly outperforms state-of-the-art baselines like \greats, establishing our method as a scalable and robust solution for efficient instruction tuning.