Text Generation
Transformers
Safetensors
Upper Grand Valley Dani
llama
genomic
speculative-decoding
conversational
text-generation-inference
Instructions to use HuggingFaceBio/Carbon-500M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HuggingFaceBio/Carbon-500M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="HuggingFaceBio/Carbon-500M") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("HuggingFaceBio/Carbon-500M") model = AutoModelForCausalLM.from_pretrained("HuggingFaceBio/Carbon-500M") 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use HuggingFaceBio/Carbon-500M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HuggingFaceBio/Carbon-500M" # 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-500M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/HuggingFaceBio/Carbon-500M
- SGLang
How to use HuggingFaceBio/Carbon-500M 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-500M" \ --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-500M", "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-500M" \ --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-500M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use HuggingFaceBio/Carbon-500M with Docker Model Runner:
docker model run hf.co/HuggingFaceBio/Carbon-500M
Update model card namespace references
#1
by lewtun HF Staff - opened
README.md
CHANGED
|
@@ -14,9 +14,9 @@ tags:
|
|
| 14 |
|
| 15 |
A small generative DNA model from the **Carbon** family.
|
| 16 |
|
| 17 |
-
**Carbon-500M is intended primarily as a draft model for speculative decoding** — it shares the tokenizer and DNA template format of [Carbon-3B](https://huggingface.co/
|
| 18 |
|
| 19 |
-
For the full design rationale, tokenizer specification, evaluation protocol, and usage notes (DNA tag wrapping, 6-mer constraints, scoring helpers), please refer to the **[Carbon-3B model card](https://huggingface.co/
|
| 20 |
|
| 21 |
> TODO: update teh tokenizer code
|
| 22 |
|
|
@@ -34,13 +34,13 @@ For the full design rationale, tokenizer specification, evaluation protocol, and
|
|
| 34 |
|
| 35 |
## How to use
|
| 36 |
|
| 37 |
-
Wrap DNA in `<dna>...</dna>` exactly as for the larger models. See the [Carbon-3B card](https://huggingface.co/
|
| 38 |
|
| 39 |
```python
|
| 40 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 41 |
import torch
|
| 42 |
|
| 43 |
-
repo = "
|
| 44 |
tok = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
|
| 45 |
model = AutoModelForCausalLM.from_pretrained(
|
| 46 |
repo, torch_dtype=torch.bfloat16,
|
|
@@ -60,12 +60,12 @@ Carbon-500M is most useful when paired with a larger Carbon model as the verifie
|
|
| 60 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 61 |
import torch
|
| 62 |
|
| 63 |
-
tok = AutoTokenizer.from_pretrained("
|
| 64 |
draft = AutoModelForCausalLM.from_pretrained(
|
| 65 |
-
"
|
| 66 |
).cuda().eval()
|
| 67 |
target = AutoModelForCausalLM.from_pretrained(
|
| 68 |
-
"
|
| 69 |
).cuda().eval()
|
| 70 |
|
| 71 |
prompt = "<dna>ATGCGCTAGCTACGATCGATCGTAGCTAGCTAGCTAGCTACG"
|
|
@@ -81,7 +81,7 @@ Output is guaranteed identical to greedy decoding with the target model alone; o
|
|
| 81 |
|
| 82 |
## Evaluation
|
| 83 |
|
| 84 |
-
Carbon-500M is benchmarked against ≈ 1B-parameter DNA models on the standard Carbon evaluation suite. See the [Carbon-3B card](https://huggingface.co/
|
| 85 |
|
| 86 |
> TODO Loubna: add one downstream table comparing Carbon-500M to other 1B-class baselines. -->
|
| 87 |
|
|
|
|
| 14 |
|
| 15 |
A small generative DNA model from the **Carbon** family.
|
| 16 |
|
| 17 |
+
**Carbon-500M is intended primarily as a draft model for speculative decoding** — it shares the tokenizer and DNA template format of [Carbon-3B](https://huggingface.co/HuggingFaceBio/Carbon-3B) and [Carbon-8B](https://huggingface.co/HuggingFaceBio/Carbon-8B), so it can be paired with either as the target model to reduce wall-clock generation cost at no quality loss. It is not designed to be competitive with the 3B/8B Carbon models on downstream benchmarks.
|
| 18 |
|
| 19 |
+
For the full design rationale, tokenizer specification, evaluation protocol, and usage notes (DNA tag wrapping, 6-mer constraints, scoring helpers), please refer to the **[Carbon-3B model card](https://huggingface.co/HuggingFaceBio/Carbon-3B)** — this card focuses only on facts specific to Carbon-500M.
|
| 20 |
|
| 21 |
> TODO: update teh tokenizer code
|
| 22 |
|
|
|
|
| 34 |
|
| 35 |
## How to use
|
| 36 |
|
| 37 |
+
Wrap DNA in `<dna>...</dna>` exactly as for the larger models. See the [Carbon-3B card](https://huggingface.co/HuggingFaceBio/Carbon-3B#tokenizer-working-with-dna-inputs) for tokenizer details.
|
| 38 |
|
| 39 |
```python
|
| 40 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 41 |
import torch
|
| 42 |
|
| 43 |
+
repo = "HuggingFaceBio/Carbon-500M"
|
| 44 |
tok = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
|
| 45 |
model = AutoModelForCausalLM.from_pretrained(
|
| 46 |
repo, torch_dtype=torch.bfloat16,
|
|
|
|
| 60 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 61 |
import torch
|
| 62 |
|
| 63 |
+
tok = AutoTokenizer.from_pretrained("HuggingFaceBio/Carbon-3B", trust_remote_code=True)
|
| 64 |
draft = AutoModelForCausalLM.from_pretrained(
|
| 65 |
+
"HuggingFaceBio/Carbon-500M", torch_dtype=torch.bfloat16
|
| 66 |
).cuda().eval()
|
| 67 |
target = AutoModelForCausalLM.from_pretrained(
|
| 68 |
+
"HuggingFaceBio/Carbon-3B", torch_dtype=torch.bfloat16
|
| 69 |
).cuda().eval()
|
| 70 |
|
| 71 |
prompt = "<dna>ATGCGCTAGCTACGATCGATCGTAGCTAGCTAGCTAGCTACG"
|
|
|
|
| 81 |
|
| 82 |
## Evaluation
|
| 83 |
|
| 84 |
+
Carbon-500M is benchmarked against ≈ 1B-parameter DNA models on the standard Carbon evaluation suite. See the [Carbon-3B card](https://huggingface.co/HuggingFaceBio/Carbon-3B#evaluation) for the task definitions and methodology.
|
| 85 |
|
| 86 |
> TODO Loubna: add one downstream table comparing Carbon-500M to other 1B-class baselines. -->
|
| 87 |
|