Model Details
This model is a mixed int4 model with group_size 128 and symmetric quantization of zai-org/GLM-4.7 generated by intel/auto-round via RTN(without algorithm tuning). Non expert layers are fallback to 8 bits. Please refer to Section Generate the model for more details. Please follow the license of the original model.
How To Use
INT4 Inference
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
MODEL_PATH = "Intel/GLM-4.7-int4-mixed-AutoRound"
messages = [{"role": "user", "content": "Give me a short introduction to large language model."}]
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_dict=True,
return_tensors="pt",
)
model = AutoModelForCausalLM.from_pretrained(
pretrained_model_name_or_path=MODEL_PATH,
torch_dtype=torch.bfloat16,
device_map="auto",
)
inputs = inputs.to(model.device)
inputs.pop("token_type_ids")
generated_ids = model.generate(**inputs, max_new_tokens=512, do_sample=False)
output_text = tokenizer.decode(generated_ids[0][inputs.input_ids.shape[1] :])
print(output_text)
"""
1. **Analyze the Request:**
* **Topic:** Large Language Models (LLMs).
* **Format:** Short introduction.
* **Goal:** Explain what they are, how they work (briefly), and why they matter, in a concise and accessible way.
2. **Identify Key Concepts to Cover:**
* Definition: What is an LLM? (AI, text processing).
* Mechanism: How does it work? (Training on massive data, predicting the next word).
* Capabilities: What can it do? (Writing, coding, translating, summarizing).
* Examples: ChatGPT, Claude, Llama (to make it concrete).
* Significance: Why is it important? (Versatility, human-like interaction).
3. **Drafting - Section by Section:**
* *The Hook/Definition:* Start with a simple definition. It's a type of AI trained on text.
* *The "How":* Explain the core mechanism simply. It's not magic; it's probability. "Next token prediction."
* *The "Scale":* Mention the "Large" part. Huge datasets, huge parameters.
* *The "What can it do":* List common use cases (chatbots, writing, coding).
* *The "Why it matters":* It's a shift in how we interact with computers (natural language).
4. **Refining and Condensing (Iterative Process):**
* *Draft 1 (Mental Outline):* A Large Language Model is an AI that reads a lot of text. It uses deep learning to understand patterns. It predicts the next word in a sentence. Because it's trained on the internet, it knows a lot. It can write essays, code, and answer questions. Examples are GPT-4. It changes how we use computers because we can talk to them normally.
* *Draft 2 (Polishing for flow and tone):* A Large Language Model (LLM) is a deep learning algorithm that can perform a variety of natural language processing tasks. It is trained on massive amounts of text data from the internet. The fundamental way it works is by predicting the next word in a sequence based on context. This allows it to generate human-like text, translate languages, and write code. Popular examples include ChatGPT and Claude. They represent a
"""
Generate the model
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
import transformers
from auto_round import AutoRound
from auto_round.utils import llm_load_model
model_name = "zai-org/GLM-4.7"
model, tokenizer = llm_load_model(model_name, device="cpu")
layer_config = {}
for n, m in model.named_modules():
if isinstance(m, torch.nn.Linear):
if "expert" in n and "shared_experts" not in n:
layer_config[n] = {"bits": 4}
print(n, 4)
elif n != "lm_head":
layer_config[n] = {"bits": 8}
print(n, 8)
autoround = AutoRound(model, tokenizer, iters=0, layer_config=layer_config, disable_opt_rtn=True))
autoround.quantize_and_save(format="auto_round", 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:
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} }
- Downloads last month
- -
Model tree for Intel/GLM-4.7-int4-mixed-AutoRound
Base model
zai-org/GLM-4.7