Text Generation
Transformers
Safetensors
Upper Grand Valley Dani
llama
genomic
biology
text-generation-inference
Instructions to use HuggingFaceBio/Carbon-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HuggingFaceBio/Carbon-3B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="HuggingFaceBio/Carbon-3B")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("HuggingFaceBio/Carbon-3B") model = AutoModelForCausalLM.from_pretrained("HuggingFaceBio/Carbon-3B", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use HuggingFaceBio/Carbon-3B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HuggingFaceBio/Carbon-3B" # 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-3B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/HuggingFaceBio/Carbon-3B
- SGLang
How to use HuggingFaceBio/Carbon-3B 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-3B" \ --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-3B", "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-3B" \ --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-3B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use HuggingFaceBio/Carbon-3B with Docker Model Runner:
docker model run hf.co/HuggingFaceBio/Carbon-3B
load chat_template in from_pretrained (vLLM apply_chat_template fix)
Browse files- tokenizer.py +26 -19
tokenizer.py
CHANGED
|
@@ -580,22 +580,29 @@ class HybridDNATokenizer(PreTrainedTokenizer):
|
|
| 580 |
return (save_directory,)
|
| 581 |
|
| 582 |
@classmethod
|
| 583 |
-
def from_pretrained(cls, pretrained_model_name_or_path
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 580 |
return (save_directory,)
|
| 581 |
|
| 582 |
@classmethod
|
| 583 |
+
def from_pretrained(cls, pretrained_model_name_or_path, *args, **kwargs):
|
| 584 |
+
# Custom loader: PreTrainedTokenizer.from_pretrained is incompatible with this
|
| 585 |
+
# tokenizer's __init__ (it re-passes bos_token etc.), so construct directly from
|
| 586 |
+
# bio_config/dna_config. That bypasses standard metadata loading, so also read
|
| 587 |
+
# chat_template from tokenizer_config.json (vLLM / apply_chat_template need it).
|
| 588 |
+
import os as _os, json as _json
|
| 589 |
+
cfg = {}
|
| 590 |
+
for _name in ("bio_config.json", "dna_config.json"):
|
| 591 |
+
_p = _os.path.join(pretrained_model_name_or_path, _name)
|
| 592 |
+
if _os.path.exists(_p):
|
| 593 |
+
with open(_p, "r", encoding="utf-8") as _f:
|
| 594 |
+
cfg = _json.load(_f)
|
| 595 |
+
break
|
| 596 |
+
_init = {"base_tokenizer_path": pretrained_model_name_or_path}
|
| 597 |
+
for _key in ("k", "tail", "auto_dna_tags"):
|
| 598 |
+
if _key in cfg:
|
| 599 |
+
_init[_key] = cfg[_key]
|
| 600 |
+
tok = cls(**_init, **kwargs)
|
| 601 |
+
if getattr(tok, "chat_template", None) is None:
|
| 602 |
+
_tc = _os.path.join(pretrained_model_name_or_path, "tokenizer_config.json")
|
| 603 |
+
if _os.path.exists(_tc):
|
| 604 |
+
with open(_tc, "r", encoding="utf-8") as _f:
|
| 605 |
+
_c = _json.load(_f)
|
| 606 |
+
if _c.get("chat_template"):
|
| 607 |
+
tok.chat_template = _c["chat_template"]
|
| 608 |
+
return tok
|