> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/automodel/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/automodel/_mcp/server.

# Phi-4

> Use Phi-4 with NeMo AutoModel for language model fine-tuning, with documented checkpoints, runnable recipes, setup guidance, and model reference details.

[Phi-3](https://azure.microsoft.com/en-us/products/phi) and [Phi-4](https://azure.microsoft.com/en-us/products/phi) are Microsoft's high-capability small language models using a shared transformer decoder architecture (`Phi3ForCausalLM`). Phi-4-mini and Phi-4 achieve strong benchmark results at relatively small parameter counts.

Set up NeMo AutoModel with the [latest container](https://catalog.ngc.nvidia.com/orgs/nvidia/containers/nemo-automodel) or follow the [installation instructions](/get-started/installation).

## Fine-Tune Phi-4

From the repository root, run:

```bash
uv run automodel --nproc-per-node=8 examples/llm_finetune/phi/phi_4_squad.yaml
```

## Choose a Workflow

| Goal                                          | Start Here                                                                                                                          |
| --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| Supervised fine-tuning (SFT) - Phi-4 on SQuAD | Use [phi\_4\_squad.yaml](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/llm_finetune/phi/phi_4_squad.yaml).            |
| Low-rank adaptation (LoRA) - Phi-4 on SQuAD   | Use [phi\_4\_squad\_peft.yaml](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/llm_finetune/phi/phi_4_squad_peft.yaml). |

## Model Reference

### Model Architecture

| Property                  | Value                                         |
| ------------------------- | --------------------------------------------- |
| Task                      | Text Generation                               |
| Architecture              | `Phi3ForCausalLM`                             |
| Parameters                | 14B                                           |
| Hugging Face Organization | [microsoft](https://huggingface.co/microsoft) |

### Available Models

| Model | HF ID                                                       |
| ----- | ----------------------------------------------------------- |
| Phi-4 | [`microsoft/Phi-4`](https://huggingface.co/microsoft/Phi-4) |
| phi-4 | [`microsoft/phi-4`](https://huggingface.co/microsoft/phi-4) |

## Related Resources

* [LLM Fine-Tuning Guide](/recipes-e2e-examples/sft-peft)