HuggingFaceBio/Carbon-8B
<p align="center"> <a href="https://huggingface.co/HuggingFaceBio/Carbon-3B/blob/main/tech-report.pdf"><b>Technical Report</b> π§¬</a> </p>
Carbon-8B
A larger, higher-capacity member of the Carbon family of generative DNA foundation models.
Carbon-8B is the 8B-parameter sibling of Carbon-3B. It is intended for users who can afford additional inference cost in exchange for stronger downstream performance. For the full design rationale, tokenizer specification, evaluation protocol, and usage details, please refer to the [Carbon-3B model card](https://huggingface.co/HuggingFaceBio/Carbon-3B) and the Carbon technical report β this card focuses only on what is specific to Carbon-8B.
- Technical report: https://github.com/huggingface/carbon/blob/main/tech-report.pdf
- Demo: https://huggingface.co/spaces/HuggingFaceBio/carbon-demo
Model Summary
- 8B-parameter decoder-only autoregressive model trained on DNA and RNA sequences with a primary focus on eukaryotes.
- Same hybrid tokenizer as Carbon-3B (non-overlapping 6-mer for DNA + Qwen3 BPE for English text). Each DNA token encodes 6 bp. Wrap DNA inputs with
<dna>...</dna>β see the Carbon-3B card for tokenizer details and usage caveats. - Native context: 32,768 tokens (β 196 kbp). Carbon-8B was extended with a long-context decay stage from an 8 k-context base, so it natively handles 32 k tokens. You can apply YaRN at 4Γ to extrapolate up to 128 k tokens (β 786 kbp).
- Released as a standard Hugging Face causal LM (
LlamaForCausalLM).
How to use
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
repo = "HuggingFaceBio/Carbon-8B"
tok = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
repo, dtype=torch.bfloat16,
).cuda().eval()
prompt = "<dna>ATGCGCTAGCTACGATCGATCGTAGCTAGCTAGCTAGCTACG" # multiple of 6 bp
inputs = tok(prompt, return_tensors="pt", add_special_tokens=False).to("cuda")
out = model.generate(**inputs, max_new_tokens=64, do_sample=False)
print(tok.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))Base-pair-level generation and scoring
The fns branch loads custom modeling code for Factorized Nucleotide Supervision (FNS). Carbon still uses its efficient 6-mer tokenizer, but during generation each selected 6-mer is assembled from six per-position nucleotide distributions, giving base-pair-level control over decoded DNA. Use this branch when you need exact base-pair counts, per-position masks, or temperature/top-p behavior applied at the nucleotide level rather than over the 4,096-way 6-mer distribution:
import math
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "HuggingFaceBio/Carbon-8B"
revision = "fns"
device = "cuda"
tokenizer = AutoTokenizer.from_pretrained(model_id, revision=revision, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id,
revision=revision,
trust_remote_code=True,
dtype=torch.bfloat16,
).to(device).eval()
context = "ATGCGCTAGCTACGATCGATCGTAGCTAGCTAGCTAGCTACG"
n_bp = 60
inputs = tokenizer(f"<dna>{context}", return_tensors="pt", add_special_tokens=False).to(device)
with torch.no_grad():
output_ids = model.generate(
**inputs,
max_new_tokens=math.ceil(n_bp / tokenizer.k),
do_sample=False,
pad_token_id=tokenizer.eos_token_id,
)
generated_ids = output_ids[0, inputs.input_ids.shape[1]:]
generated_dna = tokenizer.decode(generated_ids, skip_special_tokens=True)[:n_bp]
print(generated_dna)The same per-base marginals are exposed through score_sequence(), which returns the probability assigned to the observed base at each position. Taking the mean log probability gives a base-pair-level sequence score, where higher values indicate higher model likelihood:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "HuggingFaceBio/Carbon-8B"
revision = "fns"
device = "cuda"
tokenizer = AutoTokenizer.from_pretrained(model_id, revision=revision, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id,
revision=revision,
trust_remote_code=True,
dtype=torch.bfloat16,
).to(device).eval()
reference = "GGGCTATAAAGGCCATCGATCGATCGATCGATCGATCGATCG"
perturbed = "GGGCGCGCGCGGCCATCGATCGATCGATCGATCGATCGATCG"
with torch.no_grad():
bp_probs, actual_probs = model.score_sequence([reference, perturbed])
scores = [torch.log(p.clamp_min(1e-12)).mean().item() for p in actual_probs]
print(f"reference mean bp logp: {scores[0]:.4f}")
print(f"perturbed mean bp logp: {scores[1]:.4f}")
print(f"reference preferred: {scores[0] > scores[1]}")Training
Carbon-8B follows the same pre-training recipe as Carbon-3B on the [`HuggingFaceBio/carbon-pretraining-corpus`](https://huggingface.co/datasets/HuggingFaceBio/carbon-pretraining-corpus) with the identical data mixture on 1T DNA 6-mer tokens. The main recipe ingredients:
- Learning-rate schedule: cosine (instead of the WSD schedule used for Carbon-3B).
- Loss schedule: after 100B tokens the loss switches from cross-entropy to FNS loss until the end of training.
- Pre-training: on 1T 6-mer tokens (β 6T DNA base pairs), with GBS=512, seq=8192 β 4.19 M tok/step. On 32 nodes (TP=4, DP=64), bfloat16, AdamW. We keep the same training mixture even in the decay phase with 70% Generator eukaryote data with metadata with dropout, 16% mRNA, 4% splice mRNA and 10% Prokaryote data.
- Long-context extension stage. After pre-training, Carbon-8B undergoes a long-context decay phase that extends the native context from 8,192 to 32,768 tokens (β 196 kbp). You can apply YaRN at 4Γ to further extrapolate to 128 k tokens (β 786 kbp).
Training infrastructure, framework (Megatron-LM-Carbon), and conversion path (Megatron-Bridge) are identical to Carbon-3B.
Evaluation
All evaluations are zero-shot and use the public Carbon evaluation pipeline. See the Carbon-3B card for the full task suite, metrics, and methodology.
Downstream tasks
Genomic-NIAH (long-context retrieval)
Genomic-NIAH measures how well a DNA model actually uses its long context. See the `HuggingFaceBio/genomic-niah` dataset card for the benchmark design.
Carbon-8B retrieves reliably up to its 32 k native boundary; YaRN 4Γ recovers most of the loss at the 32 k β 64 k boundary and extends usable retrieval to β 786 kbp.
Intended use
Generative modelling, variant-effect prediction, motif-perturbation analysis, and long-context retrieval on DNA sequences. For faster inference at shorter contexts, use Carbon-3B.
β οΈ Genetic data is highly sensitive. Depending on how this model is used (local download, inference API/endpoints, third-party inference providers, Spaces demos or others), input and output data may be processed or handled differently by different providers or space owners. Please make sure you understand and agree with how your data is handled before using the model.
License
Apache 2.0.
Acknowledgements
Carbon is a joint collaboration between the research teams at Hugging Face, Zhongguancun Academy, and TIGEM/University of Naples βFederico IIβ.
Citation
@article{allal2026carbon,
title={Carbon: Decoding the Language of Life},
author={Allal, Loubna Ben and Li, Qiuyi and Fiusco, Maurizio and Tunstall, Lewis and Rasul, Kashif and Beeching, Ed and Aubakirova, Dana and Pati{\~n}o, Carlos and Frere, Thibaud and Lozhkov, Anton and others},
journal={bioRxiv},
pages={2026--05},
year={2026},
publisher={Cold Spring Harbor Laboratory}
}