寫入器 Palmyra X4 - Amazon Bedrock

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

寫入器 Palmyra X4

Writer Palmyra X4 是內容時段最多為 128,000 個字符的模型。此模型擅長處理和了解複雜的任務,因此非常適合工作流程自動化、編碼任務和資料分析。

  • 提供者 — 寫入器

  • 類別 — 文字產生、程式碼產生、豐富文字格式

  • 最後一個版本 — v1

  • 版本日期 — 2025 年 4 月 28 日

  • 模型 ID — writer.palmyra-x4-v1:0

  • 形式 — 文字

  • 權杖上限 — 輸入:122,880 個權杖,輸出:8192 個權杖

  • 語言 — 英文、西班牙文、法文、德文、中文和其他多種語言

  • 部署類型 — 無伺服器

Palmyra X4 調用請求內文欄位

當您使用 Writer 模型進行 InvokeModelInvokeModelWithResponseStream 呼叫時,請以符合下列內容的 JSON 物件填入body欄位。在 text_prompts 物件的 text 欄位中輸入提示。

{ "modelId": "writer.palmyra-x4-v1:0", "contentType": "application/json", "accept": "application/json", "body": "{\"messages\":[{\"role\":\"user\",\"content\":{\"text\":\"Explain quantum computing in simple terms\"}}]}" }

下表展示數字參數的最小值、最大值和預設值。

參數 Type 預設 範圍/驗證 描述

messages

陣列

必要

1-∞ 個項目

聊天歷史記錄訊息

溫度

float

1.0

0.0 ≤ x ≤ 2.0

取樣溫度

top_p

float

1.0

0.0 < 值 ≤ 1.0

Nucleus 取樣閾值

max_tokens

int

16

1 ≤ x ≤ 8192

要產生的字符上限

min_tokens

int

0

0 ≤ x ≤ max_tokens

停止之前的最低權杖數

stop

陣列

[]

≤4 個項目

停止序列

seed

int

null

任何整數

Random seed (隨機種子)

presence_penalty

float

0.0

-2.0 ≤ x ≤ 2.0

新的字符存在懲罰

frequency_penalty

float

0.0

-2.0 ≤ x ≤ 2.0

字符頻率懲罰

Palmyra X4 調用回應內文欄位

的回應 JSON Writer Palmyra X4使用以下格式:

{ "id": "chatcmpl-a689a6e150b048ca8814890d3d904d41", "object": "chat.completion", "created": 1745854231, "model": "writer.palmyra-x4-v1:0", "choices": [ { "index": 0, "message": { "role": "assistant", "reasoning_content": null, "content": "Quantum computing harnesses quantum mechanics to process information in extraordinarily powerful ways. Unlike classical bits, which are 0 or 1, quantum bits (qubits) can exist in multiple states simultaneously through superposition. Qubits also entangle, allowing them to be interconnected in such a way that the state of one (whether it's 0 or 1) can depend on the state of another, no matter the distance between them. This combination of superposition and entanglement enables quantum computers to solve complex problems much faster than classical computers, particularly in areas like cryptography, optimization, and simulations of molecular structures. However, quantum computing is still in its early stages, facing challenges in stability and scalability.", "tool_calls": [] }, "logprobs": null, "finish_reason": "stop", "stop_reason": null } ], "usage": { "prompt_tokens": 43, "total_tokens": 186, "completion_tokens": 143, "prompt_tokens_details": null }, "prompt_logprobs": null }

Writer Palmyra X4 範例程式碼

的範例程式碼Writer Palmyra X4:

import boto3 import json from botocore.exceptions import ClientError client = boto3.client("bedrock-runtime", region_name="us-west-2") model_id = "writer.palmyra-x4-v1:0" # Format the request payload using the model's native structure. native_request = { "temperature": 1, "messages": [ { "role": "user", "content": "Explain quantum computing in simple terms.", } ], } # Convert the native request to JSON. request = json.dumps(native_request) try: # Invoke the model with the request. response = client.invoke_model(modelId=model_id, body=request) except (ClientError, Exception) as e: print(f"ERROR: Can't invoke '{model_id}'. Reason: {e}") exit(1) # Decode the response body. model_response = json.loads(response["body"].read()) # Extract and print the response text. response_text = model_response["content"][0]["text"] print(response_text)