Semantic similarity determination and semantic search method and apparatus for semantic search

CN115934894BActive Publication Date: 2026-08-07ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
Filing Date
2022-12-14
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

但由于训练过程中相似的语义表征会呈现出聚类效果,因而在困难样本(hard sample)上所得到的语义特征向量的区分度较差,从而影响语义搜索的准确率,尤其是较高难度样本下的语义搜索的准确率

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115934894B_ABST
    Figure CN115934894B_ABST
Patent Text Reader

Abstract

Embodiments of the present specification provide a semantic similarity determination method and device for semantic search. In the method for determining semantic similarity, the semantic feature vectors of each word segment of the obtained query text and the semantic feature vectors of each word segment of the reference text are respectively provided to a multi-category semantic feature vector generation model to obtain the category semantic feature vectors of the query text and the reference text under each category; a first category semantic feature vector with the strongest search intention is selected from the category semantic feature vectors of the query text, and a second category semantic feature vector under the category of the first category semantic feature vector is selected from the category semantic feature vectors of the reference text; and the semantic similarity between the query text and the reference text is determined according to the first category semantic feature vector and the second category semantic feature vector.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments in this specification generally relate to the field of computer technology, and in particular to semantic similarity determination and semantic search methods and apparatus for semantic search. Background Technology

[0002] With the rapid development of artificial intelligence technology, semantic search technology is being applied more and more widely. To find texts semantically similar to the input text within a large dataset, various text vectorization methods are typically used to convert the text into semantic feature vectors. The similarity between these vectors is then calculated to determine the similarity between the texts. Existing methods for calculating text semantic similarity often employ optimization techniques such as pre-training or fine-tuning to improve the accuracy of semantic representations. However, because similar semantic representations exhibit clustering effects during training, the semantic feature vectors obtained on hard samples have poor discriminative power, thus affecting the accuracy of semantic search, especially on highly difficult samples. Summary of the Invention

[0003] In view of the above, embodiments of this specification provide a semantic similarity determination method and apparatus for semantic search. Using this method and apparatus, semantic similarity for semantic search can be determined, thereby improving the accuracy of semantic similarity determination and the effectiveness of semantic search.

[0004] According to one aspect of the embodiments of this specification, a method for determining semantic similarity for semantic search is provided, comprising: obtaining semantic feature vectors of each word segment of a query text and semantic feature vectors of each word segment of a reference text; providing the semantic feature vectors of each word segment of the query text and the semantic feature vectors of each word segment of the reference text to a multi-category semantic feature vector generation model to obtain category semantic feature vectors of the query text and the reference text under each category; selecting a first category semantic feature vector with the strongest search intent from the category semantic feature vectors of the query text and selecting a second category semantic feature vector under the category of the first category semantic feature vector from the category semantic feature vectors of the reference text; and determining the semantic similarity between the query text and the reference text based on the first category semantic feature vector and the second category semantic feature vector.

[0005] According to another aspect of the embodiments of this specification, a semantic search method is provided, comprising: receiving a query text provided by a user; determining the semantic similarity between the query text and each reference text in a reference text set according to the semantic similarity determination method described above; determining a semantic search result from the reference text set based on the semantic similarity between the query text and each reference text; and providing the semantic search result to the user.

[0006] According to another aspect of the embodiments of this specification, a semantic similarity determination apparatus for semantic search is provided, comprising: a vector acquisition unit configured to acquire semantic feature vectors of each word segment of a query text and semantic feature vectors of each word segment of a reference text; a vector generation unit configured to provide the semantic feature vectors of each word segment of the query text and the semantic feature vectors of each word segment of the reference text to a multi-category semantic feature vector generation model respectively, to obtain category semantic feature vectors of the query text and the reference text under each category; a vector selection unit configured to select a first category semantic feature vector with the strongest search intent from the category semantic feature vectors of the query text and a second category semantic feature vector under the category of the first category semantic feature vector from the category semantic feature vectors of the reference text; and a similarity determination unit configured to determine the semantic similarity between the query text and the reference text based on the first category semantic feature vector and the second category semantic feature vector.

[0007] According to another aspect of the embodiments of this specification, a semantic search apparatus is provided, comprising: a receiving unit configured to receive a query text provided by a user; a semantic similarity determination device for semantic search as described above; a determining unit configured to determine a semantic search result from a set of reference texts based on the semantic similarity between the query text and various reference texts determined by the semantic similarity determination device; and a feedback unit configured to provide the semantic search result to the user.

[0008] According to another aspect of the embodiments of this specification, a semantic similarity determination apparatus for semantic search is provided, comprising: at least one processor, and a memory coupled to the at least one processor, the memory storing instructions that, when executed by the at least one processor, cause the at least one processor to perform the semantic similarity determination method for semantic search as described above.

[0009] According to another aspect of the embodiments of this specification, a semantic search apparatus is provided, comprising: at least one processor, and a memory coupled to the at least one processor, the memory storing instructions that, when executed by the at least one processor, cause the at least one processor to perform the semantic search method as described above.

[0010] According to another aspect of the embodiments of this specification, a computer-readable storage medium is provided that stores a computer program, which, when executed by a processor, implements the semantic similarity determination method and / or semantic search method for semantic search as described above.

[0011] According to another aspect of the embodiments of this specification, a computer program product is provided, including a computer program that is executed by a processor to implement the semantic similarity determination method and / or semantic search method for semantic search as described above. Attached Figure Description

[0012] A further understanding of the nature and advantages of this specification can be achieved by referring to the following figures. In the figures, similar components or features may have the same reference numerals.

[0013] Figure 1 An exemplary architecture of a semantic similarity determination and semantic search method and apparatus for semantic search according to embodiments of this specification is shown.

[0014] Figure 2 A flowchart illustrating an example of a semantic similarity determination method for semantic search according to embodiments of this specification is shown.

[0015] Figure 3a , Figure 3b , Figure 3c The diagrams show an example of the structure of a multi-category semantic feature vector generation model according to embodiments of this specification.

[0016] Figure 4 A schematic diagram illustrating an example of the training process of a multi-category semantic feature vector generation model according to an embodiment of this specification is shown.

[0017] Figure 5 A schematic diagram illustrating an example application scenario of the semantic similarity determination method for semantic search according to embodiments of this specification is shown.

[0018] Figure 6 A flowchart illustrating an example of a semantic search method according to an embodiment of this specification is shown.

[0019] Figure 7A block diagram of an example of a semantic similarity determination apparatus for semantic search according to embodiments of this specification is shown.

[0020] Figure 8 A block diagram illustrating an example of a semantic search apparatus according to an embodiment of this specification is shown.

[0021] Figure 9 A schematic diagram of an example of a semantic similarity determination apparatus for semantic search according to an embodiment of this specification is shown.

[0022] Figure 10 A schematic diagram illustrating an example of a semantic search apparatus according to an embodiment of this specification is shown. Detailed Implementation

[0023] The subject matter described herein will be discussed below with reference to exemplary embodiments. It should be understood that these embodiments are discussed merely to enable those skilled in the art to better understand and implement the subject matter described herein, and are not intended to limit the scope, applicability, or examples set forth in the claims. The function and arrangement of the elements discussed may be changed without departing from the scope of the embodiments described herein. Various processes or components may be omitted, substituted, or added as needed in the various examples. Furthermore, features described in some examples may be combined in other examples.

[0024] As used herein, the term "comprising" and its variations are open terms meaning "including but not limited to". The term "based on" means "at least partially based on". The terms "one embodiment" and "an embodiment" mean "at least one embodiment". The term "another embodiment" means "at least one other embodiment". The terms "first", "second", etc., may refer to different or the same objects. Other definitions, whether explicit or implicit, may be included below. Unless explicitly indicated by the context, the definition of a term shall remain consistent throughout the specification.

[0025] In this specification, the term "token" refers to a data structure obtained by segmenting (tokenizing) longer texts such as sentences, paragraphs, and articles into units of "words". Typically, the meaning of "word" can vary depending on the text segmentation method. For example, "token" can include not only words from the original text but also manually added tags (such as "[CLS]" at the beginning of a sentence or "[SEP]" at the end of a sentence).

[0026] In this specification, the term "semantic feature vector" can refer to any vector that can be used to represent semantic information. For example, it can be a word embedding obtained in various ways.

[0027] In this specification, the term "Capsule Network" can refer to a neural network consisting of multiple capsules. Each capsule outputs a vector, rather than a scalar as a neuron in a traditional artificial neural network outputs a vector. The magnitude of the vector output by the capsule, after being transformed by a squashing function, can be used to represent the probability of the existence of the entity represented by the capsule. In a capsule network, each lower-level capsule is connected to higher-level capsules by its own coupling coefficients. These coupling coefficients are determined based on a dynamic routing algorithm.

[0028] The semantic similarity determination and semantic search method and apparatus according to embodiments of this specification will now be described in detail with reference to the accompanying drawings.

[0029] Figure 1 An exemplary architecture 100 of a semantic similarity determination and semantic search method and apparatus for semantic search according to embodiments of this specification is shown.

[0030] exist Figure 1 In this context, network 110 is used to interconnect terminal device 120 and application server 130.

[0031] Network 110 can be any type of network capable of interconnecting network entities. Network 110 can be a single network or a combination of various networks. In terms of coverage, network 110 can be a local area network (LAN), a wide area network (WAN), etc. In terms of the carrying medium, network 110 can be a wired network, a wireless network, etc. In terms of data switching technology, network 110 can be a circuit-switched network, a packet-switched network, etc.

[0032] Terminal device 120 can be any type of electronic computing device capable of connecting to network 110, accessing servers or websites on network 110, processing data or signals, etc. For example, terminal device 120 can be a desktop computer, laptop computer, tablet computer, smartphone, etc. Although in Figure 1 Only one terminal device is shown in the diagram, but it should be understood that a different number of terminal devices may be connected to network 110.

[0033] In one implementation, terminal device 120 can be used by a user. Terminal device 120 may include an application client (e.g., application client 121) that can provide various services to the user. In some cases, application client 121 may interact with application server 130. For example, application client 121 may transmit user-inputted messages to application server 130 and receive responses associated with those messages from application server 130. However, it should be understood that in other cases, application client 121 may also generate responses to user-inputted messages locally, rather than interacting with application server 130. In this document, "message" can refer to any input information, such as query text 1211 input by the user.

[0034] Application server 130 can be connected to reference text database 131. Reference text database 131 may include multiple reference texts. Optionally, reference text database 131 may also include semantic feature vectors corresponding to each word segmentation of the multiple reference texts.

[0035] It should be understood that Figure 1 All network entities shown are exemplary, and any other network entities may be involved in Architecture 100 depending on the specific application requirements.

[0036] Figure 2 A flowchart of a semantic similarity determination method 200 for semantic search according to an embodiment of this specification is shown.

[0037] like Figure 2 As shown in step 210, the semantic feature vectors of each word segment of the text to be queried and the semantic feature vectors of each word segment of the reference text are obtained.

[0038] In this embodiment, the semantic feature vectors of each word segment of the query text and the semantic feature vectors of each word segment of the reference text can be obtained through various methods. The query text and the reference text can be various texts for which semantic similarity is to be calculated, such as phrases, sentences, articles, etc. As an example, the query text and the reference text can be obtained first. Then, the obtained query text and reference text are segmented to obtain each word of the query text and the reference text. Afterwards, the semantic feature vectors of each word segment of the query text and the reference text can be obtained through various methods (e.g., the word2vec model). As another example, the semantic feature vectors of each word segment of the query text and the reference text can also be directly obtained through a method similar to the above.

[0039] In some optional implementations of this embodiment, each segment of the text to be queried and each segment of the reference text can be provided to a bidirectional encoder based on Transformers to obtain the semantic feature vectors of each segment of the text to be queried and the semantic feature vectors of each segment of the reference text.

[0040] In these implementations, the aforementioned Transformers-based bidirectional encoders can be pre-trained models such as BERT (Bidirectional Encoder Representation from Transformers), XLNet, and ALBERT. As an example, the BERT model can be pre-trained using corpus related to the query text. Then, the pre-trained BERT model can be used to encode the semantic feature vectors of each word segment of the query text and each word segment of the reference text to obtain the semantic feature vectors corresponding to each word segment.

[0041] Based on this, a pre-trained Transformers-based bidirectional encoder can be used to generate semantic feature vectors for each word segment, thereby improving the representation ability of the semantic feature vectors of the input multi-category semantic feature vector generation model and helping to improve the accuracy of the semantic similarity determination method.

[0042] In step 220, the semantic feature vectors of each word segment of the query text and the semantic feature vectors of each word segment of the reference text are respectively provided to the multi-category semantic feature vector generation model to obtain the category semantic feature vectors of the query text and the reference text under each category.

[0043] In this embodiment, the semantic feature vectors of each word segment of the query text and the semantic feature vectors of each word segment of the reference text can be provided to a multi-category semantic feature vector generation model to obtain category semantic feature vectors of the query text and the reference text under each category. Each category semantic feature vector can be used to represent the semantic features of the text under that category. The aforementioned multi-category semantic feature vector generation model can include various pre-trained artificial neural network structures for natural language processing. The categories mentioned above can, for example, be used to represent different contexts.

[0044] As an example, such as Figure 3aAs shown, the aforementioned multi-category semantic feature vector generation model can include an input layer, a hidden layer, and an output layer. The hidden layer can include multiple layers (only one layer is shown in the figure). The output layer can include, for example, a fully connected layer and a softmax layer. Each neuron in the output layer can correspond to a preset category. Therefore, after providing the semantic feature vectors of each word segment of the query text to the aforementioned multi-category semantic feature vector generation model, and passing through the input layer and hidden layer, the category semantic feature vectors of the query text under each category can be obtained based on the output of the last hidden layer and the weight matrix between the last hidden layer and the output layer. Specifically, firstly, after passing through the input layer, the semantic feature vectors of each word segment of the query text (e.g., ...) can be obtained. Where n is the number of word segments), the semantic feature vectors of each word segment are fused into a sentence vector (e.g., ...). The aforementioned fusion methods may include concatenating the semantic feature vectors (e.g., the `concat` method), summing corresponding elements in the semantic feature vectors (e.g., the `add` method), or averaging the summed elements (e.g., using the `add` method and then dividing each element by the number of words segmented). After passing through hidden layers, each neuron in the final hidden layer can output a value, thus forming a vector (e.g., [h1, h2, ..., h...]). k [where k is the number of neurons in the last hidden layer]. Then, by multiplying the connection weights between each neuron in the last hidden layer and each neuron in the output layer by the corresponding output value of the neuron in the last hidden layer, we can obtain the vector corresponding to each neuron in the output layer, which is the category semantic feature vector of the query text under each category. For example, the first neuron in the output layer can correspond to the first category. The outputs of each neuron in the last hidden layer (e.g., [h1, h2, ..., h...]) can be used to define the category semantic feature vector of the query text under each category. k ] and the corresponding connection weights (e.g., w) 11 w 21 ,…,w k1 , where w 11 w 21 w k1 The weights (which can be used to represent the connection weights between the first, second, and kth neurons in the last hidden layer and the first neuron in the output layer) are multiplied respectively to obtain the category semantic feature vector of the query text under the first category (e.g., [h1×w)). 11 h2×w 21 , ..., h k ×w k1Similarly, the second and third neurons in the output layer can correspond to the second and third categories, respectively. This allows us to obtain the category semantic feature vectors of the query text under the second and third categories. It can be understood that the number of neurons in the output layer can be flexibly set according to the actual application scenario (e.g., the required number of categories).

[0045] It should be noted that the aforementioned multi-category semantic feature vector generation model can employ a Siamese network structure. For example, the semantic feature vectors of each word segment of the query text can be provided to the first multi-category semantic feature vector generation model to obtain the category semantic feature vectors of the query text under each category. Simultaneously, the semantic feature vectors of each word segment of the reference text can be provided to the second multi-category semantic feature vector generation model to obtain the semantic feature vectors of each word segment of the reference text under each category. The network structure and parameters of the first and second multi-category semantic feature vector generation models are typically the same.

[0046] In some optional implementations of this embodiment, the semantic feature vectors of each word segment of the query text and the semantic feature vectors of each word segment of the reference text can be provided to each sub-model to obtain the category semantic feature vectors of the query text and the reference text under each category. The aforementioned multi-category semantic feature vector generation model can include multiple sub-models. Each sub-model can correspond to one category. Each sub-model can include a network containing vector neurons. Figure 3b As shown, each sub-model can output a high-dimensional vector through a vector neuron network. The output high-dimensional vectors can be used as category semantic feature vectors of the query text or reference text under each category.

[0047] Based on this, high-dimensional vectors that can be directly output by vector neurons as category semantic feature vectors can be used, which enriches the ways to obtain category semantic feature vectors.

[0048] Optionally, the above sub-models may also include capsule networks based on dynamic routing mechanisms. For example... Figure 3c As shown, the semantic feature vectors of each word segment of the query text and the semantic feature vectors of each word segment of the reference text can be provided to each capsule based on the dynamic routing mechanism, so as to obtain the category semantic feature vectors of the query text and the reference text under each category output by each capsule.

[0049] Based on this, capsule networks based on dynamic routing mechanisms can be used to improve the efficiency of category semantic feature vector generation.

[0050] Optionally, each sub-model may include an extrusion processing layer based on the hyperbolic tangent function. This can be achieved using a formula. The vectors output by sub-models such as capsules are compressed so that the norm of the output vectors ranges from [0,1). It can be used to characterize the vector obtained after extrusion processing. It can be used to characterize the vectors output by the above sub-models. It can be used to characterize the magnitude of the vector output by the above sub-model.

[0051] Based on this, compared to the formula used in existing technologies... (The relevant parameters can be referred to the description of the above formula) The vector magnitude is compressed. The hyperbolic tangent function used in this scheme can slow down the compression when the vector magnitude approaches 0, thereby increasing the smoothness of the compression process of the vector magnitude and improving the representation effect of the output vector magnitude.

[0052] Back Figure 2 In 230, the first category semantic feature vector with the strongest search intent is selected from the category semantic feature vector of the text to be queried, and the second category semantic feature vector under the category of the first category semantic feature vector is selected from the category semantic feature vector of the reference text.

[0053] In this embodiment, each category semantic feature vector output by the aforementioned multi-category semantic feature vector generation model can correspond to a search intent probability. The search intent probability can be obtained based on the aforementioned multi-category semantic feature vector generation model. As an example, the aforementioned multi-category semantic feature vector generation model can be as follows: Figure 3a As shown, the search intent probability corresponding to each category semantic feature vector can be determined based on the output results of each neuron in the output layer of the multi-category semantic feature vector generation model. For example, as mentioned above, the first neuron in the output layer can correspond to the first category. The category semantic feature vector of the query text under the first category can be represented by [h1×w]. 11 h2×w 21 , ..., h k ×w k1 The above query text, represented by the category semantic feature vector under the first category, can be converted into the corresponding search intent value (e.g., h1×w). 11 +h2×w 21 +…+h k ×w k1Similarly, the search intent values ​​corresponding to the category semantic feature vectors of the text to be queried under each category can be determined. Then, the search intent values ​​corresponding to the category semantic feature vectors under each category can be converted into corresponding search intent probabilities in various ways, such as using the softmax function.

[0054] In some optional implementations of this embodiment, as an example, the above-mentioned multi-category semantic feature vector generation model can be as follows: Figure 3b As shown, the search intent probability corresponding to the category semantic feature vector can be determined based on the magnitude of the high-dimensional vector output by the vector neuron network through the multi-category semantic feature vector generation model described above. For example, the value obtained after normalizing the magnitude of each category semantic feature vector can be used as the corresponding search intent probability.

[0055] In some optional implementations of this embodiment, as an example, the above-mentioned multi-category semantic feature vector generation model can be as follows: Figure 3c As shown, the search intent probability corresponding to each category semantic feature vector can be determined based on the modulus of the category semantic feature vectors output by the capsule, according to the multi-category semantic feature vector generation model described above. For example, the modulus of each normalized category semantic feature vector can be used as the corresponding search intent probability.

[0056] In this embodiment, the category semantic feature vector with the highest probability of search intent (e.g., the category semantic feature vector under the second category) can be selected from the category semantic feature vectors of the text to be queried as the first category semantic feature vector. Then, the category semantic feature vector under the category (e.g., the second category mentioned above) of the first category semantic feature vector can be selected from the category semantic feature vectors of the reference text as the second category semantic feature vector.

[0057] In step 240, the semantic similarity between the query text and the reference text is determined based on the semantic feature vectors of the first category and the second category.

[0058] In this embodiment, the semantic similarity between the first category semantic feature vector and the second category semantic feature vector can be determined as the semantic similarity between the query text and the reference text. The semantic similarity can be expressed in the form of at least one of the following: Euclidean distance, cosine similarity, or cosine distance.

[0059] Figure 4 A flowchart of the training process 400 of a multi-category semantic feature vector generation model according to an embodiment of this specification is shown.

[0060] like Figure 4 As shown, at 410, the training sample set is obtained.

[0061] In this embodiment, the training sample set may include sample text pairs and corresponding similarity labels for the sample text pairs. The similarity labels may include, for example, "0" (representing semantic dissimilarity) and "1" (representing semantic similarity).

[0062] In step 420, the semantic feature vectors of each word segment corresponding to the sample text pairs in the training sample set are taken as input, and the similarity labels corresponding to the sample text pairs are taken as the expected output, thus obtaining the trained multi-category semantic feature vector generation model.

[0063] In this embodiment, the semantic feature vectors of each word corresponding to the sample text pairs in the training sample set can be obtained through various methods. The sample text pairs may include sample query text and sample reference text. Various encoding methods, as described in step 210 and its optional implementations, can be used to obtain the semantic feature vectors corresponding to each word of the sample query text and sample reference text. Then, the semantic feature vectors of each word of the sample query text and the sample reference text can be provided to the initial multi-category semantic feature vector generation model to obtain the category semantic feature vectors of the sample query text and the sample reference text under each category. Next, the category semantic feature vector with the strongest search intent can be selected from the category semantic feature vectors of the sample query text as the first category semantic feature vector of the sample query text. Then, the category semantic feature vector under the category of the first category semantic feature vector of the sample query text can be selected from the category semantic feature vectors of the sample reference text as the second category semantic feature vector of the sample reference text. Next, the semantic similarity between the first category semantic feature vector of the sample query text and the second category semantic feature vector of the sample reference text can be determined. Then, a preset loss function is used to determine the difference between the semantic similarity and the corresponding similarity label between the first category semantic feature vector of the sample query text and the second category semantic feature vector of the sample reference text. This loss function can include, for example, the Cross Entropy Loss function or the Mean Square Error loss function. The network parameters of the initial multi-category semantic feature vector generation model can then be adjusted based on backpropagation. The above steps are repeated, and training is stopped when the training stopping condition is met, thus obtaining the trained multi-category semantic feature vector generation model.

[0064] Optionally, when the above encoding method uses a pre-trained encoder model such as BERT, the parameters of the encoder model can also be fine-tuned during the training process of the multi-category semantic feature vector generation model.

[0065] The difference between the continuity of semantic similarity calculations (e.g., cosine similarity, cosine distance, etc.) and the discontinuity of natural language means that directly using a loss function based on semantic similarity as the optimization objective during the training phase is not ideal for difficult samples. For example, adding a single "not" in natural language can lead to a semantic reversal. Therefore, existing technologies often use different objectives during the training and prediction phases (e.g., using a loss function based on classification results rather than semantic similarity calculations during training) to mitigate the difference between continuous functions and discontinuous natural language. However, this approach relies heavily on model initialization, resulting in unstable training performance. In contrast, the multi-category semantic feature vector generation model proposed in this paper uses a loss function during model training based on the difference between the semantic similarity between the first and second category semantic feature vectors obtained from the input sample text pairs and the corresponding similarity labels of the sample text pairs. This allows for more detailed semantic differentiation through different semantic feature vectors across multiple categories and maintains consistency between the task objectives during the training and prediction phases, significantly reducing reliance on model initialization results and improving the training stability of the multi-category semantic feature vector generation model.

[0066] Figure 5 A schematic diagram illustrating an example of an application scenario 500 of a semantic similarity determination method for semantic search according to an embodiment of this specification is shown.

[0067] like Figure 5As shown, the semantic feature vectors of each word segment of the query text (as shown in Figure 510) (as shown in Figure 520) and the semantic feature vectors of each word segment of the reference text (as shown in Figure 530) (as shown in Figure 540) can be obtained first. Then, the semantic feature vectors of each word segment of the query text (as shown in Figure 510) (as shown in Figure 520) can be provided to the multi-category semantic feature vector generation model (as shown in Figure 550) to obtain the category semantic feature vectors of the query text under each category (as shown in Figure 570). Similarly, the semantic feature vectors of each word segment of the reference text (as shown in Figure 530) (as shown in Figure 540) can be provided to the multi-category semantic feature vector generation model (as shown in Figure 560) to obtain the category semantic feature vectors of the reference text under each category (as shown in Figure 580). The multi-category semantic feature vector generation models shown in Figures 550 and 560 can be the same model using a Siamese network structure, or they can be the same model. Next, the first category semantic feature vector with the strongest search intent can be selected from the category semantic feature vectors of the query text under each category (as shown in Figure 570), for example, category semantic feature vector 2 (as shown in Figure 571). Furthermore, the second category semantic feature vector under the category of the first category semantic feature vector can be selected from the category semantic feature vector of the reference text (as shown in Figure 580), for example, category semantic feature vector 2 corresponding to the same category as category semantic feature vector 2 of the query text (as shown in Figure 581). Finally, the cosine similarity between the first category semantic feature vector (as shown in Figure 571) and the second category semantic feature vector (as shown in Figure 581) can be determined as the semantic similarity between the query text and the reference text.

[0068] use Figures 1-5The disclosed semantic similarity determination method for semantic search provides semantic feature vectors of each word segment of the query text and each word segment of the reference text to a multi-category semantic feature vector generation model. This yields category semantic feature vectors for both the query text and the reference text in their respective categories. The semantic similarity between the query text and the reference text is determined by selecting the first category semantic feature vector with the strongest search intent from the category semantic feature vectors of the query text, and selecting the second category semantic feature vector within the category containing the first category semantic feature vector from the category semantic feature vectors of the reference text. Compared to existing techniques that rely solely on optimization methods such as pre-training or fine-tuning to improve the accuracy of semantic representation, this method generates multiple category semantic feature vectors for a single text (e.g., the query text or the reference text), representing the semantic expression of the text in different contexts. This allows for distance metric calculation of semantic representations within more granular categories, resulting in more pronounced semantic distinctions and improved accuracy for difficult samples.

[0069] Figure 6 A flowchart of a semantic search method 600 according to an embodiment of this specification is shown.

[0070] like Figure 6 As shown, at 610, the text to be queried provided by the user is received.

[0071] In this embodiment, the text to be queried provided by the user can be received in various ways. The text to be queried can be text directly entered by the user, or it can be converted into text by optical character recognition (OCR) or automatic speech recognition (ASR) from images, videos, voice, etc. entered by the user using the user's terminal. There is no limitation here.

[0072] In step 620, the semantic similarity between the query text and each reference text in the reference text set is determined according to the semantic similarity determination method described above.

[0073] In this embodiment, it can be based on, as follows Figures 1-5 The semantic similarity determination method for semantic search described herein determines the semantic similarity between the query text and each reference text in a reference text set. The reference text set may include multiple reference texts. The reference texts included in the reference text set can be set according to actual needs. For example, it may include all candidate texts or a subset of candidate texts recalled based on various coarse screening methods.

[0074] In step 630, semantic search results are determined from the reference text set based on the semantic similarity between the query text and each reference text.

[0075] In this embodiment, based on the semantic similarity between the query text and each reference text, semantic search results can be determined from the reference text set in various ways. For example, the reference texts with the highest semantic similarity can be determined as semantic search results. As another example, reference texts with semantic similarity greater than a preset threshold can be used as candidate results, and then several reference texts can be determined from these candidate results as semantic search results through methods such as random selection or selection based on user preferences.

[0076] In 640, semantic search results are provided to users.

[0077] In this embodiment, the semantic search results can be provided to the user in various forms. For example, the semantic search results can be arranged in a list format in descending order of semantic similarity. Optionally, the corresponding semantic similarity can also be displayed near each semantic search result. Optionally, the category with the strongest search intent for the queried text can also be displayed, such as the category with the highest probability of search intent.

[0078] It should be noted that the users provided with the semantic search results can be the same users as those described in step 610 above, or users using the same client as those described in step 610 above; there is no limitation here.

[0079] In some optional implementations of this embodiment, the semantic search method described above can be applied to service search, and each category includes each service category.

[0080] In these implementation methods, the service search mentioned above can include searching for service-related keywords such as ordering food, shopping, express delivery, weather, and government services. Each category can include various service categories, which can be specifically set according to the actual application scenario.

[0081] Based on the above, semantic search methods that can be applied to service search and other fields are provided, thereby improving the effectiveness of semantic search under more detailed classifications, such as the ability to distinguish semantic differences between different subcategories under the same high-level category, thereby improving the accuracy of semantic search.

[0082] Figure 7 A block diagram illustrating an example of a semantic similarity determination apparatus 700 for semantic search according to an embodiment of this specification is shown. This apparatus embodiment can be used with... Figures 1-5 Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.

[0083] like Figure 7 As shown, the semantic similarity determination device 700 for semantic search may include a vector acquisition unit 710, a vector generation unit 720, a vector selection unit 730, and a similarity determination unit 740.

[0084] Vector acquisition unit 710 is configured to acquire the semantic feature vectors of each word segment of the text to be queried and the semantic feature vectors of each word segment of the reference text. The operation of vector acquisition unit 710 can be referred to above. Figure 2 The operation described in section 210.

[0085] In one example, the vector acquisition unit 710 can be further configured to: provide each segment of the query text and each segment of the reference text to a Transformers-based bidirectional encoder, respectively, to obtain the semantic feature vectors of each segment of the query text and the semantic feature vectors of each segment of the reference text. The operation of the vector acquisition unit 710 can be referred to above. Figure 2 The operation of the optional implementations in 210 described.

[0086] Vector generation unit 720 is configured to provide the semantic feature vectors of each word segment of the query text and the semantic feature vectors of each word segment of the reference text to the multi-category semantic feature vector generation model, respectively, to obtain the category semantic feature vectors of the query text and the reference text under each category. The operation of vector generation unit 720 can be referred to above. Figure 2 The operation described in section 220.

[0087] In one example, the multi-category semantic feature vector generation model described above can include multiple sub-models. Each sub-model can correspond to one category. The vector generation unit 720 can be further configured to provide the semantic feature vectors of each word segment of the query text and the semantic feature vectors of each word segment of the reference text to each sub-model, respectively, to obtain the category semantic feature vectors of the query text and the reference text under each category. The operation of the vector generation unit 720 can be referred to above. Figure 2 The operation of the 220 optional implementations described.

[0088] In one example, the sub-model described above may further include a capsule network based on a dynamic routing mechanism. The vector generation unit 720 can be further configured to provide the semantic feature vectors of each segment of the query text and each segment of the reference text to each capsule based on the dynamic routing mechanism, thereby obtaining the category semantic feature vectors of the query text and the reference text under each category. The operation of the vector generation unit 720 can be referred to above. Figure 2 The operation of the 220 optional implementations described.

[0089] In one example, each sub-model may include a squeezing layer based on the hyperbolic tangent function. See above for reference. Figure 2 Descriptions of the 220 optional implementation methods.

[0090] In one example, the loss function used by the multi-category semantic feature vector generation model during model training can be obtained based on the difference between the semantic similarity between the first and second category semantic feature vectors obtained from the input sample text pairs and the corresponding similarity labels of the sample text pairs. (Refer to the above...) Figure 4 The description of 420 and its optional implementations is provided.

[0091] Vector selection unit 730 is configured to select the first category semantic feature vector with the strongest search intent from the category semantic feature vector of the text to be queried, and to select the second category semantic feature vector under the category of the first category semantic feature vector from the category semantic feature vector of the reference text. The operation of vector selection unit 730 can be referred to above. Figure 2 The operation described in section 230.

[0092] The similarity determination unit 740 is configured to determine the semantic similarity between the query text and the reference text based on the semantic feature vectors of the first category and the second category. The operation of the similarity determination unit 740 can be referenced above. Figure 2 The operation described in section 240.

[0093] Figure 8 A block diagram illustrating an example of a semantic search apparatus 800 according to an embodiment of this specification is shown. This apparatus embodiment can be used with... Figure 6 Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.

[0094] like Figure 8 As shown, the semantic search device 800 may include a receiving unit 810, a semantic similarity determination device 820 for semantic search, a determination unit 830, and a feedback unit 840.

[0095] The receiving unit 810 is configured to receive the text to be queried provided by the user. The operation of the receiving unit 810 can be referred to above. Figure 6 The operation of 610 is described.

[0096] The semantic similarity determination device 820 used for semantic search can refer to the above. Figure 7 The relevant description in the document.

[0097] The determining unit 830 is configured to determine a semantic search result from the set of reference texts based on the semantic similarity between the query text and each reference text determined by the semantic similarity determining device. The operation of the determining unit 830 can be referred to above. Figure 6 The operation described in section 630.

[0098] Feedback unit 840 is configured to provide semantic search results to the user. The operation of feedback unit 840 can be referenced above. Figure 6 The operation described in section 640.

[0099] Reference above Figures 1 to 8 The present specification describes a semantic similarity determination method and apparatus for semantic search, and embodiments of the semantic search method and apparatus according to embodiments thereof.

[0100] The semantic similarity determination device and semantic search device for semantic search in the embodiments of this specification can be implemented in hardware, software, or a combination of hardware and software. Taking software implementation as an example, as a logical device, it is formed by the processor of its host device reading the corresponding computer program instructions from the memory into memory and executing them. In the embodiments of this specification, the semantic similarity determination device and semantic search device for semantic search can be implemented, for example, using electronic devices.

[0101] Figure 9 A schematic diagram of a semantic similarity determination apparatus 900 for semantic search according to an embodiment of this specification is shown.

[0102] like Figure 9 As shown, the semantic similarity determination apparatus 900 for semantic search may include at least one processor 910, a memory (e.g., non-volatile memory) 920, a memory 930, and a communication interface 940, and the at least one processor 910, the memory 920, the memory 930, and the communication interface 940 are connected together via a bus 950. The at least one processor 910 executes at least one computer-readable instruction (i.e., the elements implemented in software above) stored or encoded in the memory.

[0103] In one embodiment, computer-executable instructions are stored in memory, which, when executed, cause at least one processor 910 to: acquire semantic feature vectors of each segment of a query text and semantic feature vectors of each segment of a reference text; provide the semantic feature vectors of each segment of the query text and the semantic feature vectors of each segment of the reference text to a multi-category semantic feature vector generation model to obtain category semantic feature vectors of the query text and the reference text under each category; select a first category semantic feature vector with the strongest search intent from the category semantic feature vectors of the query text and a second category semantic feature vector under the category of the first category semantic feature vector from the category semantic feature vectors of the reference text; and determine the semantic similarity between the query text and the reference text based on the first category semantic feature vector and the second category semantic feature vector.

[0104] It should be understood that the computer-executable instructions stored in memory, when executed, cause at least one processor 910 to perform the above-described combinations in the various embodiments of this specification. Figure 1-5 The description includes various operations and functions.

[0105] Figure 10 A schematic diagram of a semantic search device 1000 according to an embodiment of this specification is shown.

[0106] like Figure 10 As shown, the apparatus 1000 for infringement determination may include at least one processor 1010, a memory (e.g., non-volatile memory) 1020, a RAM 1030, and a communication interface 1040, and the at least one processor 1010, memory 1020, RAM 1030, and communication interface 1040 are connected together via a bus 1050. At least one processor 1010 executes at least one computer-readable instruction (i.e., the elements implemented in software described above) stored or encoded in the memory.

[0107] In one embodiment, computer-executable instructions are stored in memory that, when executed, cause at least one processor 1010 to: receive a query text provided by a user; determine the semantic similarity between the query text and various reference texts in a reference text set according to the semantic similarity determination method described above; determine a semantic search result from the reference text set based on the semantic similarity between the query text and the various reference texts; and provide the semantic search result to the user.

[0108] It should be understood that the computer-executable instructions stored in memory, when executed, cause at least one processor 1010 to perform the above-described combinations in the various embodiments of this specification. Figure 6 The description includes various operations and functions.

[0109] According to one embodiment, a program product, such as a computer-readable medium, is provided. The computer-readable medium may have instructions (i.e., the elements implemented in software as described above), which, when executed by a computer, cause the computer to perform the above-described combinations of the various embodiments of this specification. Figure 1-6 The description includes various operations and functions.

[0110] Specifically, a system or apparatus equipped with a readable storage medium may be provided, on which software program code implementing the functions of any of the embodiments described above is stored, and the computer or processor of the system or apparatus can read and execute the instructions stored in the readable storage medium.

[0111] In this case, the program code itself, which can be read from a readable medium, can perform the functions of any of the above embodiments. Therefore, the machine-readable code and the readable storage medium storing the machine-readable code constitute a part of the present invention.

[0112] The computer program code required for the operation of each part of this manual can be written in any one or more programming languages, including object-oriented programming languages ​​such as Java, Scala, Smalltalk, Eiffel, JADE, Emerald, C++, C#, VB, .NET, and Python; conventional procedural programming languages ​​such as C, Visual Basic 2003, Perl, COBOL 2002, PHP, and ABAP; dynamic programming languages ​​such as Python, Ruby, and Groovy; or other programming languages. This program code can run on the user's computer, or as a standalone software package on the user's computer, or partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer can be connected to the user's computer via any network, such as a local area network (LAN) or wide area network (WAN), or connected to an external computer (e.g., via the Internet), or in a cloud computing environment, or used as a service, such as Software as a Service (SaaS).

[0113] Examples of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, program code can be downloaded from a server computer or the cloud via a communication network.

[0114] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

[0115] Not all steps and units in the above process and system structure diagrams are mandatory; some steps or units can be omitted as needed. The execution order of each step is not fixed and can be determined as required. The device structure described in the above embodiments can be a physical structure or a logical structure. That is, some units may be implemented by the same physical entity, or some units may be implemented by multiple physical entities, or they may be jointly implemented by certain components in multiple independent devices.

[0116] The term "exemplary" as used throughout this specification means "serving as an example, instance, or illustration" and does not imply that it is "preferred" or "advantageous" over other embodiments. Detailed descriptions are included for the purpose of providing an understanding of the described techniques. However, these techniques may be practiced without these detailed descriptions. In some instances, well-known structures and apparatuses are shown in block diagram form to avoid obscuring the concepts of the described embodiments.

[0117] The optional embodiments of the present specification have been described in detail above with reference to the accompanying drawings. However, the embodiments of the present specification are not limited to the specific details in the above embodiments. Within the scope of the technical concept of the embodiments of the present specification, various simple modifications can be made to the technical solutions of the embodiments of the present specification, and these simple modifications all fall within the protection scope of the embodiments of the present specification.

[0118] The foregoing description of this specification is provided to enable any person skilled in the art to implement or use the content of this specification. Various modifications to the content of this specification will be apparent to those skilled in the art, and the general principles defined herein can be applied to other variations without departing from the scope of protection of this specification. Therefore, this specification is not limited to the examples and designs described herein, but is consistent with the widest scope of the principles and novel features disclosed herein.

Claims

1. A method for determining semantic similarity for semantic search, comprising: Obtain the semantic feature vectors of each word in the text to be queried and the semantic feature vectors of each word in the reference text; The semantic feature vectors of each word segment of the text to be queried and the semantic feature vectors of each word segment of the reference text are respectively provided to the multi-category semantic feature vector generation model to obtain the category semantic feature vectors of the text to be queried and the reference text under each category. The first category semantic feature vector with the strongest search intent is selected from the category semantic feature vector of the text to be queried, and the second category semantic feature vector under the category of the first category semantic feature vector is selected from the category semantic feature vector of the reference text. Each category semantic feature vector corresponds to a search intent probability, and each search intent is obtained by transforming the corresponding category semantic feature vector. The search intent is reflected by the search intent probability. Based on the first category semantic feature vector and the second category semantic feature vector, the semantic similarity between the query text and the reference text is determined.

2. The semantic similarity determination method as described in claim 1, wherein, The multi-category semantic feature vector generation model includes multiple sub-models, each corresponding to a category. The step of providing the semantic feature vectors of each word segment of the query text and the semantic feature vectors of each word segment of the reference text to the multi-category semantic feature vector generation model to obtain the category semantic feature vectors of the query text and the reference text under each category includes: The semantic feature vectors of each word segment of the text to be queried and the semantic feature vectors of each word segment of the reference text are provided to each sub-model to obtain the category semantic feature vectors of the text to be queried and the reference text under each category.

3. The semantic similarity determination method as described in claim 2, wherein, The sub-model also includes capsule networks based on dynamic routing mechanisms. The step of providing the semantic feature vectors of each word segment of the query text and the semantic feature vectors of each word segment of the reference text to each sub-model to obtain the category semantic feature vectors of the query text and the reference text under each category includes: Based on a dynamic routing mechanism, the semantic feature vectors of each word segment of the query text and the semantic feature vectors of each word segment of the reference text are provided to each capsule to obtain the category semantic feature vectors of the query text and the reference text under each category.

4. The semantic similarity determination method as described in claim 2, wherein, Each sub-model includes a compression layer based on the hyperbolic tangent function.

5. The semantic similarity determination method as described in claim 1, wherein, The process of obtaining the semantic feature vectors of each word segment of the text to be queried and the semantic feature vectors of each word segment of the reference text includes: Each word segment of the query text and each word segment of the reference text are provided to a bidirectional encoder based on Transformers to obtain the semantic feature vectors of each word segment of the query text and the semantic feature vectors of each word segment of the reference text.

6. The semantic similarity determination method as described in any one of claims 1 to 5, wherein, The loss function used in the multi-category semantic feature vector generation model during model training is based on the difference between the semantic similarity between the first category semantic feature vector and the second category semantic feature vector obtained from the input sample text pairs and the similarity label corresponding to the sample text pairs.

7. A semantic search method, comprising: Receive the text to be queried provided by the user; The semantic similarity between the text to be queried and each reference text in the reference text set is determined according to the semantic similarity determination method as described in any one of claims 1 to 6. Based on the semantic similarity between the query text and each reference text, a semantic search result is determined from the reference text set; and The semantic search results are provided to the user.

8. The semantic search method as described in claim 7, wherein, The semantic search method is applied to service search, as well as to various categories including various service categories.

9. A semantic similarity determination device for semantic search, comprising: The vector acquisition unit is configured to acquire the semantic feature vectors of each word segment of the text to be queried and the semantic feature vectors of each word segment of the reference text. The vector generation unit is configured to provide the semantic feature vectors of each word segment of the text to be queried and the semantic feature vectors of each word segment of the reference text to the multi-category semantic feature vector generation model, so as to obtain the category semantic feature vectors of the text to be queried and the reference text under each category. The vector selection unit is configured to select a first category semantic feature vector with the strongest search intent from the category semantic feature vector of the text to be queried, and to select a second category semantic feature vector under the category of the first category semantic feature vector from the category semantic feature vector of the reference text. Each category semantic feature vector corresponds to a search intent probability, and each search intent is obtained by conversion based on the corresponding category semantic feature vector. The search intent is reflected by the search intent probability. as well as The similarity determination unit is configured to determine the semantic similarity between the query text and the reference text based on the first category semantic feature vector and the second category semantic feature vector.

10. The semantic similarity determination apparatus as described in claim 9, wherein, The multi-category semantic feature vector generation model includes multiple sub-models, each corresponding to a category. The vector generation unit is further configured as follows: The semantic feature vectors of each word segment of the text to be queried and the semantic feature vectors of each word segment of the reference text are provided to each sub-model to obtain the category semantic feature vectors of the text to be queried and the reference text under each category.

11. The semantic similarity determination apparatus as described in claim 10, wherein, The sub-model also includes capsule networks based on dynamic routing mechanisms. The vector generation unit is further configured as follows: Based on a dynamic routing mechanism, the semantic feature vectors of each word segment of the query text and the semantic feature vectors of each word segment of the reference text are provided to each capsule to obtain the category semantic feature vectors of the query text and the reference text under each category.

12. The semantic similarity determination apparatus as described in any one of claims 9 to 11, wherein, The vector acquisition unit is further configured to: Each word segment of the query text and each word segment of the reference text are provided to a bidirectional encoder based on Transformers to obtain the semantic feature vectors of each word segment of the query text and the semantic feature vectors of each word segment of the reference text.

13. A semantic search device, comprising: The receiving unit is configured to receive the text to be queried provided by the user. The semantic similarity determination apparatus for semantic search as described in any one of claims 9 to 12; The determining unit is configured to determine a semantic search result from the reference text set based on the semantic similarity between the query text and each reference text in the reference text set as determined by the semantic similarity determining device. as well as The feedback unit is configured to provide the semantic search results to the user.

14. A semantic similarity determination device for semantic search, comprising: At least one processor, a memory coupled to the at least one processor, and a computer program stored on the memory, wherein the at least one processor executes the computer program to implement the method as claimed in any one of claims 1 to 6.

15. A semantic search device, comprising: At least one processor, a memory coupled to the at least one processor, and a computer program stored on the memory, wherein the at least one processor executes the computer program to implement the method as claimed in claim 7 or 8.

16. A computer-readable storage medium storing a computer program that, when executed by a processor, implements the method as claimed in claims 1 to 6 or as claimed in any one of claims 7 to 8.

17. A computer program product comprising a computer program that is executed by a processor to implement the method as claimed in claims 1 to 6 or to implement the method as claimed in any one of claims 7 to 8.

Citation Information

Patent Citations

  • Method and device of searching based on category

    CN103870507A

  • Method and device for determining standard text corresponding to query text

    CN110990533A