说明
向量库新版本(V2)中:
instructions 字段是影响模型效果的关键。为了显著提升向量表示的精度,您需要根据具体的业务场景来定制该指令。请勿直接使用系统默认值。
通过合理设置 instructions,您可以引导模型更准确地聚焦输入内容的关键信息,从而适配特定的任务需求。这在跨模态检索、特定领域数据处理等场景中尤其有效。
注意:仅 doubao-embedding-vision-251215 及后续版本支持 instruction 字段。
构建指令前需明确两种核心角色,二者在不同任务中的配置规则差异显著:
根据任务类型不同,Instruction 字段分为 召回 / 排序类 和 聚类 / 分类 / 语义文本相似度(STS)类 两大场景,具体配置模板如下表:
任务类型 | 是否区分 Query/Corpus | 核心配置模板 |
|---|---|---|
召回、排序类 | 是 | Query:Target_modality: {}.\nInstruction:{}\nQuery: |
聚类、分类、STS 类 | 否 | 所有数据:Target_modality: {}.\nInstruction:{}\nQuery: |
通用要求:所有模板仅需填充 {} 部分,其余固定内容禁止修改。
此类任务用于根据 Query 计算与 Corpus 的相似度,实现目标内容的召回或排序,Query 和 Corpus 需分别配置 Instruction。
Target_modality: {}.\nInstruction:{}\nQuery:
字段填写说明
Corpus 库模态情况 | Target_modality 填写值 |
|---|---|
所有样本均为纯文本 | text |
所有样本均为图片 + 文本组合 | text and image |
所有样本均为纯视频 | video |
所有样本均为文本 + 视频组合 | text and video |
样本包含 text、image、video 三类 | text/image/video |
样本包含 text、video、text and video 三类 | text/video/text and video |
注意
Target_modality的填写错误会直接导致检索精度下降,请严格匹配 Corpus 库或数据集的模态。
Instruction:Compress the {} into one word.\nQuery:
字段填写说明
此类任务不区分 Query 和 Corpus,所有数据采用完全相同的 Instruction 配置。
Target_modality: {}.\nInstruction:{}\nQuery:
字段填写说明
若上述指令无法满足需求,可以参考 MTEB (Massive Text Embedding Benchmark) 提供的 示例 指令进行尝试。
Target_modality: text.\nInstruction:Retrieve semantically similar text\nQuery:
角色 | Instruction 字段配置 |
|---|---|
Query | Target_modality: text.\nInstruction:为这个句子生成表示以用于检索相关文章\nQuery: |
Corpus | Instruction:Compress the text into one word.\nQuery: |
检索类型 | Query 侧 Instruction 配置 | Corpus 侧 Instruction 配置 |
|---|---|---|
文搜图 | Target_modality: image.\nInstruction:Compress the text into one word.\nQuery: | Instruction:Compress the image into one word.\nQuery: |
文搜视频 | Target_modality: video.\nInstruction:Compress the text into one word.\nQuery: | Instruction:Compress the video into one word.\nQuery: |
图搜文 | Target_modality: text.\nInstruction:Compress the image into one word.\nQuery: | Instruction:Compress the text into one word.\nQuery: |
视频搜文 | Target_modality: text.\nInstruction:Compress the video into one word.\nQuery: | Instruction:Compress the text into one word.\nQuery: |
图搜图(整体内容匹配) | Target_modality: image.\nInstruction:Compress the image into one word.\nQuery: | Instruction:Compress the image into one word.\nQuery: |
业务场景 | Query 侧 Instruction 配置 | Corpus 侧 Instruction 配置 |
|---|---|---|
跨模态问答(Query:文本问题;Corpus:文本 / 图片) | Target_modality: text/image.\nInstruction:根据这个问题,找到能回答这个问题的相应文本或图片\nQuery: | 文本 Corpus:Instruction:Compress the text into one word.\nQuery: |
原图检索(忽略 PS 处理) | Target_modality: image.\nInstruction:查找与本图完全相同的图片,可能经过了ps处理,包含缩放、裁剪和水印,请忽略PS处理痕迹\nQuery: | Instruction:Compress the image into one word.\nQuery: |
电商服装检索(忽略背景 / 人物) | Target_modality: image.\nInstruction:忽略背景以及人物主体并查找这张图片中出现的同款商品图片\nQuery: | Instruction:Compress the image into one word.\nQuery: |
电商商品检索(文本描述搜图) | Target_modality: image.\nInstruction:根据下面的文本中对商品的描述,找到对应的符合条件的商品图片\nQuery: | Instruction:Compress the image into one word.\nQuery: |
菜品检索(文本描述搜图) | Target_modality: image.\nInstruction:根据这段文本中提到的有关的菜品,找到相关的菜品的图片\nQuery: | Instruction:Compress the image into one word.\nQuery: |