> This page is for version Latest.
> For other versions, use one of these documentation indexes:
> - Nightly (default): https://docs.nvidia.com/nemo/automodel/nightly/llms.txt
> - Latest: https://docs.nvidia.com/nemo/automodel/latest/llms.txt
> - 0.7.0 · 26.10: https://docs.nvidia.com/nemo/automodel/v0.7/llms.txt
> - 0.5.0 · 26.06: https://docs.nvidia.com/nemo/automodel/v0.5/llms.txt
> - 0.4.0 · 26.04: https://docs.nvidia.com/nemo/automodel/v0.4/llms.txt

> 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-2

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

[Microsoft's Phi](https://azure.microsoft.com/en-us/products/phi) are compact, high-capability language models designed to punch above their weight class. Phi-1.5 and Phi-2 use a standard transformer decoder architecture (`PhiForCausalLM`). For Phi-3 and Phi-4 see [Phi-3 / Phi-4](/nemo/automodel/latest/model-coverage/large-language-models/microsoft/Phi-4).

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

## Fine-Tune phi-2

From the repository root, run:

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

## Choose a Workflow

| Goal                                          | Start Here                                                                                                                         |
| --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| Supervised fine-tuning (SFT) - Phi-2 on SQuAD | Use [phi_2_squad.yaml](https://github.com/NVIDIA-NeMo/Automodel/blob/r0.7.0/examples/llm_finetune/phi/phi_2_squad.yaml).           |
| Low-rank adaptation (LoRA) - Phi-2 on SQuAD   | Use [phi_2_squad_peft.yaml](https://github.com/NVIDIA-NeMo/Automodel/blob/r0.7.0/examples/llm_finetune/phi/phi_2_squad_peft.yaml). |

## Model Reference

### Model Architecture

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

### Available Models

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

## Related Resources

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