|
| 1 | +--- |
| 2 | +title: "Tutorial: Getting started with DeepSeek-R1 reasoning model in Azure AI model inference" |
| 3 | +titleSuffix: Azure AI Foundry |
| 4 | +description: Learn about the reasoning capabilities of DeepSeek-R1 in Azure AI model inference. |
| 5 | +manager: scottpolly |
| 6 | +ms.service: azure-ai-model-inference |
| 7 | +ms.topic: tutorial |
| 8 | +ms.date: 03/01/2025 |
| 9 | +ms.reviewer: fasantia |
| 10 | +ms.author: msakande |
| 11 | +author: mopeakande |
| 12 | +--- |
| 13 | + |
| 14 | +# Tutorial: Get started with DeepSeek-R1 reasoning model in Azure AI model inference |
| 15 | + |
| 16 | +In this tutorial, you learn: |
| 17 | + |
| 18 | +> [!div class="checklist"] |
| 19 | +> * How to create and configure the Azure resources to use DeepSeek-R1 model in Azure AI model inference. |
| 20 | +> * How to configure the model deployment. |
| 21 | +> * How to use DeepSeek-R1 using the Azure AI Inference SDK or REST APIs. |
| 22 | +> * How to use DeepSeek-R1 using other SDKs. |
| 23 | +
|
| 24 | +## Prerequisites |
| 25 | + |
| 26 | +To complete this article, you need: |
| 27 | + |
| 28 | +* An Azure subscription. If you're using [GitHub Models](https://docs.github.com/en/github-models/), you can upgrade your experience and create an Azure subscription in the process. Read [Upgrade from GitHub Models to Azure AI model inference](../../how-to/quickstart-github-models.md) if that's your case. |
| 29 | + |
| 30 | +[!INCLUDE [about-reasoning](../includes/use-chat-reasoning/about-reasoning.md)] |
| 31 | + |
| 32 | +## Create the resources |
| 33 | + |
| 34 | +Azure AI model inference is a capability in Azure AI Services resources in Azure. You can create model deployments under the resource to consume their predictions. You can also connect the resource to Azure AI Hubs and Projects in Azure AI Foundry to create intelligent applications if needed. The following picture shows the high level architecture. |
| 35 | + |
| 36 | +:::image type="content" source="../media/quickstart-get-started-deepseek-r1/resources-architecture.png" alt-text="A diagram showing the high level architecture of the resources created in the tutorial." lightbox="../media/quickstart-get-started-deepseek-r1/resources-architecture.png"::: |
| 37 | + |
| 38 | +To create an Azure AI project that supports model inference for DeepSeek-R1, follow these steps: |
| 39 | + |
| 40 | +1. Go to [Azure AI Foundry portal](https://ai.azure.com) and log in with your account. |
| 41 | + |
| 42 | +2. On the landing page, select **Create project**. |
| 43 | + |
| 44 | +3. Give the project a name, for example "my-project". |
| 45 | + |
| 46 | +4. In this tutorial, we create a brand new project under a new AI hub, hence, select **Create new hub**. Hubs are containers for multiple projects and allow you to share resources across all the projects. |
| 47 | + |
| 48 | +5. Give the hub a name, for example "my-hub" and select **Next**. |
| 49 | + |
| 50 | +6. The wizard updates with details about the resources that are going to be created. Select **Azure resources to be created** to see the details. |
| 51 | + |
| 52 | + :::image type="content" source="../media/create-resources/create-project-with-hub-details.png" alt-text="Screenshot showing the details of the project and hub to be created." lightbox="../media/create-resources/create-project-with-hub-details.png"::: |
| 53 | + |
| 54 | +7. You can see that the following resources are created: |
| 55 | + |
| 56 | + | Property | Description | |
| 57 | + | -------------- | ----------- | |
| 58 | + | Resource group | The main container for all the resources in Azure. This helps get resources that work together organized. It also helps to have a scope for the costs associated with the entire project. | |
| 59 | + | Location | The region of the resources that you're creating. | |
| 60 | + | Hub | The main container for AI projects in Azure AI Foundry. Hubs promote collaboration and allow you to store information for your projects. | |
| 61 | + | AI Services | The resource enabling access to the flagship models in Azure AI model catalog. In this tutorial, a new account is created, but Azure AI services resources can be shared across multiple hubs and projects. Hubs use a connection to the resource to have access to the model deployments available there. To learn how, you can create connections between projects and Azure AI Services to consume Azure AI model inference you can read [Connect your AI project](../../how-to/configure-project-connection.md). | |
| 62 | + |
| 63 | +8. Select **Create**. The resources creation process starts. |
| 64 | + |
| 65 | +9. Once completed, your project is ready to be configured. |
| 66 | + |
| 67 | +10. Azure AI model inference is a Preview feature that needs to be turned on in Azure AI Foundry. At the top navigation bar, over the right corner, select the **Preview features** icon. A contextual blade shows up at the right of the screen. |
| 68 | + |
| 69 | +11. Turn the feature **Deploy models to Azure AI model inference service** on. |
| 70 | + |
| 71 | + :::image type="content" source="../media/quickstart-ai-project/ai-project-inference-endpoint.gif" alt-text="An animation showing how to turn on the Azure AI model inference service deploy models feature in Azure AI Foundry portal." lightbox="../media/quickstart-ai-project/ai-project-inference-endpoint.gif"::: |
| 72 | + |
| 73 | +12. Close the panel. |
| 74 | + |
| 75 | + |
| 76 | +## Add DeepSeek-R1 model deployment |
| 77 | + |
| 78 | +Let's now create a new model deployment for DeepSeek-R1: |
| 79 | + |
| 80 | +1. Go to **Model catalog** section in [Azure AI Foundry portal](https://ai.azure.com/explore/models) and find the model [DeepSeek-R1]() model. |
| 81 | + |
| 82 | +3. You can review the details of the model in the model card. |
| 83 | + |
| 84 | +4. Select **Deploy**. |
| 85 | + |
| 86 | +5. The wizard shows the model's terms and conditions. DeepSeek-R1 is offered as a Microsoft first party consumption service. You can review our privacy and security commitments under [Data, privacy, and Security](). Accept the terms on those cases by selecting **Subscribe and deploy**. |
| 87 | + |
| 88 | + :::image type="content" source="../media/quickstart-get-started-deepseek-r1/models-deploy-agree.png" alt-text="Screenshot showing how to agree the terms and conditions of a DeepSeek-R1 model." lightbox="../media/quickstart-get-started-deepseek-r1/models-deploy-agree.png"::: |
| 89 | + |
| 90 | +6. You can configure the deployment settings at this time. By default, the deployment receives the name of the model you're deploying. The deployment name is used in the `model` parameter for request to route to this particular model deployment. This allows you to also configure specific names for your models when you attach specific configurations. |
| 91 | + |
| 92 | +7. We automatically select an Azure AI Services connection depending on your project. Use the **Customize** option to change the connection based on your needs. DeepSeek-R1 is currently offered under the **Global Standard** deployment type which offers higher throughput and performance. |
| 93 | + |
| 94 | +8. Select **Deploy**. |
| 95 | + |
| 96 | + :::image type="content" source="../media/quickstart-get-started-deepseek-r1/models-deploy.png" alt-text="Screenshot showing how to deploy the model." lightbox="../media/quickstart-get-started-deepseek-r1/models-deploy.png"::: |
| 97 | + |
| 98 | +9. Once the deployment completes, the new model is listed in the page and it's ready to be used. |
| 99 | + |
| 100 | +## Use the model in playground |
| 101 | + |
| 102 | +You can get started by using the model in the playground to have an idea of the model capabilities. |
| 103 | + |
| 104 | +1. On the deployment details page, select **Open in playground** option in the top bar. |
| 105 | + |
| 106 | +2. In the **Deployment** drop down, the deployment you created has been automatically selected. |
| 107 | + |
| 108 | +3. Configure the system prompt as needed. In general, reasoning models don't use system messages in the same way that other types of models. |
| 109 | + |
| 110 | + :::image type="content" source="../media/quickstart-get-started-deepseek-r1/playground-chat-models.png" alt-text="Screenshot showing how to select a model deployment to use in playground, configure the system message, and test it out." lightbox="../media/quickstart-get-started-deepseek-r1/playground-chat-models.png"::: |
| 111 | + |
| 112 | +4. Type your prompt and see the outputs. |
| 113 | + |
| 114 | +5. Additionally, you can use **View code** so see details about how to access the model deployment programmatically. |
| 115 | + |
| 116 | +[!INCLUDE [best-practices](../includes/use-chat-reasoning/best-practices.md)] |
| 117 | + |
| 118 | +## Use the model in code |
| 119 | + |
| 120 | +[!INCLUDE [code-chat-reasoning](../includes/code-create-chat-reasoning.md)] |
| 121 | + |
| 122 | +Reasoning may generate longer responses and consume a larger amount of tokens. You can see the [rate limits](../quotas-limits.md) that apply to DeepSeek-R1 models. Consider having a retry strategy to handle rate limits being applied. You can also [request increases to the default limits](../quotas-limits.md#request-increases-to-the-default-limits). |
| 123 | + |
| 124 | +### Parameters |
| 125 | + |
| 126 | +In general, reasoning models don't support the following parameters you can find in chat completion models: |
| 127 | + |
| 128 | +* Temperature |
| 129 | +* Presence penalty |
| 130 | +* Repetition penalty |
| 131 | +* Parameter `top_p` |
| 132 | + |
| 133 | +## Related content |
| 134 | + |
| 135 | +* [Use chat reasoning models](../how-to/use-chat-reasoning.md) |
| 136 | +* [Use image embedding models](../how-to/use-image-embeddings.md) |
| 137 | +* [Azure AI Model Inference API](.././reference/reference-model-inference-api.md) |
0 commit comments