HuggingFaceBio

Carbon-8B

Dedicated Endpoints

Run this model inference on single tenant GPU with unmatched speed and reliability at scale.

Learn more
Container

Run this model inference with full control and performance in your environment.

Learn more

Get help setting up a custom Dedicated Endpoints.

Talk with our engineer to get a quote for reserved GPU instances with discounts.

README

License: apache-2.0

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

python

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:

py

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:

py

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 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

Table
CategoryMetric (%)Carbon 3BCarbon 8BΔ
GenerativeSequence Recovery eukaryote61.5464.05+2.51
Variant effect predictionBRCA284.6385.72+1.09
TraitGym Mendelian33.6536.43+2.78
ClinVar coding (24 kb)92.8993.11+0.22
ClinVar non-coding (24 kb)91.1491.63+0.49
PerturbationNucleotide triplet-expansion85.2089.05+3.85
Synonymous codon replacement88.8991.46+2.57
Long-context retrievalGenomic-NIAH @ 393 kbp79.0086.00+7.00

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.

Table
Context lengthCarbon 3B (native / YaRN 4×)Carbon 8B (native / YaRN 4×)Evo2 7B
16 k tokens (98 kbp)0.73 / 0.910.78 / 0.890.97
32 k tokens (196 kbp)0.55 / 0.900.69 / 0.870.95
64 k tokens (393 kbp)— / 0.79— / 0.860.80
128 k tokens (786 kbp)— / 0.27— / 0.650.53

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

markdown

@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}
}

Model provider

HuggingFaceBio

Model tree

Base

this model

Modalities

Input

Text

Output

Text

Pricing

Dedicated Endpoints

View details

Supported Functionality

Model APIs

Dedicated Endpoints

Container

More information

Explore FriendliAI today