DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to finetune a small LLM on your own JSON dataset with Litgpt

Use the Litgpt finetune command to train microsoft/phi-2 on a JSON file of examples, then chat with and serve the result.

Short answer: Install with pip install 'litgpt[extra]'; then download the example dataset with curl -L https://huggingface.co/datasets/ksaw008/finance_alpaca/resolve/main/finance_alpaca.json -o my_custom_dataset.json or point to your own JSON file; run litgpt finetune microsoft/phi-2 with --data JSON, --data.json_path my_custom_dataset.json, --data.val_split_fraction 0.1 and --out_dir out/custom-model. All steps.

  • Top pick
  • Software and DevOps
  • Intermediate
  • 1 to 3 hours
  • From the README
  • Claude Code
  • Codex
  • Cursor
  • Gemini CLI

download. The first run downloads the base model weights, which can be several gigabytes.

Who it is forA developer with a few thousand question and answer pairs from their own domain.

The problemGeneric models answer domain questions vaguely, and writing a training loop takes days.

The outcomeA finetuned checkpoint in out/custom-model/final that you can chat with and serve.

What you need first

  • Python with pip
  • A GPU for finetuning and pretraining
  • Disk space for model weights

Steps

  1. Install with pip install 'litgpt[extra]'
  2. Download the example dataset with curl -L https://huggingface.co/datasets/ksaw008/finance_alpaca/resolve/main/finance_alpaca.json -o my_custom_dataset.json or point to your own JSON file
  3. Run litgpt finetune microsoft/phi-2 with --data JSON, --data.json_path my_custom_dataset.json, --data.val_split_fraction 0.1 and --out_dir out/custom-model
  4. Test the result with litgpt chat out/custom-model/final
  5. Deploy it with litgpt serve out/custom-model/final

Prompt for your agent

Using Lightning-AI/litgpt, install it with `pip install 'litgpt[extra]'`, finetune microsoft/phi-2 on <my JSON dataset> with `litgpt finetune microsoft/phi-2 --data JSON --data.json_path my_custom_dataset.json --data.val_split_fraction 0.1 --out_dir out/custom-model`, then run `litgpt chat out/custom-model/final` and report five sample answers.

Caveat. Finetuning needs a GPU; training time depends on the dataset size and the card.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for Lightning-AI/litgpt and "Finetune a small LLM on your own JSON dataset"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer