A Text Similarity Retrieval Method and System Based on Embedded Models

CN121597825BActive Publication Date: 2026-08-14BEIJING SHENAN FUTURE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-26
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

[0002]传统文本相似度检索方法多为对待检索文本提取关键词,对关键词扩充,将扩充后的所有关键词组合与数据库进行相似度计算,这种全量检索的方法耗时长,难以满足文本实时性检索

Benefits of technology

本申请结合预先训练的嵌入式模型,基于每个关键词在目标文本中的位置和与其他关键词的语义距离对该关键词进行有序扩充获得扩充词集,进而按目标比例从扩充词集中得到多个扩充关键词;这种有序扩充关键词的方法能够在保障检索准确性的基础上,通过减少检索量尽可能高效地得到目标检索文本,从而提升检索效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121597825B_ABST
    Figure CN121597825B_ABST
Patent Text Reader

Abstract

This application provides a text similarity retrieval method and system based on an embedded model, belonging to the field of text retrieval technology. The method includes: acquiring target text; extracting keywords from the target text to obtain multiple keywords; inputting the multiple keywords into a pre-trained embedded model to obtain an expanded word set corresponding to each keyword; wherein the pre-trained embedded model is used to expand each keyword based on its position in the target text and its semantic distance from other keywords; selecting expanded keywords from each expanded word set according to a target proportion to obtain multiple expanded keywords; and determining the target retrieval text based on the text similarity between the multiple expanded keywords and various texts in the text library. The text similarity retrieval method and system based on an embedded model provided in this application can improve the speed of text similarity retrieval.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of text retrieval technology, and more specifically, relates to a text similarity retrieval method and system based on an embedded model. Background Technology

[0002] Traditional text similarity retrieval methods often involve extracting keywords from the text to be retrieved, expanding the keywords, and then combining all the expanded keywords with the database to calculate similarity. This full-scale retrieval method is time-consuming and cannot meet the requirements of real-time text retrieval.

[0003] Therefore, a text similarity retrieval method with fast real-time retrieval speed is needed. Summary of the Invention

[0004] The purpose of this application is to provide a text similarity retrieval method and system based on an embedded model, so as to improve the text similarity retrieval speed.

[0005] A first aspect of this application provides a text similarity retrieval method based on an embedded model, comprising: Obtain the target text, extract keywords from the target text, and obtain multiple keywords; Multiple keywords are input into a pre-trained embedded model to obtain an expanded vocabulary set for each keyword; the pre-trained embedded model is used to expand each keyword based on its position in the target text and its semantic distance from other keywords. Select expanded keywords from each expanded keyword set according to the target proportion to obtain multiple expanded keywords; The target retrieval text is determined based on multiple expanded keywords and the text similarity of various texts in the text library.

[0006] A second aspect of this application provides a text similarity retrieval system based on an embedded model, comprising: The keyword extraction module is used to acquire target text, extract keywords from the target text, and obtain multiple keywords; The module for obtaining the expanded word set is used to input multiple keywords into a pre-trained embedded model to obtain the expanded word set corresponding to each keyword. The pre-trained embedded model is used to expand each keyword based on its position in the target text and its semantic distance from other keywords. The module for obtaining expanded keywords is used to select expanded keywords from each expanded keyword set according to the target proportion, thereby obtaining multiple expanded keywords; The target retrieval text determination module is used to determine the target retrieval text based on multiple expanded keywords and the text similarity of various texts in the text library.

[0007] A third aspect of this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor executes the computer program to implement the steps of the above-described text similarity retrieval method based on an embedded model.

[0008] A fourth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above-described text similarity retrieval method based on an embedded model.

[0009] The beneficial effects of the text similarity retrieval method and system based on embedded models provided in this application are as follows: This application combines a pre-trained embedded model to systematically expand each keyword based on its position in the target text and its semantic distance from other keywords, thereby obtaining an expanded keyword set. Then, multiple expanded keywords are obtained from the expanded keyword set according to the target proportion. This systematic keyword expansion method can improve retrieval efficiency by reducing the amount of retrieval while ensuring retrieval accuracy. Attached Figure Description

[0010] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0011] Figure 1 A flowchart illustrating a text similarity retrieval method based on an embedded model provided in an embodiment of this application; Figure 2 A structural block diagram of a text similarity retrieval system based on an embedded model provided in an embodiment of this application; Figure 3 This is a schematic block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0012] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.

[0013] To make the objectives, technical solutions, and advantages of this application clearer, the following description will be provided in conjunction with the accompanying drawings and specific embodiments.

[0014] Please refer to Figure 1 , Figure 1 This is a flowchart illustrating a text similarity retrieval method based on an embedded model provided in an embodiment of this application. The method may include: S101: Obtain the target text, extract keywords from the target text, and obtain multiple keywords.

[0015] In this embodiment, keyword extraction refers to the process of selecting representative words or phrases from the acquired target text that reflect the core content of the text. Keyword extraction can be performed using natural language processing techniques, such as Term Frequency-Inverse Document Frequency (TF-IDF) algorithms and TextRank algorithms, to remove redundant information (such as function words and auxiliary words) from the text and retain only the key information carriers.

[0016] For example, if the target text obtained is "The application of artificial intelligence in the medical field mainly includes disease diagnosis and drug development", then the keywords extracted by keyword extraction can be "artificial intelligence", "medical field", "disease diagnosis" and "drug development".

[0017] S102: Input multiple keywords into a pre-trained embedded model to obtain an expanded word set for each keyword; wherein, the pre-trained embedded model is used to expand the keyword based on the position of each keyword in the target text and the semantic distance to other keywords.

[0018] In this embodiment, the expanded word set refers to a collection of words that are semantically related to the input keyword. These expanded words are similar in meaning to the original keyword, related to it, or have some kind of logical connection, which can enrich the expressive range of the keyword.

[0019] In this embodiment, the embedded model can be a natural language processing model that pre-trains on a large-scale text corpus, maps words to a low-dimensional semantic vector space, and mines synonyms and related words based on the positional association (contextual context) and semantic distance (vector space similarity) of words in the text, thereby realizing the semantic expansion of vocabulary.

[0020] For example, the embedded model can be a word vector model (Word2Vec) or a bidirectional encoder representation from transformers (BERT). Word2Vec simplifies the processing of text content to vector operations in a vector space, allowing the relationship between words to be measured through vector operations; BERT is based on the Transformer architecture and uses a bidirectional Transformer encoder to learn representations using the contextual information of the text.

[0021] In this embodiment, the embedded model learns from the text corpus on a large scale through pre-training to construct semantic mapping relationships between words. When a keyword is input, the embedded model retrieves the words with the closest semantic spatial distance and the strongest logical connection based on the semantic vector of the keyword itself, forming an expanded word set.

[0022] For example, if a keyword is in a specific context within the target text (e.g., "disease diagnosis" appears in the "clinical testing process" paragraph in medical text), the embedded model will prioritize associating it with professional expressions within that context (e.g., "clinical diagnosis process" or "test result determination"). As another example, when the keyword is "artificial intelligence," the expanded vocabulary obtained through the embedded model might include "machine intelligence," "intelligent system," and "AI technology," among others.

[0023] In this embodiment, the embedded model calculates the semantic vector distance between keywords and other text words; the closer the distance, the stronger the semantic association.

[0024] For example, "disease diagnosis" and "symptom judgment" are close in semantic vector distance and will be given priority to be included in the expanded vocabulary; while "disease prevention" may be used as a secondary supplement because it is slightly farther in semantic distance.

[0025] Among them, positional features reflect the semantic weight of keywords in the text, which can be captured through quantification rules. For example, keywords that appear frequently in the title, first / last paragraph, or middle paragraph are more representative. The implementation methods can include setting different weights according to the text position (title, first / last paragraph, middle paragraph), counting the frequency of occurrence, extracting the context and generating feature vectors. Semantic distance is used to filter candidate words related to the initial keywords based on semantic similarity. The implementation methods can include using word vectors (such as Word2Vec, Global Vectors for Word Representation (GloVe)), pre-trained models (such as BERT), or knowledge graphs to calculate semantic distance, and then filtering the candidate word set by setting a threshold.

[0026] S103: Select expanded keywords from each expanded keyword set according to the target proportion to obtain multiple expanded keywords.

[0027] In this embodiment, the target ratio refers to the pre-defined ratio between the number of expanded keywords selected from each expanded keyword set and the total number of words in that expanded keyword set. The setting of this target ratio needs to comprehensively consider both the accuracy and comprehensiveness of the retrieval; a ratio that is too high may introduce too much irrelevant information, while a ratio that is too low may fail to adequately expand the keyword pool.

[0028] For example, if the number of domain texts for target text 'a' is greater than a first preset number, then the retrieval level of target text 'a' is determined to be the first retrieval level, and the target ratio can be set to a%; if the number of domain texts for target text 'b' is less than or equal to the first preset number but greater than the second preset number, then the retrieval level of target text 'b' is determined to be the second retrieval level, and the target ratio can be set to b%; if the number of domain texts for target text 'c' is less than or equal to the second preset number, then the retrieval level of target text 'c' is determined to be the third retrieval level, and the target ratio can be set to c%. Wherein, the first preset number is greater than the second preset number, and a > b > c. For instance, if the number of domain texts for a certain target text is less than or equal to the second preset number, then the target text is at the third retrieval level. If the expanded vocabulary set contains 10 words, and the target ratio is set to 30%, then 3 expanded keywords are selected from this vocabulary set.

[0029] S104: Determine the target retrieval text based on the text similarity of multiple expanded keywords and various texts in the text library.

[0030] In this embodiment, text similarity refers to the degree of content similarity between the set of multiple expanded keywords and individual texts in the text library. It is typically measured by calculating the semantic matching degree and overlap between keywords and words in the text. Higher similarity indicates a stronger association between the text and the retrieval requirement.

[0031] For example, if the expanded keywords are "artificial intelligence" and "medical diagnosis," and a text in the text library mainly discusses "the application and development of artificial intelligence technology in medical diagnosis," then this text has a high similarity to the text with the expanded keywords and may be identified as the target search text. For example, if the expanded keyword is "vocational education industry-education integration," and a text in the text library discusses in detail "talent training programs and co-construction models of training bases for industry-education integration between higher vocational colleges and local manufacturing enterprises," then the content of this text is deeply consistent with the implementation scenario of the expanded keywords, and the semantic overlap and matching degree meet the standards, then this text may be identified as the target search text.

[0032] In this embodiment, text similarity is based on the vector representation of text, and is measured by the semantic association degree through the distance between vectors (such as cosine distance or Euclidean distance). Calculating text similarity is to transform the semantic information of the text into quantifiable values, enabling efficient calculation and comparison of text associations by machines. The distance between vectors can be calculated using cosine distance or Euclidean distance. Cosine distance measures the directional consistency of two vectors by calculating their cosine values, ranging from [-1, 1]. The closer the cosine value is to 1, the more similar the directions of the two vectors are, and the closer the text semantics are; conversely, the lower the text semantic relevance, the lower the cosine value. Euclidean distance calculates the straight-line distance between two vectors in space. The smaller the value, the closer the two vectors are, and the higher the text similarity; conversely, the higher the value, the lower the text similarity and the greater the difference.

[0033] For example, first convert the text into vectors (using methods such as TF-IDF or word vector average). Then, calculate text similarity using cosine distance: first calculate the dot product of the two vectors, then calculate the magnitudes of the two vectors, and finally calculate the cosine value. Specifically, assuming the vector of text aa is [1, 2, 3] and the vector of text bb is [4, 5, 6], the dot product of the two vectors is 1×4 + 2×5 + 3×6 = 32. The magnitude of vector aa is approximately 3.7417, and the magnitude of vector bb is approximately 8.7749. Then, the cosine value of vector aa and vector bb is approximately 0.973, which is close to 1, indicating that text aa and text bb have high similarity.

[0034] For example, first convert the text into vectors (using methods such as TF-IDF or word vector average). Then, calculate the similarity using Euclidean distance: calculate the sum of squared differences between corresponding dimensions of the two vectors, and then take the square root of the sum; this is the Euclidean distance. Specifically, assuming the vector for text 'aa' is [1, 2, 3] and the vector for text 'bb' is [4, 5, 6], the Euclidean distance... The smaller distance indicates that text aa and text bb have a high similarity; if the text cc vector is [10, 20, 30], then the Euclidean distance between vector aa and vector cc is approximately 33.67, which is a large distance, indicating that text aa and text cc have a low similarity.

[0035] As can be seen from the above, this application obtains a keyword expansion set based on a pre-trained embedded model, and then expands the keywords in an orderly manner according to the target proportion. This method of orderly expanding keywords can obtain the target search text as efficiently as possible while ensuring the accuracy of the search.

[0036] In one embodiment of this application, before extracting keywords from the target text to obtain multiple keywords, the method further includes: The target text is preprocessed to obtain the preprocessed target text; Correspondingly, keyword extraction is performed on the target text to obtain multiple keywords, including: Keyword extraction is performed on the preprocessed target text to obtain multiple keywords.

[0037] In this embodiment, the preprocessing may include operations such as data cleaning, format regularization, and noise filtering on the original target text, providing a more effective input for subsequent keyword extraction. Among them, the core actions of preprocessing may include removing irrelevant symbols in the text, unifying the text encoding format, and filtering high-frequency meaningless words (such as auxiliary words like "de" and "le").

[0038] Exemplarily, assume the target text is the comment of a user on a certain forum: "Wow!! This mobile phone has great performance ~~ It's just a bit expensive... Heehee". Then, meaningless symbols "!!", "~~", and "..." can be filtered out, and redundant modal particles "Wow" and "Heehee" can also be cleared. Finally, the regularized text is obtained: "This mobile phone has great performance and it's just a bit expensive".

[0039] In this embodiment, keyword extraction may refer to a technical means of screening out words or phrases that can represent the core semantics and theme of the text from the preprocessed text. Keyword extraction can rely on natural language processing algorithms to accurately locate core vocabulary by calculating the importance and semantic contribution degree of words.

[0040] Exemplarily, natural language processing algorithms may include TF-IDF or TextRank. Assume the preprocessed text is "New energy vehicle range improvement strategy and battery technology innovation". Then, based on the keyword extraction algorithm, high-weight words "new energy vehicle" (topic word), "range" (core requirement), and "battery technology" (key technology) can be identified, and low-value words "de" and "yu" (function words) can be filtered out. Finally, the keyword set of this text can be output: ["new energy vehicle", "range", "battery technology innovation"].

[0041] From the above, it can be concluded that the embodiment of this application greatly improves the quality and relevance of keywords through the process of preprocessing the target text first and then extracting keywords, laying a reliable foundation for subsequent semantic expansion and similarity retrieval based on the embedded model.

[0042] In an embodiment of this application, preprocessing is performed on the target text to obtain the preprocessed target text, including: Eliminating data noise and unifying the semantic representation dimension for the target text to obtain the preprocessed target text.

[0043] In this embodiment, eliminating data noise may refer to identifying and filtering meaningless and interfering information in the target text. For example, text format noise: garbled characters, error codes, etc., semantic noise: content unrelated to the core theme of the text, redundant noise: repeatedly expressed content; unifying the semantic representation dimension may refer to regularizing content with the same semantics but different expressions in the text into a unified format. For example, abbreviations are converted to full names ("AI" becomes "artificial intelligence"), spoken language is converted to written language ("nagging" becomes "discussion"), and professional terms are standardized ("myocardial infarction" becomes "myocardial infarction").

[0044] Exemplarily, assume that the target text is a case fragment in the medical field, and the original text is "Patient, male, 56y, with a history of'myocardial infarction' ~ Currently seeking medical treatment due to chest pain, chief complaint: severe pain in the chest, difficulty breathing... [System prompt: Please update the patient's file]". For this target text, when performing data noise elimination, format noise such as "delete y (non-standard age unit, converted to years), redundant prompt within English brackets [System prompt: Please update the patient's file]" can be filtered out, and semantic noise such as "remove meaningless English chest pain (already having the Chinese 'chest pain')" can be cleaned up; when performing unified semantic representation dimension processing on this text, professional terms are standardized: "myocardial infarction" becomes "myocardial infarction", and "chest pain" becomes "precordial pain (medical standard expression)". Finally, the preprocessed text is "Patient, male, 56 years old, with a history of'myocardial infarction', currently seeking medical treatment due to chest pain, chief complaint: severe precordial pain, difficulty breathing".

[0045] From the above, it can be concluded that in the embodiment of this application, by eliminating data noise, meaningless interference information in the text can be removed, making the core content more prominent. By unifying the semantic representation dimension, the problem of different forms with the same meaning is solved, making the semantics more focused and standardized. Preprocessing the target text can significantly improve the quality of the target text, providing a more accurate and reliable input basis for subsequent keyword extraction and text similarity retrieval, and avoiding retrieval errors caused by noise interference or semantic expression confusion.

[0046] In an embodiment of this application, before selecting expansion keywords from each expansion word set according to the target ratio to obtain multiple expansion keywords, it further includes: Determining the retrieval level of the target text based on the text field to which the target text belongs, and the retrieval level increases as the number of texts in the text field to which the target text belongs increases; Determining the target ratio of the target text according to the retrieval level, and the target ratio increases as the retrieval level increases.

[0047] In this embodiment, the text domain can refer to the professional, industry, or thematic classification to which the target text belongs. It defines the scope of the text content. For example, texts in the medical field focus on disease diagnosis and treatment, drug development, etc., while texts in the education field revolve around teaching methods and curriculum design. Texts in different fields differ in their knowledge systems and vocabulary characteristics, affecting the retrieval strategy. The retrieval level can be a quantitative division of the priority and scope of retrieval needs based on the number of texts in the target text domain. For example, the more texts in a domain (such as internet industry news, which has a large number of texts), the higher the retrieval level, meaning that more comprehensive semantic mining and expanded retrieval coverage are needed. Conversely, the fewer texts there are (such as niche intangible cultural heritage research texts), the lower the retrieval level, focusing on precise matching of core semantics.

[0048] For example, in the scenario of academic paper retrieval, if the target text is "the application of artificial intelligence in medical image diagnosis" (belonging to the medical field), and the medical field text database stores 100,000 related papers (a large number of texts), then its retrieval level is determined to be high; if the target text is "a study on the phonological features of an ancient dialect" (belonging to the niche field of dialect research), and there are only 200 papers in the field (a small number of texts), then its retrieval level is determined to be low.

[0049] In this embodiment, the target ratio can be a rule governing the proportion of expanded keywords selected from the expanded term set, determined by the retrieval level. If the number of domain texts for target text a is greater than a first preset number, then the retrieval level of target text a is determined to be the first retrieval level, and the target ratio can be set to a%; if the number of domain texts for target text b is less than or equal to the first preset number but greater than the second preset number, then the retrieval level of target text b is determined to be the second retrieval level, and the target ratio can be set to b%; if the number of domain texts for target text c is less than or equal to the second preset number, then the retrieval level of target text c is determined to be the third retrieval level, and the target ratio can be set to c%. Wherein, the first preset number is greater than the second preset number, and a > b > c. At a high retrieval level, to cover more potentially related texts, the proportion of words selected from the expanded term set will be increased; at a low retrieval level, to ensure retrieval accuracy, the proportion of words selected will be reduced, balancing retrieval breadth and precision.

[0050] For example, taking the academic paper retrieval scenario, if the target text "AI application in medical image diagnosis" has a retrieval level of the first retrieval level (the number of texts in the medical field is greater than the first preset number), the target ratio can be set to 60%, that is, 30 expanded keywords are selected from each expanded term set (assuming the "medical image analysis" expanded term set contains 50 words); if the target text "research on the phonological features of a certain ancient dialect" has a retrieval level of the third retrieval level (the number of texts in the dialect field is less than or equal to the second preset number), the target ratio can be set to 30%, and 3 expanded keywords are selected from the expanded term set (assuming the "dialect phonological research" expanded term set contains 10 words).

[0051] As can be seen from the above, the embodiments of this application first determine the retrieval level based on the number of texts in the target text's domain, and then adapt the target ratio based on the retrieval level, so that the keyword expansion strategy and the characteristics of the text domain are accurately matched. In the end, when searching for texts in different domains, an appropriate balance is found between breadth and precision, and the relevance between the search results and the needs is improved.

[0052] In one embodiment of this application, before inputting multiple keywords into a pre-trained embedded model to obtain an expanded vocabulary set corresponding to each keyword, the method further includes: Obtain multiple reference texts; For each reference text, keywords are extracted to obtain multiple reference keywords; Based on the position of each reference keyword in the reference text and its semantic distance from other reference keywords, the reference keyword is expanded to obtain the reference expanded word set corresponding to each reference keyword; The embedded model is trained based on the reference keywords and reference expanded vocabulary sets corresponding to all reference texts, resulting in a well-trained embedded model.

[0053] In this embodiment, keyword extraction involves extracting representative initial reference keywords from the preprocessed reference text as the basis for expansion.

[0054] For example, keyword extraction methods can be statistically based: the TF-IDF algorithm can be used to calculate word importance (words with high frequency and rareness in other texts are more critical), or the TextRank algorithm can be used to construct a graph model based on word co-occurrence relationships and score and rank them. Keyword extraction methods can also be semantically based: pre-trained language models (such as BERT) can be used to calculate the attention weight of words in a sentence, or core words can be extracted through keyword prediction tasks, such as using labeled data to train a classifier to extract core words. Then, the top N keywords (such as top 10-20, which can be adjusted according to the text length) are retained, prioritizing nouns, verbs and other content words, filtering out function words and low-frequency irrelevant words, forming an initial keyword set K={k1, k2, k3, ..., kn}.

[0055] In this embodiment, positional features can reflect the "semantic weight" of keywords in the text. Keywords that appear frequently in the title, first and last paragraphs, or are usually more representative can be captured by quantification rules.

[0056] For example, the keyword weight in the title can be set to 2.0, the first / last paragraph to 1.5, and the middle paragraphs to 1.0. The frequency (f) of the keyword in the text is counted; the higher the frequency, the higher the weight. Using the keyword as the center, n words before and after it (e.g., n=5) are taken to form a contextual description (e.g., the context of the keyword "machine learning" is "[artificial intelligence][in China] machine learning [in][medical][field][application]"), which is used for subsequent semantic matching. Then, a feature vector is generated for each initial keyword k as a positional feature output, quantifying its importance and context in the text.

[0057] In this embodiment, semantic distance can be based on semantic similarity with candidate words related to the initial keywords, combined with word vectors, pre-trained models, or knowledge graphs to achieve accurate matching.

[0058] For example, semantic distance can be calculated using word vectors: Vectors for keyword k can be generated using Word2Vec, GloVe, or FastText, and the semantic distance between words can be calculated using cosine similarity. Alternatively, a pre-trained model can be used to calculate semantic distance: BERT models can be used to generate semantic vectors for keywords or context, improving the matching accuracy for complex semantics (such as polysemous words and phrases). Then, candidate word selection is performed: a semantic distance threshold is set (e.g., cosine similarity ≥ 0.7), and a set of candidate words semantically related to k is selected from the corpus or pre-trained vocabulary.

[0059] In this embodiment, the optimal words are selected by combining position and semantics to expand the reference keywords, ensuring that the expanded words are semantically related to the initial reference keywords and conform to the textual context rules.

[0060] For example, firstly, semantic relevance filtering can be performed, retaining only candidate words with a semantic distance greater than or equal to a threshold and excluding irrelevant words; then, the positional features of the candidate word (let's say c) and the initial reference keyword (let's say k) can be compared. If the positional weight distribution of c in the training set is similar to that of k, its priority can be increased; if the context window of c has a high semantic similarity to that of k, it is considered to have consistent context and is retained first; then, the candidate words are ranked by weight, and the top M candidate words are selected as reference expansion words; finally, a reference word set is expanded for each initial reference keyword to form a complete keyword reference expansion word set.

[0061] As can be seen from the above, the embodiments of this application expand the keyword based on its position in the reference text and its semantic distance from other reference keywords. Then, an embedded model is trained based on the reference keywords and expanded reference keywords corresponding to all reference texts, resulting in a well-trained embedded model. Ultimately, this allows the embedded model to combine the positional importance and semantic relevance of keywords, avoiding the semantic limitations of simple keyword retrieval and filtering noise through positional features, thereby achieving a dual improvement in recall and precision for similar text retrieval.

[0062] In one embodiment of this application, the target retrieval text is determined based on the text similarity between multiple expanded keywords and various texts in the text library, including: Based on the similarity benchmark, if the semantic similarity is higher than the similarity benchmark, the target retrieval text is determined.

[0063] In this embodiment, the similarity benchmark is predetermined and serves as a semantic matching threshold for determining whether text meets the retrieval requirements. By quantifying semantic similarity, texts with sufficiently close semantic association with the expanded keywords are selected. Semantic similarity refers to the degree of semantic matching between the expanded keyword set and the text in the text library. This includes both literal word overlap (such as "artificial intelligence" and "AI technology") and semantic logical association (such as "disease diagnosis" and "symptom judgment process"). The algorithm converts this association into comparable numerical values.

[0064] For example, semantic similarity can be calculated using algorithms such as cosine similarity and edit distance. Comparable values ​​can be any score between 0 and 1, with 1 being a perfect match.

[0065] In this embodiment, the response to a semantic similarity higher than a similarity benchmark is a condition-triggered logic. That is, when the semantic similarity calculation result between the text and the expanded keywords meets the condition of "≥ a pre-set benchmark value", the system automatically determines that the text is the target search text. This logic transforms ambiguous semantic associations into explicit filtering rules, making the search results quantifiable and verifiable.

[0066] For example, suppose the expanded keyword is "new energy vehicle battery safety," and there are three texts in the text library. Text A: Design of a thermal management system for new energy vehicle batteries to ensure battery charging and discharging safety. The keyword "battery safety" is highly correlated with "ensuring battery charging and discharging safety" in Text A, with an algorithm score of 0.85 (assuming a baseline of 0.7), higher than the baseline. Text B: Case studies of engine failure repair in traditional fuel vehicles. It has no direct semantic connection to "new energy vehicle battery safety," with an algorithm score of 0.2, lower than the baseline. Text C: Research on the exterior design trends of new energy vehicles. Only the phrase "new energy vehicle" overlaps semantically; the core semantic connection (battery safety) is unrelated, with an algorithm score of 0.3, lower than the baseline. Therefore, among Texts A, B, and C, only Text A has a semantic similarity greater than the baseline and is identified as the target retrieval text.

[0067] For example, suppose the expanded keyword is "lightweight folding bicycle", the search scenario is e-commerce product search, and the similarity benchmark is set to 0.6. The text library contains text D and text E. Text D: Ultra-lightweight folding bicycle, aluminum alloy frame, easy to store. The word "lightweight" corresponds to "ultra-lightweight" and "folding bicycle" exactly, with an algorithm score of 0.8, triggering the "above benchmark" condition, and is determined to be the target search text. Text E: Mountain bike, high-strength frame, excellent off-road performance. This text is not related to the core requirement of "lightweight folding", with a score of 0.1, and does not trigger the condition.

[0068] As can be seen from the above, the embodiments of this application clarify the semantic matching threshold by setting a similarity benchmark, and then quantify the degree of association by measuring semantic similarity. Combined with the triggering logic of "judging the target text if it is higher than the benchmark", the fuzzy text semantic retrieval can be transformed into a quantifiable and executable filtering process. This mechanism not only ensures the semantic relevance between the search results and the expanded keywords (filtering low-relevance text), but also makes the retrieval process have clear rules (avoiding subjective judgment), ultimately achieving accurate and efficient target text retrieval, and providing a reliable data foundation for subsequent applications (such as information recommendation and knowledge mining).

[0069] In one embodiment of this application, determining the target retrieval text based on multiple expanded keywords and text similarity among various texts in a text library further includes: If the semantic similarity is lower than the similarity benchmark, then keywords from another part of the expanded vocabulary set will be selected for retrieval.

[0070] In this embodiment, a semantic similarity lower than the similarity benchmark means that the semantic matching degree between the text in the text library and the current expanded keyword set has not reached the pre-set "qualified threshold," i.e., the similarity benchmark. This state indicates that the current keywords do not cover the text sufficiently, and the retrieval strategy needs to be adjusted. The other part of the expanded keyword set refers to the remaining vocabulary set from the original expanded keyword set that was not used in the initial retrieval. Its function is to expand the semantic coverage by replacing and supplementing keywords, thus solving the problem of "insufficient matching" in the initial retrieval.

[0071] For example, suppose the expanded keyword set is "lung cancer diagnosis, pathological features, gene testing", and a similarity benchmark of 0.7 is set. Document F in the text library is "postoperative nursing procedures and rehabilitation guidance for lung cancer patients," which is only literally related to "lung cancer," and the core semantics "diagnosis, case, gene" are not covered, resulting in a score of 0.3, lower than the benchmark. Therefore, the "semantic similarity lower than the similarity benchmark" mechanism is triggered, and keywords are selected from the remaining parts of the expanded keyword set (such as "postoperative rehabilitation, complication prevention, survival assessment") for a new search. The new keywords semantically match the "postoperative nursing, rehabilitation" of document F, with a score of 0.8 (higher than the benchmark), successfully obtaining the target text.

[0072] As can be seen from the above, the embodiments of this application, through the mechanism of "activating another part of the expanded term set for retrieval when the semantic similarity is lower than the baseline," can effectively solve the problem of insufficient coverage in the initial retrieval. By utilizing the semantic diversity of the expanded term set and dynamically adjusting the keyword combination, both the "accuracy of the baseline screening" and the comprehensiveness of the retrieval are guaranteed through the "term set fallback." Ultimately, the retrieval process achieves "adaptive optimization," automatically adjusting the strategy for different text matching degrees, thereby improving the retrieval success rate and coverage of the target text.

[0073] Corresponding to the text similarity retrieval method based on the embedded model in the above embodiment, Figure 2 This is a structural block diagram of a text similarity retrieval system based on an embedded model, provided as an embodiment of this application. For ease of explanation, only the parts relevant to the embodiment of this application are shown. References Figure 2 The text similarity retrieval method 20 based on the embedded model includes: a keyword extraction module 21, an expanded word set acquisition module 22, an expanded keyword acquisition module 23, and a target retrieval text determination module 24.

[0074] Among them, the keyword extraction module 21 is used to obtain the target text, extract keywords from the target text, and obtain multiple keywords; The expanded word set module 22 is used to input multiple keywords into a pre-trained embedded model to obtain the expanded word set corresponding to each keyword; wherein, the pre-trained embedded model is used to expand the keyword based on the position of each keyword in the target text and the semantic distance to other keywords; The expanded keyword module 23 is used to select expanded keywords from each expanded keyword set according to the target ratio, thereby obtaining multiple expanded keywords; The target retrieval text module 24 is used to determine the target retrieval text based on multiple expanded keywords and the text similarity of each text in the text library.

[0075] In one embodiment of this application, a preprocessing module is further included before the keyword extraction module 21. The preprocessing module is used to preprocess the target text to obtain preprocessed target text; correspondingly, keyword extraction is performed on the target text to obtain multiple keywords, including: keyword extraction is performed on the preprocessed target text to obtain multiple keywords.

[0076] In one embodiment of this application, the preprocessing module is further used to eliminate data noise and unify the semantic representation dimension of the target text to obtain preprocessed target text.

[0077] In one embodiment of this application, before obtaining the expanded keyword module 23, a target ratio determination module is further included. The target ratio module is used to determine the retrieval level of the target text based on the text domain to which the target text belongs. The retrieval level increases as the number of texts in the text domain to which the target text belongs increases. The target ratio of the target text is determined according to the retrieval level. The target ratio increases as the retrieval level increases.

[0078] In one embodiment of this application, before the expanded word set acquisition module 22, a pre-trained embedded model module is further included. The pre-trained embedded model module is used to acquire multiple reference texts; for each reference text, keywords are extracted from the reference text to obtain multiple reference keywords; the reference keywords are expanded based on their position in the reference text and their semantic distance from other reference keywords to obtain a reference expanded word set corresponding to each reference keyword; the embedded model is trained based on the reference keywords and reference expanded word sets corresponding to all reference texts to obtain a trained embedded model.

[0079] In one embodiment of this application, the target retrieval text determination module 24 is used to determine the target retrieval text based on a similarity benchmark, in response to a semantic similarity higher than the similarity benchmark.

[0080] In one embodiment of this application, the target retrieval text module 24 is further configured to select keywords from another part of the expanded word set for retrieval in response to a semantic similarity lower than the similarity benchmark.

[0081] See Figure 3 , Figure 3 This is a schematic block diagram of an electronic device provided according to an embodiment of this application. Figure 3The electronic device 300 in this embodiment may include one or more processors 301, one or more input devices 302, one or more output devices 303, and one or more memories 304. The processors 301, input devices 302, output devices 303, and memories 304 communicate with each other via a communication bus 305. The memories 304 store computer programs, including program instructions. The processors 301 execute the program instructions stored in the memories 304. Specifically, the processors 301 are configured to invoke the program instructions to perform the functions of the modules in the aforementioned system embodiments, for example... Figure 2 The functions of the keyword extraction module 21, the expanded term set acquisition module 22, the expanded keyword acquisition module 23, and the target retrieval text determination module 24 are shown.

[0082] It should be understood that, in the embodiments of this application, the processor 301 may be a central processing unit (CPU), but it may also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.

[0083] Input device 302 may include a touchpad, a fingerprint sensor (for collecting the user's fingerprint information and fingerprint orientation information), a microphone, etc., and output device 303 may include a display (LCD, etc.), a speaker, etc.

[0084] The memory 304 may include read-only memory and random access memory, and provides instructions and data to the processor 301. A portion of the memory 304 may also include non-volatile random access memory. For example, the memory 304 may also store device type information.

[0085] In specific implementations, the processor 301, input device 302, and output device 303 described in the embodiments of this application can execute the implementation method described in the text similarity retrieval method based on embedded model provided in the embodiments of this application, or they can execute the implementation method of the electronic device described in the embodiments of this application, which will not be repeated here.

[0086] In another embodiment of this application, a computer-readable storage medium is provided. This computer-readable storage medium stores a computer program, which includes program instructions. When executed by a processor, the program instructions implement all or part of the processes in the methods described above. Alternatively, the computer program can instruct related hardware to complete the process. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include any entity or device capable of carrying computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.

[0087] The computer-readable storage medium can be an internal storage unit of the electronic device in any of the foregoing embodiments, such as a hard disk or memory of the electronic device. The computer-readable storage medium can also be an external storage device of the electronic device, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc., provided on the electronic device. Furthermore, the computer-readable storage medium can include both internal and external storage units of the electronic device. The computer-readable storage medium is used to store computer programs and other programs and data required by the electronic device. The computer-readable storage medium can also be used to temporarily store data that has been output or will be output.

[0088] Those skilled in the art will recognize that the modules and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0089] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the electronic devices and units described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0090] In the several embodiments provided in this application, it should be understood that the disclosed electronic devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules, units, or components may be combined or integrated into another system, or some features may be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces or modules / units, or it may be an electrical, mechanical, or other form of connection.

[0091] The modules described as separate components may or may not be physically separate. Similarly, the components shown as modules may or may not be physical modules; they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of the embodiments of this application, depending on actual needs.

[0092] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A text similarity retrieval method based on an embedded model, characterized in that, include: Obtain the target text, extract keywords from the target text, and obtain multiple keywords; The multiple keywords are input into a pre-trained embedded model to obtain an expanded word set for each keyword; wherein, the pre-trained embedded model is used to expand the keyword based on the position of each keyword in the target text and the semantic distance to other keywords; The retrieval level of the target text is determined based on the text domain to which the target text belongs, and the retrieval level increases as the number of texts in the text domain to which the target text belongs increases; The target proportion of the target text is determined based on the retrieval level, and the target proportion increases as the retrieval level increases; Select expanded keywords from each expanded keyword set according to the target proportion to obtain multiple expanded keywords; The target retrieval text is determined based on the text similarity of the multiple expanded keywords and various texts in the text library.

2. The text similarity retrieval method based on an embedded model as described in claim 1, characterized in that, Before extracting keywords from the target text to obtain multiple keywords, the process also includes: The target text is preprocessed to obtain the preprocessed target text; Accordingly, keyword extraction is performed on the target text to obtain multiple keywords, including: Keyword extraction is performed on the preprocessed target text to obtain multiple keywords.

3. The text similarity retrieval method based on an embedded model as described in claim 2, characterized in that, The preprocessing of the target text to obtain preprocessed target text includes: The target text is processed by eliminating data noise and unifying semantic representation dimensions to obtain preprocessed target text.

4. The text similarity retrieval method based on an embedded model as described in claim 1, characterized in that, Before inputting the multiple keywords into the pre-trained embedded model to obtain the expanded vocabulary set corresponding to each keyword, the process also includes: Obtain multiple reference texts; For each reference text, keywords are extracted from the reference text to obtain multiple reference keywords; Based on the position of each reference keyword in the reference text and its semantic distance from other reference keywords, the reference keyword is expanded to obtain a reference expanded word set corresponding to each reference keyword; The embedded model is trained based on the reference keywords and reference expanded vocabulary sets corresponding to all reference texts, resulting in a well-trained embedded model.

5. The text similarity retrieval method based on an embedded model as described in claim 1, characterized in that, The process of determining the target retrieval text based on the text similarity of the multiple expanded keywords and various texts in the text library includes: Based on the similarity benchmark, if the semantic similarity is higher than the similarity benchmark, the target retrieval text is determined.

6. The text similarity retrieval method based on an embedded model as described in claim 5, characterized in that, The step of determining the target retrieval text based on the text similarity of the multiple expanded keywords and various texts in the text library also includes: If the semantic similarity is lower than the similarity benchmark, then keywords from another part of the expanded vocabulary set will be selected for retrieval.

7. A text similarity retrieval system based on an embedded model, characterized in that, include: The keyword extraction module is used to acquire target text, extract keywords from the target text, and obtain multiple keywords; An expanded word set acquisition module is used to input the multiple keywords into a pre-trained embedded model to obtain an expanded word set corresponding to each keyword; wherein, the pre-trained embedded model is used to expand the keyword based on the position of each keyword in the target text and the semantic distance to other keywords; The target proportion determination module is used to determine the retrieval level of the target text based on the text domain to which the target text belongs, wherein the retrieval level increases as the number of texts in the text domain to which the target text belongs increases; and to determine the target proportion of the target text based on the retrieval level, wherein the target proportion increases as the retrieval level increases. The module for obtaining expanded keywords is used to select expanded keywords from each expanded keyword set according to the target proportion, thereby obtaining multiple expanded keywords; The target retrieval text determination module is used to determine the target retrieval text based on the text similarity between the multiple expanded keywords and each text in the text library.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 6.

9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Word expansion method and device, equipment and medium

    CN110162770A

  • Extended question recommendation method and device, computer equipment and storage medium

    CN113688636A