Instructions to use trl-internal-testing/tiny-Lfm2ForCausalLM-2.5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use trl-internal-testing/tiny-Lfm2ForCausalLM-2.5 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="trl-internal-testing/tiny-Lfm2ForCausalLM-2.5") 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("trl-internal-testing/tiny-Lfm2ForCausalLM-2.5") model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-Lfm2ForCausalLM-2.5", 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 trl-internal-testing/tiny-Lfm2ForCausalLM-2.5 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "trl-internal-testing/tiny-Lfm2ForCausalLM-2.5" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "trl-internal-testing/tiny-Lfm2ForCausalLM-2.5", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/trl-internal-testing/tiny-Lfm2ForCausalLM-2.5
- SGLang
How to use trl-internal-testing/tiny-Lfm2ForCausalLM-2.5 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 "trl-internal-testing/tiny-Lfm2ForCausalLM-2.5" \ --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": "trl-internal-testing/tiny-Lfm2ForCausalLM-2.5", "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 "trl-internal-testing/tiny-Lfm2ForCausalLM-2.5" \ --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": "trl-internal-testing/tiny-Lfm2ForCausalLM-2.5", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use trl-internal-testing/tiny-Lfm2ForCausalLM-2.5 with Docker Model Runner:
docker model run hf.co/trl-internal-testing/tiny-Lfm2ForCausalLM-2.5
Upload Lfm2ForCausalLM
#1
by albertvillanova HF Staff - opened
- chat_template.jinja +4 -2
- config.json +20 -1
- model.safetensors +1 -1
chat_template.jinja
CHANGED
|
@@ -75,8 +75,10 @@
|
|
| 75 |
{{- "<|im_start|>" + message.role + "\n" -}}
|
| 76 |
{%- if message.role == "assistant" -%}
|
| 77 |
{%- generation -%}
|
| 78 |
-
{%-
|
| 79 |
-
|
|
|
|
|
|
|
| 80 |
{%- endif -%}
|
| 81 |
{%- set _cfm_tag = "CONTINUE_FINAL_MESSAGE_TAG " -%}
|
| 82 |
{%- set _has_cfm = false -%}
|
|
|
|
| 75 |
{{- "<|im_start|>" + message.role + "\n" -}}
|
| 76 |
{%- if message.role == "assistant" -%}
|
| 77 |
{%- generation -%}
|
| 78 |
+
{%- set thinking = message.thinking or message.reasoning or message.reasoning_content -%}
|
| 79 |
+
{%- set thinking = thinking if thinking is string else "" -%}
|
| 80 |
+
{%- if thinking and (preserve_thinking or loop.index0 > ns.last_user_index) -%}
|
| 81 |
+
{{- "<think>" + thinking + "</think>" -}}
|
| 82 |
{%- endif -%}
|
| 83 |
{%- set _cfm_tag = "CONTINUE_FINAL_MESSAGE_TAG " -%}
|
| 84 |
{%- set _has_cfm = false -%}
|
config.json
CHANGED
|
@@ -2,14 +2,29 @@
|
|
| 2 |
"architectures": [
|
| 3 |
"Lfm2ForCausalLM"
|
| 4 |
],
|
|
|
|
| 5 |
"block_auto_adjust_ff_dim": false,
|
|
|
|
|
|
|
| 6 |
"block_ffn_dim_multiplier": 1.0,
|
|
|
|
|
|
|
|
|
|
| 7 |
"block_multiple_of": 256,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
"bos_token_id": 1,
|
| 9 |
"conv_L_cache": 3,
|
| 10 |
"conv_bias": false,
|
|
|
|
|
|
|
| 11 |
"dtype": "bfloat16",
|
| 12 |
"eos_token_id": 7,
|
|
|
|
|
|
|
| 13 |
"hidden_size": 8,
|
| 14 |
"initializer_range": 0.02,
|
| 15 |
"intermediate_size": 32,
|
|
@@ -21,6 +36,7 @@
|
|
| 21 |
"model_type": "lfm2",
|
| 22 |
"norm_eps": 1e-05,
|
| 23 |
"num_attention_heads": 4,
|
|
|
|
| 24 |
"num_hidden_layers": 2,
|
| 25 |
"num_key_value_heads": 2,
|
| 26 |
"pad_token_id": 0,
|
|
@@ -28,8 +44,11 @@
|
|
| 28 |
"rope_theta": 1000000.0,
|
| 29 |
"rope_type": "default"
|
| 30 |
},
|
|
|
|
|
|
|
| 31 |
"tie_word_embeddings": true,
|
| 32 |
"transformers_version": "5.0.0",
|
| 33 |
-
"use_cache":
|
|
|
|
| 34 |
"vocab_size": 65536
|
| 35 |
}
|
|
|
|
| 2 |
"architectures": [
|
| 3 |
"Lfm2ForCausalLM"
|
| 4 |
],
|
| 5 |
+
"block__name_mlp": "parallel_mlp_merged",
|
| 6 |
"block_auto_adjust_ff_dim": false,
|
| 7 |
+
"block_dim": 8,
|
| 8 |
+
"block_ff_dim": 32,
|
| 9 |
"block_ffn_dim_multiplier": 1.0,
|
| 10 |
+
"block_ffn_te_autocast": false,
|
| 11 |
+
"block_ffn_use_quantized_params": false,
|
| 12 |
+
"block_mlp_init_scale": 1.0,
|
| 13 |
"block_multiple_of": 256,
|
| 14 |
+
"block_norm_eps": 1e-05,
|
| 15 |
+
"block_out_init_scale": 1.0,
|
| 16 |
+
"block_sequence_parallel_norm_across_tp": false,
|
| 17 |
+
"block_use_swiglu": true,
|
| 18 |
+
"block_use_xavier_init": true,
|
| 19 |
"bos_token_id": 1,
|
| 20 |
"conv_L_cache": 3,
|
| 21 |
"conv_bias": false,
|
| 22 |
+
"conv_dim": 8,
|
| 23 |
+
"conv_use_xavier_init": true,
|
| 24 |
"dtype": "bfloat16",
|
| 25 |
"eos_token_id": 7,
|
| 26 |
+
"ffn_te_autocast": false,
|
| 27 |
+
"ffn_use_quantized_params": false,
|
| 28 |
"hidden_size": 8,
|
| 29 |
"initializer_range": 0.02,
|
| 30 |
"intermediate_size": 32,
|
|
|
|
| 36 |
"model_type": "lfm2",
|
| 37 |
"norm_eps": 1e-05,
|
| 38 |
"num_attention_heads": 4,
|
| 39 |
+
"num_heads": 4,
|
| 40 |
"num_hidden_layers": 2,
|
| 41 |
"num_key_value_heads": 2,
|
| 42 |
"pad_token_id": 0,
|
|
|
|
| 44 |
"rope_theta": 1000000.0,
|
| 45 |
"rope_type": "default"
|
| 46 |
},
|
| 47 |
+
"sequence_parallel_norm_across_tp": false,
|
| 48 |
+
"tie_embedding": true,
|
| 49 |
"tie_word_embeddings": true,
|
| 50 |
"transformers_version": "5.0.0",
|
| 51 |
+
"use_cache": true,
|
| 52 |
+
"use_pos_enc": true,
|
| 53 |
"vocab_size": 65536
|
| 54 |
}
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 1054864
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:75b4a6eb993c7f2777ee0621be1e667a72bfeee9b23bc3ede333c45135ab668d
|
| 3 |
size 1054864
|