Text Generation
Transformers
Safetensors
Upper Grand Valley Dani
llama
genomic
text-generation-inference
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")# 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
load chat_template in from_pretrained (vLLM apply_chat_template fix)
Browse files- tokenizer.py +47 -15
tokenizer.py
CHANGED
|
@@ -580,29 +580,61 @@ class HybridDNATokenizer(PreTrainedTokenizer):
|
|
| 580 |
return (save_directory,)
|
| 581 |
|
| 582 |
@classmethod
|
| 583 |
-
def from_pretrained(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 589 |
cfg = {}
|
| 590 |
for _name in ("bio_config.json", "dna_config.json"):
|
| 591 |
-
_p =
|
| 592 |
-
if
|
| 593 |
-
with open(_p,
|
| 594 |
-
cfg =
|
| 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 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 580 |
return (save_directory,)
|
| 581 |
|
| 582 |
@classmethod
|
| 583 |
+
def from_pretrained(
|
| 584 |
+
cls,
|
| 585 |
+
pretrained_model_name_or_path,
|
| 586 |
+
*args,
|
| 587 |
+
cache_dir=None,
|
| 588 |
+
local_files_only=False,
|
| 589 |
+
token=None,
|
| 590 |
+
revision="main",
|
| 591 |
+
trust_remote_code=False,
|
| 592 |
+
**kwargs,
|
| 593 |
+
):
|
| 594 |
# Custom loader: PreTrainedTokenizer.from_pretrained is incompatible with this
|
| 595 |
# tokenizer's __init__ (it re-passes bos_token etc.), so construct directly from
|
| 596 |
# bio_config/dna_config. That bypasses standard metadata loading, so also read
|
| 597 |
# chat_template from tokenizer_config.json (vLLM / apply_chat_template need it).
|
| 598 |
+
from transformers.utils.hub import cached_file
|
| 599 |
+
|
| 600 |
+
proxies = kwargs.pop("proxies", None)
|
| 601 |
+
subfolder = kwargs.pop("subfolder", None)
|
| 602 |
+
commit_hash = kwargs.pop("_commit_hash", None)
|
| 603 |
+
hub_kwargs = {
|
| 604 |
+
"cache_dir": cache_dir,
|
| 605 |
+
"local_files_only": local_files_only,
|
| 606 |
+
"proxies": proxies,
|
| 607 |
+
"revision": revision,
|
| 608 |
+
"subfolder": subfolder,
|
| 609 |
+
"token": token,
|
| 610 |
+
"_commit_hash": commit_hash,
|
| 611 |
+
"_raise_exceptions_for_missing_entries": False,
|
| 612 |
+
}
|
| 613 |
+
|
| 614 |
cfg = {}
|
| 615 |
for _name in ("bio_config.json", "dna_config.json"):
|
| 616 |
+
_p = cached_file(pretrained_model_name_or_path, _name, **hub_kwargs)
|
| 617 |
+
if _p is not None:
|
| 618 |
+
with open(_p, encoding="utf-8") as _f:
|
| 619 |
+
cfg = json.load(_f)
|
| 620 |
break
|
| 621 |
+
|
| 622 |
_init = {"base_tokenizer_path": pretrained_model_name_or_path}
|
| 623 |
for _key in ("k", "tail", "auto_dna_tags"):
|
| 624 |
if _key in cfg:
|
| 625 |
_init[_key] = cfg[_key]
|
| 626 |
+
|
| 627 |
+
tokenizer_config_path = cached_file(pretrained_model_name_or_path, "tokenizer_config.json", **hub_kwargs)
|
| 628 |
+
if tokenizer_config_path is not None:
|
| 629 |
+
with open(tokenizer_config_path, encoding="utf-8") as _f:
|
| 630 |
+
tokenizer_config = json.load(_f)
|
| 631 |
+
if tokenizer_config.get("chat_template"):
|
| 632 |
+
_init["chat_template"] = tokenizer_config["chat_template"]
|
| 633 |
+
|
| 634 |
+
chat_template_path = cached_file(pretrained_model_name_or_path, "chat_template.jinja", **hub_kwargs)
|
| 635 |
+
if chat_template_path is not None:
|
| 636 |
+
with open(chat_template_path, encoding="utf-8") as _f:
|
| 637 |
+
_init["chat_template"] = _f.read()
|
| 638 |
+
|
| 639 |
+
_init.update(kwargs)
|
| 640 |
+
return cls(**_init)
|