Views
No views yet
| Metric | Original | Optimized |
|---|---|---|
| Parameters | 1.1B | 1.1B (4.3% pruned) |
| Disk | 2.7GB | 1.3GB (52%↓) |
| GPU | 3.5GB+ | 2.3GB |
| Speed | 1x | 2-3x |
1from transformers import BitsAndBytesConfig, AutoProcessor, AutoModelForImageTextToText
2import torch
3
4MODEL_PATH = "ManiKumarAdapala/glm-ocr-pruned-8bit"
5
6messages = [
7 {
8 "role": "user",
9 "content": [
10 {
11 "type": "image",
12 "url": "Image.jpeg"
13 },
14 {
15 "type": "text",
16 "text": "Text Recognition:"
17 }
18 ],
19 }
20]
21
22quant_config = BitsAndBytesConfig(load_in_8bit=True)
23
24processor = AutoProcessor.from_pretrained(MODEL_PATH)
25model = AutoModelForImageTextToText.from_pretrained(
26 pretrained_model_name_or_path=MODEL_PATH,
27 quantization_config=quant_config,
28 device_map="auto",
29)
30
31inputs = processor.apply_chat_template(
32 messages,
33 tokenize=True,
34 add_generation_prompt=True,
35 return_dict=True,
36 return_tensors="pt"
37).to(model.device)
38
39inputs.pop("token_type_ids", None)
40
41generated_ids = model.generate(**inputs, max_new_tokens=8192)
42
43output_text = processor.decode(generated_ids[0][inputs["input_ids"].shape[1]:], skip_special_tokens=False)
44
45print(output_text)1@misc{GLM-OCR-Pruned8bit-2026,
2 author = {Mani, {ADAPALA MANI KUMAR} and {ZAI-org}},
3 title = {GLM-OCR Pruned & 8-bit quantized (1.1B params, 4.3% sparsity)},
4 year = {2026},
5 month = {march},
6 publisher = {Hugging Face},
7 url = {https://huggingface.co/adapala-manikumar/glm-ocr-pruned-8bit},
8 note = {1.3GB disk, 2.3GB GPU, OCR optimized, MIT}
9}