Run this model with HF Jobs
Run samadpls/torchlight-phi4-mini-GGUF on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/samadpls/torchlight-phi4-mini-GGUF. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/samadpls/torchlight-phi4-mini-GGUF on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/samadpls/torchlight-phi4-mini-GGUF. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Instructions to use samadpls/torchlight-phi4-mini-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use samadpls/torchlight-phi4-mini-GGUF with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("samadpls/torchlight-phi4-mini-GGUF") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use samadpls/torchlight-phi4-mini-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf samadpls/torchlight-phi4-mini-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf samadpls/torchlight-phi4-mini-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf samadpls/torchlight-phi4-mini-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf samadpls/torchlight-phi4-mini-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf samadpls/torchlight-phi4-mini-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf samadpls/torchlight-phi4-mini-GGUF:Q4_K_M
Use Docker
docker model run hf.co/samadpls/torchlight-phi4-mini-GGUF:Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use samadpls/torchlight-phi4-mini-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "samadpls/torchlight-phi4-mini-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "samadpls/torchlight-phi4-mini-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/samadpls/torchlight-phi4-mini-GGUF:Q4_K_M
- Ollama
How to use samadpls/torchlight-phi4-mini-GGUF with Ollama:
ollama run hf.co/samadpls/torchlight-phi4-mini-GGUF:Q4_K_M
- Unsloth Desktop
- Pi
How to use samadpls/torchlight-phi4-mini-GGUF with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "samadpls/torchlight-phi4-mini-GGUF"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "samadpls/torchlight-phi4-mini-GGUF" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use samadpls/torchlight-phi4-mini-GGUF with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "samadpls/torchlight-phi4-mini-GGUF"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "samadpls/torchlight-phi4-mini-GGUF" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8080/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "samadpls/torchlight-phi4-mini-GGUF", "messages": [ {"role": "user", "content": "Hello"} ] }' - Docker Model Runner
How to use samadpls/torchlight-phi4-mini-GGUF with Docker Model Runner:
docker model run hf.co/samadpls/torchlight-phi4-mini-GGUF:Q4_K_M
- Lemonade
How to use samadpls/torchlight-phi4-mini-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull samadpls/torchlight-phi4-mini-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.torchlight-phi4-mini-GGUF-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use samadpls/torchlight-phi4-mini-GGUF with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "samadpls/torchlight-phi4-mini-GGUF"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default samadpls/torchlight-phi4-mini-GGUF
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use samadpls/torchlight-phi4-mini-GGUF with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "samadpls/torchlight-phi4-mini-GGUF"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "samadpls/torchlight-phi4-mini-GGUF" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Add the model card
Browse filesFiles changed (4)
- .gitattributes+2
- README.mdAdded+178
- assets/hero.pngAdded
- assets/training-loss.pngAdded
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines333435363732 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textassets/hero.png filter=lfs diff=lfs merge=lfs -textassets/training-loss.png filter=lfs diff=lfs merge=lfs -text
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178---license: mitlanguage:- enbase_model: samadpls/torchlight-phi4-minibase_model_relation: quantizedpipeline_tag: text-generationdatasets:- samadpls/torchlight-threadstags:- pytorch- code- debugging- lora- mlx- phi3- gguf---
<p align="center"> <img alt="torchlight" src="https://huggingface.co/samadpls/torchlight-phi4-mini-GGUF/resolve/main/assets/hero.png" width="100%"></p>
<p align="center"> <a href="https://github.com/samadpls/torchlight"><img alt="GitHub" src="https://img.shields.io/badge/GitHub-samadpls%2Ftorchlight-181717?logo=github"></a> <a href="https://huggingface.co/datasets/samadpls/torchlight-threads"><img alt="Dataset" src="https://img.shields.io/badge/dataset-torchlight--threads-FFD21E?logo=huggingface&logoColor=000"></a> <a href="https://huggingface.co/microsoft/Phi-4-mini-instruct"><img alt="Base model: Phi-4-mini-instruct" src="https://img.shields.io/badge/base-Phi--4--mini--instruct-555"></a> <img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-EE4C2C"> <a href="https://samadpls.com"><img alt="samadpls.com" src="https://img.shields.io/badge/by-samadpls.com-EE4C2C"></a></p>
# torchlight-phi4-mini-GGUF
> This repo has GGUF files of [`samadpls/torchlight-phi4-mini`](https://huggingface.co/samadpls/torchlight-phi4-mini) for llama.cpp, Ollama and LM Studio.
## Model Overview
torchlight is a small model that helps with PyTorch questions. It is [Phi-4-mini-instruct](https://huggingface.co/microsoft/Phi-4-mini-instruct) (3.8B parameters), fine-tuned on 6,918 questions from the [PyTorch forums](https://discuss.pytorch.org). Each question is paired with the answer that solved it.
It is built not to guess. When a question has enough detail, it suggests a fix. When it doesn't, it asks for the code or the full error.
- **Trained on real answers.** Each answer is the post that solved the thread. Most were written by [ptrblck](https://discuss.pytorch.org/u/ptrblck).- **Tested on new questions.** 260 forum questions that are newer than anything the model saw in training.- **Trained on a laptop.** 6.3 hours on a MacBook Pro (M3 Pro).
## Model Details
| | ||---|---|| **Base model** | [`microsoft/Phi-4-mini-instruct`](https://huggingface.co/microsoft/Phi-4-mini-instruct) || **Size** | 3.8B parameters (11.5M trained with LoRA) || **Training data** | [`samadpls/torchlight-threads`](https://huggingface.co/datasets/samadpls/torchlight-threads) || **Language** | English || **License** | MIT || **Author** | [Abdul Samad](https://samadpls.com) || **Code** | [github.com/samadpls/torchlight](https://github.com/samadpls/torchlight) |
The model comes in three versions:
| Repo | What it is | Use it with ||---|---|---|| [`samadpls/torchlight-phi4-mini`](https://huggingface.co/samadpls/torchlight-phi4-mini) | Full model (16-bit) | transformers, mlx-lm || [`samadpls/torchlight-phi4-mini-lora`](https://huggingface.co/samadpls/torchlight-phi4-mini-lora) | LoRA adapter only | PEFT, mlx-lm || [`samadpls/torchlight-phi4-mini-GGUF`](https://huggingface.co/samadpls/torchlight-phi4-mini-GGUF) | GGUF files (Q4_K_M, Q8_0) | llama.cpp, Ollama, LM Studio |
## ⚡ Quickstart
| File | Size | Notes ||---|---|---|| `torchlight-phi4-mini-Q4_K_M.gguf` | 2.5 GB | Smaller and faster; a good default || `torchlight-phi4-mini-Q8_0.gguf` | 4.1 GB | Closer to the full model; about twice the size |
### llama.cpp
```bashllama-cli -hf samadpls/torchlight-phi4-mini-GGUF:Q4_K_M -sys "You are a careful PyTorch helper. Give specific, correct guidance with code where it helps. If a question lacks the details needed to answer it, ask for them, for example a minimal executable code snippet or the full error message, instead of guessing."```
### Ollama
Set the system prompt with `/set system` once it starts.
```bashollama run hf.co/samadpls/torchlight-phi4-mini-GGUF:Q4_K_M```
Use the same system prompt as in the examples. The model was trained with it.
## 📊 Evaluation
We ask 260 forum questions from 2025-01-01 to 2026-10-08 to five setups. Claude Opus 5.5, acting as judge, scores each answer from 1 to 5 by comparing it with the answer that solved the thread.
The evaluation is still running. Results will be added here when it finishes.
<details><summary><b>How the test works</b></summary>
- **Setups.** Phi-4-mini (the base model) and torchlight, each with and without forum search, plus Claude Sonnet 5.5 with forum search as a reference. Search covers 7,438 solved forum threads, up to twice per question.- **Settings.** The local models use greedy decoding (no sampling) and up to 1,024 new tokens.- **Scoring.** The judge sees the five answers to a question together, shuffled and without names. It follows [`prompts/judge.md`](https://github.com/samadpls/torchlight/blob/main/prompts/judge.md).- **Valid torch APIs.** A script checks that every `torch.*` name in an answer's code exists in PyTorch 2.15.- **Asks for details.** How often an answer asks for more information. This is measured on the 7 questions where the expert also asked, and on the other 253, where asking less is better.- **Note on Claude Sonnet 5.5.** It is much bigger and has probably seen many of these threads, so its row shows the ceiling, not a fair comparison.
</details>
## Training Details
**Data.** 6,918 chats from forum threads created before 2024-07-01. Each chat ends with the answer that solved the thread. 7 chats longer than 4,096 tokens were left out. The 169 validation chats come from 2024-07-01 to 2025-01-01. The test questions are newer than both.
**Settings.**
| | ||---|---|| Method | LoRA on the top 16 of 32 layers; the base weights stay frozen || LoRA rank / alpha | 16 / 32 || Learning rate | 2e-4, cosine schedule, 43 warmup steps || Batch | 2 chats, 4 accumulation steps (8 chats per update) || Epochs | 1 (3,459 batches) || Max length | 4,096 tokens || Loss | On the final answer only || Optimizer | AdamW, weight decay 0.01 || Hardware | MacBook Pro (M3 Pro), 6.3 hours || Software | mlx-lm 0.32.2, MLX 0.32.4 |
**Training results.**
<p align="center"> <img alt="Training and validation loss" src="https://huggingface.co/samadpls/torchlight-phi4-mini-GGUF/resolve/main/assets/training-loss.png" width="100%"></p>
| Epoch | Batch | Training loss | Validation loss ||---|---|---|---|| 0.00 | 0 | - | 3.280 || 0.14 | 500 | 1.995 | - || 0.29 | 1,000 | 1.738 | 1.554 || 0.43 | 1,500 | 1.713 | - || 0.58 | 2,000 | 1.674 | 1.511 || 0.72 | 2,500 | 1.665 | - || 0.87 | 3,000 | 1.623 | 1.497 || 1.00 | 3,459 | 1.687 | 1.495 |
Training loss is the average since the previous row. Batch 0 is the base model before training.
## Intended Use
**Good for:** PyTorch questions about errors, tensor shapes, training loops, data loading and CUDA.
**Not for:** code you run without reading, other frameworks, PyTorch features from after mid-2024, or anything where a wrong answer can cause harm.
## ⚠️ Limitations
- It is a small model and can be wrong while sounding sure. Check its code.- It learned the forum's style, so its answers are short. Sometimes they are too short to help on their own.- It knows PyTorch up to mid-2024, not version 2.4 or later.- The training data leans toward ptrblck's topics: debugging, CUDA, training loops and shape errors.- English only.
## License and Credits
The model is released under the MIT license, like the base model. The training data, [`samadpls/torchlight-threads`](https://huggingface.co/datasets/samadpls/torchlight-threads), is under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). The answers in it were written by the [PyTorch forum](https://discuss.pytorch.org) community, above all [ptrblck](https://discuss.pytorch.org/u/ptrblck), and every row links to its thread. This model is not made or endorsed by PyTorch or the Linux Foundation.
## Citation
```bibtex@misc{samad2026torchlight_model, author = {Abdul Samad}, title = {torchlight: a PyTorch helper fine-tuned on resolved forum threads}, year = {2026}, url = {https://huggingface.co/samadpls/torchlight-phi4-mini}}```
## Contact
Made by **Abdul Samad** ([samadpls.com](https://samadpls.com) · [GitHub @samadpls](https://github.com/samadpls)). Questions or corrections: abdulsamadsid1@gmail.com.
Large File Pointer Details
- SHA256: 7da338ee341f077b9d0dd9aa4cfcd782038900d10adc31d4051e653c5bbb7e6d
- Pointer size: 132 Bytes
- Size of remote file: 1.14 MB

Large File Pointer Details
- SHA256: bd1fb90e68e16c671980dc9cba0ddd058c5b7a9f4b6a6379735447f540513f35
- Pointer size: 131 Bytes
- Size of remote file: 148 kB