Zero-Shot Image Classification
sentence-transformers
Safetensors
Telugu
siglip
trimmed
lbourdois commited on
Commit
8ee386a
·
verified ·
1 Parent(s): daabf34

Update model card for Telugu

Browse files
Files changed (1) hide show
  1. README.md +92 -53
README.md CHANGED
@@ -1,53 +1,92 @@
1
- ---
2
- pipeline_tag: zero-shot-image-classification
3
- language: tel
4
- tags:
5
- - trimmed
6
- - vision-language
7
- library_name: transformers
8
- base_model: google/siglip2-base-patch16-512
9
- base_model_relation: quantized
10
- datasets:
11
- - Lumberjackk/fineweb-2-trimming
12
- ---
13
-
14
- # siglip2-base-patch16-512-tel-16384
15
-
16
- This model is a 49.0% smaller version of [google/siglip2-base-patch16-512](https://huggingface.co/google/siglip2-base-patch16-512)
17
- optimized for Telugu language via **text vocabulary trimming** mined on
18
- [Lumberjackk/fineweb-2-trimming](https://huggingface.co/datasets/Lumberjackk/fineweb-2-trimming).
19
-
20
- Only the **text encoder** vocabulary and embeddings are trimmed.
21
- The **vision encoder** is kept identical to the original.
22
-
23
- ## Model Statistics
24
- - **Original text vocabulary size:** 256,000 tokens
25
- - **Trimmed text vocabulary size:** 16,383 tokens
26
- - **Vocabulary reduction:** 93.6%
27
- - **Original model size:** 375,823,874 parameters
28
- - **Trimmed model size:** 191,798,786 parameters
29
- - **Size reduction:** 49.0%
30
-
31
- ## Usage
32
-
33
- ```python
34
- from transformers import AutoProcessor, AutoModel
35
- import torch
36
-
37
- model = AutoModel.from_pretrained("lbourdois/siglip2-base-patch16-512-tel-16384")
38
- processor = AutoProcessor.from_pretrained("lbourdois/siglip2-base-patch16-512-tel-16384")
39
-
40
- # Text-only encoding
41
- texts = ["a photo of a cat", "a photo of a dog"]
42
- inputs = processor(text=texts, return_tensors="pt", padding=True)
43
- with torch.inference_mode():
44
- text_features = model.get_text_features(**inputs)
45
-
46
- # Image + text (standard SigLIP2 usage)
47
- # from PIL import Image
48
- # image = Image.open("image.jpg")
49
- # inputs = processor(images=image, text=texts, return_tensors="pt", padding=True)
50
- # with torch.inference_mode():
51
- # outputs = model(**inputs)
52
- # logits_per_image = outputs.logits_per_image
53
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: zero-shot-image-classification
3
+ language: tel
4
+ license: apache-2.0
5
+ tags:
6
+ - trimmed
7
+ library_name: sentence-transformers
8
+ base_model: google/siglip2-base-patch16-512
9
+ base_model_relation: quantized
10
+ datasets:
11
+ - lbourdois/fineweb-2-trimming
12
+ ---
13
+
14
+ # siglip2-base-patch16-512-tel-16384
15
+ This model is a **48.97%** smaller version of [google/siglip2-base-patch16-512](https://huggingface.co/google/siglip2-base-patch16-512) optimized for **Telugu** language via vocabulary size reduction using the [trimming](https://huggingface.co/blog/lbourdois/introduction-to-trimming) method.
16
+ This trimmed model should perform similarly to the original model with only 16,384 tokens and a much smaller memory footprint. However, it may not perform well for other languages as tokens not commonly used in the selected languages were removed from the vocabulary.
17
+
18
+ ## Model Statistics
19
+ | Metric | Original | Trimmed | Reduction |
20
+ |--------|----------|---------|-----------|
21
+ | **Vocabulary size** | 256,000 tokens | 16,384 tokens | **93.60%** |
22
+ | **Model size** | 375,823,874 params | 191,798,786 params | **48.97%** |
23
+
24
+ ![image](https://raw.githubusercontent.com/lbourdois/blog/refs/heads/master/assets/images/Trimming/siglip2-base-patch16-512-16384.png)
25
+
26
+ ## Mining Dataset Statistics
27
+ - **Number of texts used for mining**: 200,000 texts
28
+ - **Dataset**: [lbourdois/fineweb-2-trimming](https://huggingface.co/datasets/lbourdois/fineweb-2-trimming)
29
+
30
+ ## Usage
31
+
32
+ #### Transformers (zero-shot image classification)
33
+ ```python
34
+ from transformers import pipeline
35
+
36
+ # load pipeline
37
+ image_classifier = pipeline(model="alphaedge-ai/siglip2-base-patch16-512-tel-16384", task="zero-shot-image-classification")
38
+
39
+ # load image and candidate labels
40
+ image = "http://images.cocodataset.org/val2017/000000039769.jpg"
41
+ candidate_labels = ["Potential label 1 in Telugu", "Potential label 2 in Telugu", "Potential label 3 in Telugu", "Potential label 4 in Telugu"]
42
+
43
+ # run inference
44
+ outputs = image_classifier(image, candidate_labels)
45
+ print(outputs)
46
+ ```
47
+
48
+ #### Sentence-transformers (texts-images similarity)
49
+ ```python
50
+ from sentence_transformers import SentenceTransformer
51
+
52
+ model = SentenceTransformer("alphaedge-ai/siglip2-base-patch16-512-tel-16384")
53
+
54
+ images = [
55
+ "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg",
56
+ "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/bee.jpg",
57
+ "https://huggingface.co/datasets/huggingface/cats-image/resolve/main/cats_image.jpeg"
58
+ ]
59
+ texts = ["Text 1 in Telugu", "Text 2 in Telugu", "Text 3 in Telugu", "Text 4 in Telugu"]
60
+
61
+ image_embeddings = model.encode(images)
62
+ text_embeddings = model.encode(texts)
63
+ print(image_embeddings.shape, text_embeddings.shape)
64
+
65
+ similarities = model.similarity(image_embeddings, text_embeddings)
66
+ print(similarities)
67
+ ```
68
+
69
+ ## Citations
70
+
71
+ #### SigLIP 2
72
+ ```
73
+ @misc{tschannen2025siglip2multilingualvisionlanguage,
74
+ title={SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features},
75
+ author={Michael Tschannen and Alexey Gritsenko and Xiao Wang and Muhammad Ferjad Naeem and Ibrahim Alabdulmohsin and Nikhil Parthasarathy and Talfan Evans and Lucas Beyer and Ye Xia and Basil Mustafa and Olivier Hénaff and Jeremiah Harmsen and Andreas Steiner and Xiaohua Zhai},
76
+ year={2025},
77
+ eprint={2502.14786},
78
+ archivePrefix={arXiv},
79
+ primaryClass={cs.CV},
80
+ url={https://arxiv.org/abs/2502.14786},
81
+ }
82
+ ```
83
+
84
+ #### Trimming blog post
85
+ ```
86
+ @misc{hf_blogpost_trimming,
87
+ title={Introduction to Trimming},
88
+ author={Loïck BOURDOIS and Tom AARSEN and Bram VANROY and Christopher AKIKI and Woojun JUNG and Manuel ROMERO and Prithiv SAKTHI},
89
+ year={2026},
90
+ url={https://huggingface.co/blog/lbourdois/introduction-to-trimming},
91
+ }
92
+ ```