Views
No views yet
pip install git+https://github.com/intel/auto-round.git@enable_glm4_moe_lite_quantization1
2from transformers import AutoModelForCausalLM, AutoTokenizer
3import torch
4# default: Load the model on the available device(s)
5model_name = "Intel/GLM-4.7-Flash-int4-AutoRound"
6model = AutoModelForCausalLM.from_pretrained(
7 model_name, dtype="auto", device_map="auto"
8)
9messages = [{"role": "user", "content": "hello"}]
10tokenizer = AutoTokenizer.from_pretrained(model_name)
11inputs = tokenizer.apply_chat_template(
12 messages,
13 tokenize=True,
14 add_generation_prompt=True,
15 return_dict=True,
16 return_tensors="pt",
17)
18inputs = inputs.to(model.device)
19generated_ids = model.generate(**inputs, max_new_tokens=128, do_sample=False)
20output_text = tokenizer.decode(generated_ids[0][inputs.input_ids.shape[1]:])
21print(output_text)
22"""
231. **Analyze the user's input:** The user said "hello". This is a standard greeting.
24
252. **Determine the intent:** The user is initiating a conversation. They want to know if I'm active and ready to help.
26
273. **Formulate the response:**
28 * Acknowledge the greeting.
29 * Offer assistance.
30 * Keep it friendly and helpful.
31
324. **Drafting the response (internal monologue/trial):**
33 * *Option 1:* Hello. How can I help? (Simple, direct)
34 * *Option 2
35
36"""1VLLM_USE_PRECOMPILED=1 pip install git+https://github.com/vllm-project/vllm.git@main
2pip install git+https://github.com/huggingface/transformers.git1vllm serve Intel/GLM-4.7-Flash-int4-AutoRound \
2 --host localhost \
3 --tool-call-parser glm47 \
4 --reasoning-parser glm45 \
5 --enable-auto-tool-choice \
6 --served-model-name glm-4.7-flash \
7 --tensor-parallel-size 4 \
8 --port 43211curl --noproxy '*' http://127.0.0.1:4321/v1/chat/completions \
2 -H "Content-Type: application/json" \
3 -d '{
4 "model": "Intel/GLM-4.7-Flash-int4-AutoRound",
5 "messages": [
6 {"role": "user", "content": "hello"}
7 ],
8 "max_tokens": 256,
9 "temperature": 0.6
10 }'
11
12"""
13"""pip install git+https://github.com/intel/auto-round.git@enable_glm4_moe_lite_quantization1auto_round \
2--model=zai-org/GLM-4.7-Flash \
3--scheme "W4A16" \
4--ignore_layers="shared_experts,layers.0.mlp" \
5--format=auto_round \
6--enable_torch_compile \
7--output_dir=./tmp_autoround