Amazon Bedrock เบื้องต้น
Nikhil Rangarajan
Data Scientist
โมเดลมีพารามิเตอร์สำหรับควบคุมพฤติกรรม
temperature: ควบคุมความสุ่มในการทำนาย
top_p: ควบคุมความหลากหลายของผลลัพธ์โดยเลือก token ที่มีความน่าจะเป็นสูงสุดmax_tokens: กำหนดความยาวสูงสุดของผลลัพธ์
ความสุ่มและความสร้างสรรค์ของการตอบสนอง
Temperature ต่ำ (ใกล้ 0): ผลลัพธ์มีความแน่นอนและเจาะจงมากขึ้น
Temperature สูง (ใกล้ 1): ผลลัพธ์หลากหลายและสร้างสรรค์มากขึ้น
โมเดลส่วนใหญ่ใน Bedrock ใช้ค่าเริ่มต้นที่ 0.7
prompt = "Write a headline for a
tech article"
request = {
"temperature": 0.2,
"messages": [
{
"role": "user",
"content": [{"type": "text",
"text": prompt}],
}
],
...
}
Temperature คือ "ความเต็มใจรับความเสี่ยง" ของโมเดล
Temperature ต่ำ ทำงานเหมือนผู้ตัดสินใจที่รอบคอบ
Temperature สูง ทำงานเหมือนนักคิดสร้างสรรค์ที่กล้าเสี่ยง

prompt = "Explain quantum computing"
# Focused response
request["top_p"] = 0.1
# Diverse response
request["top_p"] = 0.9
Max_tokens จำกัดความยาวของการตอบสนอง:

prompt = "Explain quantum computing"
# Focused shorter response
request["top_p"] = 0.1
request["max_tokens"] = 100
# Diverse longer response
request["top_p"] = 0.9
request["max_tokens"] = 500

Amazon Bedrock เบื้องต้น