Spaces:
Sleeping
A newer version of the Gradio SDK is available: 6.26.0
title: LFM2.5 Tool Use
emoji: 🛠️
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.49.1
app_file: app.py
pinned: false
tags:
- tool-use
- liquid
- lfm2.5
- zerogpu
LFM2.5-1.2B-Thinking Tool-Calling Demo
A Hugging Face ZeroGPU Space that runs LiquidAI's LFM2.5-1.2B-Thinking in-process with transformers and shows it performing tool (function) calling in a Gradio chat UI.
Hardware: set this Space to ZeroGPU in Settings → Hardware (then Restart). The
respondhandler is decorated with@spaces.GPU, so the model loads inbfloat16on an attached GPU per request.
The model can call two mocked tools:
web_search(query)— returns canned search resultssend_email(to, subject, body)— pretends to send an email
How it works
LFM2.5 emits tool calls in its native Pythonic format, wrapped in special tokens:
<|tool_call_start|>[web_search(query="liquid ai lfm")]<|tool_call_end|>
app.py parses that with the ast module, executes the matching tool, feeds the JSON result back as a tool-role message, and lets the model produce a final answer — looping up to 5 turns. Tokens stream into the UI as they generate.
Note: the LFM2.5-1.2B chat template has a known bug where a structured
tool_callsfield is dropped on re-render, which breaks multi-turn tool calling. To avoid it we store the raw assistant text (special tokens intact) in the conversation history instead of relying ontool_calls.
ZeroGPU & bfloat16
The Space runs on ZeroGPU (shared GPU allocated per request). The model is loaded in bfloat16 onto the attached GPU inside the @spaces.GPU-decorated handler — ~2.4 GB, well within a T4's 16 GB. Generation streams into the UI; the whole multi-turn loop runs within one @spaces.GPU(duration=180) call.
Run locally
pip install -r requirements.txt
python app.py
Adapted from the original Ollama-based main.py. Tool-calling reference: Liquid docs.