

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 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)。有关更多代码示例，请参阅 [使用 Amazon Bedrock 的代码示例 AWS SDKs](service_code_examples.md)。

Amazon Bedrock 中的基础模型支持输入和输出模态，这些模态因模型而异。要查看 Writer AI 模型支持的模态，请参阅 [Amazon Bedrock 中支持的根基模型](models-supported.md)。要查看 Writer AI 模型支持哪些 Amazon Bedrock 功能，请参阅 [Amazon Bedrock 中支持的根基模型](models-supported.md)。要查看 Writer AI 模型在哪些 AWS 区域中可用，请参阅 [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 评估中位列榜首，并且在复杂任务与代理式工作流中展现出卓越性能。它拥有一个可容纳 128000 个词元的上下文窗口，并集成了一套企业级能力，包括高级推理、工具调用、LLM 委托、内置 RAG、代码生成、结构化输出、多模态及多语言支持。通过对接企业专用工具来扩展其执行能力，Palmyra X4 助力开发人员构建能够执行系统更新、交易处理、电子邮件发送、工作流触发等操作的应用程序与代理。

**Writer Palmyra X5**

Writer Palmyra X5 拥有一个可容纳 100 万个词元的上下文窗口，彻底消除了应用程序与代理开发中的上下文限制。它是 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 是一种上下文窗口容量高达 128000 个词元的模型。该模型擅长处理和理解复杂任务，非常适用于工作流自动化、编码任务及数据分析场景。
+ 提供商 – Writer
+ 类别 – 文本生成、代码生成、富文本格式
+ 最新版本 – v1
+ 发布日期 – 2025 年 4 月 28 日
+ 模型 ID – `writer.palmyra-x4-v1:0`
+ 模态 – 文本
+ 最大词元数 – 输入：122880 个词元，输出：8192 个词元
+ 语言 – 英语、西班牙语、法语、德语、中文以及其他多种语言
+ 部署类型 – 无服务器

## Palmyra X4 调用请求正文字段
<a name="model-parameters-palmyra-x4-request-body"></a>

当您使用 Writer 模型调用 [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\"}}]}"
}
```

下表显示了数字参数的最小值、最大值和默认值。


****  

| 参数 | 类型 | 默认值 | 范围/验证 | 描述 | 
| --- | --- | --- | --- | --- | 
| 消息 | 数组 | 必需 | 1-∞ 项目 | 聊天历史记录消息 | 
| 温度 | 浮点数 | 1.0 | 0.0 ≤ x ≤ 2.0 | 采样温度 | 
| top\$1p | 浮点数 | 1.0 | 0.0 < 值 ≤ 1.0 | Nucleus 采样阈值 | 
| max\$1tokens | 整数 | 16 | 1 ≤ x ≤ 8192 | 要生成的最大词元数 | 
| min\$1tokens | 整数 | 0 | 0 ≤ x ≤ max\$1tokens | 停止前的最小词元数 | 
| stop | 数组 | [] | ≤4 个条目 | 停止序列 | 
| 种子 | 整数 | null | 任意整数 | Random seed (随机种子) | 
| presence\$1penalty | 浮点数 | 0.0 | -2.0 ≤ x ≤ 2.0 | 新词元出现惩罚 | 
| frequency\$1penalty | 浮点数 | 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 模型具有以下控制项：
+ 提供商 – Writer
+ 类别 – 文本生成、代码生成、富文本格式
+ 最新版本 – v1
+ 发布日期 – 2025 年 4 月 28 日
+ 模型 ID – `writer.palmyra-x5-v1:0`
+ 模态 – 文本
+ 最大词元数 – 输入：1040000 个词元，输出：8192 个词元
+ 语言 – 英语、西班牙语、法语、德语、中文以及其他多种语言
+ 部署类型 – 无服务器

## Palmyra X5 调用请求正文字段
<a name="model-parameters-palmyra-x5-request-body"></a>

当您使用 Writer 模型调用 [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\"}}]}"
}
```

下表显示了数字参数的最小值、最大值和默认值。


****  

| 参数 | 类型 | 默认值 | 范围/验证 | 描述 | 
| --- | --- | --- | --- | --- | 
| 消息 | 数组 | 必需 | 1-∞ 项目 | 聊天历史记录消息 | 
| 温度 | 浮点数 | 1.0 | 0.0 ≤ x ≤ 2.0 | 采样温度 | 
| top\$1p | 浮点数 | 1.0 | 0.0 < x ≤ 1.0 | Nucleus 采样阈值 | 
| max\$1tokens | 整数 | 16 | 1 ≤ x ≤ 8192 | 要生成的最大词元数 | 
| min\$1tokens | 整数 | 0 | 0 ≤ x ≤ max\$1tokens | 停止前的最小词元数 | 
| stop | 数组 | [] | ≤4 个条目 | 停止序列 | 
| 种子 | 整数 | null | 任意整数 | Random seed (随机种子) | 
| presence\$1penalty | 浮点数 | 0.0 | -2.0 ≤ x ≤ 2.0 | 新词元出现惩罚 | 
| frequency\$1penalty | 浮点数 | 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
}
```