Views
No views yet
| Language | Unknown Ratio | Chars/Token | Tokens/Word | Total Chars | Total Words | Total Tokens | Unknown Tokens |
|---|---|---|---|---|---|---|---|
| English | 0.000000 | 4.20 | 1.42 | 30,503,959 | 5,144,303 | 7,284,362 | 0 |
| Malayalam | 0.000000 | 4.26 | 2.39 | 28,815,402 | 2,936,177 | 7,031,500 | 0 |
| Sindhi | 0.000000 | 3.73 | 1.37 | 7,790,177 | 1,640,539 | 2,240,778 | 0 |
| Average | 0.000000 | 4.06 | 1.73 | 67,109,538 | 9,721,019 | 16,556,640 | 0 |
| Language | Unknown Ratio | Chars/Token | Tokens/Word | Total Chars | Total Words | Total Tokens | Unknown Tokens |
|---|---|---|---|---|---|---|---|
| English | 0.000000 | 4.22 | 1.41 | 30,503,959 | 5,144,303 | 7,261,193 | 0 |
| Malayalam | 0.000000 | 4.44 | 2.31 | 28,815,402 | 2,936,177 | 6,789,148 | 0 |
| Sindhi | 0.000000 | 3.78 | 1.35 | 7,790,177 | 1,640,539 | 2,220,958 | 0 |
| Average | 0.000000 | 4.15 | 1.69 | 67,109,538 | 9,721,019 | 16,271,299 | 0 |
DeepseekV3Config to achieve this. The configuration file configuration_deepseek.py provided in the source code gives us the necessary parameters to create a dense version of the model along with reduced parameters.1from transformers import DeepseekV3Config
2
3# Configuration for a ~150M parameter dense SLM
4config_150m_dense = DeepseekV3Config(
5 # --- Core Dense Model Dimensions ---
6 vocab_size=129280, # Keep the original vocabulary
7 hidden_size=512, # Smaller embedding dimension
8 num_hidden_layers=24, # Number of transformer layers
9 intermediate_size=2048, # FFN intermediate size (4 * hidden_size)
10 num_attention_heads=8, # Attention heads
11 num_key_value_heads=8, # Use standard Multi-Head Attention
12
13 # --- Disable MoE ---
14 n_shared_experts=None, # Set to None for a dense model
15 n_routed_experts=None, # Set to None for a dense model
16 num_experts_per_tok=None, # Set to None for a dense model
17
18 # --- Important Optimization ---
19 tie_word_embeddings=True, # Share embedding and output layer weights
20
21 # --- Other standard parameters ---
22 hidden_act="silu",
23 max_position_embeddings=4096,
24 rms_norm_eps=1e-6,
25 rope_theta=10000.0,
26 bos_token_id=0,
27 eos_token_id=1,
28)
29
30# We can now use this config object to initialize your model
31# from transformers import DeepseekV3ForCausalLM
32# model = DeepseekV3ForCausalLM(config_150m_dense)
33# print(f"Model created with {model.num_parameters() / 1e6:.2f}M parameters.")hidden_size, num_hidden_layers, and intermediate_size to create a smaller yet effective model. To convert the MoE model to a dense format, we set n_shared_experts, n_routed_experts, and num_experts_per_tok to None and set first_k_dense = num_hidden_layers to convert all hidden layers to dense layer. Additionally, to reduce parameters, we enabled weight tying between the embedding and output layers by setting tie_word_embeddings=True. Using this configuration, we initialized the model and verified that it had approximately 149.2 million parameters.Trainer API. Since the Trainer API does not train based on tokens, a heuristic was used to estimate the number of epochs required to process a target number of tokens (3 billion). The heuritic is as follows:batch_size * gradient_accumulation_steps * seq_length * num_gpus
For this model with batch_size=32, gradient_accumulation_steps=1, seq_length=256, and num_gpus=4, we need 91552 steps to process 3 billion tokens.(object, location) pairs were generated using LLMs. These pairs were randomly picked to create a synthetic dataset of questions and answers in English. The dataset was then translated to Malayalam and Sindhi using Google Translate.SFTTrainer from the trl library using LoRA adapters from unsloth library for memory efficiency. The model was finetuned for 3 epochs on the dataset