تعرف على كيفية استخدام الإخراج القابل للتكرار (معاينة)
بشكل افتراضي إذا سألت نموذج إكمال دردشة Azure OpenAI السؤال نفسه عدة مرات من المحتمل أن تحصل على استجابة مختلفة. ولذلك تعتبر الردود غير محددة. الإخراج القابل للتكرار هو ميزة معاينة جديدة تسمح لك بتغيير السلوك الافتراضي بشكل انتقائي لمساعدة المنتج على إخراجات أكثر حتمية.
دعم الإخراج القابل للتكرار
الإخراج القابل للتكرار مدعوم حاليا فقط مع ما يلي:
النماذج المدعومة
gpt-35-turbo
(1106) - توفر المنطقةgpt-35-turbo
(0125) - توفر المنطقةgpt-4
(1106-Preview) - توفر المنطقةgpt-4
(0125-Preview) - توفر المنطقة
إصدار 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 لكل طلب من طلباتنا الثلاثة، مع الحفاظ على نفس جميع المعلمات الأخرى، يمكننا إنتاج نتائج أكثر اتساقا بكثير.
هام
الحتمية غير مضمونة مع الإخراج القابل للتكرار. حتى في الحالات التي تستدعي فيها المعلمة الأولية و system_fingerprint
هي نفسها عبر واجهة برمجة التطبيقات، فإنه ليس من غير المألوف حاليا ملاحظة درجة من التغير في الاستجابات. ستؤدي استدعاءات واجهة برمجة التطبيقات المتطابقة ذات القيم الأكبر max_tokens
بشكل عام إلى استجابات أقل حتمية حتى عند تعيين المعلمة الأولية.
تفاصيل المعلمة
seed
هي معلمة اختيارية، والتي يمكن تعيينها إلى عدد صحيح أو خال.
هذه الميزة في المعاينة. إذا تم تحديده، فسيبذل نظامنا أفضل جهد للعينة بشكل محدد، بحيث يجب أن ترجع الطلبات المتكررة بنفس القيمة الأولية والمعلمات نفس النتيجة. الحتمية غير مضمونة، ويجب عليك الرجوع إلى معلمة الاستجابة system_fingerprint
لمراقبة التغييرات في الخلفية.
system_fingerprint
هو سلسلة وهو جزء من كائن إكمال الدردشة.
تمثل بصمة الإصبع هذه تكوين الخلفية التي يعمل بها النموذج.
يمكن استخدامه مع معلمة الطلب الأولي لفهم متى تم إجراء تغييرات الخلفية التي قد تؤثر على الحتمية.
لعرض كائن إكمال الدردشة الكامل باستخدام system_fingerprint
، يمكنك إضافة print(response.model_dump_json(indent=2))
إلى رمز Python السابق بجوار عبارة الطباعة الموجودة، أو $response | convertto-json -depth 5
في نهاية مثال PowerShell. ينتج عن هذا التغيير المعلومات الإضافية التالية كجزء من الإخراج:
المخرجات
{
"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
، وما إلى ذلك.
الملاحظات
https://aka.ms/ContentUserFeedback.
قريبًا: خلال عام 2024، سنتخلص تدريجيًا من GitHub Issues بوصفها آلية إرسال ملاحظات للمحتوى ونستبدلها بنظام ملاحظات جديد. لمزيد من المعلومات، راجعإرسال الملاحظات وعرضها المتعلقة بـ