Text Generation
Transformers
Safetensors
English
qwen3
dna
genomics
biology
variant-effect-prediction
conversational
text-generation-inference
Instructions to use HuggingFaceBio/Carbon-X with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HuggingFaceBio/Carbon-X with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="HuggingFaceBio/Carbon-X") 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") model = AutoModelForCausalLM.from_pretrained("HuggingFaceBio/Carbon-X", 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 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HuggingFaceBio/Carbon-X" # 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", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/HuggingFaceBio/Carbon-X
- SGLang
How to use HuggingFaceBio/Carbon-X 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" \ --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", "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" \ --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", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use HuggingFaceBio/Carbon-X with Docker Model Runner:
docker model run hf.co/HuggingFaceBio/Carbon-X
danaaubakirova HF Staff
Model card: move the agent-tool section before Limitations; add examples and the carbon-dna skill
b3f11f8 verified Download examples/inspect_agent.py from HuggingFaceBio/Carbon-X: direct link, hf CLI and curl.
- Browser
- Download file 2.63 kB
-
https://huggingface.co/HuggingFaceBio/Carbon-X/resolve/refs%2Fpr%2F2/examples/inspect_agent.py
- Command line
-
hf download hf://HuggingFaceBio/Carbon-X@refs/pr/2/examples/inspect_agent.py
-
curl -L -o inspect_agent.py https://huggingface.co/HuggingFaceBio/Carbon-X/resolve/refs%2Fpr%2F2/examples/inspect_agent.py
2.63 kB
| """Use Carbon-X as a tool for an Inspect react() agent. | |
| Serve Carbon-X first: vllm serve HuggingFaceBio/Carbon-X --trust-remote-code | |
| Then run: python inspect_agent.py | |
| """ | |
| from inspect_ai import Task, eval, task | |
| from inspect_ai.agent import as_solver, react | |
| from inspect_ai.dataset import Sample | |
| from inspect_ai.scorer import includes | |
| from inspect_ai.solver import solver | |
| from inspect_ai.tool import ToolError, tool | |
| from inspect_ai.util import store | |
| from openai import AsyncOpenAI | |
| carbon = AsyncOpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY") | |
| def ask_carbon(): | |
| async def execute(question: str, sequences: list[str], context: str = "") -> str: | |
| """Ask Carbon-X, a DNA language model, about this task's DNA sequences. Its answers are predictions. | |
| Args: | |
| question: One self-contained question. | |
| sequences: Names of the sequences to send, as given in the task. | |
| context: Known facts, such as the gene, positions or alleles. | |
| """ | |
| dna = store().get("sequences") | |
| if missing := [name for name in sequences if name not in dna]: | |
| raise ToolError(f"Unknown sequence names: {missing}. Available: {list(dna)}") | |
| parts = [context, question] if context else [question] | |
| parts += [f"{name}: <dna>{dna[name]}</dna>" for name in sequences] | |
| response = await carbon.chat.completions.create( | |
| model="HuggingFaceBio/Carbon-X", | |
| messages=[{"role": "user", "content": "\n\n".join(parts)}], | |
| max_tokens=4096, | |
| extra_body={"chat_template_kwargs": {"enable_thinking": False}}, | |
| ) | |
| return response.choices[0].message.content | |
| return execute | |
| def load_sequences(): | |
| async def solve(state, generate): | |
| store().set("sequences", state.metadata["sequences"]) # the tool reads DNA from here | |
| return state | |
| return solve | |
| def carbon_agent(): | |
| sample = Sample( | |
| input="Sequence `variant` differs from `reference` at position 20 (A>T). Is the variant benign or pathogenic?", | |
| target="pathogenic", | |
| metadata={"sequences": { | |
| "reference": "ATGGTGCATCTGACTCCTGAGGAGAAGTCTGCCGTTACTGCCCTGTGGGGCAAGG", | |
| "variant": "ATGGTGCATCTGACTCCTGTGGAGAAGTCTGCCGTTACTGCCCTGTGGGGCAAGG", | |
| }}, | |
| ) | |
| agent = react(prompt="Consult Carbon-X with the ask_carbon tool before you answer.", tools=[ask_carbon()]) | |
| return Task(dataset=[sample], solver=[load_sequences(), as_solver(agent)], scorer=includes()) | |
| eval(carbon_agent(), model="openai/gpt-5") # any Inspect model with tool calling as the agent | |