Text Generation
Transformers
Safetensors
English
qwen3
dna
genomics
biology
mid-training
conversational
text-generation-inference
Instructions to use HuggingFaceBio/Carbon-X-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HuggingFaceBio/Carbon-X-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="HuggingFaceBio/Carbon-X-Base") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("HuggingFaceBio/Carbon-X-Base") model = AutoModelForCausalLM.from_pretrained("HuggingFaceBio/Carbon-X-Base", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use HuggingFaceBio/Carbon-X-Base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HuggingFaceBio/Carbon-X-Base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HuggingFaceBio/Carbon-X-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/HuggingFaceBio/Carbon-X-Base
- SGLang
How to use HuggingFaceBio/Carbon-X-Base with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "HuggingFaceBio/Carbon-X-Base" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HuggingFaceBio/Carbon-X-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "HuggingFaceBio/Carbon-X-Base" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HuggingFaceBio/Carbon-X-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use HuggingFaceBio/Carbon-X-Base with Docker Model Runner:
docker model run hf.co/HuggingFaceBio/Carbon-X-Base
Rename to Carbon-X-Base
Browse files
README.md
CHANGED
|
@@ -21,7 +21,7 @@ pipeline_tag: text-generation
|
|
| 21 |
<a href="https://github.com/huggingface/carbon/tree/main"><b>Code</b></a>
|
| 22 |
</p>
|
| 23 |
|
| 24 |
-
# Carbon-X-
|
| 25 |
|
| 26 |
The mid-trained base model behind [Carbon-X](https://huggingface.co/HuggingFaceBio/Carbon-X): Qwen3-14B after learning DNA as a new modality over 302B tokens of DNA and text, before any task-specific post-training.
|
| 27 |
|
|
@@ -37,13 +37,13 @@ The mid-trained base model behind [Carbon-X](https://huggingface.co/HuggingFaceB
|
|
| 37 |
|
| 38 |
## Model Summary
|
| 39 |
|
| 40 |
-
**Carbon-X-
|
| 41 |
|
| 42 |
DNA and text share a single token stream in a single decoder, with no separate DNA encoder. A hybrid tokenizer keeps the Qwen3 BPE vocabulary for text and encodes DNA as non-overlapping 6-mers, so one DNA token covers 6 base pairs.
|
| 43 |
|
| 44 |
-
Mid-training is where the model learns DNA. Carbon-X-
|
| 45 |
|
| 46 |
-
Carbon-X-
|
| 47 |
|
| 48 |
- **Fine-tuning** your own DNA-and-language model on new tasks.
|
| 49 |
- **Scoring sequences** by likelihood, for example to compare a variant with its reference.
|
|
@@ -61,7 +61,7 @@ To ask questions about sequences in a chat, use [Carbon-X](https://huggingface.c
|
|
| 61 |
|
| 62 |
## How to use
|
| 63 |
|
| 64 |
-
Carbon-X-
|
| 65 |
|
| 66 |
```bash
|
| 67 |
pip install -U transformers
|
|
@@ -71,7 +71,7 @@ pip install -U transformers
|
|
| 71 |
import torch
|
| 72 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 73 |
|
| 74 |
-
model_id = "HuggingFaceBio/Carbon-X-
|
| 75 |
|
| 76 |
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 77 |
model = AutoModelForCausalLM.from_pretrained(model_id, dtype=torch.bfloat16, device_map="cuda")
|
|
@@ -127,7 +127,7 @@ The tokenizer switches between BPE for text and 6-mers for DNA:
|
|
| 127 |
|
| 128 |
### Fine-tuning with TRL
|
| 129 |
|
| 130 |
-
Carbon-X-
|
| 131 |
|
| 132 |
```python
|
| 133 |
import torch
|
|
@@ -135,7 +135,7 @@ from datasets import load_dataset
|
|
| 135 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 136 |
from trl import SFTConfig, SFTTrainer
|
| 137 |
|
| 138 |
-
model_id = "HuggingFaceBio/Carbon-X-
|
| 139 |
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 140 |
model = AutoModelForCausalLM.from_pretrained(model_id, dtype=torch.bfloat16)
|
| 141 |
|
|
@@ -162,9 +162,9 @@ Set `eos_token="<|im_end|>"`: the tokenizer's default end-of-sequence token is `
|
|
| 162 |
|
| 163 |
## Evaluation
|
| 164 |
|
| 165 |
-
We tracked DNA and English benchmarks throughout mid-training. The table compares Qwen3-14B, the starting model, with Carbon-X-
|
| 166 |
|
| 167 |
-
| Group | Benchmark | Qwen3-14B | Carbon-X-
|
| 168 |
|---|---|---:|---:|
|
| 169 |
| DNA | Sequence recovery | 29.5 | **56.2** |
|
| 170 |
| DNA | Eukaryote species classification | 28.2 | **36.7** |
|
|
@@ -220,10 +220,10 @@ The instruction data keeps the model able to follow chat-formatted prompts, whic
|
|
| 220 |
|
| 221 |
## Limitations
|
| 222 |
|
| 223 |
-
Carbon-X-
|
| 224 |
|
| 225 |
- ⚠️ **Genetic data is highly sensitive.** Depending on how you use this model (local download, inference API or 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. Make sure you understand and agree with how your data is handled before using the model.
|
| 226 |
-
- **Not post-trained for DNA questions.** Carbon-X-
|
| 227 |
- **Hallucinations.** The model may invent a sequence's identity or function, and its biological claims should be verified.
|
| 228 |
- **Some English forgetting.** Mid-training preserved most of Qwen3-14B's English ability, but not all of it (OpenBookQA drops 2.4 points).
|
| 229 |
- **Long inputs.** Mid-training used 8,192-token sequences (up to ≈ 49 kbp of DNA). The model accepts up to 40,960 tokens, but we have not evaluated inputs much longer than those seen in training.
|
|
|
|
| 21 |
<a href="https://github.com/huggingface/carbon/tree/main"><b>Code</b></a>
|
| 22 |
</p>
|
| 23 |
|
| 24 |
+
# Carbon-X-Base
|
| 25 |
|
| 26 |
The mid-trained base model behind [Carbon-X](https://huggingface.co/HuggingFaceBio/Carbon-X): Qwen3-14B after learning DNA as a new modality over 302B tokens of DNA and text, before any task-specific post-training.
|
| 27 |
|
|
|
|
| 37 |
|
| 38 |
## Model Summary
|
| 39 |
|
| 40 |
+
**Carbon-X-Base** is a 14.8B-parameter decoder-only language model trained jointly on DNA sequences and natural-language text. It starts from [Qwen3-14B](https://huggingface.co/Qwen/Qwen3-14B), extends its vocabulary with DNA tokens, and is then trained on a 302B-token mixture that is 55% raw DNA, 15% biology text, 20% English and 10% instruction data. This is the checkpoint we fine-tuned and trained with reinforcement learning to build [Carbon-X](https://huggingface.co/HuggingFaceBio/Carbon-X).
|
| 41 |
|
| 42 |
DNA and text share a single token stream in a single decoder, with no separate DNA encoder. A hybrid tokenizer keeps the Qwen3 BPE vocabulary for text and encodes DNA as non-overlapping 6-mers, so one DNA token covers 6 base pairs.
|
| 43 |
|
| 44 |
+
Mid-training is where the model learns DNA. Carbon-X-Base nearly doubles Qwen3-14B's accuracy at recovering DNA sequences while keeping its English benchmark scores within a few points ([Evaluation](#evaluation)). It also made reinforcement learning work: RL applied directly to Qwen3-14B never rose above chance on our FrontierVEP variant-effect benchmark, while the same RL starting from Carbon-X-Base did.
|
| 45 |
|
| 46 |
+
Carbon-X-Base is meant as a starting point:
|
| 47 |
|
| 48 |
- **Fine-tuning** your own DNA-and-language model on new tasks.
|
| 49 |
- **Scoring sequences** by likelihood, for example to compare a variant with its reference.
|
|
|
|
| 61 |
|
| 62 |
## How to use
|
| 63 |
|
| 64 |
+
Carbon-X-Base uses a standard causal LM architecture. The DNA tokenizer is custom code, so pass `trust_remote_code=True` when you load the tokenizer.
|
| 65 |
|
| 66 |
```bash
|
| 67 |
pip install -U transformers
|
|
|
|
| 71 |
import torch
|
| 72 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 73 |
|
| 74 |
+
model_id = "HuggingFaceBio/Carbon-X-Base"
|
| 75 |
|
| 76 |
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 77 |
model = AutoModelForCausalLM.from_pretrained(model_id, dtype=torch.bfloat16, device_map="cuda")
|
|
|
|
| 127 |
|
| 128 |
### Fine-tuning with TRL
|
| 129 |
|
| 130 |
+
Carbon-X-Base keeps the Qwen3 chat template, so you can fine-tune it on conversational data with [TRL](https://github.com/huggingface/trl). The settings below are the ones we used for Carbon-X's supervised fine-tuning, with a global batch size of 32:
|
| 131 |
|
| 132 |
```python
|
| 133 |
import torch
|
|
|
|
| 135 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 136 |
from trl import SFTConfig, SFTTrainer
|
| 137 |
|
| 138 |
+
model_id = "HuggingFaceBio/Carbon-X-Base"
|
| 139 |
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 140 |
model = AutoModelForCausalLM.from_pretrained(model_id, dtype=torch.bfloat16)
|
| 141 |
|
|
|
|
| 162 |
|
| 163 |
## Evaluation
|
| 164 |
|
| 165 |
+
We tracked DNA and English benchmarks throughout mid-training. The table compares Qwen3-14B, the starting model, with Carbon-X-Base at the end of mid-training (accuracy, %):
|
| 166 |
|
| 167 |
+
| Group | Benchmark | Qwen3-14B | Carbon-X-Base |
|
| 168 |
|---|---|---:|---:|
|
| 169 |
| DNA | Sequence recovery | 29.5 | **56.2** |
|
| 170 |
| DNA | Eukaryote species classification | 28.2 | **36.7** |
|
|
|
|
| 220 |
|
| 221 |
## Limitations
|
| 222 |
|
| 223 |
+
Carbon-X-Base is a research checkpoint. It has **not been clinically validated**, and it should not be used to make medical decisions.
|
| 224 |
|
| 225 |
- ⚠️ **Genetic data is highly sensitive.** Depending on how you use this model (local download, inference API or 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. Make sure you understand and agree with how your data is handled before using the model.
|
| 226 |
+
- **Not post-trained for DNA questions.** Carbon-X-Base can hold a conversation, but its answers about specific sequences are unreliable. For example, it can miscopy or mistranslate a sequence it is asked to explain. Use [Carbon-X](https://huggingface.co/HuggingFaceBio/Carbon-X) for question answering, or fine-tune this model for your task.
|
| 227 |
- **Hallucinations.** The model may invent a sequence's identity or function, and its biological claims should be verified.
|
| 228 |
- **Some English forgetting.** Mid-training preserved most of Qwen3-14B's English ability, but not all of it (OpenBookQA drops 2.4 points).
|
| 229 |
- **Long inputs.** Mid-training used 8,192-token sequences (up to ≈ 49 kbp of DNA). The model accepts up to 40,960 tokens, but we have not evaluated inputs much longer than those seen in training.
|