OpenLLaMA Documentation
repository·main·Indexed 27 days ago
https://github.com/openlm-research/open_llamaAn open-source reproduction of Meta's LLaMA models released under the Apache 2.0 license. OpenLLaMA provides 3B, 7B, and 13B models trained on 1T tokens, available in PyTorch (Hugging Face Transformers) and JAX (EasyLM) formats. It serves as a drop-in replacement for LLaMA in existing LLM workflows, with v1 and v2 versions available.
What's inside OpenLLaMA
- OpenLLaMA is an open-source reproduction of Meta AI's LLaMA, released under the Apache 2.0 license. It provides a series of 3B, 7B, and 13B models trained on 1T tokens. The weights are available in PyTorch format (for Hugging Face Transformers) and JAX format (for EasyLM). OpenLLaMA models are designed as drop-in replacements for the original LLaMA in existing implementations.
Evaluate OpenLLaMA with LM-Eval-Harness
mainOpenLLaMA models can be evaluated across various tasks using the lm-evaluation-harness library. The project provides performance benchmarks for OpenLLaMA versions (3B, 7B, 13B) across metrics such asanli,arc_challenge,arc_easy,boolq,hellaswag,openbookqa,piqa,record,rte,truthfulqa_mc,wic, andwinogrande.Evaluate OpenLLaMA with LM-Eval-Harness
mainTo evaluate OpenLLaMA using
lm-eval-harness, you must ensure the fast tokenizer is disabled to obtain correct results. When configuring the model inlm-eval-harness, passuse_fast=Falseto the tokenizer initialization.tokenizer = self.AUTO_TOKENIZER_CLASS.from_pretrained( pretrained if tokenizer is None else tokenizer, revision=revision + ("/" + subfolder if subfolder is not None else ""), use_fast=False )Load OpenLLaMA weights with EasyLM
mainOpenLLaMA weights are available in JAX format specifically for use with the EasyLM framework. Unlike the original LLaMA, OpenLLaMA's tokenizer and weights are trained from scratch, so you do not need to obtain the original LLaMA tokenizer or weights. Refer to the EasyLM LLaMA documentation for specific implementation details.Load OpenLLaMA weights with Hugging Face Transformers
mainYou can load OpenLLaMA weights directly from the Hugging Face Hub using the
transformerslibrary.CRITICAL: Avoid using the Hugging Face 'fast' tokenizer, as auto-converted fast tokenizers may produce incorrect tokenizations. Instead, use the
LlamaTokenizerclass directly or passuse_fast=Falseto theAutoTokenizerclass.import torch from transformers import LlamaTokenizer, LlamaForCausalLM ## v2 models model_path = 'openlm-research/open_llama_3b_v2' # model_path = 'openlm-research/open_llama_7b_v2' ## v1 models # model_path = 'openlm-research/open_llama_3b' # model_path = 'openlm-research/open_llama_7b' # model_path = 'openlm-research/open_llama_13b' tokenizer = LlamaTokenizer.from_pretrained(model_path) model = LlamaForCausalLM.from_pretrained( model_path, torch_dtype=torch.float16, device_map='auto', ) prompt = 'Q: What is the largest animal?\nA:' input_ids = tokenizer(prompt, return_tensors="pt").input_ids generation_output = model.generate( input_ids=input_ids, max_new_tokens=32 ) print(tokenizer.decode(generation_output[0]))OpenLLaMA Model Versions and Paths
mainOpenLLaMA is released in v1 and v2 versions. v2 models use a different data mixture (Falcon refined-web, StarCoder, and RedPajama subsets) and are generally better than v1.
Note on Code Generation: For code-related tasks (e.g., HumanEval), use v2 models. The v1 tokenizer merges multiple empty spaces, which makes it unsuitable for code generation tasks.
Cite OpenLLaMA in research
mainIf you use OpenLLaMA in your research or applications, please cite the project using the following BibTeX entry:
@software{openlm2023openllama, author = {Geng, Xinyang and Liu, Hao}, title = {OpenLLaMA: An Open Reproduction of LLaMA}, month = May, year = 2023, url = {https://github.com/openlm-research/open_llama} }