MLX
lora
nushell
tool-calling

LFM3 1.7B, LoRA for Nushell tool calls

A LoRA on LiquidAI/LFM3-1.7B that turns a plain request into one run_nushell tool call. It was trained with MLX on a Mac, on a dataset generated from scratch, and scored by executing its calls: a call is correct only if running it returns the reference value.

On all 231 held-out requests Well-formed Runs Returns the reference value 95% interval Seconds per request
LFM3 1.7B with this adapter 100% 98% 92.6% (214) 88.5–95.4% 1.18
gpt-6-luna (reasoning off) 100% 74% 22.1% (51) 17.2–27.9% 2.05
claude-haiku-5-5 100% 90% 13.0% (30) 9.3–17.9% 1.10

The base model, before training, is correct on 8% of the 40 requests it was run on (3 of 40); the adapter gets 95% of those 40. The other models got the same system prompt, tool and user text, with no examples. There is one reference value per request and it is compared exactly, so a call that answers in another shape counts as wrong. Times are not like for like: ours is generation on one Mac with MLX, the others are whole requests to a hosted endpoint.

The 231 requests come from four generated projects the model never saw in training.

It also works at 2 bits. With the base weights stored at 2.25 bits each (412 MB for the 24 blocks, down from 8 bits), retrained block by block and then distilled against the full model, it is correct on 190 of the same 231 requests: 82.3%, against 92.6%. Requantising to 2 bits without retraining gives 0%. The code is experiments/lowbit.py in the repository; the 2-bit weights themselves are not uploaded yet.

What is here

  • adapter.safetensors: LoRA weights for every linear layer of the 24 blocks (rank 8, alpha 16, 8.2 M parameters), in the names mlx_lm.tuner.lora.LoRALinear uses.
  • prompt_format.json: the system prompt, the tool definition, the assistant prefix and the stop strings it was trained with.
  • adapter_config.json: the settings above.

Use

The repository has the loader and the prompt builder:

from mlx_vlm import load
from nushell_lfm.lora import attach_lora, set_lora
from nushell_lfm.target import generate

model, processor = load("path/to/lfm3-1.7b-mlx-8bit")
lm, layers, _ = attach_lora(model, rank=8, alpha=16.0, dropout=0.0, placement="all_linear")
lm.load_weights("adapter.safetensors", strict=False)
set_lora(layers, training=False)
row = {"speech": "List what is in etc and give it to me as JSON.", "context": "A project checkout. Paths are relative to the workspace root.", "workspace_files": ["etc/app.toml", "etc/flags.json"]}
print(generate(lm, processor.tokenizer, row, max_new=220))

The request goes in as: the system prompt, then a user turn of Request: …, Workspace: …, Files: … (optionally preceded by syntax references), with the tool definition, and the assistant turn started with <tool_call>.

Training

825 rows × 2 epochs (414 updates), batch 4, learning rate 2e-4 with warm-up and cosine decay, AdamW, gradient clipping at 1.0, on the 8-bit MLX build. The setting was chosen by a sweep over rank and learning rate and an ablation of where the adapter goes, each scored by execution on 24 held-out requests.

Limits

  • It knows the kinds of request in its dataset: file listing and search, text and table operations, config lookups, pipelines with recovery. SQL, dataframes and multi-step agents were out of scope.
  • Held-out projects share chain patterns with training; the score is for a known kind of request in an unseen project.
  • Generated commands should be run somewhere they can do no harm. The repository runs them in a throwaway copy of the project.

Links

Sources

Base model: LiquidAI/LFM3-1.7B. Method: Hu et al., LoRA: Low-Rank Adaptation of Large Language Models, ICLR 2022 (arXiv:2106.09685). Commands and their signatures: Nushell 0.117.0. Sampling weights: the Nushell book and cookbook; NL2Bash (Lin et al., LREC 2018); spignelon/bash_history; Shell Aliases on GitHub (Schröder & Cito, 2022). The full list is in the repository's CITATIONS.md.

Downloads last month

-

Downloads are not tracked for this model. How to track
MLX
Hardware compatibility
Log In to add your hardware

Quantized

Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for maxhugger/nushell-lfm3-1.7b-lora

Adapter
(55)
this model

Dataset used to train maxhugger/nushell-lfm3-1.7b-lora

Paper for maxhugger/nushell-lfm3-1.7b-lora