Open your terminal, and make a new folder called llama3-demo in your workspace. Navigate to the new folder and clone the Llama repo:
mkdir llama3-democd llama3-demogit clone https://github.com/meta-llama/llama3.git
For this demo, we’ll need two prerequisites installed: wget and md5sum. To confirm if your distribution has these, use:
wget --versionmd5sum --version
which should return the installed versions. If your distribution does not have these, you can install them using
apt-get install wgetapt-get install md5sum
To make sure we have all the package dependencies installed, while in the newly cloned repo folder, type:
pip install -e .
We are now all set to download the model weights for our local setup. Our team has created a helper script to make it easy to download the model weights. In your terminal, type:
./download.sh
The script will ask for the URL from your email. Paste in the URL you received from Meta. It will then ask you to enter the list of models to download. For our example, we’ll download the 8B pretrained model and the fine-tuned 8B chat models. So we’ll enter “8B,8B-instruct”.
Downloading the 8B models
top_p: float = 0.9Running the 8B model on the example text completion script
To try out the fine-tuned chat model (8B-instruct), we have a similar example called example_chat_completion.py.
torchrun --nproc_per_node 1 example_chat_completion.py --ckpt_dir Meta-Llama-3-8B-Instruct/ --tokenizer_path Meta-Llama-3-8B-Instruct/tokenizer.model --max_seq_len 512 --max_batch_size 6
Note that in this case, we use the Meta-Llama-3-8B-Instruct/ model and provide the correct tokenizer under the instruct model folder.
Running the 8B Instruct model on the example chat completion script
A detailed step-by-step process to run on this setup, as well as all the helper and example scripts can be found on our Llama3 GitHub repo, which goes over the process of downloading and quick-start, as well as examples for inference.