Text Generation
Transformers
PyTorch
English
chatglm
conversational
text2text-generation
custom_code
Instructions to use NewBreaker/chatglm-6b-int4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NewBreaker/chatglm-6b-int4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NewBreaker/chatglm-6b-int4", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("NewBreaker/chatglm-6b-int4", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use NewBreaker/chatglm-6b-int4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NewBreaker/chatglm-6b-int4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NewBreaker/chatglm-6b-int4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/NewBreaker/chatglm-6b-int4
- SGLang
How to use NewBreaker/chatglm-6b-int4 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 "NewBreaker/chatglm-6b-int4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NewBreaker/chatglm-6b-int4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "NewBreaker/chatglm-6b-int4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NewBreaker/chatglm-6b-int4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use NewBreaker/chatglm-6b-int4 with Docker Model Runner:
docker model run hf.co/NewBreaker/chatglm-6b-int4
NewBreaker commited on
Commit ·
9768cd8
1
Parent(s): 3f712ba
auto git
Browse files- config.json +0 -1
- demo_pipeline.py +1 -1
- load_model.py +8 -7
config.json
CHANGED
|
@@ -8,7 +8,6 @@
|
|
| 8 |
"AutoModel": "modeling_chatglm.ChatGLMForConditionalGeneration",
|
| 9 |
"AutoModelForSeq2SeqLM": "modeling_chatglm.ChatGLMForConditionalGeneration"
|
| 10 |
},
|
| 11 |
-
"device": "cuda",
|
| 12 |
"bos_token_id": 130004,
|
| 13 |
"eos_token_id": 130005,
|
| 14 |
"mask_token_id": 130000,
|
|
|
|
| 8 |
"AutoModel": "modeling_chatglm.ChatGLMForConditionalGeneration",
|
| 9 |
"AutoModelForSeq2SeqLM": "modeling_chatglm.ChatGLMForConditionalGeneration"
|
| 10 |
},
|
|
|
|
| 11 |
"bos_token_id": 130004,
|
| 12 |
"eos_token_id": 130005,
|
| 13 |
"mask_token_id": 130000,
|
demo_pipeline.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
|
| 2 |
from transformers import pipeline
|
| 3 |
-
nlp = pipeline('text2text-generation',model ='
|
| 4 |
# response = nlp
|
|
|
|
| 1 |
|
| 2 |
from transformers import pipeline
|
| 3 |
+
nlp = pipeline('text2text-generation',model ='THUDM/chatglm-6b',trust_remote_code=True)
|
| 4 |
# response = nlp
|
load_model.py
CHANGED
|
@@ -1,9 +1,10 @@
|
|
| 1 |
-
from transformers import AutoTokenizer, AutoModel
|
| 2 |
|
| 3 |
#
|
| 4 |
-
tokenizer = AutoTokenizer.from_pretrained(".\\", trust_remote_code=True)
|
| 5 |
-
# model = AutoModel.from_pretrained(".\\", trust_remote_code=True).float()
|
| 6 |
-
model = AutoModel.from_pretrained(".\\", trust_remote_code=True)
|
| 7 |
-
model = model.eval()
|
| 8 |
-
response, history = model.chat(tokenizer, "你好", history=[])
|
| 9 |
-
print("response:", response)
|
|
|
|
|
|
| 1 |
+
from transformers import AutoTokenizer, AutoModel,pipeline
|
| 2 |
|
| 3 |
#
|
| 4 |
+
# tokenizer = AutoTokenizer.from_pretrained(".\\", trust_remote_code=True)
|
| 5 |
+
# # model = AutoModel.from_pretrained(".\\", trust_remote_code=True).float()
|
| 6 |
+
# model = AutoModel.from_pretrained(".\\", trust_remote_code=True)
|
| 7 |
+
# model = model.eval()
|
| 8 |
+
# response, history = model.chat(tokenizer, "你好", history=[])
|
| 9 |
+
# print("response:", response)
|
| 10 |
+
npl = pipeline('')
|