作者:来自 Elastic Kapil Jadhav, Brendan Jugan 及 Ranjana Devaji

semantic_text 现在默认使用 Elastic Inference Service 上的 jina-embeddings-v5-text,从而在 Elasticsearch 中实现多语言语义搜索。
动手体验 Elasticsearch:深入探索 Elasticsearch Labs 仓库中的示例 notebooks,开始免费的云试用,或立即在本地机器上试用 Elastic。
今天,我们很高兴地宣布,semantic_text 现在默认使用 Elastic Inference Service(EIS)上的 jina-embeddings-v5-text 系列,无需额外配置即可实现内置的多语言推理。
EIS 提供托管的、GPU 加速的推理,并与 Elasticsearch 紧密集成。使用 EIS,你无需为 embedding 模型托管、扩展或维护基础设施。
语义搜索基于语义检索结果。文本会被转换为向量 embedding,使查询即使在用词不同的情况下也能匹配相关概念。
semantic_text 字段类型简化了整个流程:在索引时自动分块、生成 embedding,并通过 semantic query 无缝查询,无需构建自定义 pipeline 或管理独立的模型推理。
jina-embeddings-v5-text 模型系列刚刚在 EIS 上发布,使开发者能够在核心 semantic_text 工作流中直接使用强大的多语言 embedding。因此,现在你的语义搜索开箱即支持跨语言能力,全球数据集(如支持文章、产品描述、用户评论和多语言网站)无需额外配置即可使用。
这一默认设置在无需运维开销的情况下,实现了覆盖全球的语义检索能力。
jina-embeddings-v5-text
jina-embeddings-v5-text 模型代表了 EIS 上最新一代紧凑且高性能的多语言 embedding 模型。
- 最先进的多语言性能 :在 MMTEB 基准测试中,在数百种语言上获得顶级分数。jina-embeddings-v5-text-nano 在 500M 参数以下模型中领先,而 jina-embeddings-v5-text-small 明显优于更大规模的替代方案。
- 多任务能力:涵盖检索、语义匹配、聚类和分类等任务。
- 灵活选择以适配你的使用场景:提供两种模型尺寸(small、nano),可在速度、成本和质量之间平衡。
- 长上下文支持:高效处理长文本 embedding,非常适合具有扩展上下文的文档集合。
开始使用
1)创建索引
定义一个 semantic_text 字段,无需额外配置。embedding 会在索引时使用默认模型自动生成。对于生产工作负载,建议显式指定模型,以确保行为和结果的一致性。
PUT /multilingual-reviews
{
"mappings": {
"properties": {
"product": { "type": "keyword" },
"review": { "type": "semantic_text" },
"language": { "type": "keyword" }
}
}
}
索引多语言文档
添加六种不同语言的产品评论。每个文档的 review 字段会在摄取时自动生成 embedding,无需单独的 pipeline 或预处理。
POST /multilingual-reviews/_bulk?refresh=wait_for
{ "index": { "_id": "1" } }
{ "product": "wireless-headphones", "review": "Amazing noise cancellation and the battery lasts all day. Perfect for long flights.", "language": "en" }
{ "index": { "_id": "2" } }
{ "product": "wireless-headphones", "review": "La cancelación de ruido es impresionante. Muy cómodos incluso después de horas de uso.", "language": "es" }
{ "index": { "_id": "3" } }
{ "product": "wireless-headphones", "review": "ノイズキャンセリングが素晴らしく、長時間つけていても耳が痛くなりません。", "language": "ja" }
{ "index": { "_id": "4" } }
{ "product": "wireless-headphones", "review": "Réduction de bruit excellente et très confortable pour les longs trajets en avion.", "language": "fr" }
{ "index": { "_id": "5" } }
{ "product": "wireless-headphones", "review": "Hervorragende Geräuschunterdrückung. Ideal für Pendler und Vielflieger.", "language": "de" }
{ "index": { "_id": "6" } }
{ "product": "wireless-headphones", "review": "O cancelamento de ruído é excelente e a bateria dura o dia todo.", "language": "pt" }
3)使用英文查询实现跨语言搜索
GET /multilingual-reviews/_search
{
"query": {
"match": {
"review": "comfortable for long flights"
}
}
}
结果显示所有六条评论按照与英文查询的语义相关性进行排序:
{
"took": 83,
"timed_out": false,
"_shards": {
"total": 6,
"successful": 6,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 6,
"relation": "eq"
},
"max_score": 0.8275735,
"hits": [
{
"_index": "multilingual-reviews",
"_id": "4",
"_score": 0.8275735,
"_source": {
"product": "wireless-headphones",
"review": "Réduction de bruit excellente et très confortable pour les longs trajets en avion.",
"language": "fr"
}
},
{
"_index": "multilingual-reviews",
"_id": "1",
"_score": 0.7616198,
"_source": {
"product": "wireless-headphones",
"review": "Amazing noise cancellation and the battery lasts all day. Perfect for long flights.",
"language": "en"
}
},
{
"_index": "multilingual-reviews",
"_id": "5",
"_score": 0.72122526,
"_source": {
"product": "wireless-headphones",
"review": "Hervorragende Geräuschunterdrückung. Ideal für Pendler und Vielflieger.",
"language": "de"
}
},
{
"_index": "multilingual-reviews",
"_id": "2",
"_score": 0.6867013,
"_source": {
"product": "wireless-headphones",
"review": "La cancelación de ruido es impresionante. Muy cómodos incluso después de horas de uso.",
"language": "es"
}
},
{
"_index": "multilingual-reviews",
"_id": "3",
"_score": 0.66513836,
"_source": {
"product": "wireless-headphones",
"review": "ノイズキャンセリングが素晴らしく、長時間つけていても耳が痛くなりません。",
"language": "ja"
}
},
{
"_index": "multilingual-reviews",
"_id": "6",
"_score": 0.61658823,
"_source": {
"product": "wireless-headphones",
"review": "O cancelamento de ruído é excelente e a bateria dura o dia todo.",
"language": "pt"
}
}
]
}
}
请注意,法语评论排名第一,甚至高于英文评论。这是因为"très confortable pour les longs trajets en avion"("非常适合长时间飞机旅行,十分舒适")在语义上比英文评论更接近查询,而英文评论将重点分散在降噪、电池续航和飞行等方面。这展示了 jina-embeddings-v5-text-small 按语义而非语言进行排序的能力。
4)使用日文查询实现跨语言搜索
GET /multilingual-reviews/_search
{
"query": {
"match": {
"review": "長時間のフライトに最適"
}
}
}
结果显示所有六条评论按照与日文查询("Ideal for long-haul flights")的语义相关性进行排序:
{
"took": 89,
"timed_out": false,
"_shards": {
"total": 6,
"successful": 6,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 6,
"relation": "eq"
},
"max_score": 0.7556782,
"hits": [
{
"_index": "multilingual-reviews",
"_id": "4",
"_score": 0.7556782,
"_source": {
"product": "wireless-headphones",
"review": "Réduction de bruit excellente et très confortable pour les longs trajets en avion.",
"language": "fr"
}
},
{
"_index": "multilingual-reviews",
"_id": "1",
"_score": 0.7395687,
"_source": {
"product": "wireless-headphones",
"review": "Amazing noise cancellation and the battery lasts all day. Perfect for long flights.",
"language": "en"
}
},
{
"_index": "multilingual-reviews",
"_id": "5",
"_score": 0.68835545,
"_source": {
"product": "wireless-headphones",
"review": "Hervorragende Geräuschunterdrückung. Ideal für Pendler und Vielflieger.",
"language": "de"
}
},
{
"_index": "multilingual-reviews",
"_id": "3",
"_score": 0.6487931,
"_source": {
"product": "wireless-headphones",
"review": "ノイズキャンセリングが素晴らしく、長時間つけていても耳が痛くなりません。",
"language": "ja"
}
},
{
"_index": "multilingual-reviews",
"_id": "6",
"_score": 0.6241487,
"_source": {
"product": "wireless-headphones",
"review": "O cancelamento de ruído é excelente e a bateria dura o dia todo.",
"language": "pt"
}
},
{
"_index": "multilingual-reviews",
"_id": "2",
"_score": 0.6183049,
"_source": {
"product": "wireless-headphones",
"review": "La cancelación de ruido es impresionante. Muy cómodos incluso después de horas de uso.",
"language": "es"
}
}
]
}
}
排名几乎与英文查询相同:法语和英语仍然领先,因为它们在语义上与"非常适合长途飞行"最相关,而不受查询语言影响。日语评论不会因为查询是日语而被人为提升。它排名第四,因为内容讨论的是佩戴舒适性,而不是飞行。语义相关性优先于语言匹配。
注意:对于仅使用英文的场景
如果你更倾向于稀疏表示,或希望继续在英文工作负载中使用 Elastic Learned Sparse EncodeR(ELSER),ELSER 仍然可用并受到完全支持,可作为 semantic_text 的一种选项。
在创建索引时,你可以通过在 mappings 中指定 inference_id: "elser" 来显式选择 ELSER。
结论:无边界的语义搜索
随着 semantic_text 现在默认使用 Elastic Inference Service 上的 jina-embeddings-v5-text 系列,多语言语义搜索已成为 Elasticsearch 中的标准开发体验。这意味着开发者可以构建跨全球数据集运行的搜索、检索增强生成(retrieval augmented generation - RAG)和 AI 应用,而无需拼接各种 pipeline。
创建一个 semantic_text 字段,索引你的数据,然后开始搜索。所有 Elastic Cloud 试用都可以访问 Elastic Inference Service。现在就可以在 Elastic Cloud Serverless 或 Elastic Cloud Hosted 上试用,或者通过 Cloud Connect 在你的自管理集群中使用 EIS。
原文:https://www.elastic.co/search-labs/blog/cloud-connect-elastic-inference-service