Model Details

This model is an int4 model with group_size 128 and symmetric quantization of zai-org/GLM-4.7-Flash generated by intel/auto-round. Please refer to Section Generate the model for more details. Please follow the license of the original model.

How To Use

INT4 Inference

Transformers (CPU/Intel GPU/CUDA)

Please make sure you have installed the auto_round package from the correct branch:

pip install git+https://github.com/intel/auto-round.git@enable_glm4_moe_lite_quantization

from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# default: Load the model on the available device(s)
model_name = "Intel/GLM-4.7-Flash-int4-AutoRound"
model = AutoModelForCausalLM.from_pretrained(
    model_name, dtype="auto", device_map="auto"
)
messages = [{"role": "user", "content": "hello"}]
tokenizer = AutoTokenizer.from_pretrained(model_name)
inputs = tokenizer.apply_chat_template(
    messages,
    tokenize=True,
    add_generation_prompt=True,
    return_dict=True,
    return_tensors="pt",
)
inputs = inputs.to(model.device)
generated_ids = model.generate(**inputs, max_new_tokens=128, do_sample=False)
output_text = tokenizer.decode(generated_ids[0][inputs.input_ids.shape[1]:])
print(output_text)
"""
1.  **Analyze the user's input:** The user said "hello". This is a standard greeting.

2.  **Determine the intent:** The user is initiating a conversation. They want to know if I'm active and ready to help.

3.  **Formulate the response:**
    *   Acknowledge the greeting.
    *   Offer assistance.
    *   Keep it friendly and helpful.

4.  **Drafting the response (internal monologue/trial):**
    *   *Option 1:* Hello. How can I help? (Simple, direct)
    *   *Option 2

"""

vLLM (CPU/Intel GPU/CUDA)

VLLM_USE_PRECOMPILED=1 pip install git+https://github.com/vllm-project/vllm.git@main
pip install git+https://github.com/huggingface/transformers.git

start a vllm server:

vllm serve Intel/GLM-4.7-Flash-int4-AutoRound \
     --host localhost \
     --tool-call-parser glm47 \
     --reasoning-parser glm45 \
     --enable-auto-tool-choice \
     --served-model-name glm-4.7-flash \
     --tensor-parallel-size 4 \
     --port 4321

send request:

curl --noproxy '*' http://127.0.0.1:4321/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "Intel/GLM-4.7-Flash-int4-AutoRound",
    "messages": [
      {"role": "user", "content": "hello"}
    ],
    "max_tokens": 256,
    "temperature": 0.6
  }'

"""
"""

Generate the model

Please make sure you have installed the auto_round package from the correct branch:

pip install git+https://github.com/intel/auto-round.git@enable_glm4_moe_lite_quantization
auto_round \
--model=zai-org/GLM-4.7-Flash \
--scheme "W4A16" \
--ignore_layers="shared_experts,layers.0.mlp" \
--format=auto_round \
--enable_torch_compile \
--output_dir=./tmp_autoround

Ethical Considerations and Limitations

The model can produce factually incorrect output, and should not be relied on to produce factually accurate information. Because of the limitations of the pretrained model and the finetuning datasets, it is possible that this model could generate lewd, biased or otherwise offensive outputs.

Therefore, before deploying any applications of the model, developers should perform safety testing.

Caveats and Recommendations

Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.

Here are a couple of useful links to learn more about Intel's AI software:

  • Intel Neural Compressor link

Disclaimer

The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please consult an attorney before using this model for commercial purposes.

Cite

@article{cheng2023optimize, title={Optimize weight rounding via signed gradient descent for the quantization of llms}, author={Cheng, Wenhua and Zhang, Weiwei and Shen, Haihao and Cai, Yiyang and He, Xin and Lv, Kaokao and Liu, Yi}, journal={arXiv preprint arXiv:2309.05516}, year={2023} }

arxiv github

Downloads last month
238
Safetensors
Model size
1B params
Tensor type
F32
·
I32
·
BF16
·
F16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Intel/GLM-4.7-Flash-int4-AutoRound

Quantized
(45)
this model

Paper for Intel/GLM-4.7-Flash-int4-AutoRound