Skip to content
LlamaIndex 文档版本 跟随上游 源快照 97a2d211 更新于 2026-10-18

如果你在 Colab 中打开这个 Notebook,可能需要先安装 LlamaIndex 🦙。

%pip install llama-index-embeddings-alephalpha
!pip install llama-index
# Initialise with your AA token
import os

os.environ["AA_TOKEN"] = "your_token_here"

使用 luminous-base 嵌入模型。

  • representation=“Document”:用于要存入向量数据库的文本(文档)
  • representation=“Query”:用于在向量数据库中检索最相关文档的搜索查询
  • representation=“Symmetric”:用于聚类、分类、异常检测或可视化任务。
from llama_index.embeddings.alephalpha import AlephAlphaEmbedding

# To customize your token, do this
# otherwise it will lookup AA_TOKEN from your env variable
# embed_model = AlephAlpha(token="<aa_token>")

# with representation='query'
embed_model = AlephAlphaEmbedding(
    model="luminous-base",
    representation="Query",
)

embeddings = embed_model.get_text_embedding("Hello Aleph Alpha!")

print(len(embeddings))
print(embeddings[:5])
representation_enum: SemanticRepresentation.Query

5120
[0.14257812, 2.59375, 0.33203125, -0.33789062, -0.94140625]
# with representation='Document'
embed_model = AlephAlphaEmbedding(
    model="luminous-base",
    representation="Document",
)

embeddings = embed_model.get_text_embedding("Hello Aleph Alpha!")

print(len(embeddings))
print(embeddings[:5])
representation_enum: SemanticRepresentation.Document

5120
[0.14257812, 2.59375, 0.33203125, -0.33789062, -0.94140625]

BytesRouter 是社区翻译站点,所有译文仅供参考,一切以官方英文原文为准。