lbourdois commited on
Commit
0ebfbaf
·
verified ·
1 Parent(s): 8df8569

Update model card for Malay

Browse files
Files changed (1) hide show
  1. README.md +86 -73
README.md CHANGED
@@ -1,73 +1,86 @@
1
- ---
2
- language: msa
3
- license: gemma
4
- tags:
5
- - trimmed
6
- - gemma
7
- - gemma-3
8
- base_model: google/gemma-3-1b-it
9
- base_model_relation: quantized
10
- datasets:
11
- - Lumberjackk/fineweb-2-trimming
12
- ---
13
-
14
- # gemma-3-1b-it-msa-16384
15
-
16
- This model is a **28.31% smaller** version of [google/gemma-3-1b-it](https://huggingface.co/google/gemma-3-1b-it) optimized for Malay language via vocabulary size reduction using the [trimming](https://huggingface.co/blog/introduction-to-trimming) method.
17
-
18
- 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 Malay were removed from the vocabulary.
19
-
20
- ## Model Statistics
21
-
22
- | Metric | Original | Trimmed | Reduction |
23
- |--------|----------|---------|-----------|
24
- | **Vocabulary size** | 262,144 tokens | 16,384 tokens | **93.75%** |
25
- | **Model size** | 999,885,952 params | 716,770,432 params | **28.31%** |
26
-
27
- ## Mining Dataset Statistics
28
-
29
- - **Number of texts used for mining**: 200,000 texts
30
- - **Dataset**: [Lumberjackk/fineweb-2-trimming](https://huggingface.co/datasets/Lumberjackk/fineweb-2-trimming)
31
-
32
- ## Usage
33
- ```python
34
- from transformers import AutoModelForCausalLM, AutoTokenizer
35
-
36
- model_name = "lbourdois/gemma-3-1b-it-msa-16384"
37
-
38
- tokenizer = AutoTokenizer.from_pretrained(model_name)
39
- model = AutoModelForCausalLM.from_pretrained(
40
- model_name,
41
- torch_dtype="auto",
42
- device_map="auto"
43
- )
44
-
45
- prompt = "Your prompt in Malay."
46
- messages = [{"role": "user", "content": prompt}]
47
- text = tokenizer.apply_chat_template(
48
- messages,
49
- tokenize=False,
50
- add_generation_prompt=True
51
- )
52
- model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
53
-
54
- generated_ids = model.generate(**model_inputs, max_new_tokens=256)
55
- output_ids = generated_ids[0][len(model_inputs.input_ids[0]):]
56
- response = tokenizer.decode(output_ids, skip_special_tokens=True)
57
- print(response)
58
- ```
59
-
60
- ## Citation
61
-
62
- #### Gemma 3
63
- ```bibtex
64
- @misc{gemmateam2025gemma3technicalreport,
65
- title={Gemma 3 Technical Report},
66
- author={Gemma Team},
67
- year={2025},
68
- eprint={2503.19786},
69
- archivePrefix={arXiv},
70
- primaryClass={cs.CL},
71
- url={https://arxiv.org/abs/2503.19786},
72
- }
73
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: text-generation
3
+ language: msa
4
+ license: gemma
5
+ tags:
6
+ - trimmed
7
+ library_name: transformers
8
+ base_model: google/gemma-3-1b-it
9
+ base_model_relation: quantized
10
+ datasets:
11
+ - lbourdois/fineweb-2-trimming
12
+ ---
13
+
14
+ # gemma-3-1b-it-msa-16384
15
+ This model is a **28.31%** smaller version of [google/gemma-3-1b-it](https://huggingface.co/google/gemma-3-1b-it) optimized for Malay 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** | 262,144 tokens | 16,384 tokens | **93.75%** |
22
+ | **Model size** | 999,885,952 params | 716,770,432 params | **28.31%** |
23
+
24
+ ![image](https://raw.githubusercontent.com/lbourdois/blog/refs/heads/master/assets/images/Trimming/gemma-3-1b-it-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
+ ```python
32
+ from transformers import AutoModelForCausalLM, AutoTokenizer
33
+
34
+ model_name = "alphaedge-ai/gemma-3-1b-it-msa-16384"
35
+
36
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
37
+ model = AutoModelForCausalLM.from_pretrained(
38
+ model_name,
39
+ torch_dtype="auto",
40
+ device_map="auto"
41
+ )
42
+
43
+ prompt = "Your prompt in Malay."
44
+ messages = [{"role": "user", "content": prompt}]
45
+ text = tokenizer.apply_chat_template(
46
+ messages,
47
+ tokenize=False,
48
+ add_generation_prompt=True
49
+ )
50
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
51
+
52
+ generated_ids = model.generate(**model_inputs, max_new_tokens=256)
53
+ output_ids = generated_ids[0][len(model_inputs.input_ids[0]):]
54
+ response = tokenizer.decode(output_ids, skip_special_tokens=True)
55
+ print(response)
56
+ ```
57
+
58
+ ## Citations
59
+
60
+ #### Gemma 3
61
+ ```bibtex
62
+ @misc{gemmateam2025gemma3technicalreport,
63
+ title={Gemma 3 Technical Report},
64
+ author={Gemma Team},
65
+ year={2025},
66
+ eprint={2503.19786},
67
+ archivePrefix={arXiv},
68
+ primaryClass={cs.CL},
69
+ url={https://arxiv.org/abs/2503.19786},
70
+ }
71
+ ```
72
+
73
+ #### Trimming blog post
74
+ ```
75
+ @misc{hf_blogpost_trimming,
76
+ title={Introduction to Trimming},
77
+ author={Loïck BOURDOIS and Tom AARSEN and Bram VANROY and Christopher AKIKI and Woojun JUNG and Manuel ROMERO and Prithiv SAKTHI},
78
+ year={2026},
79
+ url={https://huggingface.co/blog/lbourdois/introduction-to-trimming},
80
+ }
81
+ ```
82
+
83
+ ### License
84
+ This model is derived from [google/gemma-3-1b-it](https://huggingface.co/google/gemma-3-1b-it).
85
+ Use of this model is governed by the [Gemma Terms of Use](https://ai.google.dev/gemma/terms).
86
+ By using this model, you agree to the Gemma Terms of Use. This model is not affiliated with or endorsed by Google.