llama README

The project's README from github.com/meta-llama/llama. As one markdown file: README.md.

Note of deprecation

Thank you for developing with Llama models. As part of the Llama 3.1 release, we’ve consolidated GitHub repos and added some additional repos as we’ve expanded Llama’s functionality into being an e2e Llama Stack. Please use the following repos going forward:

If you have any questions, please feel free to file an issue on any of the above repos and we will do our best to respond in a timely manner.

Thank you!

(Deprecated) Llama 2

We are unlocking the power of large language models. Llama 2 is now accessible to individuals, creators, researchers, and businesses of all sizes so that they can experiment, innovate, and scale their ideas responsibly.

This release includes model weights and starting code for pre-trained and fine-tuned Llama language models — ranging from 7B to 70B parameters.

This repository is intended as a minimal example to load Llama 2 models and run inference. For more detailed examples leveraging Hugging Face, see llama-cookbook.

Updates post-launch

See UPDATES.md. Also for a running list of frequently asked questions, see here.

Download

In order to download the model weights and tokenizer, please visit the Meta website and accept our License.

Once your request is approved, you will receive a signed URL over email. Then run the download.sh script, passing the URL provided when prompted to start the download.

Pre-requisites: Make sure you have wget and md5sum installed. Then run the script: ./download.sh.

Keep in mind that the links expire after 24 hours and a certain amount of downloads. If you start seeing errors such as 403: Forbidden, you can always re-request a link.

Access to Hugging Face

We are also providing downloads on Hugging Face. You can request access to the models by acknowledging the license and filling the form in the model card of a repo. After doing so, you should get access to all the Llama models of a version (Code Llama, Llama 2, or Llama Guard) within 1 hour.

Quick Start

You can follow the steps below to quickly get up and running with Llama 2 models. These steps will let you run quick inference locally. For more examples, see the Llama 2 cookbook repository.

  1. In a conda env with PyTorch / CUDA available clone and download this repository.

  2. In the top-level directory run:

    pip install -e .
    
  3. Visit the Meta website and register to download the model/s.

  4. Once registered, you will get an email with a URL to download the models. You will need this URL when you run the download.sh script.

  5. Once you get the email, navigate to your downloaded llama repository and run the download.sh script.

    • Make sure to grant execution permissions to the download.sh script
    • During this process, you will be prompted to enter the URL from the email.
    • Do not use the “Copy Link” option but rather make sure to manually copy the link from the email.
  6. Once the model/s you want have been downloaded, you can run the model locally using the command below:

torchrun --nproc_per_node 1 example_chat_completion.py \
    --ckpt_dir llama-2-7b-chat/ \
    --tokenizer_path tokenizer.model \
    --max_seq_len 512 --max_batch_size 6

Note

Inference

Different models require different model-parallel (MP) values:

Model MP
7B 1
13B 2
70B 8

All models support sequence length up to 4096 tokens, but we pre-allocate the cache according to max_seq_len and max_batch_size values. So set those according to your hardware.

Pretrained Models

These models are not finetuned for chat or Q&A. They should be prompted so that the expected answer is the natural continuation of the prompt.

See example_text_completion.py for some examples. To illustrate, see the command below to run it with the llama-2-7b model (nproc_per_node needs to be set to the MP value):

torchrun --nproc_per_node 1 example_text_completion.py \
    --ckpt_dir llama-2-7b/ \
    --tokenizer_path tokenizer.model \
    --max_seq_len 128 --max_batch_size 4

Fine-tuned Chat Models

The fine-tuned models were trained for dialogue applications. To get the expected features and performance for them, a specific formatting defined in chat_completion needs to be followed, including the INST and <<SYS>> tags, BOS and EOS tokens, and the whitespaces and breaklines in between (we recommend calling strip() on inputs to avoid double-spaces).

You can also deploy additional classifiers for filtering out inputs and outputs that are deemed unsafe. See the llama-cookbook repo for an example of how to add a safety checker to the inputs and outputs of your inference code.

Examples using llama-2-7b-chat:

torchrun --nproc_per_node 1 example_chat_completion.py \
    --ckpt_dir llama-2-7b-chat/ \
    --tokenizer_path tokenizer.model \
    --max_seq_len 512 --max_batch_size 6

Llama 2 is a new technology that carries potential risks with use. Testing conducted to date has not — and could not — cover all scenarios. In order to help developers address these risks, we have created the Responsible Use Guide. More details can be found in our research paper as well.

Issues

Please report any software “bug”, or other problems with the models through one of the following means:

Model Card

See MODEL_CARD.md.

License

Our model and weights are licensed for both researchers and commercial entities, upholding the principles of openness. Our mission is to empower individuals, and industry through this opportunity, while fostering an environment of discovery and ethical AI advancements.

See the LICENSE file, as well as our accompanying Acceptable Use Policy

References

  1. Research Paper
  2. Llama 2 technical overview
  3. Open Innovation AI Research Community

For common questions, the FAQ can be found here which will be kept up to date over time as new questions arise.

Original Llama

The repo for the original llama release is in the llama_v1 branch.

llama (meta-llama/llama)

Searching Database…

59.6K ·GitHub
Что это такое?Это эталонный код инференса от Meta для запуска языковых моделей Llama 2 (от 7B до 70B параметров) на вашем компьютере. Он позволяет загрузить предобученные или дообученные для чата веса и генерировать текстовые продолжения.
Это готовое приложение или просто пример кода?Это минимальный пример кода, а не готовое приложение или сервер. Вы клонируете репозиторий, загружаете веса сами и запускаете Python-скрипты, например example_chat_completion.py, напрямую.
Как запустить модели?Создайте окружение conda с PyTorch и CUDA, запросите доступ к моделям на сайте Meta, затем запустите './download.sh' с подписанной ссылкой, которая придёт вам на почту, и запустите инференс через torchrun, указав каталог с чекпоинтом и токенизатор.
Что нужно для запуска?Окружение conda с PyTorch и CUDA, а также 'wget' и 'md5sum' для скрипта загрузки и достаточно GPU под требования модели по model-parallel (1/2/8 GPU для 7B/13B/70B).
Стоит ли использовать этот репозиторий для работы с Llama?Нет: этот репозиторий устарел. Meta перенесла текущую разработку в llama-models, llama-toolchain, llama-agentic-system и llama-cookbook, поэтому этот код теперь всего лишь устаревший минимальный пример.
Можно ли использовать веса в коммерческих целях?Да. Meta выдаёт лицензию на модель и веса как исследователям, так и коммерческим организациям, при условии соблюдения файла LICENSE и Политики допустимого использования.
Нужно ли конкретное количество GPU?Да: разным размерам моделей нужно разное количество GPU для model-parallel (MP): 1 GPU для 7B, 2 для 13B и 8 для 70B.
Чем предобученные модели отличаются от чат-моделей?Предобученные модели только естественно продолжают текст и не настроены на диалог, а дообученные чат-модели ожидают определённый формат промпта с INST/BOS/EOS для разговора.
Какой длины контекст могут обработать эти модели?Все модели поддерживают длину последовательности до 4096 токенов, но вам нужно самим задать max_seq_len и max_batch_size в соответствии с объёмом памяти вашего оборудования.
Можно ли получить веса с Hugging Face вместо download.sh?Да: после принятия лицензии на сайте Meta можно также запросить доступ через карточки моделей на Hugging Face. Обычно доступ предоставляют в течение часа.
Что использовать вместо этого репозитория сейчас?Meta рекомендует llama-models для весов и карточек моделей, llama-toolchain для дообучения и безопасности, llama-agentic-system для агентных приложений и llama-cookbook для примеров от сообщества.
Creator
meta-llama
Size
1.1 MB
Stars
59.6K
Updated
CommitJan 26
Age
3y
Commits · 90 Days