### Install BLT with uv for Reproducibility Source: https://github.com/facebookresearch/blt/blob/main/README.md This experimental method uses 'uv' for reproducible environment setup. It installs dependencies and prepares the environment for running BLT scripts. ```bash uv pip install --group pre_build --no-build-isolation uv pip install --group compile_xformers --no-build-isolation uv sync uv run python download_blt_weights.py uv run python demo.py "A BLT has" ``` -------------------------------- ### Install BLT with Conda and Pip Source: https://github.com/facebookresearch/blt/blob/main/README.md Use this method to set up the BLT environment using conda for environment management and pip for package installation. Ensure you have the correct CUDA version for PyTorch. ```bash git clone https://github.com/facebookresearch/blt cd blt conda create -n blt python=3.12 conda activate blt pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu121 pip install ninja pip install -v -U git+https://github.com/facebookresearch/xformers.git@de742ec3d64bd83b1184cc043e541f15d270c148 pip install -r requirements.txt ``` -------------------------------- ### Generate Text with BLT Demo Script Source: https://github.com/facebookresearch/blt/blob/main/README.md Execute the demo script to generate text using the BLT model. This script also serves as an example for loading BLT in custom code. ```bash python demo.py "A BLT has" ``` -------------------------------- ### Build BLT Environment with Slurm Source: https://github.com/facebookresearch/blt/blob/main/README.md This option uses a Slurm job script to create the BLT environment. It's suitable for clusters with Slurm workload manager. Activate the environment using the provided command after setup. ```bash git clone https://github.com/facebookresearch/blt cd blt bash setup/create_env.sh # or if you have access to a SLURM cluster sbatch setup/create_env.sh ``` -------------------------------- ### Activate Conda Environment after Slurm Setup Source: https://github.com/facebookresearch/blt/blob/main/README.md After setting up the environment using the Slurm job script, activate the created conda environment using this command. The environment name includes a date. ```bash conda activate blt_ ``` -------------------------------- ### Launch Debug Training Job (Single GPU) Source: https://github.com/facebookresearch/blt/blob/main/README.md Launch a debug training job on a single GPU using the bytelatent.train module. ```bash python -m bytelatent.train config=bytelatent/configs/debug.yaml ``` -------------------------------- ### Download and Prepare Hugging Face Data Source: https://github.com/facebookresearch/blt/blob/main/README.md Use this script to download and prepare data from Hugging Face. Specify the dataset, data directory, seed, and number of chunks. Adjust nchunks based on the number of GPUs available. ```bash python setup/download_prepare_hf_data.py fineweb_edu --data_dir ./data --seed 42 --nchunks ``` -------------------------------- ### Launch Debug Training Job (SLURM) Source: https://github.com/facebookresearch/blt/blob/main/README.md Launch a debug training job using the SLURM tool. Adapt configurations like dump_dir, data.root_dir, and data.tokenizer.path. ```bash # stool stands for SLURM tool ! python -m bytelatent.stool script=bytelatent.train config=bytelatent/configs/debug.yaml nodes=1 partition= ``` -------------------------------- ### Launch Debug Training Job (torchrun) Source: https://github.com/facebookresearch/blt/blob/main/README.md Launch a debug training job locally using torchrun, specifying the number of processes per node and the configuration file. ```bash torchrun --nproc-per-node 8 -m bytelatent.train config=bytelatent/configs/debug.yaml ``` -------------------------------- ### Download Tokenizer Source: https://github.com/facebookresearch/blt/blob/main/README.md Download a tokenizer, such as Llama3, to a specified save path using your Hugging Face API key. ```bash python setup/download_tokenizer.py llama3 --api_key ``` -------------------------------- ### Load BLT Model and Tokenizer in Python Source: https://github.com/facebookresearch/blt/blob/main/README.md This Python code demonstrates how to load the BLT model, tokenizer, and patcher components from Hugging Face for custom use. It initializes the necessary classes for text generation. ```python from bytelatent.transformer import LMTransformer from bytelatent.model.blt import ByteLatentTransformer from bytelatent.hf import BltTokenizerAndPatcher entropy_repo = "facebook/blt-entropy" blt_repo = "facebook/blt-1b" entropy_model = LMTransformer.from_pretrained(entropy_repo) blt_model = ByteLatentTransformer.from_pretrained(blt_repo) tok_and_patcher = BltTokenizerAndPatcher.from_pretrained(blt_repo) tokenizer = tok_and_patcher.tokenizer_args.build() patcher = tok_and_patcher.patcher_args.build() ``` -------------------------------- ### Download BLT Model Weights Source: https://github.com/facebookresearch/blt/blob/main/README.md Run this Python script to download the pre-trained BLT model weights. The weights will be saved to the 'hf-weights' directory. ```bash python download_blt_weights.py ``` -------------------------------- ### Load BLT Weights via Hugging Face CLI Source: https://github.com/facebookresearch/blt/blob/main/README.md Use the Hugging Face CLI to load BLT model weights and generate text from a prompt. Ensure you have requested access to the weights on the Hugging Face model page. ```bash python -m bytelatent.hf load-transformers --entropy-repo facebook/blt-entropy --blt-repo facebook/blt-1b --prompt "My test prompt" hub ``` -------------------------------- ### Lint Project Code Source: https://github.com/facebookresearch/blt/blob/main/README.md Run the linting script to check for code style and quality issues. ```bash bash dev/lint.sh ``` -------------------------------- ### Relaunch Crashed SLURM Job Source: https://github.com/facebookresearch/blt/blob/main/README.md If a SLURM job crashes, it can be relaunched using the sbatch command with the path to the dump directory's submit script. ```bash sbatch path/to/dump_dir/submit.slurm ``` -------------------------------- ### BLT Paper Citation Source: https://github.com/facebookresearch/blt/blob/main/README.md Citation for the Byte Latent Transformer paper. ```bibtex @article{meta_blt, author = {Artidoro Pagnoni, Ram Pasunuru, Pedro Rodriguez, John Nguyen, Benjamin Muller, Margaret Li, Chunting Zhou, Lili Yu, Jason Weston, Luke Zettlemoyer, Gargi Ghosh, Mike Lewis, Ari Holtzman†, Srinivasan Iyer}, title = {Byte Latent Transformer: Patches Scale Better Than Tokens}, url = {https://github.com/facebookresearch/blt}, year = {2024} } ``` -------------------------------- ### Lingua Code Citation Source: https://github.com/facebookresearch/blt/blob/main/README.md Citation for the Meta Lingua code library. ```bibtex @misc{meta_lingua, author = {Mathurin Videau, Badr Youbi Idrissi, Daniel Haziza, Luca Wehrstedt, Jade Copet, Olivier Teytaud, David Lopez-Paz}, title = {{Meta Lingua}: A minimal {PyTorch LLM} training library}, url = {https://github.com/facebookresearch/lingua}, year = {2024} } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.