> 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](/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](/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/main/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/main/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](/recipes-e2e-examples/sft-peft)