Instructions to use ItsHotdogFred/lfm2.5-350m-npc-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use ItsHotdogFred/lfm2.5-350m-npc-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("LiquidAI/LFM2.5-350M") model = PeftModel.from_pretrained(base_model, "ItsHotdogFred/lfm2.5-350m-npc-lora") - Transformers
How to use ItsHotdogFred/lfm2.5-350m-npc-lora with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ItsHotdogFred/lfm2.5-350m-npc-lora") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ItsHotdogFred/lfm2.5-350m-npc-lora", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use ItsHotdogFred/lfm2.5-350m-npc-lora with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ItsHotdogFred/lfm2.5-350m-npc-lora" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ItsHotdogFred/lfm2.5-350m-npc-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ItsHotdogFred/lfm2.5-350m-npc-lora
- SGLang
How to use ItsHotdogFred/lfm2.5-350m-npc-lora 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 "ItsHotdogFred/lfm2.5-350m-npc-lora" \ --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": "ItsHotdogFred/lfm2.5-350m-npc-lora", "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 "ItsHotdogFred/lfm2.5-350m-npc-lora" \ --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": "ItsHotdogFred/lfm2.5-350m-npc-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ItsHotdogFred/lfm2.5-350m-npc-lora with Docker Model Runner:
docker model run hf.co/ItsHotdogFred/lfm2.5-350m-npc-lora
LFM2.5 350M NPC LoRA
This is a LoRA adapter for LiquidAI/LFM2.5-350M, fine-tuned for medieval fantasy RPG NPC dialogue.
The adapter is designed to generate structured NPC responses from two inputs:
- An NPC system prompt containing the NPC's name, job, location, and available abilities.
- A player prompt containing the player's name, reputation, and message.
It outputs the NPC response in the same schema used by the training data:
Message: <NPC dialogue>
Reputation: <reputation delta>
Abilities: <optional ability or abilities used>
Dataset
Trained on ItsHotdogFred/npc-training-data-v1, an English SFT dataset for GregAI NPC behavior.
Each row has three columns:
| Column | Description |
|---|---|
system_message |
NPC identity, job, current location, and abilities |
player_message |
Player name, reputation, and message |
ai_message |
Target NPC response, reputation change, and abilities used |
Prompt Format
Use the same prompt format that was used during training:
You are controlling a medieval fantasy RPG NPC. Use the NPC identity, location, abilities, and the player's reputation/message to answer exactly in the requested NPC output format.
NPC state:
Name: Richard
Job: Stable Hand
Current_location: Plain : Neutral
Abilities: "[Flee : Get away from the current area]"
Player input:
Name: Claire
Reputation: Bad
Message: Run while you still can
NPC output:
Example output:
Message: What is the meaning of this? I'm leaving right now!
Reputation: -2
Abilities: "[Flee : Get away from the current area]"
Usage
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base_model_id = "LiquidAI/LFM2.5-350M"
adapter_id = "ItsHotdogFred/lfm2.5-350m-npc-lora"
tokenizer = AutoTokenizer.from_pretrained(adapter_id, trust_remote_code=True)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id,
dtype=torch.float16,
device_map="auto",
trust_remote_code=True,
)
model = PeftModel.from_pretrained(base_model, adapter_id)
model.eval()
prompt = """You are controlling a medieval fantasy RPG NPC. Use the NPC identity, location, abilities, and the player's reputation/message to answer exactly in the requested NPC output format.
NPC state:
Name: Richard
Job: Stable Hand
Current_location: Plain : Neutral
Abilities: "[Flee : Get away from the current area]"
Player input:
Name: Claire
Reputation: Bad
Message: Run while you still can
NPC output:
"""
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
output_ids = model.generate(
**inputs,
max_new_tokens=120,
do_sample=True,
temperature=0.7,
top_p=0.9,
pad_token_id=tokenizer.eos_token_id,
)
generated_ids = output_ids[0, inputs["input_ids"].shape[-1]:]
print(tokenizer.decode(generated_ids, skip_special_tokens=True).strip())
Training
This adapter was trained with supervised fine-tuning using TRL and PEFT LoRA.
Key settings:
- Base model:
LiquidAI/LFM2.5-350M - Method: LoRA SFT
- LoRA rank:
16 - LoRA alpha:
32 - LoRA dropout:
0.05 - Max sequence length:
512 - Epochs:
3.2 - Learning rate:
2e-4 - Train/eval split:
90/10
Intended Use
This adapter is intended for game prototyping and NPC dialogue generation in a medieval fantasy RPG setting. It is best used when the caller provides structured NPC and player context in the training format.
Limitations
- The adapter is specialized for short, structured NPC turns and may not behave well as a general chatbot.
- It may invent details if the prompt omits important NPC state or abilities.
- Reputation changes and ability selection should be treated as model suggestions and validated by game logic before use.
- The training data is fantasy RPG themed, so outputs may not transfer cleanly to modern, sci-fi, or non-game settings without more data.
Base Model License
This adapter depends on LiquidAI/LFM2.5-350M. Check the base model card and license terms before commercial use or redistribution.
Citation
@misc{vonwerra2022trl,
title = {{TRL: Transformer Reinforcement Learning}},
author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin GalloueDec},
year = 2020,
journal = {GitHub repository},
publisher = {GitHub},
howpublished = {\url{https://github.com/huggingface/trl}}
}
- Downloads last month
- 43