主题
本 Notebook 展示如何使用 Netmind AI 生成嵌入。
访问 https://www.netmind.ai/ 并注册以获取 API 密钥。
设置
如果你在 Colab 中打开这个 Notebook,可能需要先安装 LlamaIndex 🦙。
%pip install llama-index-embeddings-netmind1
!pip install llama-index1
# You can set the API key in the embeddings or env
# import os
# os.environ["NETMIND_API_KEY"] = "your-api-key"
from llama_index.embeddings.netmind import NetmindEmbedding
embed_model = NetmindEmbedding(
model_name="BAAI/bge-m3", api_key="your-api-key"
)1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
获取嵌入
embeddings = embed_model.get_text_embedding("hello world")1
print(len(embeddings))1
10241
print(embeddings[:5])1
[-0.04039396345615387, 0.03703497350215912, -0.02897450141608715, 0.016117244958877563, -0.03569157049059868]1