다음을 통해 공유


재현 가능한 출력(미리 보기)을 사용하는 방법 알아보기

기본적으로 Azure OpenAI 채팅 완료 모델에 동일한 질문을 여러 번 요청하면 다른 응답을 가져올 가능성이 높습니다. 따라서 응답은 비결정적인 것으로 간주됩니다. 재현 가능한 출력은 보다 결정적인 출력을 생성하기 위해 기본 동작을 선택적으로 변경할 수 있는 새로운 미리 보기 기능입니다.

재현 가능한 출력 지원

재현 가능한 출력은 현재 다음에서만 지원됩니다.

지원되는 모델

  • gpt-35-turbo(1106)
  • gpt-35-turbo (0125)
  • gpt-4 (1106-미리 보기)
  • gpt-4 (0125-미리 보기)
  • gpt-4(turbo-2024-04-09)
  • gpt-4o(2024-05-13)

모델 지역 가용성에 대한 최신 정보를 보려면 모델 페이지를 참조하세요.

API 버전

재현 가능한 출력에 대한 지원이 API 버전 2023-12-01-preview에 처음 추가되었습니다.

예시

먼저 다른 매개 변수가 동일한 경우에도 채팅 완료 응답에 공통적으로 나타나는 가변성을 보여 주기 위해 동일한 질문에 대해 세 가지 응답을 생성합니다.

import os
from openai import AzureOpenAI

client = AzureOpenAI(
  azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"), 
  api_key=os.getenv("AZURE_OPENAI_API_KEY"),  
  api_version="2024-02-01"
)

for i in range(3):
  print(f'Story Version {i + 1}\n---')
    
  response = client.chat.completions.create(
    model="gpt-35-turbo-0125", # Model = should match the deployment name you chose for your 0125-preview model deployment
    #seed=42,
    temperature=0.7,
    max_tokens =50, 
    messages=[
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Tell me a story about how the universe began?"}
    ]
  )
  
  print(response.choices[0].message.content)
  print("---\n")
  
  del response

출력

Story Version 1
---
Once upon a time, before there was time, there was nothing but a vast emptiness. In this emptiness, there existed a tiny, infinitely dense point of energy. This point contained all the potential for the universe as we know it. And
---

Story Version 2
---
Once upon a time, long before the existence of time itself, there was nothing but darkness and silence. The universe lay dormant, a vast expanse of emptiness waiting to be awakened. And then, in a moment that defies comprehension, there
---

Story Version 3
---
Once upon a time, before time even existed, there was nothing but darkness and stillness. In this vast emptiness, there was a tiny speck of unimaginable energy and potential. This speck held within it all the elements that would come

각 스토리에는 유사한 요소가 있고 일부 축어적인 반복이 있을 수 있지만 응답이 길어질수록 더 많이 갈라지는 경향이 있습니다.

이제 이전과 동일한 코드를 실행하지만 이번에는 seed=42라는 매개 변수 행의 주석 처리를 제거합니다.

import os
from openai import AzureOpenAI

client = AzureOpenAI(
  azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"), 
  api_key=os.getenv("AZURE_OPENAI_API_KEY"),  
  api_version="2024-02-01"
)

for i in range(3):
  print(f'Story Version {i + 1}\n---')
    
  response = client.chat.completions.create(
    model="gpt-35-turbo-0125", # Model = should match the deployment name you chose for your 0125-preview model deployment
    seed=42,
    temperature=0.7,
    max_tokens =50, 
    messages=[
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Tell me a story about how the universe began?"}
    ]
  )
  
  print(response.choices[0].message.content)
  print("---\n")
  
  del response

출력

Story Version 1
---
In the beginning, there was nothing but darkness and silence. Then, suddenly, a tiny point of light appeared. This point of light contained all the energy and matter that would eventually form the entire universe. With a massive explosion known as the Big Bang
---

Story Version 2
---
In the beginning, there was nothing but darkness and silence. Then, suddenly, a tiny point of light appeared. This point of light contained all the energy and matter that would eventually form the entire universe. With a massive explosion known as the Big Bang
---

Story Version 3
---
In the beginning, there was nothing but darkness and silence. Then, suddenly, a tiny point of light appeared. This was the moment when the universe was born.

The point of light began to expand rapidly, creating space and time as it grew.
---

세 가지 요청 각각에 대해 다른 모든 매개 변수는 동일하게 유지하고 seed 매개 변수 42를 공통으로 사용하면 훨씬 더 일관된 결과를 생성할 수 있습니다.

Important

재현 가능한 출력에서는 결정성이 보장되지 않습니다. 시드 매개 변수와 system_fingerprint가 다른 API 호출 간에 동일하더라도 응답에서 어느 정도의 변동이 확인되는 것은 드문 일이 아닙니다. 더 큰 max_tokens 값을 사용해서 동일한 API 호출을 수행하면 일반적으로 시드 매개 변수가 설정된 경우에도 덜 결정적인 응답이 생성됩니다.

매개 변수 세부 정보:

seed는 선택적 매개 변수이며 정수 또는 null로 설정될 수 있습니다.

이 기능은 미리 보기 상태입니다. 지정된 경우 시스템은 결정론적으로 샘플링하기 위해 최선을 다하므로 동일한 시드 및 매개 변수를 사용하는 반복 요청이 동일한 결과를 반환해야 합니다. 결정성은 보장되지 않으며 백 엔드의 변경 내용을 모니터링하려면 system_fingerprint 응답 매개 변수를 참조해야 합니다.

system_fingerprint는 문자열이며 채팅 완료 개체의 일부입니다.

이 지문은 모델이 실행되는 백 엔드 구성을 나타냅니다.

결정성에 영향을 미칠 수 있는 백 엔드 변경이 발생한 시기를 이해하기 위해 시드 요청 매개 변수와 함께 사용할 수 있습니다.

system_fingerprint를 사용하여 전체 채팅 완료 개체를 보려면 기존 print 문 옆의 이전 Python 코드에 print(response.model_dump_json(indent=2))를 추가하거나 PowerShell 예 끝에 $response | convertto-json -depth 5를 추가하면 됩니다. 이 변경으로 인해 다음과 같은 추가 정보가 출력의 일부가 됩니다.

출력

{
  "id": "chatcmpl-8LmLRatZxp8wsx07KGLKQF0b8Zez3",
  "choices": [
    {
      "finish_reason": "length",
      "index": 0,
      "message": {
        "content": "In the beginning, there was nothing but a vast emptiness, a void without form or substance. Then, from this nothingness, a singular event occurred that would change the course of existence forever—The Big Bang.\n\nAround 13.8 billion years ago, an infinitely hot and dense point, no larger than a single atom, began to expand at an inconceivable speed. This was the birth of our universe, a moment where time and space came into being. As this primordial fireball grew, it cooled, and the fundamental forces that govern the cosmos—gravity, electromagnetism, and the strong and weak nuclear forces—began to take shape.\n\nMatter coalesced into the simplest elements, hydrogen and helium, which later formed vast clouds in the expanding universe. These clouds, driven by the force of gravity, began to collapse in on themselves, creating the first stars. The stars were crucibles of nuclear fusion, forging heavier elements like carbon, nitrogen, and oxygen",
        "role": "assistant",
        "function_call": null,
        "tool_calls": null
      },
      "content_filter_results": {
        "hate": {
          "filtered": false,
          "severity": "safe"
        },
        "self_harm": {
          "filtered": false,
          "severity": "safe"
        },
        "sexual": {
          "filtered": false,
          "severity": "safe"
        },
        "violence": {
          "filtered": false,
          "severity": "safe"
        }
      }
    }
  ],
  "created": 1700201417,
  "model": "gpt-4",
  "object": "chat.completion",
  "system_fingerprint": "fp_50a4261de5",
  "usage": {
    "completion_tokens": 200,
    "prompt_tokens": 27,
    "total_tokens": 227
  },
  "prompt_filter_results": [
    {
      "prompt_index": 0,
      "content_filter_results": {
        "hate": {
          "filtered": false,
          "severity": "safe"
        },
        "self_harm": {
          "filtered": false,
          "severity": "safe"
        },
        "sexual": {
          "filtered": false,
          "severity": "safe"
        },
        "violence": {
          "filtered": false,
          "severity": "safe"
        }
      }
    }
  ]
}

추가 고려 사항

재현 가능한 출력을 사용하려면 채팅 완료 호출 전체에서 seed를 동일한 정수로 설정해야 합니다. 또한 temperature, max_tokens 등과 같은 다른 매개 변수도 일치해야 합니다.