Text Generation
Transformers
Safetensors
English
Chinese
baichuan
custom_code
text-generation-inference
4-bit precision
gptq
Instructions to use TheBloke/Baichuan2-13B-Chat-GPTQ with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TheBloke/Baichuan2-13B-Chat-GPTQ with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="TheBloke/Baichuan2-13B-Chat-GPTQ", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("TheBloke/Baichuan2-13B-Chat-GPTQ", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use TheBloke/Baichuan2-13B-Chat-GPTQ with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "TheBloke/Baichuan2-13B-Chat-GPTQ" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TheBloke/Baichuan2-13B-Chat-GPTQ", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/TheBloke/Baichuan2-13B-Chat-GPTQ
- SGLang
How to use TheBloke/Baichuan2-13B-Chat-GPTQ 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 "TheBloke/Baichuan2-13B-Chat-GPTQ" \ --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": "TheBloke/Baichuan2-13B-Chat-GPTQ", "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 "TheBloke/Baichuan2-13B-Chat-GPTQ" \ --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": "TheBloke/Baichuan2-13B-Chat-GPTQ", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use TheBloke/Baichuan2-13B-Chat-GPTQ with Docker Model Runner:
docker model run hf.co/TheBloke/Baichuan2-13B-Chat-GPTQ
Fix bug "AttributeError: BaiChuanTokenizer has no attribute vocab_size"
Browse files- tokenization_baichuan.py +5 -5
tokenization_baichuan.py
CHANGED
|
@@ -68,6 +68,11 @@ class BaichuanTokenizer(PreTrainedTokenizer):
|
|
| 68 |
if isinstance(pad_token, str)
|
| 69 |
else pad_token
|
| 70 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
super().__init__(
|
| 72 |
bos_token=bos_token,
|
| 73 |
eos_token=eos_token,
|
|
@@ -79,11 +84,6 @@ class BaichuanTokenizer(PreTrainedTokenizer):
|
|
| 79 |
clean_up_tokenization_spaces=clean_up_tokenization_spaces,
|
| 80 |
**kwargs,
|
| 81 |
)
|
| 82 |
-
self.vocab_file = vocab_file
|
| 83 |
-
self.add_bos_token = add_bos_token
|
| 84 |
-
self.add_eos_token = add_eos_token
|
| 85 |
-
self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
|
| 86 |
-
self.sp_model.Load(vocab_file)
|
| 87 |
|
| 88 |
def __getstate__(self):
|
| 89 |
state = self.__dict__.copy()
|
|
|
|
| 68 |
if isinstance(pad_token, str)
|
| 69 |
else pad_token
|
| 70 |
)
|
| 71 |
+
self.vocab_file = vocab_file
|
| 72 |
+
self.add_bos_token = add_bos_token
|
| 73 |
+
self.add_eos_token = add_eos_token
|
| 74 |
+
self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
|
| 75 |
+
self.sp_model.Load(vocab_file)
|
| 76 |
super().__init__(
|
| 77 |
bos_token=bos_token,
|
| 78 |
eos_token=eos_token,
|
|
|
|
| 84 |
clean_up_tokenization_spaces=clean_up_tokenization_spaces,
|
| 85 |
**kwargs,
|
| 86 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
def __getstate__(self):
|
| 89 |
state = self.__dict__.copy()
|