Instructions to use yujiepan/lfm3-tiny-random with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yujiepan/lfm3-tiny-random with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yujiepan/lfm3-tiny-random", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("yujiepan/lfm3-tiny-random", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("yujiepan/lfm3-tiny-random", trust_remote_code=True, device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use yujiepan/lfm3-tiny-random with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yujiepan/lfm3-tiny-random" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yujiepan/lfm3-tiny-random", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/yujiepan/lfm3-tiny-random
- SGLang
How to use yujiepan/lfm3-tiny-random with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "yujiepan/lfm3-tiny-random" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yujiepan/lfm3-tiny-random", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "yujiepan/lfm3-tiny-random" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yujiepan/lfm3-tiny-random", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use yujiepan/lfm3-tiny-random with Docker Model Runner:
docker model run hf.co/yujiepan/lfm3-tiny-random
Sync redesigned LFM3 from tiny-random/lfm3
Browse files- .meta/create_model.py +10 -2
- .meta/model.log +110 -110
- README.md +8 -6
- config.json +5 -5
- model.safetensors +2 -2
.meta/create_model.py
CHANGED
|
@@ -25,8 +25,16 @@ def create_model(source_model_id: str, source_revision: str, save_folder: str) -
|
|
| 25 |
|
| 26 |
config = json.loads(Path(hf_hub_download(source_model_id, "config.json", revision=source_revision)).read_text())
|
| 27 |
# Keep the two-conv prefix and two complete full/conv/sliding/conv cycles.
|
| 28 |
-
#
|
| 29 |
-
config.update(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
config["layer_types"] = config["layer_types"][:10]
|
| 31 |
(folder / "config.json").write_text(json.dumps(config, indent=2) + "\n")
|
| 32 |
|
|
|
|
| 25 |
|
| 26 |
config = json.loads(Path(hf_hub_download(source_model_id, "config.json", revision=source_revision)).read_text())
|
| 27 |
# Keep the two-conv prefix and two complete full/conv/sliding/conv cycles.
|
| 28 |
+
# Match tiny-random/lfm2's residual/MLP widths; retain LFM3's 4:1 Q/KV ratio.
|
| 29 |
+
config.update(
|
| 30 |
+
hidden_size=64,
|
| 31 |
+
intermediate_size=128,
|
| 32 |
+
num_hidden_layers=10,
|
| 33 |
+
num_attention_heads=4,
|
| 34 |
+
num_key_value_heads=1,
|
| 35 |
+
head_dim=32,
|
| 36 |
+
max_position_embeddings=128000,
|
| 37 |
+
)
|
| 38 |
config["layer_types"] = config["layer_types"][:10]
|
| 39 |
(folder / "config.json").write_text(json.dumps(config, indent=2) + "\n")
|
| 40 |
|
.meta/model.log
CHANGED
|
@@ -1,170 +1,170 @@
|
|
| 1 |
Lfm3ForCausalLM(
|
| 2 |
(model): Lfm3Model(
|
| 3 |
-
(embed_tokens): Embedding(128000,
|
| 4 |
(layers): ModuleList(
|
| 5 |
(0-1): 2 x Lfm3DecoderLayer(
|
| 6 |
(conv): Lfm3ShortConv(
|
| 7 |
-
(conv): Conv1d(
|
| 8 |
-
(in_proj): Linear(in_features=
|
| 9 |
-
(out_proj): Linear(in_features=
|
| 10 |
)
|
| 11 |
(feed_forward): Lfm3MLP(
|
| 12 |
-
(w1): Linear(in_features=
|
| 13 |
-
(w3): Linear(in_features=
|
| 14 |
-
(w2): Linear(in_features=
|
| 15 |
-
)
|
| 16 |
-
(operator_norm): Lfm3RMSNorm((
|
| 17 |
-
(ffn_norm): Lfm3RMSNorm((
|
| 18 |
-
(post_operator_norm): Lfm3RMSNorm((
|
| 19 |
-
(post_ffn_norm): Lfm3RMSNorm((
|
| 20 |
)
|
| 21 |
(2): Lfm3DecoderLayer(
|
| 22 |
(self_attn): Lfm3Attention(
|
| 23 |
-
(q_proj): Linear(in_features=
|
| 24 |
-
(k_proj): Linear(in_features=
|
| 25 |
-
(v_proj): Linear(in_features=
|
| 26 |
-
(o_proj): Linear(in_features=
|
| 27 |
(q_norm): Lfm3RMSNorm((32,), eps=1e-05)
|
| 28 |
(k_norm): Lfm3RMSNorm((32,), eps=1e-05)
|
| 29 |
-
(gate_proj): Linear(in_features=
|
| 30 |
)
|
| 31 |
(feed_forward): Lfm3MLP(
|
| 32 |
-
(w1): Linear(in_features=
|
| 33 |
-
(w3): Linear(in_features=
|
| 34 |
-
(w2): Linear(in_features=
|
| 35 |
-
)
|
| 36 |
-
(operator_norm): Lfm3RMSNorm((
|
| 37 |
-
(ffn_norm): Lfm3RMSNorm((
|
| 38 |
-
(post_operator_norm): Lfm3RMSNorm((
|
| 39 |
-
(post_ffn_norm): Lfm3RMSNorm((
|
| 40 |
)
|
| 41 |
(3): Lfm3DecoderLayer(
|
| 42 |
(conv): Lfm3ShortConv(
|
| 43 |
-
(conv): Conv1d(
|
| 44 |
-
(in_proj): Linear(in_features=
|
| 45 |
-
(out_proj): Linear(in_features=
|
| 46 |
)
|
| 47 |
(feed_forward): Lfm3MLP(
|
| 48 |
-
(w1): Linear(in_features=
|
| 49 |
-
(w3): Linear(in_features=
|
| 50 |
-
(w2): Linear(in_features=
|
| 51 |
-
)
|
| 52 |
-
(operator_norm): Lfm3RMSNorm((
|
| 53 |
-
(ffn_norm): Lfm3RMSNorm((
|
| 54 |
-
(post_operator_norm): Lfm3RMSNorm((
|
| 55 |
-
(post_ffn_norm): Lfm3RMSNorm((
|
| 56 |
)
|
| 57 |
(4): Lfm3DecoderLayer(
|
| 58 |
(self_attn): Lfm3Attention(
|
| 59 |
-
(q_proj): Linear(in_features=
|
| 60 |
-
(k_proj): Linear(in_features=
|
| 61 |
-
(v_proj): Linear(in_features=
|
| 62 |
-
(o_proj): Linear(in_features=
|
| 63 |
(q_norm): Lfm3RMSNorm((32,), eps=1e-05)
|
| 64 |
(k_norm): Lfm3RMSNorm((32,), eps=1e-05)
|
| 65 |
-
(gate_proj): Linear(in_features=
|
| 66 |
)
|
| 67 |
(feed_forward): Lfm3MLP(
|
| 68 |
-
(w1): Linear(in_features=
|
| 69 |
-
(w3): Linear(in_features=
|
| 70 |
-
(w2): Linear(in_features=
|
| 71 |
-
)
|
| 72 |
-
(operator_norm): Lfm3RMSNorm((
|
| 73 |
-
(ffn_norm): Lfm3RMSNorm((
|
| 74 |
-
(post_operator_norm): Lfm3RMSNorm((
|
| 75 |
-
(post_ffn_norm): Lfm3RMSNorm((
|
| 76 |
)
|
| 77 |
(5): Lfm3DecoderLayer(
|
| 78 |
(conv): Lfm3ShortConv(
|
| 79 |
-
(conv): Conv1d(
|
| 80 |
-
(in_proj): Linear(in_features=
|
| 81 |
-
(out_proj): Linear(in_features=
|
| 82 |
)
|
| 83 |
(feed_forward): Lfm3MLP(
|
| 84 |
-
(w1): Linear(in_features=
|
| 85 |
-
(w3): Linear(in_features=
|
| 86 |
-
(w2): Linear(in_features=
|
| 87 |
-
)
|
| 88 |
-
(operator_norm): Lfm3RMSNorm((
|
| 89 |
-
(ffn_norm): Lfm3RMSNorm((
|
| 90 |
-
(post_operator_norm): Lfm3RMSNorm((
|
| 91 |
-
(post_ffn_norm): Lfm3RMSNorm((
|
| 92 |
)
|
| 93 |
(6): Lfm3DecoderLayer(
|
| 94 |
(self_attn): Lfm3Attention(
|
| 95 |
-
(q_proj): Linear(in_features=
|
| 96 |
-
(k_proj): Linear(in_features=
|
| 97 |
-
(v_proj): Linear(in_features=
|
| 98 |
-
(o_proj): Linear(in_features=
|
| 99 |
(q_norm): Lfm3RMSNorm((32,), eps=1e-05)
|
| 100 |
(k_norm): Lfm3RMSNorm((32,), eps=1e-05)
|
| 101 |
-
(gate_proj): Linear(in_features=
|
| 102 |
)
|
| 103 |
(feed_forward): Lfm3MLP(
|
| 104 |
-
(w1): Linear(in_features=
|
| 105 |
-
(w3): Linear(in_features=
|
| 106 |
-
(w2): Linear(in_features=
|
| 107 |
-
)
|
| 108 |
-
(operator_norm): Lfm3RMSNorm((
|
| 109 |
-
(ffn_norm): Lfm3RMSNorm((
|
| 110 |
-
(post_operator_norm): Lfm3RMSNorm((
|
| 111 |
-
(post_ffn_norm): Lfm3RMSNorm((
|
| 112 |
)
|
| 113 |
(7): Lfm3DecoderLayer(
|
| 114 |
(conv): Lfm3ShortConv(
|
| 115 |
-
(conv): Conv1d(
|
| 116 |
-
(in_proj): Linear(in_features=
|
| 117 |
-
(out_proj): Linear(in_features=
|
| 118 |
)
|
| 119 |
(feed_forward): Lfm3MLP(
|
| 120 |
-
(w1): Linear(in_features=
|
| 121 |
-
(w3): Linear(in_features=
|
| 122 |
-
(w2): Linear(in_features=
|
| 123 |
-
)
|
| 124 |
-
(operator_norm): Lfm3RMSNorm((
|
| 125 |
-
(ffn_norm): Lfm3RMSNorm((
|
| 126 |
-
(post_operator_norm): Lfm3RMSNorm((
|
| 127 |
-
(post_ffn_norm): Lfm3RMSNorm((
|
| 128 |
)
|
| 129 |
(8): Lfm3DecoderLayer(
|
| 130 |
(self_attn): Lfm3Attention(
|
| 131 |
-
(q_proj): Linear(in_features=
|
| 132 |
-
(k_proj): Linear(in_features=
|
| 133 |
-
(v_proj): Linear(in_features=
|
| 134 |
-
(o_proj): Linear(in_features=
|
| 135 |
(q_norm): Lfm3RMSNorm((32,), eps=1e-05)
|
| 136 |
(k_norm): Lfm3RMSNorm((32,), eps=1e-05)
|
| 137 |
-
(gate_proj): Linear(in_features=
|
| 138 |
)
|
| 139 |
(feed_forward): Lfm3MLP(
|
| 140 |
-
(w1): Linear(in_features=
|
| 141 |
-
(w3): Linear(in_features=
|
| 142 |
-
(w2): Linear(in_features=
|
| 143 |
-
)
|
| 144 |
-
(operator_norm): Lfm3RMSNorm((
|
| 145 |
-
(ffn_norm): Lfm3RMSNorm((
|
| 146 |
-
(post_operator_norm): Lfm3RMSNorm((
|
| 147 |
-
(post_ffn_norm): Lfm3RMSNorm((
|
| 148 |
)
|
| 149 |
(9): Lfm3DecoderLayer(
|
| 150 |
(conv): Lfm3ShortConv(
|
| 151 |
-
(conv): Conv1d(
|
| 152 |
-
(in_proj): Linear(in_features=
|
| 153 |
-
(out_proj): Linear(in_features=
|
| 154 |
)
|
| 155 |
(feed_forward): Lfm3MLP(
|
| 156 |
-
(w1): Linear(in_features=
|
| 157 |
-
(w3): Linear(in_features=
|
| 158 |
-
(w2): Linear(in_features=
|
| 159 |
-
)
|
| 160 |
-
(operator_norm): Lfm3RMSNorm((
|
| 161 |
-
(ffn_norm): Lfm3RMSNorm((
|
| 162 |
-
(post_operator_norm): Lfm3RMSNorm((
|
| 163 |
-
(post_ffn_norm): Lfm3RMSNorm((
|
| 164 |
)
|
| 165 |
)
|
| 166 |
(rotary_emb): Lfm3RotaryEmbedding()
|
| 167 |
-
(embedding_norm): Lfm3RMSNorm((
|
| 168 |
)
|
| 169 |
-
(lm_head): Linear(in_features=
|
| 170 |
)
|
|
|
|
| 1 |
Lfm3ForCausalLM(
|
| 2 |
(model): Lfm3Model(
|
| 3 |
+
(embed_tokens): Embedding(128000, 64, padding_idx=124893)
|
| 4 |
(layers): ModuleList(
|
| 5 |
(0-1): 2 x Lfm3DecoderLayer(
|
| 6 |
(conv): Lfm3ShortConv(
|
| 7 |
+
(conv): Conv1d(64, 64, kernel_size=(7,), stride=(1,), padding=(6,), groups=64, bias=False)
|
| 8 |
+
(in_proj): Linear(in_features=64, out_features=192, bias=False)
|
| 9 |
+
(out_proj): Linear(in_features=64, out_features=64, bias=False)
|
| 10 |
)
|
| 11 |
(feed_forward): Lfm3MLP(
|
| 12 |
+
(w1): Linear(in_features=64, out_features=128, bias=False)
|
| 13 |
+
(w3): Linear(in_features=64, out_features=128, bias=False)
|
| 14 |
+
(w2): Linear(in_features=128, out_features=64, bias=False)
|
| 15 |
+
)
|
| 16 |
+
(operator_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 17 |
+
(ffn_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 18 |
+
(post_operator_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 19 |
+
(post_ffn_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 20 |
)
|
| 21 |
(2): Lfm3DecoderLayer(
|
| 22 |
(self_attn): Lfm3Attention(
|
| 23 |
+
(q_proj): Linear(in_features=64, out_features=128, bias=False)
|
| 24 |
+
(k_proj): Linear(in_features=64, out_features=32, bias=False)
|
| 25 |
+
(v_proj): Linear(in_features=64, out_features=32, bias=False)
|
| 26 |
+
(o_proj): Linear(in_features=128, out_features=64, bias=False)
|
| 27 |
(q_norm): Lfm3RMSNorm((32,), eps=1e-05)
|
| 28 |
(k_norm): Lfm3RMSNorm((32,), eps=1e-05)
|
| 29 |
+
(gate_proj): Linear(in_features=64, out_features=4, bias=False)
|
| 30 |
)
|
| 31 |
(feed_forward): Lfm3MLP(
|
| 32 |
+
(w1): Linear(in_features=64, out_features=128, bias=False)
|
| 33 |
+
(w3): Linear(in_features=64, out_features=128, bias=False)
|
| 34 |
+
(w2): Linear(in_features=128, out_features=64, bias=False)
|
| 35 |
+
)
|
| 36 |
+
(operator_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 37 |
+
(ffn_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 38 |
+
(post_operator_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 39 |
+
(post_ffn_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 40 |
)
|
| 41 |
(3): Lfm3DecoderLayer(
|
| 42 |
(conv): Lfm3ShortConv(
|
| 43 |
+
(conv): Conv1d(64, 64, kernel_size=(7,), stride=(1,), padding=(6,), groups=64, bias=False)
|
| 44 |
+
(in_proj): Linear(in_features=64, out_features=192, bias=False)
|
| 45 |
+
(out_proj): Linear(in_features=64, out_features=64, bias=False)
|
| 46 |
)
|
| 47 |
(feed_forward): Lfm3MLP(
|
| 48 |
+
(w1): Linear(in_features=64, out_features=128, bias=False)
|
| 49 |
+
(w3): Linear(in_features=64, out_features=128, bias=False)
|
| 50 |
+
(w2): Linear(in_features=128, out_features=64, bias=False)
|
| 51 |
+
)
|
| 52 |
+
(operator_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 53 |
+
(ffn_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 54 |
+
(post_operator_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 55 |
+
(post_ffn_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 56 |
)
|
| 57 |
(4): Lfm3DecoderLayer(
|
| 58 |
(self_attn): Lfm3Attention(
|
| 59 |
+
(q_proj): Linear(in_features=64, out_features=128, bias=False)
|
| 60 |
+
(k_proj): Linear(in_features=64, out_features=32, bias=False)
|
| 61 |
+
(v_proj): Linear(in_features=64, out_features=32, bias=False)
|
| 62 |
+
(o_proj): Linear(in_features=128, out_features=64, bias=False)
|
| 63 |
(q_norm): Lfm3RMSNorm((32,), eps=1e-05)
|
| 64 |
(k_norm): Lfm3RMSNorm((32,), eps=1e-05)
|
| 65 |
+
(gate_proj): Linear(in_features=64, out_features=4, bias=False)
|
| 66 |
)
|
| 67 |
(feed_forward): Lfm3MLP(
|
| 68 |
+
(w1): Linear(in_features=64, out_features=128, bias=False)
|
| 69 |
+
(w3): Linear(in_features=64, out_features=128, bias=False)
|
| 70 |
+
(w2): Linear(in_features=128, out_features=64, bias=False)
|
| 71 |
+
)
|
| 72 |
+
(operator_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 73 |
+
(ffn_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 74 |
+
(post_operator_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 75 |
+
(post_ffn_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 76 |
)
|
| 77 |
(5): Lfm3DecoderLayer(
|
| 78 |
(conv): Lfm3ShortConv(
|
| 79 |
+
(conv): Conv1d(64, 64, kernel_size=(7,), stride=(1,), padding=(6,), groups=64, bias=False)
|
| 80 |
+
(in_proj): Linear(in_features=64, out_features=192, bias=False)
|
| 81 |
+
(out_proj): Linear(in_features=64, out_features=64, bias=False)
|
| 82 |
)
|
| 83 |
(feed_forward): Lfm3MLP(
|
| 84 |
+
(w1): Linear(in_features=64, out_features=128, bias=False)
|
| 85 |
+
(w3): Linear(in_features=64, out_features=128, bias=False)
|
| 86 |
+
(w2): Linear(in_features=128, out_features=64, bias=False)
|
| 87 |
+
)
|
| 88 |
+
(operator_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 89 |
+
(ffn_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 90 |
+
(post_operator_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 91 |
+
(post_ffn_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 92 |
)
|
| 93 |
(6): Lfm3DecoderLayer(
|
| 94 |
(self_attn): Lfm3Attention(
|
| 95 |
+
(q_proj): Linear(in_features=64, out_features=128, bias=False)
|
| 96 |
+
(k_proj): Linear(in_features=64, out_features=32, bias=False)
|
| 97 |
+
(v_proj): Linear(in_features=64, out_features=32, bias=False)
|
| 98 |
+
(o_proj): Linear(in_features=128, out_features=64, bias=False)
|
| 99 |
(q_norm): Lfm3RMSNorm((32,), eps=1e-05)
|
| 100 |
(k_norm): Lfm3RMSNorm((32,), eps=1e-05)
|
| 101 |
+
(gate_proj): Linear(in_features=64, out_features=4, bias=False)
|
| 102 |
)
|
| 103 |
(feed_forward): Lfm3MLP(
|
| 104 |
+
(w1): Linear(in_features=64, out_features=128, bias=False)
|
| 105 |
+
(w3): Linear(in_features=64, out_features=128, bias=False)
|
| 106 |
+
(w2): Linear(in_features=128, out_features=64, bias=False)
|
| 107 |
+
)
|
| 108 |
+
(operator_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 109 |
+
(ffn_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 110 |
+
(post_operator_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 111 |
+
(post_ffn_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 112 |
)
|
| 113 |
(7): Lfm3DecoderLayer(
|
| 114 |
(conv): Lfm3ShortConv(
|
| 115 |
+
(conv): Conv1d(64, 64, kernel_size=(7,), stride=(1,), padding=(6,), groups=64, bias=False)
|
| 116 |
+
(in_proj): Linear(in_features=64, out_features=192, bias=False)
|
| 117 |
+
(out_proj): Linear(in_features=64, out_features=64, bias=False)
|
| 118 |
)
|
| 119 |
(feed_forward): Lfm3MLP(
|
| 120 |
+
(w1): Linear(in_features=64, out_features=128, bias=False)
|
| 121 |
+
(w3): Linear(in_features=64, out_features=128, bias=False)
|
| 122 |
+
(w2): Linear(in_features=128, out_features=64, bias=False)
|
| 123 |
+
)
|
| 124 |
+
(operator_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 125 |
+
(ffn_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 126 |
+
(post_operator_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 127 |
+
(post_ffn_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 128 |
)
|
| 129 |
(8): Lfm3DecoderLayer(
|
| 130 |
(self_attn): Lfm3Attention(
|
| 131 |
+
(q_proj): Linear(in_features=64, out_features=128, bias=False)
|
| 132 |
+
(k_proj): Linear(in_features=64, out_features=32, bias=False)
|
| 133 |
+
(v_proj): Linear(in_features=64, out_features=32, bias=False)
|
| 134 |
+
(o_proj): Linear(in_features=128, out_features=64, bias=False)
|
| 135 |
(q_norm): Lfm3RMSNorm((32,), eps=1e-05)
|
| 136 |
(k_norm): Lfm3RMSNorm((32,), eps=1e-05)
|
| 137 |
+
(gate_proj): Linear(in_features=64, out_features=4, bias=False)
|
| 138 |
)
|
| 139 |
(feed_forward): Lfm3MLP(
|
| 140 |
+
(w1): Linear(in_features=64, out_features=128, bias=False)
|
| 141 |
+
(w3): Linear(in_features=64, out_features=128, bias=False)
|
| 142 |
+
(w2): Linear(in_features=128, out_features=64, bias=False)
|
| 143 |
+
)
|
| 144 |
+
(operator_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 145 |
+
(ffn_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 146 |
+
(post_operator_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 147 |
+
(post_ffn_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 148 |
)
|
| 149 |
(9): Lfm3DecoderLayer(
|
| 150 |
(conv): Lfm3ShortConv(
|
| 151 |
+
(conv): Conv1d(64, 64, kernel_size=(7,), stride=(1,), padding=(6,), groups=64, bias=False)
|
| 152 |
+
(in_proj): Linear(in_features=64, out_features=192, bias=False)
|
| 153 |
+
(out_proj): Linear(in_features=64, out_features=64, bias=False)
|
| 154 |
)
|
| 155 |
(feed_forward): Lfm3MLP(
|
| 156 |
+
(w1): Linear(in_features=64, out_features=128, bias=False)
|
| 157 |
+
(w3): Linear(in_features=64, out_features=128, bias=False)
|
| 158 |
+
(w2): Linear(in_features=128, out_features=64, bias=False)
|
| 159 |
+
)
|
| 160 |
+
(operator_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 161 |
+
(ffn_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 162 |
+
(post_operator_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 163 |
+
(post_ffn_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 164 |
)
|
| 165 |
)
|
| 166 |
(rotary_emb): Lfm3RotaryEmbedding()
|
| 167 |
+
(embedding_norm): Lfm3RMSNorm((64,), eps=1e-05)
|
| 168 |
)
|
| 169 |
+
(lm_head): Linear(in_features=64, out_features=128000, bias=False)
|
| 170 |
)
|
README.md
CHANGED
|
@@ -9,22 +9,23 @@ This is a randomly initialized tiny model based on [LiquidAI/LFM3-1.7B](https://
|
|
| 9 |
|
| 10 |
| Feature | Source | This repo |
|
| 11 |
|---|---|---|
|
| 12 |
-
| Checkpoint tensor elements | 1.73B BF16 |
|
| 13 |
-
| Safetensors weight files | 3.46 GB (model.safetensors) |
|
| 14 |
| Layers / layer-type cycle | 24 / two-conv prefix, then full/conv/sliding/conv | 10 / same prefix and two complete cycles |
|
| 15 |
-
| Hidden width / MLP width | 2,048 / 7,680 |
|
| 16 |
-
| Q heads / KV heads / head_dim | 16 / 4 / 128 |
|
| 17 |
| Short-conv kernel / cache | 7 / 7 | Same |
|
| 18 |
| RoPE | full 0.5 partial, theta 1e6; sliding theta 1e4 | Same |
|
| 19 |
| Sandwich norms / QK RMSNorm / sigmoid head gate | present | Same |
|
| 20 |
| Vocabulary rows / embedding tying | 128,000 / tied | Same |
|
|
|
|
| 21 |
| Stored precision | BF16 | Same |
|
| 22 |
|
| 23 |
-
|
| 24 |
|
| 25 |
| File path | Size |
|
| 26 |
|------|------|
|
| 27 |
-
| model.safetensors |
|
| 28 |
|
| 29 |
### Example usage
|
| 30 |
|
|
@@ -73,5 +74,6 @@ if __name__ == "__main__":
|
|
| 73 |
### Change log
|
| 74 |
|
| 75 |
- 2026-10-30: Initial version.
|
|
|
|
| 76 |
|
| 77 |
*This repo is generated by GPT-6.1-Sol.*
|
|
|
|
| 9 |
|
| 10 |
| Feature | Source | This repo |
|
| 11 |
|---|---|---|
|
| 12 |
+
| Checkpoint tensor elements | 1.73B BF16 | 8.62M BF16 |
|
| 13 |
+
| Safetensors weight files | 3.46 GB (model.safetensors) | 17.26 MB (model.safetensors) |
|
| 14 |
| Layers / layer-type cycle | 24 / two-conv prefix, then full/conv/sliding/conv | 10 / same prefix and two complete cycles |
|
| 15 |
+
| Hidden width / MLP width | 2,048 / 7,680 | 64 / 128 |
|
| 16 |
+
| Q heads / KV heads / head_dim | 16 / 4 / 128 | 4 / 1 / 32 |
|
| 17 |
| Short-conv kernel / cache | 7 / 7 | Same |
|
| 18 |
| RoPE | full 0.5 partial, theta 1e6; sliding theta 1e4 | Same |
|
| 19 |
| Sandwich norms / QK RMSNorm / sigmoid head gate | present | Same |
|
| 20 |
| Vocabulary rows / embedding tying | 128,000 / tied | Same |
|
| 21 |
+
| Maximum context length | 262,144 | 128,000 |
|
| 22 |
| Stored precision | BF16 | Same |
|
| 23 |
|
| 24 |
+
Residual width 64 and MLP width 128 follow [tiny-random/lfm2](https://huggingface.co/tiny-random/lfm2). The pinned upstream implementation is included for Transformers loading. This repo provides a Transformers example; no serving-backend validation is claimed.
|
| 25 |
|
| 26 |
| File path | Size |
|
| 27 |
|------|------|
|
| 28 |
+
| model.safetensors | 17.3MB |
|
| 29 |
|
| 30 |
### Example usage
|
| 31 |
|
|
|
|
| 74 |
### Change log
|
| 75 |
|
| 76 |
- 2026-10-30: Initial version.
|
| 77 |
+
- 2026-10-31: Resize to hidden width 64 and MLP width 128, following tiny-random/lfm2; use four Q heads and one KV head while preserving the LFM3 layer cadence.
|
| 78 |
|
| 79 |
*This repo is generated by GPT-6.1-Sol.*
|
config.json
CHANGED
|
@@ -13,8 +13,8 @@
|
|
| 13 |
"dtype": "bfloat16",
|
| 14 |
"eos_token_id": 124900,
|
| 15 |
"head_dim": 32,
|
| 16 |
-
"hidden_size":
|
| 17 |
-
"intermediate_size":
|
| 18 |
"layer_types": [
|
| 19 |
"conv",
|
| 20 |
"conv",
|
|
@@ -27,12 +27,12 @@
|
|
| 27 |
"sliding_attention",
|
| 28 |
"conv"
|
| 29 |
],
|
| 30 |
-
"max_position_embeddings":
|
| 31 |
"model_type": "lfm3",
|
| 32 |
"norm_eps": 1e-05,
|
| 33 |
-
"num_attention_heads":
|
| 34 |
"num_hidden_layers": 10,
|
| 35 |
-
"num_key_value_heads":
|
| 36 |
"pad_token_id": 124893,
|
| 37 |
"rope_parameters": {
|
| 38 |
"full_attention": {
|
|
|
|
| 13 |
"dtype": "bfloat16",
|
| 14 |
"eos_token_id": 124900,
|
| 15 |
"head_dim": 32,
|
| 16 |
+
"hidden_size": 64,
|
| 17 |
+
"intermediate_size": 128,
|
| 18 |
"layer_types": [
|
| 19 |
"conv",
|
| 20 |
"conv",
|
|
|
|
| 27 |
"sliding_attention",
|
| 28 |
"conv"
|
| 29 |
],
|
| 30 |
+
"max_position_embeddings": 128000,
|
| 31 |
"model_type": "lfm3",
|
| 32 |
"norm_eps": 1e-05,
|
| 33 |
+
"num_attention_heads": 4,
|
| 34 |
"num_hidden_layers": 10,
|
| 35 |
+
"num_key_value_heads": 1,
|
| 36 |
"pad_token_id": 124893,
|
| 37 |
"rope_parameters": {
|
| 38 |
"full_attention": {
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6c2c8b4d4fde884ed076ad2e6ad1ba42744f997a124105b5be2d6ef5de1fdcf9
|
| 3 |
+
size 17261704
|