# karpathy/llama2.c

Inference Llama 2 in one file of pure C

Repository: https://github.com/karpathy/llama2.c
Canonical: https://ross.abutalabs.com/products/llama2c
Language: C
License: MIT
License Family: permissive
Last push: 2024-08-06T09:44:40+00:00

## Health v2 (maintenance only)
Score: 28/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 0, release rhythm 35, longevity 81
- inputs: {"age_days": 1137, "days_push": 757, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: no_releases
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 20028, forks 2617 (observed 2026-08-28T04:11:29.557586+00:00)

## What it is
A minimal, dependency-free implementation of the Llama 2 LLM architecture that trains in PyTorch and runs inference in a single ~700-line pure C file. It can also load Meta's Llama 2 checkpoints (fp32), though it is intended for small models and educational use.

## Use cases
- run a llama 2 model in pure c
- learn how transformer llm inference works internally
- train a tiny llama 2 model and generate text from it
- embed a small language model in a c program with no dependencies
- study a minimal alternative to llama.cpp
- generate stories with a small language model on a laptop

## When to choose
- you want to read and understand every line of an LLM inference engine
- you need to run very small (up to ~7B fp32, practically much smaller) Llama 2 models with zero dependencies
- you are teaching or learning how LLMs work end to end, from training to inference

## When to avoid
- you need production-grade performance, quantization, or broad model support - use llama.cpp instead
- you want to serve large models or use GPU acceleration
- you need a maintained, feature-rich inference stack rather than an educational project

## Facets
- artifact type: library
- maturity: active
- function: llm-inference, machine-learning, deep-learning, llm-training
- domain: large-language-models, deep-learning, artificial-intelligence, education
- platform: c, cross-platform, cli
- tags: llama-2, minimalist, educational, single-file, tinystories, transformer-inference

## Member repositories
- karpathy/llama2.c (main) score 28

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:11:29.557586+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T16:59:22.510821+00:00, confidence not recorded.
  - readme: https://github.com/karpathy/llama2.c (fetched 2026-08-28T04:11:29.557586+00:00, sha 020d72eb8e15)
- Data as of 2026-08-30T08:39:29.467469+00:00.
