tokyotech-llm/Llama-3.1-8B-math-ablation-exp2-LR2.5e-5-WD0.1-iter0010000

Model

0

stars

16

commits

1

linked in READMEs

May 7, 2025

updated

llama
safetensors

README

Model Card

SwallowCodeMath Icon

Model Summary

This model is a continual pre-training of Llama-3.1-8B on a mix of mathematical datasets from SwallowMath and multilingual text datasets. The model was trained to evaluate the performance of mathematical reasoning and problem-solving as part of the SwallowMath ablation experiments (experiment 2).

It was trained on 50 billion tokens using a mix of 4.8% SwallowMath (finemath-4+ rewritten) , 13.1% Code, and 82% multilingual text, following the setup described in the SwallowMath paper. Training was performed using Megatron-LM.

Use

Generation

# pip install -q transformers
from transformers import AutoModelForCausalLM, AutoTokenizer

model = "tokyotech-llm/<model-name>"
device = "cuda"  # for GPU usage or "cpu" for CPU usage

tokenizer = AutoTokenizer.from_pretrained(model)
model = AutoModelForCausalLM.from_pretrained(model).to(device)

inputs = tokenizer.encode("Solve the equation 2x + 3 = 7:", return_tensors="pt").to(device)
outputs = model.generate(inputs, max_length=100)
print(tokenizer.decode(outputs[0]))

Training

Model

  • Architecture: Llama-3.1
  • Pretraining tokens: 50B
  • Precision: bfloat16
  • Sequence length: 8,192
  • Tokenizer: Llama-3 tokenizer

Data

The training mix consists of:

  • Mathematical Data (~4.84%):
    • Target Math Data: 2.4B tokens
  • Code Data (~13.12%):
    • SwallowCode (Syntax, Pylint Filtered): 6.5B tokens
  • Multilingual Text (~82.04%):
    • Japanese Wikipedia: 0.84B tokens
    • Japanese Swallow Corpus v2: 33.0B tokens
    • Laboro-ParaCorpus: 0.22B tokens
    • English Wikipedia: 1.1B tokens
    • English Cosmopedia: 3.3B tokens
    • English DCLM: 2.2B tokens

Details are in the paper’s Appendix.

Hardware

  • GPUs: 64 NVIDIA H100 (94GB)
  • Interconnect: InfiniBand NDR200
  • Supercomputer: TSUBAME, Institute of Science Tokyo

Software

  • Megatron-LM (version core_r0.9.0) for training
  • lm-evaluation-harness for evaluation
  • BigCodeBench for code evaluation

Evaluation

The model was evaluated using the setup described in the SwallowMath paper, with the lm-evaluation-harness and BigCodeBench. Benchmarks include mathematical reasoning (GSM8K, MATH), code generation (HumanEval), and general tasks (OpenBookQA, TriviaQA, HellaSwag, SQuAD 2.0, XWINO, MMLU, BBH). Results are reported for checkpoints at 10B, 20B, 30B, 40B, and 50B tokens.

Evaluation Results (SwallowMath experiment 2)

Tokens (B)OpenBookQATriviaQAHellaSwagSQuAD2.0XWINOMMLUHumanEvalGSM8KBBHMATH
100.37200.66430.59700.34430.90150.63430.34390.56030.55350.2480
200.38000.65800.59460.34280.89940.62930.37620.61560.56690.2860
300.36600.66180.59640.34700.90110.62980.35300.62620.63830.3040
400.37000.66100.59730.35350.90880.63580.37380.64220.62370.3100
500.38000.66370.59720.35370.90450.63370.36830.65350.64140.3160

Citation

@misc{fujii2025rewritingpretrainingdataboosts,
      title={Rewriting Pre-Training Data Boosts LLM Performance in Math and Code}, 
      author={Kazuki Fujii and Yukito Tajima and Sakae Mizuki and Hinari Shimada and Taihei Shiotani and Koshiro Saito and Masanari Ohi and Masaki Kawamura and Taishi Nakamura and Takumi Okamoto and Shigeki Ishida and Kakeru Hattori and Youmi Ma and Hiroya Takamura and Rio Yokota and Naoaki Okazaki},
      year={2025},
      eprint={2505.02881},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2505.02881}, 
}

Contributors

kazukifujii

16 commits

tokyotech-llm/Llama-3.1-8B-math-ablation-exp2-LR2.5e-5-WD0.1-iter0010000

Model

0

stars

16

commits

1

linked in READMEs

May 7, 2025

updated

llama
safetensors

README

Model Card

SwallowCodeMath Icon

Model Summary

This model is a continual pre-training of Llama-3.1-8B on a mix of mathematical datasets from SwallowMath and multilingual text datasets. The model was trained to evaluate the performance of mathematical reasoning and problem-solving as part of the SwallowMath ablation experiments (experiment 2).

It was trained on 50 billion tokens using a mix of 4.8% SwallowMath (finemath-4+ rewritten) , 13.1% Code, and 82% multilingual text, following the setup described in the SwallowMath paper. Training was performed using Megatron-LM.

Use

Generation

# pip install -q transformers
from transformers import AutoModelForCausalLM, AutoTokenizer

model = "tokyotech-llm/<model-name>"
device = "cuda"  # for GPU usage or "cpu" for CPU usage

tokenizer = AutoTokenizer.from_pretrained(model)
model = AutoModelForCausalLM.from_pretrained(model).to(device)

inputs = tokenizer.encode("Solve the equation 2x + 3 = 7:", return_tensors="pt").to(device)
outputs = model.generate(inputs, max_length=100)
print(tokenizer.decode(outputs[0]))

Training

Model

  • Architecture: Llama-3.1
  • Pretraining tokens: 50B
  • Precision: bfloat16
  • Sequence length: 8,192
  • Tokenizer: Llama-3 tokenizer

Data

The training mix consists of:

  • Mathematical Data (~4.84%):
    • Target Math Data: 2.4B tokens
  • Code Data (~13.12%):
    • SwallowCode (Syntax, Pylint Filtered): 6.5B tokens
  • Multilingual Text (~82.04%):
    • Japanese Wikipedia: 0.84B tokens
    • Japanese Swallow Corpus v2: 33.0B tokens
    • Laboro-ParaCorpus: 0.22B tokens
    • English Wikipedia: 1.1B tokens
    • English Cosmopedia: 3.3B tokens
    • English DCLM: 2.2B tokens

Details are in the paper’s Appendix.

Hardware

  • GPUs: 64 NVIDIA H100 (94GB)
  • Interconnect: InfiniBand NDR200
  • Supercomputer: TSUBAME, Institute of Science Tokyo

Software

  • Megatron-LM (version core_r0.9.0) for training
  • lm-evaluation-harness for evaluation
  • BigCodeBench for code evaluation

Evaluation

The model was evaluated using the setup described in the SwallowMath paper, with the lm-evaluation-harness and BigCodeBench. Benchmarks include mathematical reasoning (GSM8K, MATH), code generation (HumanEval), and general tasks (OpenBookQA, TriviaQA, HellaSwag, SQuAD 2.0, XWINO, MMLU, BBH). Results are reported for checkpoints at 10B, 20B, 30B, 40B, and 50B tokens.

Evaluation Results (SwallowMath experiment 2)

Tokens (B)OpenBookQATriviaQAHellaSwagSQuAD2.0XWINOMMLUHumanEvalGSM8KBBHMATH
100.37200.66430.59700.34430.90150.63430.34390.56030.55350.2480
200.38000.65800.59460.34280.89940.62930.37620.61560.56690.2860
300.36600.66180.59640.34700.90110.62980.35300.62620.63830.3040
400.37000.66100.59730.35350.90880.63580.37380.64220.62370.3100
500.38000.66370.59720.35370.90450.63370.36830.65350.64140.3160

Citation

@misc{fujii2025rewritingpretrainingdataboosts,
      title={Rewriting Pre-Training Data Boosts LLM Performance in Math and Code}, 
      author={Kazuki Fujii and Yukito Tajima and Sakae Mizuki and Hinari Shimada and Taihei Shiotani and Koshiro Saito and Masanari Ohi and Masaki Kawamura and Taishi Nakamura and Takumi Okamoto and Shigeki Ishida and Kakeru Hattori and Youmi Ma and Hiroya Takamura and Rio Yokota and Naoaki Okazaki},
      year={2025},
      eprint={2505.02881},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2505.02881}, 
}

Contributors

kazukifujii

16 commits