Instructions to use notnotsamuel/LFM2.5-350M-RLCD with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use notnotsamuel/LFM2.5-350M-RLCD with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="notnotsamuel/LFM2.5-350M-RLCD") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("notnotsamuel/LFM2.5-350M-RLCD") model = AutoModelForCausalLM.from_pretrained("notnotsamuel/LFM2.5-350M-RLCD", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use notnotsamuel/LFM2.5-350M-RLCD with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "notnotsamuel/LFM2.5-350M-RLCD" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "notnotsamuel/LFM2.5-350M-RLCD", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/notnotsamuel/LFM2.5-350M-RLCD
- SGLang
How to use notnotsamuel/LFM2.5-350M-RLCD 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 "notnotsamuel/LFM2.5-350M-RLCD" \ --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": "notnotsamuel/LFM2.5-350M-RLCD", "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 "notnotsamuel/LFM2.5-350M-RLCD" \ --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": "notnotsamuel/LFM2.5-350M-RLCD", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use notnotsamuel/LFM2.5-350M-RLCD with Docker Model Runner:
docker model run hf.co/notnotsamuel/LFM2.5-350M-RLCD
Implementation notes
This release implements parallel constrained inference using unchanged LFM2.5-350M weights. No training, optimizer, fine-tuning, or parameter update is performed. It does not reproduce TypeSafe's proprietary Jev training or internals.
LFM2.5 compatibility
The pinned base config has 16 layers: six full-attention layers and ten short-convolution layers, with convolution cache length 3. Merely copying keys and values would lose convolution history or alias mutable state.
With Transformers 5.17.0, LFM2 uses DynamicCache containing both attention and linear-attention cache layer objects. LinearAttentionLayer.conv_states stores its short-convolution history. Generic batch_repeat_interleave does not handle these convolution layer objects. We deep-copy the cache and call reorder_cache with repeated index zero; its layer-specific implementations copy both KV tensors and convolution states along the batch dimension. Convolution states are not shared as writable expanded views.
A shared native chat-template prompt includes the complete JSON schema, all candidate values, the context, and an assistant opening {\n. For each field and candidate, we append a field suffix followed by a complete serialized JSON value and a newline delimiter. All such branches are right-padded and evaluated in one causal batch from independent copies of the shared cache. Padded state is never reused. We sum FP32 log-softmax scores over the candidate's complete token sequence, including its quotes and delimiter, and select the largest score per field. The delimiter makes candidate endings explicit; e.g. express and express plus are separate sequences. Ties choose the first listed candidate.
This uses two model calls regardless of candidate length, but FLOPs, memory, and batch width grow with total candidate count and length. Full-sequence scores have length and tokenization biases; they are not semantic confidence estimates. Tokenization is deliberately segmented at the field/value boundary, so the score is for that specific token sequence, not a sum over all tokenizations of a string.
Correctness and benchmark methodology
tests/test_engine.py checks hybrid cached branches against full-context forwards, checks that base KV and convolution state remain unchanged, compares every candidate likelihood against an uncached reference (including overlapping multi-token strings), and tests strict JSON/schema evaluation. FP16 scores need numerical tolerances across batching and device kernel order. All actual device validation outputs are retained.
The baseline uses greedy generate, the same shared prompt prefix and complete schema, the same model revision, dtype and eager attention implementation, without grammar constraints or output repair. It restores the common prefilled brace before strict parsing. Whitespace formatting is not forced to be verbose. Both methods use the same model and precision settings with deterministic decoding.
The model's field decisions remain independent: other selected fields are not fed back into a branch. Only a flat, closed object with required boolean or string-enum fields is supported. Cross-field constraints, nested objects, optional fields, arbitrary numbers, and free text are rejected or unsupported. Programmatic serialization guarantees syntax and this restricted schema's membership for successful calls, not truth, calibrated probability, relational consistency, or immunity to model errors.