Text Generation
Transformers
PyTorch
t5
text2text-generation
biology
single-cell
single-cell analysis
text-generation-inference
Instructions to use zjunlp/chatcell-large with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zjunlp/chatcell-large with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="zjunlp/chatcell-large")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("zjunlp/chatcell-large") model = AutoModelForSeq2SeqLM.from_pretrained("zjunlp/chatcell-large") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use zjunlp/chatcell-large with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "zjunlp/chatcell-large" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "zjunlp/chatcell-large", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/zjunlp/chatcell-large
- SGLang
How to use zjunlp/chatcell-large 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 "zjunlp/chatcell-large" \ --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": "zjunlp/chatcell-large", "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 "zjunlp/chatcell-large" \ --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": "zjunlp/chatcell-large", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use zjunlp/chatcell-large with Docker Model Runner:
docker model run hf.co/zjunlp/chatcell-large
File size: 1,061 Bytes
5e439c3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | from typing import Dict, List
from transformers import (
AutoTokenizer,
AutoModelForSeq2SeqLM,
)
# in line with the default config of the model
CONFIG = {
'max_length': 512,
'num_return_sequences': 1,
'no_repeat_ngram_size': 2,
'top_k': 50,
'top_p': 0.95,
'do_sample': True,
}
class EndpointHandler:
def __init__(self, path: str = ""):
self.tokenizer = AutoTokenizer.from_pretrained(path)
self.model = AutoModelForSeq2SeqLM.from_pretrained(path)
def __call__(self, data: Dict[str, str]) -> List[Dict[str, str]]:
inputs = data.pop('inputs', None)
if inputs is None or inputs == '':
return [{'generated_text': 'No input provided'}]
# preprocess
input_ids = self.tokenizer(inputs, return_tensors="pt").input_ids
# inference
output_ids = self.model.generate(input_ids, **CONFIG)
# postprocess
response = self.tokenizer.decode(output_ids[0], skip_special_tokens=True)
return [{'generated_text': response}] |