Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time
November 4, 2022 12:17
August 22, 2021 01:56
December 16, 2022 10:28
December 16, 2022 10:28
February 25, 2021 22:39
February 25, 2021 13:05
October 17, 2021 01:37
February 25, 2021 22:39


Mistral: A strong and cool northwesterly wind that builds as it moves, bringing good health and clear skies.

license pre-commit

A framework for transparent and accessible large-scale language model training, built with Hugging Face πŸ€— . Includes tools and helpful scripts for incorporating new pre-training datasets, various schemes for single node and distributed training - including on cloud providers like GCP, and importantly, scripts for evaluation.

Visit our Read the Docs for the full documentation.

A Propulsion Endeavor πŸš€



Mistral has been tested with Python 3.8.12, PyTorch 1.11.0 (compiled with CUDA 11.3), CUDA 11.3, NCCL 2.10, Transformers 4.17.0, and DeepSpeed 0.6.0.

The environment can be easily built with the following commands:

conda create -n mistral python=3.8.12 pytorch=1.11.0 torchdata cudatoolkit=11.3 -c pytorch
conda activate mistral
pip install -r setup/pip-requirements.txt

A .yaml export of a tested environment is provided at environments/environment-gpu.yaml.

Environments and non-Python dependencies can be managed with conda, and Python dependencies can be managed with pip (note: conda was used for the PyTorch install to get the version compiled with CUDA 11.3).

Training GPT-2 Micro


First, make sure to update conf/mistral-micro.yaml with the directories you want to store the Hugging Face cache and model runs.

# Artifacts & Caching
    cache_dir: /path/to/artifacts
    run_dir: /path/to/runs

Next, make sure that /path/to/mistral is on your PYTHONPATH.

Single-node single-GPU training

For single-node single-gpu training, run:

conda activate mistral
cd mistral
CUDA_VISIBLE_DEVICES=0 python --config conf/mistral-micro.yaml --nnodes 1 --nproc_per_node 1 --training_arguments.fp16 true --training_arguments.per_device_train_batch_size 2 --run_id tutorial-gpt2-micro

Multi-node multi-GPU training with DeepSpeed

Modify /job/hostfile in the following way:

<Hostname of first machine> slots=<Number of GPUs>
<Hostname of second machine> slots=<Number of GPUs>
<Hostname of the nth machine> slots=<Number of GPUs>

Below is an example hostfile where we train on machine1 and machine2 with 8 GPUs each:

machine1 slots=8
machine2 slots=8

To start distributed training, run:

conda activate mistral
cd mistral
deepspeed --num_gpus 8 --num_nodes 2 --master_addr machine1 --config conf/tutorial-gpt2-micro.yaml --nnodes 2 --nproc_per_node 8 --training_arguments.fp16 true --training_arguments.per_device_train_batch_size 4 --training_arguments.deepspeed conf/deepspeed/z2-small-conf.json --run_id tutorial-gpt2-micro-multi-node

Note: You may need to adjust your batch size depending on the capacity of your GPUs.

If you are interested in training a model on Google Cloud, check out our Google Cloud + Kubernetes Tutorial.

Using the model

Model checkpoints will be stored in the directory specified by the artifacts.run_dir. An example checkpoint might be in /path/to/runs/tutorial-gpt2-micro/checkpoint-1000.

Mistral stores model checkpoints in the Hugging Face format, so models can be loaded and used in the same manner as if one had trained the model with Hugging Face.

For instance, to generate text with πŸ€— Transformers:

from transformers import GPT2LMHeadModel, GPT2Tokenizer

tokenizer = GPT2Tokenizer.from_pretrained("gpt2")

model = GPT2LMHeadModel.from_pretrained("stanford-crfm/eowyn-x777-checkpoint-400000")

input_ids = tokenizer.encode(
    "Hello world, this is a language model prompt.", return_tensors="pt"

sample_output = model.generate(input_ids, do_sample=True, max_length=50, top_k=50)

print("Output:\n" + 100 * "-")
print(tokenizer.decode(sample_output[0], skip_special_tokens=True))

Check out this Google CoLab Notebook to run this demo!


The Propulsion team has trained 5 GPT-2 Medium models and 5 GPT-2 Small models on the OpenWebText corpus, as found in πŸ€— datasets.

Each model has 600 checkpoints, subject to the following checkpoint schedule:

  • Every 10 Steps, for the first 0 - 100 Steps.
  • Every 50 Steps, from 100 - 2000 Steps.
  • Every 100 Steps, from 2000 - 20,000 Steps.
  • Every 1000 Steps, from 20,000 - 400,000 Steps.

Checkpoints can be downloaded from πŸ€— hub.

Run Type Seed Download
Alias GPT-2 Small 21 download
Battlestar GPT-2 Small 49 download
Caprica GPT-2 Small 81 download
Darkmatter GPT-2 Small 343 download
Expanse GPT-2 Small 777 download
Arwen GPT-2 Medium 21 download
Beren GPT-2 Medium 49 download
Celebrimbor GPT-2 Medium 81 download
Durin GPT-2 Medium 343 download
Eowyn GPT-2 Medium 777 download

Each model has a distinct git repo, and each checkpoint is stored as a branch.

As an example, here's how to get the battlestar model's checkpoint for step 300000:

# Make sure you have git-lfs installed
# (
git lfs install

# get checkpoint 300000 for battlestar
git clone --branch checkpoint-300000 --single-branch
cd battlestar-gpt2-small-x49
git lfs pull

For convenience, every model and step checkpoint is listed in mistral_models.json.


To ask questions, report issues, or request features, please use the GitHub Issue Tracker. Before creating a new issue, please make sure to search for existing issues that may solve your problem.

Differences between Mistral and Hugging Face

Please visit the following page that outlines the differences between the two codebases.


Please see the following page for information on contributing.


Mistral: A strong, northwesterly wind: Framework for transparent and accessible large-scale language model training, built with Hugging Face πŸ€— Transformers.







No packages published