pytorch-llama  by hkproj

PyTorch implementation of the LLaMA 2 architecture

Created 2 years ago
350 stars

Top 79.5% on SourcePulse

GitHubView on GitHub
Project Summary

This repository provides a from-scratch implementation of Meta's LLaMA 2 large language model using PyTorch. It is intended for researchers and engineers who need a deep understanding of LLM architectures and wish to experiment with custom modifications or integrations without relying on pre-built libraries.

How It Works

The project meticulously reconstructs the LLaMA 2 architecture, including its transformer blocks, attention mechanisms (grouped-query attention), and normalization layers, entirely within PyTorch. This approach allows for granular control over the model's components and facilitates direct experimentation with architectural variations.

Quick Start & Requirements

  • Install: pip install -r requirements.txt
  • Prerequisites: Python 3.8+, PyTorch 2.0+, Transformers, NumPy, SentencePiece. GPU with CUDA support is highly recommended for practical use.
  • Setup: Requires downloading LLaMA 2 model weights separately.
  • Docs: https://github.com/hkproj/pytorch-llama

Highlighted Details

  • Full implementation of LLaMA 2 architecture.
  • Includes Grouped-Query Attention (GQA) for improved inference efficiency.
  • Supports model parallelism for training/inference on multiple GPUs.
  • Provides example scripts for inference and basic fine-tuning.

Maintenance & Community

The project is maintained by hkproj. Community engagement channels are not explicitly listed in the README.

Licensing & Compatibility

The repository itself appears to be under the MIT License. However, the use of LLaMA 2 weights is subject to Meta's own license terms, which may have restrictions on commercial use.

Limitations & Caveats

This is a foundational implementation and may lack the optimizations and features found in more mature libraries like Hugging Face Transformers. Training from scratch requires significant computational resources and expertise.

Health Check
Last Commit

2 years ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
5 stars in the last 30 days

Explore Similar Projects

Starred by Andrej Karpathy Andrej Karpathy(Founder of Eureka Labs; Formerly at Tesla, OpenAI; Author of CS 231n), George Hotz George Hotz(Author of tinygrad; Founder of the tiny corp, comma.ai), and
20 more.

TinyLlama by jzhang38

0.1%
9k
Tiny pretraining project for a 1.1B Llama model
Created 2 years ago
Updated 1 year ago
Starred by Andrej Karpathy Andrej Karpathy(Founder of Eureka Labs; Formerly at Tesla, OpenAI; Author of CS 231n), John Yang John Yang(Coauthor of SWE-bench, SWE-agent), and
28 more.

stanford_alpaca by tatsu-lab

0.1%
30k
Instruction-following LLaMA model training and data generation
Created 2 years ago
Updated 1 year ago
Starred by Roy Frostig Roy Frostig(Coauthor of JAX; Research Scientist at Google DeepMind), Zhiqiang Xie Zhiqiang Xie(Coauthor of SGLang), and
40 more.

llama by meta-llama

0.1%
59k
Inference code for Llama 2 models (deprecated)
Created 2 years ago
Updated 7 months ago
Feedback? Help us improve.