다음을 통해 공유


자습서: Azure AI Foundry 모델에서 DeepSeek-R1 추론 모델 시작

이 자습서에서는 다음을 알아봅니다.

  • Azure AI Foundry 모델에서 DeepSeek-R1 사용하도록 Azure 리소스를 만들고 구성하는 방법입니다.
  • 모델 배포를 구성하는 방법입니다.
  • Azure AI 유추 SDK 또는 REST API를 사용하여 DeepSeek-R1 사용하는 방법입니다.
  • 다른 SDK에서 DeepSeek-R1 사용하는 방법입니다.

필수 조건

이 문서를 완료하려면 다음이 필요합니다.

추론 모델

추론 모델은 수학, 코딩, 과학, 전략 및 물류와 같은 도메인에서 더 높은 수준의 성능에 도달할 수 있습니다. 이러한 모델이 출력을 생성하는 방법은 대답을 생성하기 전에 생각 체인을 명시적으로 사용하여 가능한 모든 경로를 탐색하는 것입니다. 그들은 답변을 만들면서 확인하여 더 정확한 결론에 도달하는 데 도움이 됩니다. 결과적으로, 추론 모델은 효과적인 결과를 생성하기 위해 프롬프트에 더 적은 컨텍스트가 필요할 수 있습니다.

모델의 성능을 스케일링하는 이러한 방법은 더 높은 대기 시간 및 비용에 대해 성능을 거래하기 때문에 유추 컴퓨팅 시간 이라고 합니다. 반면, 다른 방법은 학습 컴퓨팅 시간을 통해 확장될 수 있습니다.

추론 모델은 다음 두 가지 유형의 콘텐츠를 출력으로 생성합니다.

  • 추론 완료
  • 출력 완료

이러한 두 완성은 모두 모델에서 생성된 콘텐츠에 포함됩니다. 따라서 모델과 관련된 토큰 제한 및 비용에 기여합니다. 같은 DeepSeek-R1일부 모델은 추론 콘텐츠로 응답할 수 있습니다. 다른 항목(예: o1)은 완료만 출력합니다.

리소스 만들기

Foundry 모델은 Azure의 Azure AI Foundry 리소스에 있는 기능입니다. 리소스에서 모델 배포를 만들어 예측을 사용할 수 있습니다. 필요한 경우 Azure AI Foundry의 Azure AI 허브 및 프로젝트에 리소스를 연결하여 지능형 애플리케이션을 만들 수도 있습니다.

DeepSeek-R1에 대한 배포를 지원하는 Azure AI 프로젝트를 만들려면 다음 단계를 수행합니다. Bicep을 사용하여 Azure CLI 또는 인프라를 코드로 사용하여 리소스를 만들 수도 있습니다.

팁 (조언)

Azure AI Foundry 포털에서 왼쪽 창을 사용자 지정할 수 있으므로 이러한 단계에 표시된 것과 다른 항목이 표시될 수 있습니다. 원하는 항목이 표시되지 않으면 왼쪽 창 아래쪽에 있는 ... 더 보기를 선택하십시오.

  1. Azure AI Foundry 포털에 로그인합니다.

  2. 방문 페이지의 헤더에 있는 미리 보기 기능 아이콘으로 이동하여 Azure AI Foundry 리소스에 모델 배포 기능이 켜져 있는지 확인합니다.

    Foundry 리소스에 배포를 사용하도록 설정하는 단계를 보여 주는 스크린샷

  3. 방문 페이지에서 "모델 및 기능 탐색" 섹션으로 이동하고 전체 모델 카탈로그로 이동하여 모델 카탈로그 를 엽니다. 모델 카탈로그 섹션을 보여 주는 Foundry 포털 홈페이지의 스크린샷.

  4. DeepSeek-R1 모델을 검색하고 해당 모델 카드를 엽니다.

  5. 이 모델 사용을 선택합니다. 이 작업을 수행하면 작업할 Azure AI Foundry 프로젝트 및 리소스를 만드는 마법사가 열립니다. 프로젝트의 기본 이름을 유지하거나 변경할 수 있습니다.

    팁 (조언)

    Azure AI Foundry 모델에서 Azure OpenAI를 사용하고 있나요? Azure OpenAI 리소스를 사용하여 Azure AI Foundry 포털에 연결된 경우 Azure OpenAI 모델만 카탈로그에 표시됩니다. DeepSeek-R1을 비롯한 전체 모델 목록을 보려면 상위 알림 섹션을 사용하고 더 많은 모델 탐색 옵션으로 카드를 찾습니다.

    카탈로그에서 모든 모델을 탐색하는 옵션이 있는 카드를 보여 주는 스크린샷.

    새 창에 전체 모델 목록이 표시됩니다. 목록에서 DeepSeek-R1 을 선택하고 배포를 선택합니다. 마법사에서 새 프로젝트를 만들도록 요청합니다.

  6. 마법사의 "고급 옵션" 섹션에서 드롭다운을 선택하여 프로젝트와 함께 만든 다른 기본값의 세부 정보를 확인합니다. 이러한 기본값은 최적의 기능을 위해 선택되며 다음을 포함합니다.

    재산 설명
    리소스 그룹 Azure의 모든 리소스에 대한 기본 컨테이너입니다. 이렇게 하면 함께 작동하는 리소스를 구성할 수 있습니다. 또한 전체 프로젝트와 관련된 비용에 대한 범위를 갖는 데 도움이 됩니다.
    지역 생성 중인 리소스의 지역입니다.
    AI Foundry 리소스 Azure AI 모델 카탈로그의 주력 모델에 액세스할 수 있는 리소스입니다. 이 자습서에서는 새 계정이 만들어지지만 Azure AI Foundry 리소스(이전의 Azure AI Services 리소스)는 여러 허브 및 프로젝트에서 공유할 수 있습니다. 허브는 리소스에 대한 연결을 사용하여 사용 가능한 모델 배포에 액세스할 수 있습니다. 모델을 사용하는 Azure AI Foundry 리소스에 대한 연결을 만드는 방법을 알아보려면 AI 프로젝트 연결을 참조하세요.
  7. 만들기를 선택하여 다른 기본값과 함께 Foundry 프로젝트를 만듭니다. 프로젝트 만들기가 완료될 때까지 기다립니다. 이 작업에는 몇 분이 소요됩니다.

모델 배포

  1. 프로젝트 및 리소스가 만들어지면 배포 마법사가 나타납니다. DeepSeek-R1은 Microsoft의 자사 소비 서비스로 제공됩니다. 데이터, 개인 정보 및 보안에 따라 개인 정보 보호 및 보안 약정을 검토할 수 있습니다.

  2. 가격 책정 및 약관 탭을 선택하여 모델에 대한 가격 책정 세부 정보를 검토합니다.

  3. 동의를 선택하고 계속 진행하여 배포를 계속합니다.

  4. 이때 배포 설정을 구성할 수 있습니다. 기본적으로 배포는 배포하는 모델의 이름을 받습니다. 배포 이름은 이 특정 모델 배포로 model 라우팅하기 위한 요청에 대한 매개 변수에 사용됩니다. 이를 통해 특정 구성을 첨부할 때 모델에 대한 특정 이름도 구성할 수 있습니다.

  5. Azure AI Foundry는 프로젝트에서 이전에 만든 Foundry 리소스를 자동으로 선택합니다. 사용자 지정 옵션을 사용하여 필요에 따라 연결을 변경합니다. DeepSeek-R1 현재 더 높은 처리량과 성능을 제공하는 Global Standard 배포 유형에 따라 제공됩니다.

    모델을 배포하는 방법을 보여 주는 스크린샷

  6. 배포를 선택합니다.

  7. 배포가 완료되면 배포 세부 정보 페이지가 열립니다. 이제 새 모델을 사용할 준비가 되었습니다.

놀이터에서 모델 사용

실습에서 모델을 사용하여 모델의 기능을 파악할 수 있습니다.

  1. 배포 세부 정보 페이지의 위쪽 표시줄 에서 플레이그라운드 열기 를 선택합니다. 이 작업은 채팅 플레이그라운드를 엽니다.

  2. 채팅 플레이그라운드의 배포 드롭다운에서 만든 배포가 이미 자동으로 선택되어 있습니다.

  3. 필요에 따라 시스템 프롬프트를 구성합니다. 일반적으로 추론 모델은 다른 유형의 모델과 동일한 방식으로 시스템 메시지를 사용하지 않습니다.

    플레이그라운드에서 사용할 모델 배포를 선택하고, 시스템 메시지를 구성하고, 테스트하는 방법을 보여 주는 스크린샷

  4. 프롬프트를 입력하고 출력을 확인합니다.

  5. 또한 보기 코드를 사용하여 프로그래밍 방식으로 모델 배포에 액세스하는 방법에 대한 세부 정보를 볼 수 있습니다.

프롬프트 추론 모델

추론 모델에 대한 프롬프트를 작성할 때 다음 사항을 고려합니다.

  • 간단한 지침을 사용하고 생각의 사슬 기술을 사용하지 마십시오.
  • 기본 제공 추론 기능은 간단한 제로샷 프롬프트를 보다 복잡한 메서드만큼 효과적으로 만듭니다.
  • RAG 시나리오와 같은 추가 컨텍스트 또는 문서를 제공할 때 가장 관련성이 큰 정보만 포함하면 모델이 응답을 과도하게 복잡하게 만드는 것을 방지할 수 있습니다.
  • 추론 모델은 시스템 메시지의 사용을 지원할 수 있습니다. 그러나 다른 비이성적 모델만큼 엄격하게 따르지 않을 수도 있습니다.
  • 멀티 턴 애플리케이션을 만들 때 추론 콘텐츠 섹션에 설명된 대로 추론 콘텐츠 없이 모델의 최종 답변만 추가해 보세요.

추론 모델은 응답을 생성하는 데 시간이 더 오래 걸릴 수 있습니다. 그들은 더 깊고 구조화 된 문제 해결을 가능하게 생각의 긴 추론 체인을 사용합니다. 또한 자체 확인을 수행하여 답변을 교차 확인하고 실수를 수정하여 새로운 자기 반사 동작을 보여 줍니다.

코드에서 모델 사용

Foundry 모델 엔드포인트 및 자격 증명을 사용하여 모델에 연결합니다.

배포와 연결된 URL 및 키를 가져오는 방법을 보여 주는 스크린샷

Azure AI 모델 유추 패키지를 사용하여 코드에서 모델을 사용할 수 있습니다.

pip와 같은 패키지 관리 시스템을 사용하여 azure-ai-inference 패키지를 설치합니다.

pip install azure-ai-inference

그런 다음 패키지를 사용하여 모델을 활용할 수 있습니다. 다음 예는 채팅 완성을 활용하는 클라이언트를 생성하는 방법을 보여 줍니다.

import os
from azure.ai.inference import ChatCompletionsClient
from azure.core.credentials import AzureKeyCredential

client = ChatCompletionsClient(
    endpoint="https://<resource>.services.ai.azure.com/models",
    credential=AzureKeyCredential(os.environ["AZURE_INFERENCE_CREDENTIAL"]),
)

시작하려면 샘플을 살펴보고 API 참조 설명서를 참조하세요.

from azure.ai.inference.models import SystemMessage, UserMessage

response = client.complete(
    messages=[
        UserMessage(content="How many languages are in the world?"),
    ],
    model="DeepSeek-R1"
)

print(response.choices[0].message.content)

추론은 더 긴 응답을 생성하고 더 많은 수의 토큰을 사용할 수 있습니다. DeepSeek-R1 모델에 적용되는 속도 제한을 볼 수 있습니다. 적용되는 속도 제한을 처리하기 위한 재시도 전략을 사용하는 것이 좋습니다. 기본 한도로 증가를 요청할 수도 있습니다.

추론 콘텐츠

DeepSeek-R1과 같은 일부 추론 모델은 완성을 생성하고 그 뒤에 추론을 포함합니다. 완료와 관련된 추론은 태그 <think></think> 내의 응답 콘텐츠에 포함됩니다. 모델은 추론 콘텐츠를 생성할 시나리오를 선택할 수 있습니다. 다음 예제에서는 Python을 사용하여 추론 콘텐츠를 생성하는 방법을 보여줍니다.

import re

match = re.match(r"<think>(.*?)</think>(.*)", response.choices[0].message.content, re.DOTALL)

print("Response:", )
if match:
    print("\tThinking:", match.group(1))
    print("\tAnswer:", match.group(2))
else:
    print("\tAnswer:", response.choices[0].message.content)
print("Model:", response.model)
print("Usage:")
print("\tPrompt tokens:", response.usage.prompt_tokens)
print("\tTotal tokens:", response.usage.total_tokens)
print("\tCompletion tokens:", response.usage.completion_tokens)
Thinking: Okay, the user is asking how many languages exist in the world. I need to provide a clear and accurate answer. Let's start by recalling the general consensus from linguistic sources. I remember that the number often cited is around 7,000, but maybe I should check some reputable organizations.\n\nEthnologue is a well-known resource for language data, and I think they list about 7,000 languages. But wait, do they update their numbers? It might be around 7,100 or so. Also, the exact count can vary because some sources might categorize dialects differently or have more recent data. \n\nAnother thing to consider is language endangerment. Many languages are endangered, with some having only a few speakers left. Organizations like UNESCO track endangered languages, so mentioning that adds context. Also, the distribution isn't even. Some countries have hundreds of languages, like Papua New Guinea with over 800, while others have just a few. \n\nA user might also wonder why the exact number is hard to pin down. It's because the distinction between a language and a dialect can be political or cultural. For example, Mandarin and Cantonese are considered dialects of Chinese by some, but they're mutually unintelligible, so others classify them as separate languages. Also, some regions are under-researched, making it hard to document all languages. \n\nI should also touch on language families. The 7,000 languages are grouped into families like Indo-European, Sino-Tibetan, Niger-Congo, etc. Maybe mention a few of the largest families. But wait, the question is just about the count, not the families. Still, it's good to provide a bit more context. \n\nI need to make sure the information is up-to-date. Let me think – recent estimates still hover around 7,000. However, languages are dying out rapidly, so the number decreases over time. Including that note about endangerment and language extinction rates could be helpful. For instance, it's often stated that a language dies every few weeks. \n\nAnother point is sign languages. Does the count include them? Ethnologue includes some, but not all sources might. If the user is including sign languages, that adds more to the count, but I think the 7,000 figure typically refers to spoken languages. For thoroughness, maybe mention that there are also over 300 sign languages. \n\nSummarizing, the answer should state around 7,000, mention Ethnologue's figure, explain why the exact number varies, touch on endangerment, and possibly note sign languages as a separate category. Also, a brief mention of Papua New Guinea as the most linguistically diverse country. \n\nWait, let me verify Ethnologue's current number. As of their latest edition (25th, 2022), they list 7,168 living languages. But I should check if that's the case. Some sources might round to 7,000. Also, SIL International publishes Ethnologue, so citing them as reference makes sense. \n\nOther sources, like Glottolog, might have a different count because they use different criteria. Glottolog might list around 7,000 as well, but exact numbers vary. It's important to highlight that the count isn't exact because of differing definitions and ongoing research. \n\nIn conclusion, the approximate number is 7,000, with Ethnologue being a key source, considerations of endangerment, and the challenges in counting due to dialect vs. language distinctions. I should make sure the answer is clear, acknowledges the variability, and provides key points succinctly.

Answer: The exact number of languages in the world is challenging to determine due to differences in definitions (e.g., distinguishing languages from dialects) and ongoing documentation efforts. However, widely cited estimates suggest there are approximately **7,000 languages** globally.
Model: DeepSeek-R1
Usage: 
  Prompt tokens: 11
  Total tokens: 897
  Completion tokens: 886

매개 변수

일반적으로 추론 모델은 채팅 완성 모델에서 찾을 수 있는 다음 매개 변수를 지원하지 않습니다.

  • 온도
  • 현재 상태 패널티
  • 반복 페널티
  • 매개 변수 top_p