如何在 vespa 中运行最近邻搜索?

问题描述 投票:0回答:1

尝试使用以下查询获取给定嵌入的最近邻居:

vespa 查询 -v 'yql=从 VectorSearch3_content 选择文本,其中 {targetHits:10}nearestNeighbor(embedding,q)' 'hits=1' 'ranking=closeness' 'input.query(q)=$Q'

获取附件错误。

我需要在某个地方定义亲密程度吗?如果是这样,如何以及在哪里通过 pyvespa 进行?

尝试获取最近邻居记录,但收到服务器错误“消息”:“模式 [VectorSearch3] 中不存在名为“closeness”的配置文件”

embedding yahoo-api vespa vector-database semantic-search
1个回答
0
投票

该错误意味着排名配置文件“接近度”未定义。 https://docs.vespa.ai/en/nearest-neighbor-search-guide.html#schema有一个排名配置文件使用的示例。

对于一个简单的 pyvespa 示例,请查看 https://pyvespa.readthedocs.io/en/latest/examples/pyvespa-examples.html,其中此代码片段向架构添加了排名配置文件:

app_package.schema.add_rank_profile(
    RankProfile(
        name = "max_distance",
        inputs = [("query(qpoint)", "tensor<float>(d[3])")],
        first_phase = "euclidean_distance(attribute(point), query(qpoint), d)"
    )
)

在您的示例中,类似(我不知道您的张量类型/使用正确的字段名称)

app_package.schema.add_rank_profile(
    RankProfile(
        name = "myrankprofile",
        inputs = [("query(q)", "tensor<float>(d[3])")],
        first_phase = "closeness(field, embedding)"
    )
)

为了减少混乱,可以将排名配置文件称为除紧密度之外的其他名称,并在查询中使用“ranking=myrankprofile” - 希望这会有所帮助!

© www.soinside.com 2019 - 2024. All rights reserved.