Run this model with HF Jobs
Run trl-internal-testing/tiny-Lfm2ForCausalLM on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/trl-internal-testing/tiny-Lfm2ForCausalLM. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/trl-internal-testing/tiny-Lfm2ForCausalLM on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/trl-internal-testing/tiny-Lfm2ForCausalLM. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/trl-internal-testing/tiny-Lfm2ForCausalLM. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use trl-internal-testing/tiny-Lfm2ForCausalLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use trl-internal-testing/tiny-Lfm2ForCausalLM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="trl-internal-testing/tiny-Lfm2ForCausalLM") 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") model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-Lfm2ForCausalLM", 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 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" # 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", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/trl-internal-testing/tiny-Lfm2ForCausalLM
- SGLang
How to use trl-internal-testing/tiny-Lfm2ForCausalLM 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" \ --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", "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" \ --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", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use trl-internal-testing/tiny-Lfm2ForCausalLM with Docker Model Runner:
docker model run hf.co/trl-internal-testing/tiny-Lfm2ForCausalLM
Upload Lfm2ForCausalLM
#1
by albertvillanova HF Staff - opened
Files changed (3)
- chat_template.jinja+37-2
- config.json+13-1
- model.safetensors+1-1
123418 unmodified lines2324252627282930313233343536{{- bos_token -}}{%- set system_prompt = "" -%}{%- set ns = namespace(system_prompt="") -%}{%- if messages[0]["role"] == "system" -%}18 unmodified lines{%- endif -%}{%- for message in messages -%}{{- "<|im_start|>" + message["role"] + "\n" -}}{%- set content = message["content"] -%}{%- if content is not string -%}{%- set content = content | tojson -%}{%- endif -%}{%- if message["role"] == "tool" -%}{%- set content = "<|tool_response_start|>" + content + "<|tool_response_end|>" -%}{%- endif -%}{{- content + "<|im_end|>\n" -}}{%- endfor -%}{%- if add_generation_prompt -%}{{- "<|im_start|>assistant\n" -}}1234567891011121314151617181920212223242526272829303118 unmodified lines50515253545556575859606162636465666768697071{{- bos_token -}}{%- macro format_arg_value(arg_value) -%}{%- if arg_value is string -%}{{- "'" + (arg_value | replace("\\", "\\\\") | replace("'", "\\'") | replace("\n", "\\n") | replace("\r", "\\r")) + "'" -}}{%- elif arg_value is mapping or arg_value is iterable -%}{{- arg_value | tojson -}}{%- else -%}{{- arg_value | string -}}{%- endif -%}{%- endmacro -%}{%- macro render_tool_calls(tool_calls) -%}{%- set tool_calls_ns = namespace(tool_calls=[]) -%}{%- for tool_call in tool_calls -%}{%- set func = tool_call["function"] if "function" in tool_call else tool_call -%}{%- set func_name = func["name"] -%}{%- set func_args = func.get("arguments") -%}{%- set args_ns = namespace(arg_strings=[]) -%}{%- if func_args is mapping -%}{%- for arg_name, arg_value in func_args.items() -%}{%- set args_ns.arg_strings = args_ns.arg_strings + [arg_name + "=" + format_arg_value(arg_value)] -%}{%- endfor -%}{%- elif func_args is string and (func_args | trim) not in ["", "{}", "null"] -%}{{- raise_exception("Tool call arguments must be a mapping, got a JSON-encoded string: parse arguments with json.loads() before applying the chat template") -}}{%- endif -%}{%- set tool_calls_ns.tool_calls = tool_calls_ns.tool_calls + [func_name + "(" + (args_ns.arg_strings | join(", ")) + ")"] -%}{%- endfor -%}{{- "<|tool_call_start|>[" + (tool_calls_ns.tool_calls | join(", ")) + "]<|tool_call_end|>" -}}{%- endmacro -%}{%- set system_prompt = "" -%}{%- set ns = namespace(system_prompt="") -%}{%- if messages[0]["role"] == "system" -%}18 unmodified lines{%- endif -%}{%- for message in messages -%}{{- "<|im_start|>" + message["role"] + "\n" -}}{%- set content = message.get("content") -%}{%- if content is not string -%}{%- set content = content | tojson -%}{%- endif -%}{%- if message["role"] == "tool" -%}{%- set content = "<|tool_response_start|>" + content + "<|tool_response_end|>" -%}{%- endif -%}{%- if message["role"] == "assistant" and message.get("tool_calls") -%}{%- if content and content != "null" -%}{{- content -}}{%- endif -%}{{- render_tool_calls(message["tool_calls"]) -}}{{- "<|im_end|>\n" -}}{%- else -%}{{- content + "<|im_end|>\n" -}}{%- endif -%}{%- endfor -%}{%- if add_generation_prompt -%}{{- "<|im_start|>assistant\n" -}}
2 unmodified lines3456789101112137 unmodified lines21222324252627282930312 unmodified lines"Lfm2ForCausalLM"],"block_auto_adjust_ff_dim": true,"block_ffn_dim_multiplier": 1.0,"block_multiple_of": 8,"bos_token_id": 1,"conv_L_cache": 3,"conv_bias": false,"dtype": "bfloat16","eos_token_id": 7,"hidden_size": 8,7 unmodified lines"model_type": "lfm2","norm_eps": 1e-05,"num_attention_heads": 4,"num_hidden_layers": 2,"num_key_value_heads": 2,"pad_token_id": 0,"rope_theta": 1000000.0,"transformers_version": "4.56.2","use_cache": false,"vocab_size": 65536}2 unmodified lines345678910111213141516171819202122237 unmodified lines313233343536373839404142432 unmodified lines"Lfm2ForCausalLM"],"block_auto_adjust_ff_dim": true,"block_dim": 8,"block_ff_dim": 32,"block_ffn_dim_multiplier": 1.0,"block_mlp_init_scale": 1.0,"block_multiple_of": 8,"block_norm_eps": 1e-05,"block_out_init_scale": 1.0,"block_use_swiglu": true,"block_use_xavier_init": true,"bos_token_id": 1,"conv_L_cache": 3,"conv_bias": false,"conv_dim": 8,"conv_dim_out": 8,"conv_use_xavier_init": true,"dtype": "bfloat16","eos_token_id": 7,"hidden_size": 8,7 unmodified lines"model_type": "lfm2","norm_eps": 1e-05,"num_attention_heads": 4,"num_heads": 4,"num_hidden_layers": 2,"num_key_value_heads": 2,"pad_token_id": 0,"rope_theta": 1000000.0,"transformers_version": "4.56.2","use_cache": true,"use_pos_enc": true,"vocab_size": 65536}
123version https://git-lfs.github.com/spec/v1oid sha256:9009f3f8bad23dbd483b8baf9554731f3a85359534b5e2a90ec5753063046337size 1054096123version https://git-lfs.github.com/spec/v1oid sha256:7cf8031f34b33a591cb956c0ee9561e2dcad9d8bc960a2f896af332ce4e67183size 1054096
chat_template.jinja+37-2
config.json+13-1
model.safetensors+1-1