lit-llama
Implementation of the LLaMA language model based on nanoGPT. Supports flash attention, Int8 and GPTQ 4bit quantization, LoRA and LLaMA-Adapter fine-tuning, pre-training. Apache 2.0-licensed.
File Explorer
- cpu-tests.yml
- azure-gpu-tests.yml
- CODEOWNERS
- adapter.py
- adapter_v2.py
- full.py
- lora.py
- adapter.py
- adapter_v2.py
- full.py
- length_grouped_sampler.py
- lora.py
- adapter.py
- adapter_v2.py
- full.py
- lora.py
- convert_lora_weights.md
- customize_paths.md
- download_weights.md
- finetune_adapter.md
- finetune_adapter_v2.md
- finetune_full.md
- finetune_lora.md
- inference.md
- tpus.md
- train_redpajama.md
- unstructured_dataset.md
- __init__.py
- adapter.py
- adapter_v2.py
- lora.py
- model.py
- packed_dataset.py
- quantization.py
- tokenizer.py
- utils.py
- redpajama.py
- shakespeare.py
- gptq.py
- convert_checkpoint.py
- convert_hf_checkpoint.py
- convert_lora_weights.py
- download.py
- prepare_alpaca.py
- prepare_any_text.py
- prepare_dolly.py
- prepare_redpajama.py
- prepare_shakespeare.py
- conftest.py
- test_adapter.py
- test_adapter_v2.py
- test_generate.py
- test_lora.py
- test_model.py
- test_packed_dataset.py
- test_prepare_redpajama.py
- test_prepare_shakespeare.py
- test_rmsnorm.py
- test_rope.py
- test_utils.py
- .gitignore
- generate.py
- LICENSE
- pyproject.toml
- README.md
- setup.py
# Installation Guide
pythonSetup Steps
git clone https://github.com/Lightning-AI/lit-llama && cd lit-llama
Clone the repository and navigate into the project folder.
pip install -e ".[all]"
Install the package with all optional dependencies.
python scripts/download.py
Download the pretrained model weights.
python generate.py --prompt "Hello, my name is"
Run the model to test text generation.
Key Commands
pip install -e ".[all]"
Install the package and all dependencies in editable mode.
python generate.py --prompt "Hello, my name is"
Perform text generation using downloaded model weights.
python quantize/gptq.py --output_path checkpoints/lit-llama/7B/llama-gptq.4bit.pth --dtype bfloat16 --quantize gptq.int4
Convert model weights using GPTQ-style int4 quantization.
python scripts/prepare_alpaca.py
Download and prepare the Alpaca dataset for finetuning.
python finetune/lora.py
Finetune the model using the LoRA technique.
# Use via CDN
jsDelivrjsDelivr serves any public GitHub repository as a CDN with zero setup. Pick a version and a file to get a ready-to-paste link and snippet.
Command Glossary
Commands referenced in this DOCs, explained below.
git clone
View Details ▼
git clone
Clone an existing repository.
git clone {{remote_repository_location}} {{path/to/directory}}
Clone an existing repository into a new directory (the default directory is the repository name):
git clone --recursive {{remote_repository_location}}
Clone an existing repository and its submodules:
git clone {{[-n|--no-checkout]}} {{remote_repository_location}}
Clone only the `.git` directory of an existing repository:
pip install
View Details ▼
pip install
Install Python packages.
pip install {{package1 package2 ...}}
Install one or more packages:
pip install {{package1 package2 ...}} {{[-U|--upgrade]}}
Upgrade all specified packages to the latest version, installing any that are not already present:
pip install {{package}}=={{version}}
Install a specific version of a package:
python
View Details ▼
python
Python language interpreter.
python
Start a REPL (interactive shell):
python {{path/to/file.py}}
Execute a specific Python file:
python -i {{path/to/file.py}}
Execute a specific Python file and start a REPL:
