LFM2.5-8B-A1B-SFT-function-calling
LiquidAI/LFM2.5-8B-A1B fine-tuned with TRL on the 60k xLAM samples of argilla/apigen-function-calling: a query, the tools it may use, and the one or several parallel calls that answer it. All weights are trained, with the loss on the assistant turn only. One epoch on 8 H100s, with the 32 experts split 8 ways (expert parallelism) and everything else FSDP-sharded. The training script is 1_sft.py.

938 steps in 16 minutes. The loss goes from 1.16 to 0.03 and the token accuracy from 90.5% to 99.3%.
Usage
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from trl.chat_template_utils import add_response_schema, parse_response
def get_weather(city: str, unit: str) -> str:
"""
Gets the current weather in a city.
Args:
city: The name of the city.
unit: The temperature unit, "celsius" or "fahrenheit".
"""
model_id = "trl-lib/LFM2.5-8B-A1B-SFT-function-calling"
tokenizer = add_response_schema(AutoTokenizer.from_pretrained(model_id))
model = AutoModelForCausalLM.from_pretrained(model_id, dtype=torch.bfloat16, device_map="cuda")
messages = [{"role": "user", "content": "Is it warmer in Lisbon or in Oslo right now? Answer in Fahrenheit."}]
prompt = tokenizer.apply_chat_template(messages, tools=[get_weather], add_generation_prompt=True)["input_ids"]
output = model.generate(torch.tensor([prompt], device="cuda"), max_new_tokens=128, do_sample=False)
print(parse_response(tokenizer, output[0, len(prompt) :].tolist(), prefix=prompt))
{'role': 'assistant', 'tool_calls': [{'type': 'function', 'function': {'name': 'get_weather', 'arguments': {'city': 'Lisbon', 'unit': 'fahrenheit'}}}, {'type': 'function', 'function': {'name': 'get_weather', 'arguments': {'city': 'Oslo', 'unit': 'fahrenheit'}}}], 'content': ''}