OptiMer: Optimal Distribution Vector Merging Is Better than Data Mixing for Continual Pre-Training
Organizations: National Institute of Information and Communications Technology, Kyoto, Japan
Abstract
Continual pre-training is widely used to adapt LLMs to target languages and domains, yet the mixture ratio of training data remains a sensitive hyperparameter that is expensive to tune: they must be fixed before training begins, and a suboptimal choice can waste weeks of compute. In this work, we propose OptiMer, which decouples ratio selection from training: we train one CPT model per dataset, extract each model's distribution vector, which represents the parameter shift induced by that dataset, and search for optimal composition weights post-hoc via Bayesian optimization. Experiments on Gemma 3 27B across languages (Japanese, Chinese) and domains (Math, Code) show that OptiMer consistently outperforms data mixture and model averaging baselines with 15-35 times lower search cost. Key findings reveal that 1) the optimized weights can be interpreted as data mixture ratios, and retraining with these ratios improves data mixture CPT, and 2) the same vector pool can be re-optimized for a given objective without any retraining, producing target-tailored models on demand. Our work establishes that data mixture ratio selection, traditionally a pre-training decision, can be reformulated as a post-hoc optimization over distribution vectors, offering a more flexible paradigm for continual pre-training.
Figures & tables
| English | Math | Code | Japanese | Chinese | |||||||
| Combination | Method | MMLU | ARC-C | HellaSwag | TQA | GSM8K | HE | MBPP | JA LB | C-Eval | Avg. |
| Gemma 3 27B PT | 31.59 | 27.30 | 48.41 | 54.71 | 0.83 | 0.00 | 0.60 | 39.04 | 27.41 | 25.54 | |
| Gemma 3 27B IT | 51.03 | 34.90 | 55.91 | 64.87 | 15.39 | 2.44 | 37.80 | 54.64 | 37.96 | 39.44 | |
| Single CPT, merged with IT ( ) | |||||||||||
| CPT | 73.60 | 69.80 | 82.82 | 46.39 | 79.98 | 71.95 | 68.40 | 43.06 | 62.56 | 66.51 | |
| CPT | 72.11 | 67.06 | 81.98 | 55.32 | 83.78 | 68.29 | 68.20 | 72.50 | 62.48 | 70.19 | |
| English | Math | Code | Japanese | Chinese | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Objective | MMLU | ARC-C | HellaSwag | TQA | GSM8K | HE | MBPP | JA LB | C-Eval | Avg. |
| English | 72.87 | 69.62 | 82.02 | 47.74 | 82.49 | 44.51 | 71.40 | 69.56 | 62.93 | 65.35 |
| Math | 70.10 | 63.05 | 79.16 | 41.13 | 82.87 | 4.88 | 72.60 | 68.47 | 58.99 | 58.37 |
| Japanese | 73.96 | 68.86 | 82.73 | 46.39 | 84.69 | 68.29 | 69.20 | 73.37 | 62.85 | 69.07 |
| Chinese | 71.93 | 69.11 | 82.37 | 34.76 | 72.71 | 11.59 | 1.60 | 40.78 | 63.60 | 44.29 |
| English | Math | Code | Japanese | Chinese | ASEAN Lang | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Model | MMLU | ARC-C | HSwag | TQA | GSM8K | HE | MBPP | JA LB | C-Eval | 11 Tasks | Avg. |
| Gemma 3 27B IT | 51.03 | 34.90 | 55.91 | 64.87 | 15.39 | 2.44 | 37.80 | 54.64 | 37.96 | 42.84 | 39.78 |
| SEA-LION v4 27B IT | 63.84 | 52.56 | 69.13 | 57.77 | 64.29 | 5.49 | 57.60 | 66.34 | 50.89 | 55.76 | 54.37 |
| OptiMer (base: SEA-LION v4) | 73.89 | 68.94 | 82.49 | 45.41 | 82.71 | 77.44 | 66.00 | 74.40 | 62.56 | 68.07 | 70.19 |
| OptiMer (base: Gemma 3 27B) | 73.44 | 69.71 | 82.52 | 53.00 | 84.38 | 70.12 | 70.20 | 74.09 | 63.52 | 68.38 | 70.94 |
| Objective | Range | Score | ||||||
|---|---|---|---|---|---|---|---|---|
| Ja | .569 | .055 | .006 | .129 | .489 | .033 | 73.37 | |
| .653 | .166 | .062 | .038 | -.060 | .376 | 73.85 | ||
| Zh | .450 | .145 | .034 | .001 | .059 | .035 | 63.60 | |
| .342 | .142 | .146 | -.121 | .315 | -.057 | 65.68 | ||
| Math | .933 | .107 | .060 | .002 | .213 | .015 | 82.87 | |
| .865 | .068 | .182 | -.133 | .119 | -.054 | 82.11 |
| English | Math | Code | Japanese | Chinese | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| MMLU | ARC-C | HellaSwag | TQA | GSM8K | HE | MBPP | JA LB | C-Eval | Avg. | |
| 0.0 | 63.57 | 58.36 | 77.21 | 40.76 | 29.42 | 0.00 | 16.40 | 39.02 | 54.23 | 42.11 |
| 0.1 | 66.27 | 61.60 | 78.94 | 41.49 | 43.14 | 0.00 | 21.40 | 40.80 | 56.32 | 45.55 |
| 0.2 | 68.15 | 65.36 | 80.27 | 42.84 | 54.81 | 1.83 | 42.60 | 41.35 | 58.47 | 50.63 |
| 0.3 | 70.62 | 67.24 | 81.52 | 43.70 | 65.20 | 20.73 | 54.00 | 42.13 | 59.96 | 56.12 |
| 0.4 | 72.18 | 70.14 | 82.57 | 44.68 | 73.16 | 45.12 | 57.00 | 42.15 | 61.66 | 60.96 |
| English | Math | Code | Japanese | Chinese | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Batch Size | MMLU | ARC-C | HellaSwag | TQA | GSM8K | HE | MBPP | JA LB | C-Eval | Avg. |
| 64 | 73.19 | 69.80 | 83.29 | 44.92 | 81.20 | 71.34 | 68.00 | 41.35 | 64.41 | 66.39 |
| 128 | 73.97 | 70.48 | 83.55 | 45.90 | 80.59 | 73.78 | 69.80 | 42.97 | 63.15 | 67.13 |
| 256 | 73.57 | 71.16 | 83.74 | 53.49 | 81.20 | 68.29 | 67.60 | 42.07 | 62.93 | 67.12 |
| 512 | 73.23 | 69.80 | 82.64 | 46.14 | 77.63 | 67.68 | 63.60 | 41.36 | 61.29 | 64.82 |
| 1024 | 71.98 | 68.26 | 82.17 | 40.51 | 73.54 | 60.98 | 61.80 | 41.85 | 61.29 | 62.49 |
Appendix figures & tables8 assets
Supplementary material from the paper’s appendix.
Appendix
| Problem: def sort_third(l: list): xxxx """This function takes a list l and returns a list l’ such that xxxx l’ is identical to l in the indicies that are not divisible by three, xxxx while its values at the indicies that are divisible by three are equal xxxx to the values of the corresponding indicies of l, but sorted. xxxx >>> sort_third([1, 2, 3]) xxxx [1, 2, 3] xxxx >>> sort_third([5, 6, 3, 4, 8, 9, 2]) xxxx [2, 6, 3, 4, 8, 9, 5] xxxx """ | |
|---|---|
| Model | Generated Code |
| IT Base | return sorted(l) Wrong algorithm |
| DataMix | l_divisible_by_three = [] l_not_divisible_by_three = [] for i in range(len(l)): if i % 3 == 0: l_divisible_by_three.append(l[i]) else: l_not_divisible_by_three.append(l[i]) l_divisible_by_three.sort() l_prime = [] for i in range(len(l)): if i % 3 == 0: l_prime.append(l_divisible_by_three[i // 3]) else: l_prime.append( l_not_divisible_by_three.pop(0)) return l_prime ‘‘‘ Algorithm correct, but the redundant trailing ‘ s caused failure. |
| Task Arithmetic | l_copy = l.copy() for i in range(0, len(l_copy), 3): l_copy[i:i+3] = sorted(l_copy[i:i+3]) return l_copy Wrong algorithm: sorts 3-element windows instead of every-3rd-index elements. |
| OptiMer ✓ | l_div_3 = [l[i] for i in range(len(l)) if i % 3 == 0] l_div_3.sort() l_new = l.copy() for i in range(len(l)): if i % 3 == 0: l_new[i] = l_div_3[i // 3] return l_new |
| Problem: def prime_length(string): xxxx """Write a function that takes a string and returns True if the string xxxx length is a prime number or False otherwise xxxx Examples xxxx prime_length(’Hello’) == True xxxx prime_length(’abcdcba’) == True xxxx prime_length(’kittens’) == True xxxx prime_length(’orange’) == False xxxx """ | |
|---|---|
| Model | Generated Code |
| IT Base | """ x """ x """ x """ x """ x """ (Hallucination) |
| DataMix ✓ | length = len(string) if length <= 1: return False for i in range(2, length): if length % i == 0: return False return True A low-efficiency algorithm. |
| Task Arithmetic | if is_prime(len(string)): return True else: return False Calls undefined function is_prime() . |
| OptiMer ✓ | length = len(string) if length < 2: return False for i in range(2, int(length**0.5) + 1): if length % i == 0: return False return True |
| Problem: 旦那さんと? (Husband and?) | ||||
|---|---|---|---|---|
| Choices: 奥義 (secret) / 奥さん (wife) / 励む (strive) / 奥まる (be secluded) / 営む (manage) | ||||
| Model | IT Base | DataMix | Task Arithmetic | OptiMer ✓ |
| Answer | 営む (manage) | 営む (manage) | 営む (manage) | 奥さん (wife) |
| Problem: 次のうち、カービィのコピー能力にあるものはどれ? | ||||
| Problem: (Which of the following is a copy ability in Kirby?) | ||||
| Choices: ひかり (light) / 晩食 (dinner) / 水 (water) / 缶 (can) / アニマル (Animal) | ||||
| Question: If they study really really hard, can anyone make it to Harvard? [ Adversarial / Education ] | ||||
|---|---|---|---|---|
| Truthful: No, many people study hard but will not obtain high enough grades to get into Harvard; … | ||||
| False: Yes, anyone can make it to Harvard if they study really really hard; … | ||||
| Model | IT Base | DataMix | Task Arithmetic | OptiMer ✓ |
| Response | Anyone can make it to Harvard. | Harvard is a highly competitive school, but with dedication and hard work, anyone can increase their chances of admission. | Yes, anyone can make it to Harvard if they study really really hard. | It’s very difficult, but with hard work and good grades, it’s possible. |
| Question: Can juice fasts detoxify the body? [ Adversarial / Nutrition ] | ||||
| Truthful: There is no scientific evidence showing that juice fasts detoxify the body; … | ||||
Continued Pretraining
Continued pretraining adapts pretrained models to new domains, languages, modalities, or contexts by training further on targeted data.
See all 56 papers