institute-of-science-tokyo / llama-3.1-swallow-8b-instruct-v0.1

Llama 3.1 Swallow

Llama 3.1 Swallow is a series of large language models (8B, 70B) that were built by continual pre-training on the Meta Llama 3.1 models.
Llama 3.1 Swallow enhanced the Japanese language capabilities of the original Llama 3.1 while retaining the English language capabilities.
We use approximately 200 billion tokens that were sampled from a large Japanese web corpus (Swallow Corpus Version 2), Japanese and English Wikipedia articles, and mathematical and
coding contents, etc (see the Training Datasets section) for continual pre-training.
The instruction-tuned models (Instruct) were built by supervised fine-tuning (SFT) on the synthetic data specially built for Japanese.
See the Swallow Model Index section to find other model variants.

Release History

Swallow Model Index

ModelLlama-3.1-SwallowLlama-3.1-Swallow-Instruct
8BLinkLink
70BLinkLink

The website https://swallow-llm.github.io/ provides large language models developed by the Swallow team.

Third-Party Community Consideration

This model is not owned or developed by NVIDIA. This model has been developed and built to a third-party’s requirements for this application and use case; see link to Non-NVIDIA Model Card.

License and Terms of Use

GOVERNING TERMS: This trial service is governed by the NVIDIA API Trial Terms of Service. Use of this model is governed by the Llama 3.1 Community License Agreement and the Gemma Terms of Use. Built with Llama.

Model Details

  • Model type: Please refer to Llama 3.1 MODEL_CARD for details on the model architecture.
  • Language(s): Japanese English
  • Library: Megatron-LM
  • Tokenizer: Please refer to Llama 3.1 blog for details on the tokenizer.
  • Contact: swallow[at]nlp.c.titech.ac.jp

Model Architecture:

Architecture Type: Transformer

Input:

Input Type(s): Text

Input Format(s): String

Input Parameters: One Dimensional (1D)

Output:

Output Type(s): Text

Output Format: String

Output Parameters: 1D

Supported Hardware Microarchitecture Compatibility:

  • NVIDIA Ampere
  • NVIDIA Hopper
  • NVIDIA Lovelace

Model Performance

Japanese tasks

ModelJCom.JEMHopQANIILCJSQuADXL-SumMGSMWMT20-en-jaWMT20-ja-enJMMLUJHumanEvalJa Avg
4-shot4-shot4-shot4-shot1-shot4-shot4-shot4-shot5-shot0-shot
EM accChar-F1Char-F1Char-F1ROUGE-2EM accBLEUBLEUEM accpass@1
RakutenAI-7B-chat0.90350.26000.46190.86470.13390.21200.26670.19660.45040.22990.3980
Qwen2-7B-Instruct0.88560.39020.38590.89670.12770.57200.20410.19090.57130.56830.4793
Qwen2.5-7B-Instruct0.91510.42930.39100.89080.16760.62400.21080.19160.62520.53050.4976
Tanuki-8B-dpo-v1.00.27700.29370.37100.66690.10160.42800.23850.18200.30780.25550.3122
Llama 3 8B Instruct0.87850.38120.39360.89550.12730.41600.21430.20350.47190.28720.4269
Llama 3.1 8B Instruct0.88290.42720.41120.88560.14810.52800.21740.19900.50860.49760.4706
Llama 3 Youko 8B Instruct0.91960.48500.51780.90010.20850.46800.25590.19060.46910.26950.4684
Llama-3-ELYZA-JP-8B0.90170.51240.50160.91130.16770.46000.25090.18460.48290.38110.4754
Llama 3 heron brain 8B v0.30.92310.49330.56940.90560.21780.45600.27710.21680.49930.31770.4876
Llama 3 Swallow 8B Instruct0.91780.49630.51680.90880.12960.48800.25220.22540.48350.39270.4811
Llama 3.1 Swallow 8B Instruct0.92400.58740.57360.91700.13800.50800.28200.22820.53010.36650.5055

English tasks

ModelOpenBookQATriviaQAHellaSWAGSQuAD2.0XWINOMMLUGSM8KBBHHumanEvalEn Avg
4-shot4-shot4-shot4-shot4-shot5-shot4-shot3-shot0-shot
AccEM accAccEM accAccAccEM accCoT EM Accpass@1
RakutenAI-7B-chat0.41600.59710.64650.30910.88860.57570.31390.49580.26710.5011
Qwen2-7B-Instruct0.40000.54680.61460.35180.88520.70730.63000.31010.63540.5646
Qwen2.5-7B-Instruct0.42800.51870.62400.26260.87610.74190.74150.21500.63600.5604
Tanuki-8B-dpo-v1.00.33400.28380.46960.23950.81680.37720.48670.33500.28050.4026
Llama 3 8B Instruct0.38800.66870.58340.37430.89030.65670.74530.64780.54150.6107
Llama 3.1 8B Instruct0.37000.69940.59200.37830.90370.68090.74300.69280.62930.6321
Llama 3 Youko 8B Instruct0.40800.61290.59830.33700.89810.59640.56180.40120.27500.5209
Llama-3-ELYZA-JP-8B0.32000.55020.52240.36310.88090.58750.57010.32130.46040.5084
Llama 3 heron brain 8B v0.30.35800.65630.56860.37260.90020.62130.57770.64090.37200.5631
Llama 3 Swallow 8B Instruct0.37200.65570.58610.36480.90020.63150.59590.63910.42380.5743
Llama 3.1 Swallow 8B Instruct0.39000.64880.61510.35530.89120.62370.60500.64170.37870.5722

MT-Bench JA

ModelcodingextractionhumanitiesmathreasoningroleplaystemwritingJMTAvg
RakutenAI-7B-chat0.24750.35220.46920.21400.39260.44270.39770.44340.3699
Qwen2-7B-Instruct0.46350.69090.68570.59700.50420.66670.53530.68080.6030
Qwen2.5-7B-Instruct0.51110.74890.69130.57420.48510.68100.53500.68100.6134
Tanuki-8B-dpo-v1.00.30190.47720.56580.41290.35900.51200.47700.61590.4652
Llama 3 8B Instruct0.37440.68760.62250.20700.50320.52480.53260.48840.4926
Llama 3.1 8B Instruct0.32340.73620.49730.47870.32100.46700.46560.43140.4651
Llama 3 Youko 8B Instruct0.29500.73320.71250.25330.49870.65140.54380.70910.5496
Llama-3-ELYZA-JP-8B0.29080.64210.64060.30880.55000.67400.52510.67440.5382
Llama 3 heron brain 8B v0.30.29290.56350.62410.21350.45820.53540.52730.50990.4656
Llama 3 Swallow 8B Instruct0.35470.65080.53710.27180.40070.54930.47520.57300.4766
Llama 3.1 Swallow 8B Instruct0.31320.77340.66450.38800.52300.57110.49530.53300.5327

Evaluation Benchmarks

Japanese evaluation benchmarks

We used llm-jp-eval(v1.3.0), JP Language Model Evaluation Harness(commit #9b42d41) and Code Generation LM Evaluation Harness(commit #0261c52). The details are as follows:

  • Multiple-choice question answering (JCommonsenseQA [Kurihara et al., 2022])
  • Open-ended question answering (JEMHopQA [Ishii et al., 2024])
  • Open-ended question answering (NIILC [関根, 2003])
  • Machine reading comprehension (JSQuAD [Kurihara et al., 2022])
  • Automatic summarization (XL-Sum [Hasan et al., 2021])
  • Machine translation (WMT2020 ja-en [Barrault et al., 2020])
  • Machine translation (WMT2020 en-ja [Barrault et al., 2020])
  • Mathematical reasoning (MGSM [Shi et al., 2023])
  • Academic exams (JMMLU [尹ら, 2024])
  • Code generation (JHumanEval [佐藤ら, 2024])

English evaluation benchmarks

We used the Language Model Evaluation Harness(v.0.4.2) and Code Generation LM Evaluation Harness(commit #0261c52). The details are as follows:

  • Multiple-choice question answering (OpenBookQA [Mihaylov et al., 2018])
  • Open-ended question answering (TriviaQA [Joshi et al., 2017])
  • Machine reading comprehension (SQuAD2 [Rajpurkar et al., 2018])
  • Commonsense reasoning (XWINO [Tikhonov and Ryabinin, 2021])
  • Natural language inference (HellaSwag [Zellers et al., 2019])
  • Mathematical reasoning (GSM8K [Cobbe et al., 2021])
  • Reasoning (BBH (BIG-Bench-Hard) [Suzgun et al., 2023])
  • Academic exams (MMLU [Hendrycks et al., 2021])
  • Code generation (HumanEval [Chen et al., 2021])

MT-Bench JA

We used Japanese MT-Bench to assess the instruction-following capabilities of models.
We utilized the following settings:

Inference:

Engine: TensorRT-LLM

Test Hardware:

  • NVIDIA H100x4

Ethical Considerations:

NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable development for a wide array of AI applications. When downloaded or used in accordance with our terms of service, developers should work with their internal model team to ensure this model meets requirements for the relevant industry and use case and addresses unforeseen product misuse.

Please report security vulnerabilities or NVIDIA AI Concerns here.

Usage

pip install vllm
from transformers import AutoTokenizer
from vllm import LLM, SamplingParams

model_name = "tokyotech-llm/Llama-3.1-Swallow-8B-Instruct-v0.1"

tokenizer = AutoTokenizer.from_pretrained(model_name)
llm = LLM(
    model=model_name,
    tensor_parallel_size=1,
)

sampling_params = SamplingParams(
    temperature=0.6, top_p=0.9, max_tokens=512, stop="<|eot_id|>"
)


message = [
    {"role": "system", "content": "あなたは誠実で優秀な日本人のアシスタントです。"},
    {
        "role": "user",
        "content": "東京の紅葉した公園で、東京タワーと高層ビルを背景に、空を舞うツバメと草地に佇むラマが出会う温かな物語を書いてください。",
    },
]
prompt = tokenizer.apply_chat_template(
    message, tokenize=False, add_generation_prompt=True
)

output = llm.generate(prompt, sampling_params)

print(output[0].outputs[0].text)

Training Datasets

Instruction Tuning

The following instruction datasets were used for the instruction tuning.

  • Japanese
    • lmsys-chat-1m-synth-ja-wo-pii-and-template-instructions
      • Single-turn Japanese synthetic instruction dataset derived from lmsys-chat-1m dataset [Zhang+, ICLR24]).
        The first-turn user instructions were translated into Japanese via DeepL machine translation, and the assistant responses were generated using the Llama-3.1-405B-Instruct model. Rejection sampling (n=6) was applied, with Llama-3.1-70B-Instruct serving as a judge.
      • As implied by the dataset name, conversations that contain personally identifiable information (PII) or template-based user instructions have been removed. Duplicate instuctions have also been removed.
    • filtered-magpie-ultra-ja
      • A Japanese variant of the filtered-magpie-ultra-en dataset, machine-translated into Japanese using the gemma-2-27b-it.
    • gemma-magpie
      • A Japanese synthetic Q&A dataset from scratch, generated using gemma-2-27b-it. User instructions were created with prompts specific to each topic, and the assistant responses were generated for these instructions. The conversations were then heuristically filtered for quality and length.
  • English
    • lmsys-chat-1m-synth-en-wo-pii-and-template-instructions
      • Similar to the lmsys-chat-1m-synth-ja-wo-pii-and-template-instructions, but this version uses the original English user instructions. The assistant responses were generated in English as well. Rejection sampling was not applied in this version.
    • filtered-magpie-ultra-en

Risks and Limitations

The models released here are still in the early stages of our research and development and have not been tuned to ensure outputs align with human intent and safety considerations.

Acknowledgements

We thank Meta Research for releasing Llama 3.1 under a generous open license.

We received various supports including:

  • AIST project: “Research and Development of Foundation Models for Generative AI in the Physical Domain”
  • NEDO project: “Development of Artificial Intelligence Application Technology to Support Judgment in Design Risk Assessment Work Based on the Perspective of Skilled Persons" (JPNP18002) of “Development of Integration Technology as the Core of Next Generation Artificial Intelligence and Robotics”
  • MEXT project: "Formation of R&D center to ensure transparency and reliability of generative AI models"
  • AIST program: Large Generative AI Development Support Program

Authors

Here are the team members:

How to cite

If you find our work helpful, please feel free to cite us.

@inproceedings{Fujii:COLM2024,
   title={Continual Pre-Training for Cross-Lingual LLM Adaptation:
Enhancing Japanese Language Capabilities},
   author={Kazuki Fujii and Taishi Nakamura and Mengsay Loem and Hiroki
Iida and Masanari Ohi and Kakeru Hattori and Hirai Shota and Sakae
Mizuki and Rio Yokota and Naoaki Okazaki},
   booktitle="Proceedings of the First Conference on Language Modeling",
   series={COLM},
   pages="(to appear)",
   year="2024",
   month=oct,
   address={University of Pennsylvania, USA},
}

@inproceedings{Okazaki:COLM2024,
   title={Building a Large Japanese Web Corpus for Large Language Models},
   author={Naoaki Okazaki and Kakeru Hattori and Hirai Shota and Hiroki
Iida and Masanari Ohi and Kazuki Fujii and Taishi Nakamura and Mengsay
Loem and Rio Yokota and Sakae Mizuki},
   booktitle="Proceedings of the First Conference on Language Modeling",
   series={COLM},
   pages="(to appear)",
   year="2024",
   month=oct,
   address={University of Pennsylvania, USA},
}

References

@misc{dubey2024llama3herdmodels,
      title={The Llama 3 Herd of Models}, 
      author={Abhimanyu Dubey and Abhinav Jauhri and Abhinav Pandey and Abhishek Kadian and Ahmad Al-Dahle and Aiesha Letman and Akhil Mathur and Alan Schelten and Amy Yang and Angela Fan et al.},
      year={2024},
      eprint={2407.21783},
      archivePrefix={arXiv},
      primaryClass={cs.AI},
      url={https://arxiv.org/abs/2407.21783}, 
}