本文介绍如何通过模型服务灵积DashScope将文本转换为向量,并入库至向量检索服务DashVector中进行向量检索。
模型服务灵积DashScope,通过灵活、易用的模型API服务,让各种模态模型的能力,都能方便的为AI开发者所用。通过灵积API,开发者不仅可以直接集成大模型的强大能力,也可以对模型进行训练微调,实现模型定制化。
前提条件
- DashVector:
- 已创建Cluster: 创建Cluster
- 已获得API-KEY: API-KEY管理
- 已安装最新版SDK: 安装DashVector SDK
- DashScope:
- 已开通服务并获得API-KEY: 开通DashScope并创建API-KEY
- 已安装最新版SDK: 安装DashScope SDK
通用文本向量
简介
通用文本向量,是通义实验室基于LLM底座的多语言文本统一向量模型,面向全球多个主流语种,提供高水准的向量服务,帮助开发者将文本数据快速转换为高质量的向量数据。
模型名称 | 向量维度 | 度量方式 | 向量数据类型 | 备注 |
text-embedding-v1 | 1536 | Cosine | Float32 |
|
text-embedding-v2 | 1536 | Cosine | Float32 |
|
说明
关于灵积通用文本向量更多信息请参考: 通用文本向量。
使用示例
说明
需要进行如下替换代码才能正常运行:
- DashVector api-key替换示例中的{your-dashvector-api-key}
- DashVector Cluster Endpoint替换示例中的{your-dashvector-cluster-endpoint}
- DashScope api-key替换示例中的{your-dashscope-api-key}
Python示例:
相关最佳实践
ONE-PEACE多模态向量表征
ONE-PEAC是一个图文音三模态通用表征模型,同样可通过ONE-PEAC将文本转换为向量。