Text Generation
Transformers
Safetensors
PyTorch
English
French
Spanish
lfm2
classification
inference-only
structured-generation
constrained-decoding
apple-silicon
conversational
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)# pip install -U transformers accelerate # 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=256) 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
Download modal_benchmark.py from notnotsamuel/LFM2.5-350M-RLCD: direct link, hf CLI and curl.
- Browser
- Download file 1.9 kB
-
https://huggingface.co/notnotsamuel/LFM2.5-350M-RLCD/resolve/main/modal_benchmark.py
- Command line
-
hf download hf://notnotsamuel/LFM2.5-350M-RLCD/modal_benchmark.py
-
curl -L -o modal_benchmark.py https://huggingface.co/notnotsamuel/LFM2.5-350M-RLCD/resolve/main/modal_benchmark.py
1.9 kB
| """Run with: modal run --profile samuel modal_benchmark.py --gpu L40S""" | |
| import json | |
| from pathlib import Path | |
| import modal | |
| app = modal.App("lfm25-350m-rlcd-benchmark") | |
| image = (modal.Image.debian_slim(python_version="3.11") | |
| .pip_install_from_requirements("requirements.txt") | |
| .add_local_python_source("rlcd") | |
| .add_local_dir("tests", "/root/tests")) | |
| cache = modal.Volume.from_name("lfm25-350m-rlcd-hf-cache", create_if_missing=True) | |
| def execute(suite="diagnostic"): | |
| import os | |
| import subprocess | |
| from rlcd.benchmark import run | |
| os.environ["RLCD_TEST_DEVICE"] = "cuda" | |
| test = subprocess.run(["python", "-m", "pytest", "-q", "-s", "/root/tests"], capture_output=True, text=True) | |
| print(test.stdout, flush=True) | |
| if test.returncode: | |
| raise RuntimeError(test.stdout + test.stderr) | |
| result = run(device="cuda", dtype="float16", warmups=2, repeats=3, suite=suite, max_new_tokens=768 if suite == "stress" else 192) | |
| result["validation"] = {"pytest_stdout": test.stdout, "pytest_stderr": test.stderr, "returncode": test.returncode} | |
| return result | |
| def l40s(suite="diagnostic"): | |
| return execute(suite) | |
| def h100(suite="diagnostic"): | |
| return execute(suite) | |
| def main(gpu: str = "L40S", suite: str = "diagnostic"): | |
| if suite not in {"diagnostic", "stress"}: | |
| raise ValueError(suite) | |
| fn = {"L40S":l40s, "H100":h100}[gpu] | |
| result = fn.remote(suite) | |
| path = Path("results") / (gpu.lower() + ("-stress" if suite == "stress" else "") + ".json") | |
| path.parent.mkdir(exist_ok=True) | |
| path.write_text(json.dumps(result, indent=2) + "\n") | |
| print(json.dumps(result["summary"], indent=2)) | |