

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

# Writer AI Palmyra 模型
<a name="model-parameters-writer-palmyra"></a>

本節說明 Writer AI 模型的請求參數和回應欄位。使用此資訊透過 [InvokeModel](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html) 和 [InvokeModelWithResponseStream](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModelWithResponseStream.html) (串流) 操作對 Writer AI 模型進行推論呼叫。本節也包含 Python 程式碼範例，示範如何呼叫 Writer AI 模型。若要在推論操作中使用模型，您需要模型的模型 ID。若要取得模型 ID，請參閱[Amazon Bedrock 中支援的基礎模型](models-supported.md)。某些模型也可以使用 [Converse API](conversation-inference.md)。若要檢查 Converse API 是否支援特定 Writer AI 模型，請參閱 [支援的模型和模型功能](conversation-inference-supported-models-features.md)。如需更多程式碼範例，請參閱 [使用 AWS SDKs Amazon Bedrock 程式碼範例](service_code_examples.md)。

Amazon Bedrock 中的基礎模型支援輸入和輸出模態，因模型而異。若要檢查 Writer AI 模型支援的模態，請參閱 [Amazon Bedrock 中支援的基礎模型](models-supported.md)。若要檢查 Writer AI 模型支援的 Amazon Bedrock 功能，請參閱 [Amazon Bedrock 中支援的基礎模型](models-supported.md)。若要檢查哪些 AWS 區域提供 Writer AI 模型，請參閱 [Amazon Bedrock 中支援的基礎模型](models-supported.md)。

當您使用 Writer AI 模型進行推論呼叫時，您會包含模型的提示。如需建立 Amazon Bedrock 支援之模型提示的相關資訊，請參閱 [提示工程概念](prompt-engineering-guidelines.md)。如需 Writer AI 特定提示資訊，請參閱《[Writer AI 提示工程指南]()》。

**Writer Palmyra X4**

Writer Palmyra X4 在 Stanford HELM 上名列前茅，針對複雜的任務和代理式工作流程上實現卓越的效能。其結合了 128k 字符內容視窗與企業級功能套件，包括進階推理、工具呼叫、LLM 委派、內建 RAG、程式碼產生、結構化輸出、多模態和多語言支援。Palmyra X4 使用可擴展模型採取行動能力的企業特定工具，讓開發人員能夠建置應用程式和代理程式，以更新系統、執行交易、傳送電子郵件、觸發工作流程等。

**Writer Palmyra X5**

Writer Palmyra X5 擁有含一百萬個字符的內容視窗，會標記應用程式和代理程式開發的內容限制結束。Writer 的最新模型透過擴展的記憶體和處理能力，在長上下文推論上達到卓越的效能，讓開發人員能夠加速建置更複雜的多步驟代理式工作流程。如同 Palmyra X4，Palmyra X5 包含企業就緒功能套件，包括進階推理、工具呼叫、LLM 委派、內建 RAG、程式碼產生、結構化輸出、多模態和多語言支援。

**Topics**
+ [Writer Palmyra X4](model-parameters-palmyra-x4.md)
+ [Writer Palmyra X5](model-parameters-palmyra-x5.md)

# Writer Palmyra X4
<a name="model-parameters-palmyra-x4"></a>

Writer Palmyra X4 是一種模型，具有最多可達 128,000 個字符的內容視窗。此模型精於處理與理解複雜的任務，因此非常適合工作流程自動化、編碼任務和資料分析。
+ 提供者 — 寫入器
+ 類別 — 文字產生、程式碼產生、RTF 格式設定
+ 最新版本 — v1
+ 發行日期 — 2025 年 4 月 28 日
+ 模型 ID — `writer.palmyra-x4-v1:0`
+ 模式 — 文字
+ 字符上限 – 輸入：122,880 個字符，輸出：8192 個字符
+ 語言 — 英語、西班牙語、法語、德語、中文和其他多種語言
+ 部署類型 — 無伺服器

## Palmyra X4 調用請求內文欄位
<a name="model-parameters-palmyra-x4-request-body"></a>

當您使用寫入器模型進行 [InvokeModel](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html) 或 [InvokeModelWithResponseStream](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModelWithResponseStream.html) 呼叫時，請使用符合下列的 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\"}}]}"
}
```

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


****  

| 參數 | 類型 | 預設 | 範圍/驗證 | 描述 | 
| --- | --- | --- | --- | --- | 
| messages | 陣列 | 必要 | 1-∞ 個項目 | 聊天歷史記錄訊息 | 
| 溫度 | float | 1.0 | 0.0 ≤ x ≤ 2.0 | 取樣溫度 | 
| top\$1p | float | 1.0 | 0.0 < 值 ≤ 1.0 | 核心取樣閾值 | 
| max\$1tokens | int | 16 | 1 ≤ x ≤ 8192 | 要產生的字符數上限 | 
| min\$1tokens | int | 0 | 0 ≤ x ≤ max\$1tokens | 停止之前的字符數下限 | 
| stop | 陣列 | [] | ≤4 個項目 | 停止序列 | 
| seed | int | null | 任何整數 | Random seed (隨機種子) | 
| presence\$1penalty | float | 0.0 | -2.0 ≤ x ≤ 2.0 | 新的字符出現懲罰 | 
| frequency\$1penalty | float | 0.0 | -2.0 ≤ x ≤ 2.0 | 字符頻率懲罰 | 

## Palmyra X4 調用回應內文欄位
<a name="model-parameters-palmyra-x4-response-body"></a>

Writer Palmyra X4 的回應 JSON 使用下列格式：

```
{
  "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 範例程式碼
<a name="model-parameters-palmyra-x4-example-code"></a>

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)
```

# Writer Palmyra X5
<a name="model-parameters-palmyra-x5"></a>

Writer Palmyra X5 包含企業就緒功能套件，包括進階推理、工具呼叫、LLM 委派、內建 RAG、程式碼產生、結構化輸出、多模態和多語言支援。

Writer Palmyra X5 模型具有下列控制項：
+ 提供者 — 寫入器
+ 類別 — 文字產生、程式碼產生、RTF 格式設定
+ 最新版本 — v1
+ 發行日期 — 2025 年 4 月 28 日
+ 模型 ID — `writer.palmyra-x5-v1:0`
+ 模式 — 文字
+ 字符上限 – 輸入：1,040,000 個字符，輸出：8192 個字符
+ 語言 — 英語、西班牙語、法語、德語、中文和其他多種語言
+ 部署類型 — 無伺服器

## Palmyra X5 調用請求內文欄位
<a name="model-parameters-palmyra-x5-request-body"></a>

當您使用寫入器模型進行 [InvokeModel](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html) 或 [InvokeModelWithResponseStream](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModelWithResponseStream.html) 呼叫時，請使用符合下列的 JSON 物件填充 `body` 欄位。在 `text_prompts` 物件的 `text` 欄位中輸入提示。

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

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


****  

| 參數 | 類型 | 預設 | 範圍/驗證 | 描述 | 
| --- | --- | --- | --- | --- | 
| messages | 陣列 | 必要 | 1-∞ 個項目 | 聊天歷史記錄訊息 | 
| 溫度 | float | 1.0 | 0.0 ≤ x ≤ 2.0 | 取樣溫度 | 
| top\$1p | float | 1.0 | 0.0 < x ≤ 1.0 | 核心取樣閾值 | 
| max\$1tokens | int | 16 | 1 ≤ x ≤ 8192 | 要產生的字符數上限 | 
| min\$1tokens | int | 0 | 0 ≤ x ≤ max\$1tokens | 停止之前的字符數下限 | 
| stop | 陣列 | [] | ≤4 個項目 | 停止序列 | 
| seed | int | null | 任何整數 | Random seed (隨機種子) | 
| presence\$1penalty | float | 0.0 | -2.0 ≤ x ≤ 2.0 | 新的字符出現懲罰 | 
| frequency\$1penalty | float | 0.0 | -2.0 ≤ x ≤ 2.0 | 字符頻率懲罰 | 

## Palmyra X5 調用回應內文欄位
<a name="model-parameters-palmyra-x5-response-body"></a>

Writer Palmyra X5 的回應 JSON 使用下列格式：

```
{
  "id": "chatcmpl-a689a6e150b048ca8814890d3d904d41",
  "object": "chat.completion",
  "created": 1745854231,
  "model": "writer.palmyra-x5-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
}
```