nielsr HF Staff commited on
Commit
25f9c48
·
verified ·
1 Parent(s): a67be32

Improve model card: Add pipeline tag, library name, project links, and usage example

Browse files

This PR enhances the model card by:
- Adding `pipeline_tag: text-generation` for better discoverability.
- Specifying `library_name: transformers` for clearer integration with the Hugging Face Transformers library.
- Including a link to the project page for additional information.
- Providing a direct Python usage example for quick inference.

Files changed (1) hide show
  1. README.md +67 -12
README.md CHANGED
@@ -1,20 +1,75 @@
1
  ---
2
  base_model:
3
  - meta-llama/Llama-2-70b-hf
4
- base_model_relation: quantized
5
  license: llama2
 
 
 
6
  ---
7
- # Model Card
8
 
9
- - Base model: `meta-llama/Llama-2-70b-hf`
10
- - Quantization method: SqueezeLLM
11
- - Target bit-width: 4
12
- - Backend kernel: Any-Precision-LLM kernel (`ap-gemv`)
13
- - Calibration data: RedPajama (1024 sentences / 4096 tokens)
14
- - Calibration objective: Next-token prediction
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- # How to run
17
- - Follow the instruction in https://github.com/snu-mllab/GuidedQuant.
18
 
19
- # References
20
- - [Model Paper](https://arxiv.org/abs/2505.07004)
 
 
 
 
 
 
 
1
  ---
2
  base_model:
3
  - meta-llama/Llama-2-70b-hf
 
4
  license: llama2
5
+ base_model_relation: quantized
6
+ pipeline_tag: text-generation
7
+ library_name: transformers
8
  ---
 
9
 
10
+ # GuidedQuant: Large Language Model Quantization via Exploiting End Loss Guidance
11
+
12
+ This repository contains a quantized version of `meta-llama/Llama-2-70b-hf` using the **GuidedQuant** method. GuidedQuant is a novel quantization approach that integrates gradient information from the end loss into the quantization objective while preserving cross-weight dependencies within output channels. It consistently boosts the performance of state-of-the-art quantization methods across weight-only scalar, weight-only vector, and weight-and-activation quantization. Additionally, it introduces a novel non-uniform scalar quantization algorithm, **LNQ**, which is guaranteed to monotonically decrease the quantization objective value, and outperforms existing methods in this category.
13
+
14
+ - **Paper**: [GuidedQuant: Large Language Model Quantization via Exploiting End Loss Guidance](https://arxiv.org/abs/2505.07004)
15
+ - **Project Page**: [https://jusjinuk.me/blog/guidedquant/](https://jusjinuk.me/blog/guidedquant/)
16
+ - **Code**: [https://github.com/snu-mllab/GuidedQuant](https://github.com/snu-mllab/GuidedQuant)
17
+
18
+ ### Model Details
19
+
20
+ - **Base model**: `meta-llama/Llama-2-70b-hf`
21
+ - **Quantization method**: SqueezeLLM (with GuidedQuant enhancement)
22
+ - **Target bit-width**: 4
23
+ - **Backend kernel**: Any-Precision-LLM kernel (`ap-gemv`)
24
+ - **Calibration data**: RedPajama (1024 sentences / 4096 tokens)
25
+ - **Calibration objective**: Next-token prediction
26
+
27
+ ## How to Use
28
+
29
+ You can easily load and test this quantized model using the `AnyPrecisionForCausalLM` class, as shown in the following example (runs on one RTX 3090).
30
+
31
+ ```python
32
+ from any_precision.modules.AnyPrecisionForCausalLM import AnyPrecisionForCausalLM
33
+ from transformers import AutoTokenizer, TextStreamer
34
+ import torch
35
+
36
+ # This specific model within the repository (adjust if the model ID on the Hub is different):
37
+ quantized_model_name = "jusjinuk/Llama-2-70b-hf-4bit-guidedquant-lnq"
38
+ # Use float16 for Llama models, and bfloat16 for Qwen / Gemma models
39
+ dtype = torch.float16 if "llama" in quantized_model_name.lower() else torch.bfloat16
40
+
41
+ model = AnyPrecisionForCausalLM.from_quantized(quantized_model_name, torch_dtype=dtype)
42
+ tokenizer = AutoTokenizer.from_pretrained(quantized_model_name)
43
+ streamer = TextStreamer(tokenizer)
44
+
45
+ prompt = "Write me a short and concise story about Harry, Ron, and Hermione.
46
+ "
47
+ chat = [
48
+ {"role": "system", "content": "You are a helpful assistant.
49
+ "},
50
+ {"role": "user", "content": prompt},
51
+ ]
52
+
53
+ inputs = tokenizer.apply_chat_template(
54
+ chat, tokenize=True, return_tensors="pt", add_generation_prompt=True
55
+ ).to(model.device)
56
+
57
+ model.generate(inputs,
58
+ max_new_tokens=200, do_sample=False, temperature=1.0, streamer=streamer, pad_token_id=tokenizer.eos_token_id
59
+ )
60
+ ```
61
+
62
+ For detailed installation instructions and advanced usage (e.g., inference speed-up, different quantization types, evaluation), please refer to the [official GitHub repository](https://github.com/snu-mllab/GuidedQuant).
63
+
64
+ ## Citation
65
 
66
+ Please cite our paper if you find our work useful:
 
67
 
68
+ ```bibtex
69
+ @inproceedings{kim2025guidedquant,
70
+ title={GuidedQuant: Large Language Model Quantization via Exploiting End Loss Guidance},
71
+ author={Jinuk Kim and Marwa El Halabi and Wonpyo Park and Clemens JS Schaefer and Deokjae Lee and Yeonhong Park and Jae W. Lee and Hyun Oh Song},
72
+ booktitle = {International Conference on Machine Learning (ICML)},
73
+ year={2025},
74
+ }
75
+ ```