lbourdois commited on
Commit
ef57c9e
·
verified ·
1 Parent(s): 0b51e92

Update model card for Afrikaans

Browse files
Files changed (1) hide show
  1. README.md +104 -47
README.md CHANGED
@@ -1,47 +1,104 @@
1
- ---
2
- language: afr
3
- license: apache-2.0
4
- tags:
5
- - trimmed
6
- - qwen3
7
- base_model: Qwen/Qwen3-0.6B
8
- base_model_relation: quantized
9
- datasets:
10
- - Lumberjackk/fineweb-2-trimming
11
- ---
12
-
13
- # Qwen3-0.6B-afr-32768
14
-
15
- This model is a **32.47% smaller** version of [Qwen/Qwen3-0.6B](https://huggingface.co/Qwen/Qwen3-0.6B) optimized for Afrikaans via vocabulary size reduction ([trimming](https://huggingface.co/blog/introduction-to-trimming)).
16
-
17
- | Metric | Original | Trimmed | Reduction |
18
- |--------|----------|---------|-----------|
19
- | **Vocabulary size** | 151,643 | 32,768 | **78.39%** |
20
- | **Parameters** | 751,632,384 | 507,576,320 | **32.47%** |
21
-
22
- ## Usage
23
-
24
- ```python
25
- from transformers import AutoModelForCausalLM, AutoTokenizer
26
-
27
- tokenizer = AutoTokenizer.from_pretrained("AlphaEdge-AI/Qwen3-0.6B-afr-32768")
28
- model = AutoModelForCausalLM.from_pretrained("AlphaEdge-AI/Qwen3-0.6B-afr-32768", torch_dtype="auto", device_map="auto")
29
-
30
- prompt = "Your prompt in Afrikaans."
31
- messages = [{"role": "user", "content": prompt}]
32
- text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=True)
33
- model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
34
-
35
- generated_ids = model.generate(**model_inputs, max_new_tokens=32768)
36
- output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
37
-
38
- try:
39
- index = len(output_ids) - output_ids[::-1].index(32767)
40
- except ValueError:
41
- index = 0
42
-
43
- thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("\n")
44
- content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n")
45
- print("thinking:", thinking_content)
46
- print("content:", content)
47
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: text-generation
3
+ language: afr
4
+ license: apache-2.0
5
+ tags:
6
+ - trimmed
7
+ library_name: transformers
8
+ base_model: Qwen3-0.6B
9
+ base_model_relation: quantized
10
+ datasets:
11
+ - lbourdois/fineweb-2-trimming
12
+ ---
13
+
14
+ # Qwen3-0.6B-afr-32768
15
+ This model is a **32.47% smaller** version of [Qwen/Qwen3-0.6B](https://huggingface.co/Qwen/Qwen3-0.6B) optimized for **Afrikaans** 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 32,768 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** | 151,936 tokens | 32,768 tokens | **78.43%** |
22
+ | **Model size** | 751,632,384 params | 507,576,320 params | **32.47%** |
23
+
24
+ ![image](https://raw.githubusercontent.com/lbourdois/blog/refs/heads/master/assets/images/Trimming/qwen3-0.6B-32768.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/Qwen3-0.6B-afr-32768"
35
+
36
+ # load the tokenizer and the model
37
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
38
+ model = AutoModelForCausalLM.from_pretrained(
39
+ model_name,
40
+ torch_dtype="auto",
41
+ device_map="auto"
42
+ )
43
+
44
+ # prepare the model input
45
+ prompt = "Your prompt in Afrikaans."
46
+ messages = [
47
+ {"role": "user", "content": prompt}
48
+ ]
49
+ text = tokenizer.apply_chat_template(
50
+ messages,
51
+ tokenize=False,
52
+ add_generation_prompt=True,
53
+ enable_thinking=True # Switches between thinking and non-thinking modes. Default is True.
54
+ )
55
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
56
+
57
+ # conduct text completion
58
+ generated_ids = model.generate(
59
+ **model_inputs,
60
+ max_new_tokens=32768
61
+ )
62
+ output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
63
+
64
+ # parsing thinking content
65
+ try:
66
+ # rindex finding 32767 (</think>)
67
+ index = len(output_ids) - output_ids[::-1].index(32767)
68
+ except ValueError:
69
+ index = 0
70
+
71
+ thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("
72
+ ")
73
+ content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("
74
+ ")
75
+
76
+ print("thinking content:", thinking_content)
77
+ print("content:", content)
78
+
79
+ ```
80
+
81
+ ## Citations
82
+
83
+ #### Qwen3
84
+ ```
85
+ @misc{qwen3technicalreport,
86
+ title={Qwen3 Technical Report},
87
+ author={Qwen Team},
88
+ year={2025},
89
+ eprint={2505.09388},
90
+ archivePrefix={arXiv},
91
+ primaryClass={cs.CL},
92
+ url={https://arxiv.org/abs/2505.09388},
93
+ }
94
+ ```
95
+
96
+ #### Trimming blog post
97
+ ```
98
+ @misc{hf_blogpost_trimming,
99
+ title={Introduction to Trimming},
100
+ author={Loïck BOURDOIS and Tom AARSEN and Bram VANROY and Christopher AKIKI and Woojun JUNG and Manuel ROMERO and Prithiv SAKTHI},
101
+ year={2026},
102
+ url={https://huggingface.co/blog/lbourdois/introduction-to-trimming},
103
+ }
104
+ ```