Instructions to use maxhugger/nushell-lfm3-1.7b-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use maxhugger/nushell-lfm3-1.7b-lora with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download maxhugger/nushell-lfm3-1.7b-lora --local-dir nushell-lfm3-1.7b-lora
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
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 namesmlx_lm.tuner.lora.LoRALinearuses.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
- Code, notebook and how everything was made: maxtheman/nushell-lfm
- LoRA adapter (MLX): maxhugger/nushell-lfm3-1.7b-lora
- ONNX build for the browser: maxhugger/nushell-lfm3-1.7b-onnx
- Dataset: maxhugger/nushell-tool-calls
- Demo in the browser: nushell-lfm-demo
- Nushell in WebAssembly on its own: nu-wasm
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.
Quantized