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
Initial GPTQ model commit
Browse files- configuration_baichuan.py +48 -0
configuration_baichuan.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) 2023, Baichuan Intelligent Technology. All rights reserved.
|
| 2 |
+
|
| 3 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class BaichuanConfig(PretrainedConfig):
|
| 7 |
+
model_type = "baichuan"
|
| 8 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
| 9 |
+
|
| 10 |
+
def __init__(
|
| 11 |
+
self,
|
| 12 |
+
vocab_size=64000,
|
| 13 |
+
hidden_size=5120,
|
| 14 |
+
intermediate_size=13696,
|
| 15 |
+
num_hidden_layers=40,
|
| 16 |
+
num_attention_heads=40,
|
| 17 |
+
hidden_act="silu",
|
| 18 |
+
model_max_length=4096,
|
| 19 |
+
initializer_range=0.02,
|
| 20 |
+
rms_norm_eps=1e-6,
|
| 21 |
+
use_cache=True,
|
| 22 |
+
pad_token_id=0,
|
| 23 |
+
bos_token_id=1,
|
| 24 |
+
eos_token_id=2,
|
| 25 |
+
tie_word_embeddings=False,
|
| 26 |
+
gradient_checkpointing=False,
|
| 27 |
+
z_loss_weight=0,
|
| 28 |
+
**kwargs,
|
| 29 |
+
):
|
| 30 |
+
self.vocab_size = vocab_size
|
| 31 |
+
self.model_max_length = model_max_length
|
| 32 |
+
self.hidden_size = hidden_size
|
| 33 |
+
self.intermediate_size = intermediate_size
|
| 34 |
+
self.num_hidden_layers = num_hidden_layers
|
| 35 |
+
self.num_attention_heads = num_attention_heads
|
| 36 |
+
self.hidden_act = hidden_act
|
| 37 |
+
self.initializer_range = initializer_range
|
| 38 |
+
self.rms_norm_eps = rms_norm_eps
|
| 39 |
+
self.use_cache = use_cache
|
| 40 |
+
self.z_loss_weight = z_loss_weight
|
| 41 |
+
self.gradient_checkpointing = (gradient_checkpointing,)
|
| 42 |
+
super().__init__(
|
| 43 |
+
pad_token_id=pad_token_id,
|
| 44 |
+
bos_token_id=bos_token_id,
|
| 45 |
+
eos_token_id=eos_token_id,
|
| 46 |
+
tie_word_embeddings=tie_word_embeddings,
|
| 47 |
+
**kwargs,
|
| 48 |
+
)
|