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 ·
09d423b
1
Parent(s): 60a8d23
auto git
Browse files- README.md +2 -0
- config.json +1 -1
- demo_call_api.py +10 -9
README.md
CHANGED
|
@@ -27,6 +27,8 @@ widget:
|
|
| 27 |
example_title: Rammstein's album Mutter
|
| 28 |
pipeline_tag: text2text-generation
|
| 29 |
|
|
|
|
|
|
|
| 30 |
|
| 31 |
---
|
| 32 |
|
|
|
|
| 27 |
example_title: Rammstein's album Mutter
|
| 28 |
pipeline_tag: text2text-generation
|
| 29 |
|
| 30 |
+
tags:
|
| 31 |
+
- conversational
|
| 32 |
|
| 33 |
---
|
| 34 |
|
config.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
| 9 |
"AutoModel": "modeling_chatglm.ChatGLMForConditionalGeneration",
|
| 10 |
"AutoModelForSeq2SeqLM": "modeling_chatglm.ChatGLMForConditionalGeneration"
|
| 11 |
},
|
| 12 |
-
|
| 13 |
"bos_token_id": 130004,
|
| 14 |
"eos_token_id": 130005,
|
| 15 |
"gmask_token_id": 130001,
|
|
|
|
| 9 |
"AutoModel": "modeling_chatglm.ChatGLMForConditionalGeneration",
|
| 10 |
"AutoModelForSeq2SeqLM": "modeling_chatglm.ChatGLMForConditionalGeneration"
|
| 11 |
},
|
| 12 |
+
|
| 13 |
"bos_token_id": 130004,
|
| 14 |
"eos_token_id": 130005,
|
| 15 |
"gmask_token_id": 130001,
|
demo_call_api.py
CHANGED
|
@@ -1,14 +1,15 @@
|
|
| 1 |
-
from transformers import AutoModel,AutoTokenizer
|
| 2 |
-
|
| 3 |
-
model = AutoModel.from_pretrained("NewBreaker/chatglm-6b-int4",trust_remote_code=True)
|
| 4 |
-
tokenizer = AutoTokenizer.from_pretrained("NewBreaker/chatglm-6b-int4", trust_remote_code=True)
|
| 5 |
|
| 6 |
from transformers import AutoConfig
|
| 7 |
|
| 8 |
-
config = AutoConfig.from_pretrained("
|
| 9 |
|
| 10 |
-
# Push the config to your namespace with the name "my-finetuned-bert".
|
| 11 |
-
config.push_to_hub("my-finetuned-bert")
|
| 12 |
|
| 13 |
-
# Push the config to
|
| 14 |
-
config.push_to_hub("
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# from transformers import AutoModel,AutoTokenizer
|
| 2 |
+
#
|
| 3 |
+
# model = AutoModel.from_pretrained("NewBreaker/chatglm-6b-int4",trust_remote_code=True)
|
| 4 |
+
# tokenizer = AutoTokenizer.from_pretrained("NewBreaker/chatglm-6b-int4", trust_remote_code=True)
|
| 5 |
|
| 6 |
from transformers import AutoConfig
|
| 7 |
|
| 8 |
+
config = AutoConfig.from_pretrained("silver/chatglm-6b-int4-qe-slim",trust_remote_code=True)
|
| 9 |
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
# # Push the config to your namespace with the name "my-finetuned-bert".
|
| 12 |
+
config.push_to_hub("silver/chatglm-6b-int4-qe-slim")
|
| 13 |
+
#
|
| 14 |
+
# # Push the config to an organization with the name "my-finetuned-bert".
|
| 15 |
+
# config.push_to_hub("huggingface/my-finetuned-bert")
|