Text Generation
Transformers
Safetensors
English
Chinese
chatglm
Mental Health
Chatbot
LLM
conversational
custom_code
Instructions to use derek33125/project-angel-chatglm4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use derek33125/project-angel-chatglm4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="derek33125/project-angel-chatglm4", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("derek33125/project-angel-chatglm4", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use derek33125/project-angel-chatglm4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "derek33125/project-angel-chatglm4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "derek33125/project-angel-chatglm4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/derek33125/project-angel-chatglm4
- SGLang
How to use derek33125/project-angel-chatglm4 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 "derek33125/project-angel-chatglm4" \ --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": "derek33125/project-angel-chatglm4", "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 "derek33125/project-angel-chatglm4" \ --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": "derek33125/project-angel-chatglm4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use derek33125/project-angel-chatglm4 with Docker Model Runner:
docker model run hf.co/derek33125/project-angel-chatglm4
Update
The model is now following the update from GLM-4-9B-Chat and now requires transformers>=4.44.0. Please update your dependencies accordingly.
Also follow the dependencies it before using
Introduction
This model is GLM-4-9B-Chat, fine-tuned with the Smile dataset to focus on mental health care.
Since it is fine-tuned with a Chinese dataset, please use it in Chinese, even though the base model supports English text.
Use the following method to quickly call the GLM-4-9B-Chat language model
Use the transformers backend for inference:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
device = "cuda"
tokenizer = AutoTokenizer.from_pretrained("derek33125/project-angel-chatglm4", trust_remote_code=True)
query = "我感到很悲伤"
inputs = tokenizer.apply_chat_template([{"role": "user", "content": query}],
add_generation_prompt=True,
tokenize=True,
return_tensors="pt",
return_dict=True
)
inputs = inputs.to(device)
model = AutoModelForCausalLM.from_pretrained(
"derek33125/project-angel-chatglm4",
torch_dtype=torch.bfloat16,
low_cpu_mem_usage=True,
trust_remote_code=True
).to(device).eval()
gen_kwargs = {"max_length": 2500, "do_sample": True, "top_k": 1}
with torch.no_grad():
outputs = model.generate(**inputs, **gen_kwargs)
outputs = outputs[:, inputs['input_ids'].shape[1]:]
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
- Downloads last month
- 10
Model tree for derek33125/project-angel-chatglm4
Base model
zai-org/glm-4-9b-chat