

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

# Llama 3.1 8B 指令
<a name="model-card-meta-llama-3-1-8b-instruct"></a>

## ![白色背景上的蓝色无限符号或八字形图标。](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/models/meta.png) Meta — Llama 3.1 8B 指令
<a name="model-card-meta-llama-3-1-8b-instruct-header"></a>

## 模型详细信息
<a name="model-card-meta-llama-3-1-8b-instruct-details"></a>

Llama 3.1 8B Instruct 是 Meta 紧凑的 80 亿个参数模型，具有 128K 的上下文窗口，适用于边缘部署和微调。有关模型开发和性能的更多信息，请参阅[model/service 卡片](https://www.llama.com/docs/model-cards-and-prompt-formats/llama3_1/)。
+ **模型发布日期：2024 年 ** 7 月 23 日
+ **车型停产日期：**不早于 /2025 7/23
+ **最终用户许可协议和使用条款：**[查看 ](https://github.com/meta-llama/llama-models/blob/main/models/llama3_1/LICENSE)
+ **模型生命周期：**活跃
+ **上下文窗口：**128K 代币
+ **最大输出令牌：**4K
+ **知识截止时间：**2023 年 12 月


| **输入模式 ** | **输出模式 ** | **[支持的 API ](bedrock/latest/userguide/apis.html) ** | **[支持的终端节点 ](bedrock/latest/userguide/endpoints.html) ** | 
| --- | --- | --- | --- | 
| ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png)音频 | ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png)嵌入 | ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png) Responses | ![Green circle with white checkmark icon.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-yes.png) bedrock-runtime | 
| ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png)图片 | ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png)图片 | ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png) Chat Completions | ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png) bedrock-mantle | 
| ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png)演讲 | ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png)演讲 | ![Green circle with white checkmark icon.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-yes.png) Invoke |  | 
| ![Green circle with white checkmark icon.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-yes.png)文本 | ![Green circle with white checkmark icon.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-yes.png)文本 | ![Green circle with white checkmark icon.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-yes.png) Converse |  | 
| ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png)视频 | ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png)视频 |  |  | 

**提示**  
只要有可能，我们建议将`bedrock-runtime`终端节点用于新应用程序。有关详细信息，请参阅[亚马逊 Bedrock 支持的终端节点](endpoints.md)。

## 能力和特性
<a name="model-card-meta-llama-3-1-8b-instruct-capabilities"></a>

***基岩特征 * **

**使用`bedrock-runtime`终端节点支持的功能 **


| **支持的 ** | **不支持 ** | 
| --- | --- | 
|  + ![Green circle with white checkmark icon.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-yes.png)[回复直播 ](bedrock/latest/APIReference/API_runtime_InvokeModelWithResponseStream.html)<br />+ ![Green circle with white checkmark icon.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-yes.png)[护栏 ](bedrock/latest/userguide/guardrails.html)<br />+ ![Green circle with white checkmark icon.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-yes.png)[Client-side 工具调用 ](bedrock/latest/userguide/tool-use.html)<br />+ ![Green circle with white checkmark icon.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-yes.png)[即时管理 ](bedrock/latest/userguide/prompt-management.html)<br />+ ![Green circle with white checkmark icon.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-yes.png)[流量 ](bedrock/latest/userguide/flows.html)<br />+ ![Green circle with white checkmark icon.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-yes.png)[代理人 ](bedrock/latest/userguide/agents.html)  |  + ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png)[智能提示路由 ](bedrock/latest/userguide/prompt-routing.html)<br />+ ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png)[滥用检测 ](bedrock/latest/userguide/abuse-detection.html)<br />+ ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png)[即时优化 ](bedrock/latest/userguide/prompt-management-optimize.html)<br />+ ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png)[数代币 ](bedrock/latest/userguide/count-tokens.html)<br />+ ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png)[知识库 ](bedrock/latest/userguide/knowledge-base.html)<br />+ ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png)[模型评估 ](bedrock/latest/userguide/evaluation.html)<br />+ ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png)[结构化输出 ](bedrock/latest/userguide/structured-outputs.html)  | 

## 定价
<a name="model-card-meta-llama-3-1-8b-instruct-pricing"></a>

有关定价信息，请参阅[亚马逊基岩定价](https://aws.amazon.com/bedrock/pricing/)页面。

## 以编程方式访问
<a name="model-card-meta-llama-3-1-8b-instruct-programmatic-access"></a>

使用以下模型 ID 和端点 URL 以编程方式访问此模型。有关可用 API 和终端节点的更多信息，请参阅支持[的 API ](bedrock/latest/userguide/apis.html) 和支持的[终端节点](bedrock/latest/userguide/endpoints.html)。


| **Endpoint** | **模特 ID ** | **In-Region 端点 URL ** | **地理推断 ID ** | **全局推理 ID ** | 
| --- | --- | --- | --- | --- | 
| bedrock-runtime | meta.llama3-1-8b-instruct-v1:0 | https://bedrock-runtime.{region}.amazonaws.com | us.meta.llama3-1-8b-instruct-v1:0 | 不支持 | 

*例如，如果区域为 us-east-1（弗吉尼亚北部），则基岩运行时终端节点 URL 将为 “”，基岩地堡的网址将为 https://bedrock-runtime.us-east-1.amazonaws.com “”。https://bedrock-mantle.us-east-1.api.aws/v1*

## 服务等级
<a name="model-card-meta-llama-3-1-8b-instruct-tiers"></a>

Amazon Bedrock 提供多个服务等级以满足您的工作负载要求。**Standard ** 提供按代币付费的访问权限，无需承诺（设置`"service_tier": "default"`或省略该字段）。****Priority 以溢价（套装`"service_tier": "priority"`）提供最快的响应时间。**Flex ** 为灵活、非时间敏感的工作负载（套装）提供更低成本的访问权限。`"service_tier": "flex"`**预留**为可预测的工作负载提供专用吞吐量和期限承诺；它是在账户级别设置的，而不是根据每个请求设置的（请联系您的 AWS 账户团队来启用）。有关更多信息，请参阅[服务等级](bedrock/latest/userguide/service-tiers-inference.html)。


| **Standard** | **优先级** | **Flex ** | **已保留 ** | 
| --- | --- | --- | --- | 
| ![Green circle with white checkmark icon.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-yes.png) | ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png) | ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png) | ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png) | 

## 区域可用性
<a name="model-card-meta-llama-3-1-8b-instruct-regional-availability"></a>

***区域可用性一览 * **

Amazon Bedrock 提供三种推理选项：将请求**In-Region**保留在单一区域内以确保严格合规；在尊重数据驻留的前提下跨地理区域（例如美国、欧盟和亚太地区）进行地理路由；在没有居住限制的情况下，**全球 Cross-Region**路由到全球任何地方。** Cross-Region **有关更多详细信息，请参阅该[按型号划分的区域可用性](models-region-compatibility.md)页面。


| **区域** | **In-Region** | **地理 ** | **Global** | 
| --- | --- | --- | --- | 
| us-east-1（弗吉尼亚北部） | ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png) | ![Green circle with white checkmark icon.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-yes.png) | ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png) | 
| us-east-2（俄亥俄州） | ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png) | ![Green circle with white checkmark icon.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-yes.png) | ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png) | 
| us-west-2（俄勒冈州） | ![Green circle with white checkmark icon.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-yes.png) | ![Green circle with white checkmark icon.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-yes.png) | ![Red circle with white X icon indicating error, cancel, or close action.](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/images/icons/icon-no.png) | 

***地理推理细节 * **

**地理：美国 **

地理推断 ID：`us.meta.llama3-1-8b-instruct-v1:0`


| **来源区域 ** | **目的地区域 ** | 
| --- | --- | 
| us-east-1（弗吉尼亚州北部） | us-east-1（弗吉尼亚北部）、us-east-2（俄亥俄州）、us-west-2（俄勒冈州） | 
| us-east-2（俄亥俄州） | us-east-1（弗吉尼亚北部）、us-east-2（俄亥俄州）、us-west-2（俄勒冈州） | 
| us-west-2 (俄勒冈) | us-east-1（弗吉尼亚北部）、us-east-2（俄亥俄州）、us-west-2（俄勒冈州） | 

## 配额和限制
<a name="model-card-meta-llama-3-1-8b-instruct-quotas"></a>

您的 AWS 账户有默认配额，以维持服务的性能并确保适当使用 Amazon Bedrock。分配给账户的默认配额可能会根据地区因素、付款历史记录、欺诈性使用、配额[增加请求的 and/or 批准情况进行更新](bedrock/latest/userguide/quotas-increase.html)。有关更多信息，请参阅[Amazon Bedrock 的配额](quotas.md)文档并查看模型[的](general/latest/gr/bedrock.html#limits_bedrock)限制。

## 示例代码
<a name="model-card-meta-llama-3-1-8b-instruct-sample-code"></a>

**第 1 步- AWS 账户：**如果您已经有 AWS 账户，请跳过此步骤。如果您是新手 AWS，请注册一个 A [ WS 账户](https://portal.aws.amazon.com/billing/signup)。

**第 2 步-API 密钥：**前往[亚马逊 Bedrock 控制台](https://console.aws.amazon.com/bedrock/home#/api-keys/long-term/create)并生成长期 API 密钥。

**第 3 步-获取 SDK：**要使用此入门指南，必须已安装 Python。然后根据您使用的 API 安装相关软件。

```
pip install boto3
```

**第 4 步-设置环境变量：将您的环境**配置为使用 API 密钥进行身份验证。

```
AWS_BEARER_TOKEN_BEDROCK="<provide your Bedrock API key>"
```

**第 5 步-运行您的第一个推理请求：**将文件另存为 `bedrock-first-request.py`

------
#### [ Invoke API ]

```
import json
import boto3

client = boto3.client('bedrock-runtime', region_name='us-east-1')
response = client.invoke_model(
    modelId='meta.llama3-1-8b-instruct-v1:0',
    body=json.dumps({
            'messages': [{ 'role': 'user', 'content': 'Can you explain the features of Amazon Bedrock?'}],
            'max_tokens': 1024
    })
)
print(json.loads(response['body'].read()))
```

------
#### [ Converse API ]

```
import boto3

client = boto3.client('bedrock-runtime', region_name='us-east-1')
response = client.converse(
    modelId='meta.llama3-1-8b-instruct-v1:0',
    messages=[
        {
            'role': 'user',
            'content': [{'text': 'Can you explain the features of Amazon Bedrock?'}]
        }
    ]
)
print(response)
```

------