Nichonauta commited on
Commit
d3b809f
·
verified ·
1 Parent(s): fd16fe9

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +71 -0
README.md ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: lfm1.0
4
+ license_link: https://huggingface.co/LiquidAI/LFM2.5-350M/blob/main/LICENSE
5
+ language:
6
+ - en
7
+ - ar
8
+ - zh
9
+ - fr
10
+ - de
11
+ - ja
12
+ - ko
13
+ - es
14
+ - pt
15
+ base_model: Nichonauta/LFM2.5-350M-ToMoE
16
+ tags:
17
+ - lfm2
18
+ - mixture-of-experts
19
+ - tomoe
20
+ - quantization
21
+ pipeline_tag: text-generation
22
+ library_name: transformers
23
+ ---
24
+
25
+ # LFM2.5-350M-ToMoE-INT4
26
+
27
+ Weight-only **INT4** quantization of the real ToMoE MoE — **[Nichonauta/LFM2.5-350M-ToMoE](https://huggingface.co/Nichonauta/LFM2.5-350M-ToMoE)** (derived from [LiquidAI/LFM2.5-350M](https://huggingface.co/LiquidAI/LFM2.5-350M)).
28
+
29
+ Unlike the GGUF companions (which are **dense-equivalents** because llama.cpp cannot represent the channel-MoE), this repository stores the **actual pruned MoE weights** quantized in safetensors format:
30
+
31
+ - `LinearINT4` replaces the MLP/attention/conv Linear layers (per-channel symmetric for INT8; per-group of 64 with zero-point for INT4), packed 2-nibbles-per-byte for INT4.
32
+ - The **routers, embeddings and norms stay fp32** (tiny and sensitive); weights dequantize lazily in the forward pass.
33
+ - Same custom model definition (`modeling_lfm2_moe_final.py`, `trust_remote_code`), plus the `quantization` flag in `config.json`.
34
+
35
+ ## Metrics vs the fp32 MoE
36
+
37
+ | Metric | fp32 MoE | INT8 | INT4 |
38
+ |---|---|---|---|
39
+ | PPL wikitext-2 (raw, 1810 tok) | 994 | 987 | 1221 |
40
+ | PPL chat-formatted (prompt+answer) | 314 | 785 | 941 |
41
+ | `model.safetensors` size | 1226 MB | 400 MB | — |
42
+
43
+ The 350M MoE sits at a fragile equilibrium (chat PPL 314 is already near the repetition-collapse regime): INT8 pushes it to ~785 and INT4 to ~941 on chat, while raw-text PPL stays roughly unchanged. This is a property of the pruned model, not of the quantizer.
44
+
45
+ ## Usage (transformers, trust_remote_code)
46
+
47
+ ```python
48
+ from transformers import AutoModelForCausalLM, AutoTokenizer
49
+
50
+ model = AutoModelForCausalLM.from_pretrained(
51
+ "Nichonauta/LFM2.5-350M-ToMoE-INT4",
52
+ trust_remote_code=True,
53
+ torch_dtype=torch.bfloat16,
54
+ device_map="cuda:0",
55
+ attn_implementation="eager",
56
+ )
57
+ tokenizer = AutoTokenizer.from_pretrained("Nichonauta/LFM2.5-350M-ToMoE-INT4")
58
+ ```
59
+
60
+ The `quantization` field in `config.json` makes the custom modeling file build the quantized Linear layers automatically.
61
+
62
+ ## Files
63
+
64
+ - `model.safetensors` — INT4 weights + fp32 scales/zero-points + fp32 routers/embeddings/buffers
65
+ - `modeling_lfm2_moe_final.py` — custom model definition with `LinearINT4` support (trust_remote_code)
66
+ - `config.json` — model configuration (`quantization: "int4"`, `auto_map`)
67
+ - `tokenizer.json`, `tokenizer_config.json`, `chat_template.jinja`, `generation_config.json`, `LICENSE`
68
+
69
+ ## License
70
+
71
+ Derivative of LiquidAI/LFM2.5-350M — released under the **LFM Open License v1.0** (see `LICENSE`).