LLM-DNA
Extract LLM DNA vectors — low-dimensional, training-free representations that capture functional behavior and evolutionary relationships between language models.
📄 Paper: LLM DNA: Tracing Model Evolution via Functional Representations (ICLR 2026 Oral)
Overview
The explosive growth of large language models has created a vast but opaque landscape: millions of models exist, yet their evolutionary relationships through fine-tuning, distillation, or adaptation are often undocumented. LLM-DNA provides a general, scalable, training-free pipeline for extracting LLM DNA — mathematically-grounded representations that satisfy inheritance and genetic determinism properties.
Key Features:
- 🧬 Extract DNA vectors from any HuggingFace or local model
- 🚀 Training-free, works across architectures and tokenizers
- 📊 Tested on 305+ LLMs with superior or competitive performance
- 🔍 Uncover undocumented relationships between models
- 🌳 Build evolutionary trees using phylogenetic algorithms
Installation
pip install llm-dna
Use llm-dna for install/package naming, and llm_dna for Python imports.
Optional extras are available for model families that need additional runtime dependencies:
# Apple Silicon / MLX-backed models
pip install "llm-dna[apple]"
# Quantized HuggingFace models (bitsandbytes, GPTQ, compressed-tensors, optimum)
pip install "llm-dna[quantization]"
# Architecture-specific model families such as Mamba or TIMM-backed models
pip install "llm-dna[model_families]"
# Everything above
pip install "llm-dna[full]"
Extra guidance:
apple: required for MLX andmlx-community/*style model families on Apple Silicon.quantization: required for many GPTQ, bitsandbytes, and compressed-tensors model families.model_families: required for specific architectures whose modeling code depends on packages likemamba-ssmortimm.
Quick Start
from llm_dna import DNAExtractionConfig, calc_dna
config = DNAExtractionConfig(
model_name="distilgpt2",
dataset="rand",
gpu_id=0,
max_samples=100,
)
result = calc_dna(config)
print(f"DNA shape: {result.vector.shape}") # (128,)
Python API
from llm_dna import DNAExtractionConfig, calc_dna
config = DNAExtractionConfig(
model_name="Qwen/Qwen2.5-0.5B-Instruct",
dataset="rand",
gpu_id=0,
max_samples=100,
dna_dim=128,
reduction_method="random_projection", # or "pca", "svd"
trust_remote_code=True,
)
result = calc_dna(config)
# DNA vector (numpy.ndarray)
vector = result.vector
# Saved paths (when save=True)
print(result.output_path)
print(result.summary_path)
CLI
# Single model
calc-dna --model-name distilgpt2 --dataset rand --gpus 0
# Multiple models with round-robin GPU assignment
calc-dna --llm-list ./configs/llm_list.txt --gpus 0,1
# With hyperparameters
calc-dna \
--model-name mistralai/Mistral-7B-v0.1 \
--dna-dim 256 \
--max-samples 200 \
--reduction-method pca \
--load-in-8bit
Notes
- Metadata auto-fetched: Model metadata is automatically retrieved from HuggingFace Hub and cached.
- Auth token: Pass via
token=...or setHF_TOKENenvironment variable. - Chat templates: Disabled by default. Enable with
--use-chat-template(CLI) oruse_chat_template=True(API).
Tests
# All tests (including integration tests with real model loading)
pytest tests/ -v
# Fast tests only (skip real model loading)
pytest tests/ -m "not slow"
Citation
If you use LLM-DNA in your research, please cite:
@inproceedings{wu2026llmdna,
title={LLM DNA: Tracing Model Evolution via Functional Representations},
author={Wu, Zhaomin and Zhao, Haodong and Wang, Ziyang and Guo, Jizhou and Wang, Qian and He, Bingsheng},
booktitle={The Fourteenth International Conference on Learning Representations},
year={2026},
url={https://openreview.net/pdf?id=UIxHaAqFqQ}
}
License
Apache 2.0
Release files for llm-dna 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| llm_dna-0.2.3.tar.gz | 87.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llm_dna-0.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 188.6 kB
Release files / llm_dna-0.2.3.tar.gz
| Download URL | llm_dna-0.2.3.tar.gz |
|---|---|
| Size | 87.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ada2a1360d932bfdf0bb045a6049f9930d3b09e87cd5a58c9fddba11be5bff5c
|
|
BLAKE2b-256 checksum How to use checksums |
0cb006effcc257fae00162894094437457a0e67637ad9dcdedf0a07b0e94b800
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 8, 2026.
Transparency logRelease files / llm_dna-0.2.3-py3-none-any.whl
| Download URL | llm_dna-0.2.3-py3-none-any.whl |
|---|---|
| Size | 101.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d13de31f58aa0dbee1a9c50402286ad6b20035157ba62a51a76ca87c90ea1d8
|
|
BLAKE2b-256 checksum How to use checksums |
354e2aa0bef843671f5d00268fc9627ba8cd2cc19ca4a9043787de088aa1f273
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 8, 2026.
Transparency log