Tiny Models
Collection
Tiny models used for testing • 14 items • Updated
How to use inference-optimization/Kimi-K3-0.18B with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("feature-extraction", model="inference-optimization/Kimi-K3-0.18B", trust_remote_code=True) # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("inference-optimization/Kimi-K3-0.18B", trust_remote_code=True, device_map="auto")This is a tiny version of moonshotai/Kimi-K3 created for testing and development.
The following parameters were reduced from the original model:
| Parameter | Original | Tiny |
|---|---|---|
| num_hidden_layers | 93 | 4 |
| hidden_size | 7168 | 512 |
| num_attention_heads | 96 | 4 |
| num_key_value_heads | 96 | 4 |
| intermediate_size (dense) | 33792 | 1024 |
| moe_intermediate_size | 3072 | 256 |
| routed_expert_hidden_size | 3584 | 256 |
| num_experts | 896 | 8 |
| num_experts_per_token | 16 | 2 |
| num_shared_experts | 2 | 1 |
| kv_lora_rank | 512 | 64 |
| q_lora_rank | 1536 | 128 |
| qk_nope_head_dim | 128 | 64 |
| qk_rope_head_dim | 64 | 32 |
| v_head_dim | 128 | 64 |
| linear_attn head_dim | 128 | 64 |
The 4-layer architecture preserves all original layer types:
Single-file checkpoint (model.safetensors, ~0.69 GB). Keys follow the same
language_model.model.layers.X.* hierarchy as the original, without quantization
(the base model is MX4-quantized; this tiny model uses plain float weights).
Success: perplexity=2.12 (target <= 10.0)
Generation: "According to all known laws of aviation, there is no way a bee should
be able to fly. Its wings are too small to get its fat little"
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"inference-optimization/Kimi-K3-0.18B",
trust_remote_code=True,
device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained(
"inference-optimization/Kimi-K3-0.18B",
trust_remote_code=True,
)
input_ids = tokenizer("According to all known laws", return_tensors="pt").input_ids.to(model.device)
output = model.generate(input_ids, max_new_tokens=20)
print(tokenizer.decode(output[0]))
This model was created using the llm-compressor create-tiny-model claude skill.
Several compatibility fixes were applied to the custom modeling code to work with newer transformers:
OutputRecorder import moved from transformers.utils.generic to transformers.utils.output_capturingtie_weights() updated to accept **kwargs for newer transformers API_tied_weights_keys converted from list to dictcreate_causal_mask call updated to new signature (inputs_embeds, removed cache_position)KimiDynamicCache gained get_query_offset and get_mask_sizes(int, ...) compatibilityKimiMoEGate training assertion removed; KimiSparseMoeBlock.moe_train added for gradient-compatible dispatchtrust_remote_code=True is required to load the custom modeling files.