Ibm-Granite 在 Replicate 上的 Granite-3.1-2b-Instruct 模型入门指南
Source: Dev.to
Overview
Granite‑3.1‑2b‑Instruct 是由 ibm‑granite 维护的开源语言模型。它在前代模型 granite‑3.0‑2b‑instruct 的基础上进行扩展,将上下文长度从 4 K 提升至 128 K token,同时在计算效率和性能之间保持平衡。该模型属于 Granite‑3.1 系列,系列中还包括更大的变体 granite‑3.1‑8b‑instruct,可满足不同的计算需求。
Model Details
- Architecture: Decoder‑only transformer
- Parameter count: 2 billion
- Context window: Up to 128 K tokens
- License: Open source (check the repository for the exact license)
模型接受基于文本的提示,并通过聊天式界面生成类似人类的回复。它使用系统提示来引导其行为。
Prompting Parameters
| 参数 | 描述 | 默认值 |
|---|---|---|
| Prompt | 模型需要响应的主要文本输入 | – |
| System Prompt | 引导模型行为的提示(例如 “You are a helpful assistant”) | “You are a helpful assistant” |
| Temperature | 控制输出随机性;数值越高生成的文本越多样化 | 0.6 |
| Max Tokens | 生成输出的最大长度 | – |
| Min Tokens | 生成输出的最小长度 | – |
| Top K / Top P | 采样时控制 token 选择的参数 | – |
| Frequency Penalty | 降低高频 token 的重复出现 | – |
| Presence Penalty | 鼓励模型在输出中引入尚未出现的新 token | – |
Features
- Text Generation: 以数组形式生成文本响应,便于后续处理。
- Context‑Aware Responses: 在聊天模式下保持对话上下文,支持多轮交互。
- Instruction Following: 旨在理解并执行各种用户指令,准确度相对较高。
Usage Tips
- 设置明确的系统提示,以定义助手的角色和语气。
- 根据所需创意程度调整 temperature:数值低时答案更确定,数值高时输出更丰富多变。
- 使用 top‑K / top‑P 采样,微调连贯性与多样性之间的平衡。
- 在出现重复或过于通用的回复时,应用 frequency 和 presence 惩罚。
欲获取更详细的信息,请参阅官方 Granite‑3.1‑2b‑Instruct 仓库及文档。