arXiv:2503.03703cs.CL2025-03ICLR被引 3

用词向量实现快速语义匹配,百亿级语料秒级搜索

SoftMatcha: A Soft and Fast Pattern Matcher for Billion-Scale Corpus Searches

  • 通过词向量松弛字符串匹配,实现语义层面的灵活查找
  • 百亿语料搜索耗时不足1秒,速度媲美传统方法
  • 适合语言学分析与有害内容识别,支持多语言

自然语言处理与计算语言学研究者常需在大规模语料中观察真实语言使用情况。现有工具如grep和关键词上下文共现器依赖表层字符串匹配,难以处理拼写变异和同义表达。而稠密向量搜索又过于粗略,易召回无关但主题相似文本。为此,我们提出一种新型算法,利用词向量松弛表层匹配,实现高效语义匹配。该算法基于倒排索引,可扩展至百亿规模语料。我们实现了高效版本并提供在线工具。实验表明:(i)在百亿语料上搜索耗时低于1秒,速度与表面匹配和稠密向量搜索相当;(ii)能从大量英日文维基文章中提取语义匹配的有害实例;(iii)可有效应用于拉丁语等形态变化丰富的语言的语料语言学分析。

原文摘要 · Abstract (English)

Researchers and practitioners in natural language processing and computational linguistics frequently observe and analyze the real language usage in large-scale corpora. For that purpose, they often employ off-the-shelf pattern-matching tools, such as grep, and keyword-in-context concordancers, which is widely used in corpus linguistics for gathering examples. Nonetheless, these existing techniques rely on surface-level string matching, and thus they suffer from the major limitation of not being able to handle orthographic variations and paraphrasing -- notable and common phenomena in any natural language. In addition, existing continuous approaches such as dense vector search tend to be overly coarse, often retrieving texts that are unrelated but share similar topics. Given these challenges, we propose a novel algorithm that achieves \emph{soft} (or semantic) yet efficient pattern matching by relaxing a surface-level matching with word embeddings. Our algorithm is highly scalable with respect to the size of the corpus text utilizing inverted indexes. We have prepared an efficient implementation, and we provide an accessible web tool. Our experiments demonstrate that the proposed method (i) can execute searches on billion-scale corpora in less than a second, which is comparable in speed to surface-level string matching and dense vector search; (ii) can extract harmful instances that semantically match queries from a large set of English and Japanese Wikipedia articles; and (iii) can be effectively applied to corpus-linguistic analyses of Latin, a language with highly diverse inflections.

语义搜索百亿级词向量语言学

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。