Text Generation
Transformers
Safetensors
Upper Grand Valley Dani
llama
genomic
text-generation-inference
Run this model with HF Jobs
Run HuggingFaceBio/Carbon-8B on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/HuggingFaceBio/Carbon-8B. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/HuggingFaceBio/Carbon-8B on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/HuggingFaceBio/Carbon-8B. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/HuggingFaceBio/Carbon-8B. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use HuggingFaceBio/Carbon-8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HuggingFaceBio/Carbon-8B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="HuggingFaceBio/Carbon-8B")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("HuggingFaceBio/Carbon-8B") model = AutoModelForCausalLM.from_pretrained("HuggingFaceBio/Carbon-8B", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use HuggingFaceBio/Carbon-8B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HuggingFaceBio/Carbon-8B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HuggingFaceBio/Carbon-8B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/HuggingFaceBio/Carbon-8B
- SGLang
How to use HuggingFaceBio/Carbon-8B 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-8B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HuggingFaceBio/Carbon-8B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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-8B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HuggingFaceBio/Carbon-8B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use HuggingFaceBio/Carbon-8B with Docker Model Runner:
docker model run hf.co/HuggingFaceBio/Carbon-8B
Update README.md
Browse files23 unmodified lines24252627282910 unmodified lines40414243444523 unmodified lines- **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`).```pythonfrom transformers import AutoModelForCausalLM, AutoTokenizerimport torch10 unmodified linesprint(tok.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))```## TrainingCarbon-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:23 unmodified lines242526272829303110 unmodified lines4243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811923 unmodified lines- **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```pythonfrom transformers import AutoModelForCausalLM, AutoTokenizerimport torch10 unmodified linesprint(tok.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))```### Base-pair-level generation and scoringThe `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:```pyimport mathimport torchfrom transformers import AutoModelForCausalLM, AutoTokenizermodel_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 = 60inputs = 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:```pyimport torchfrom transformers import AutoModelForCausalLM, AutoTokenizermodel_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]}")```## TrainingCarbon-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:
README.md+74