Text search method, device, equipment and storage medium

By fusing the first keyword in the target text with the feature vectors of multiple knowledge texts to generate a knowledge fusion vector, the accuracy problem caused by polysemy in text search is solved, and higher search accuracy is achieved.

CN113569002BActive Publication Date: 2025-09-30TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110139356.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-02-01
Publication Date
2025-09-30
Estimated Expiration
2041-02-08

AI Technical Summary

Technical Problem

Existing text search applications have low search accuracy due to the polysemy of a word and cannot accurately provide the text that users want to view.

Method used

By obtaining multiple knowledge texts of the first keyword in the target text, the feature vector of the first keyword is fused with the feature vectors of the multiple knowledge texts to generate a knowledge fusion vector to more completely represent the semantics of the first keyword, thereby improving the accuracy of the search text.

Benefits of technology

The accuracy of text search is improved, making the search results more in line with the user's search needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113569002B_ABST
    Figure CN113569002B_ABST
Patent Text Reader

Abstract

This application discloses a text search method, apparatus, device, and storage medium, belonging to the field of machine learning. The method includes: obtaining multiple knowledge texts for a first keyword in a target text, wherein the multiple knowledge texts are used to represent the different semantics of the first keyword; obtaining a feature vector for the first keyword based on the first keyword and other texts in the target text other than the first keyword; fusing the feature vector of the first keyword with the feature vectors of the multiple knowledge texts based on the similarity between the feature vector of the first keyword and the feature vectors of the multiple knowledge texts to obtain a knowledge fusion vector for the first keyword; and obtaining a search text corresponding to the target text based on the knowledge fusion vector. The knowledge text is introduced into the process of feature extraction of the first keyword, thereby improving the accuracy of the subsequent search text obtained based on the knowledge fusion vector.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of machine learning, and in particular to a text search method, apparatus, device, and storage medium. Background Art

[0002] With the rapid development of network technology today, users will use various text search applications to obtain the text they want to view.

[0003] In related technologies, text search applications search for text based on the textual features of the search text itself. However, due to the phenomenon of polysemy, that is, the same keyword may have different meanings in different search texts, when searching based on the textual features of the search text itself, the content returned by the text search application may not be the text the user wants to view, resulting in low text search accuracy. Summary of the Invention

[0004] The embodiments of the present application provide a text search method, apparatus, device, and storage medium that can improve text search performance. The technical solution is as follows:

[0005] In one aspect, a text search method is provided, the method comprising:

[0006] Acquire multiple knowledge texts of a first keyword in a target text, wherein the multiple knowledge texts are used to represent different semantics of the first keyword;

[0007] Obtaining a feature vector of the first keyword based on the first keyword and other text in the target text except the first keyword;

[0008] Based on the similarity between the feature vector of the first keyword and the feature vectors of the plurality of knowledge texts, the feature vector of the first keyword is fused with the feature vectors of the plurality of knowledge texts to obtain a knowledge fusion vector of the first keyword;

[0009] A search text corresponding to the target text is obtained based on the knowledge fusion vector.

[0010] In a possible implementation, acquiring the search text corresponding to the target text based on the knowledge fusion vector includes:

[0011] In response to the similarity between the knowledge fusion vector of any search text and the knowledge fusion vector of the first keyword meeting a target similarity condition, the any search text is determined as a search text corresponding to the target text.

[0012] In a possible implementation, the method for obtaining the knowledge fusion vector of the search text includes:

[0013] Segmenting at least one of the title or introduction of the search text into words to obtain a plurality of reference words of the search text;

[0014] In response to any reference word among the plurality of reference words in the search text being identical to any word in a knowledge text library, determining the any reference word as a second keyword, the knowledge text library storing a plurality of words and a plurality of knowledge texts corresponding to the plurality of words;

[0015] Acquire a plurality of knowledge texts corresponding to the second keyword from the knowledge text library;

[0016] Obtaining a feature vector of the second keyword based on the second keyword and other text in the search text except the second keyword;

[0017] Based on the similarity between the feature vector of the second keyword and the feature vectors of multiple knowledge texts corresponding to the second keyword, the feature vector of the second keyword and the feature vectors of multiple knowledge texts corresponding to the second keyword are fused to obtain a knowledge fusion vector of the search text.

[0018] In one aspect, a text search device is provided, comprising:

[0019] a knowledge text acquisition module, configured to acquire a plurality of knowledge texts of a first keyword in a target text, wherein the plurality of knowledge texts are used to represent different semantics of the first keyword;

[0020] a feature vector acquisition module, configured to acquire a feature vector of the first keyword based on the first keyword and other text in the target text except the first keyword;

[0021] a feature vector fusion module, configured to fuse the feature vector of the first keyword with the feature vectors of the plurality of knowledge texts based on similarities between the feature vector of the first keyword and the feature vectors of the plurality of knowledge texts to obtain a knowledge fusion vector of the first keyword;

[0022] The text acquisition module is used to acquire the search text corresponding to the target text based on the knowledge fusion vector.

[0023] In one possible implementation, the feature vector acquisition module is configured to input the first keyword and the other text into a feature extraction model; and perform attention encoding on the first keyword and the other text through the feature extraction model to obtain a feature vector of the first keyword.

[0024] In one possible implementation, the feature vector acquisition module is used to obtain the first query vector, first key vector and first value vector of the first keyword; obtain the second key vector and second value vector of the other text; normalize the product of the first query vector and the first key vector and the product of the first query vector and the second key vector to obtain the first attention weight of the first keyword and the second attention weight of the other text to the first keyword; add the product of the first attention weight and the first value vector and the product of the second attention weight and the second value vector to obtain the feature vector of the first keyword.

[0025] In a possible implementation, the feature vector fusion module is configured to perform the following steps using a feature extraction model:

[0026] determining, based on similarities between the feature vector of the first keyword and the feature vectors of the plurality of knowledge texts, a plurality of first association weights between the feature vector of the first keyword and the feature vectors of the plurality of knowledge texts, the first association weights being used to represent a degree of relevance between the corresponding knowledge text and the first keyword;

[0027] Based on a plurality of first association weights, the feature vector of the first keyword is fused with the feature vectors of the plurality of knowledge texts to obtain a knowledge fusion vector of the first keyword.

[0028] In one possible embodiment, the feature vector fusion module is used to perform weighted summation of the feature vector of the first keyword and the feature vectors of the multiple knowledge texts based on multiple first association weights to obtain a fusion vector of the first keyword; perform multi-head attention encoding on the fusion vector to obtain multiple attention encoding vectors of the first keyword; and obtain a knowledge fusion vector of the first keyword based on the multiple attention encoding vectors.

[0029] In a possible implementation, the feature vector fusion module is used to concatenate the multiple attention coding vectors to obtain an attention coding matrix; and perform dimensionality reduction processing on the attention coding matrix to obtain a knowledge fusion vector of the first keyword.

[0030] In one possible implementation, the feature extraction model training device includes:

[0031] A sample data acquisition module is used to acquire sample data, wherein the sample data includes a sample text, a sample search text, and a sample similarity between the sample text and the sample search text;

[0032] A first input module, configured to input the sample text and the sample search text into the feature extraction model;

[0033] A feature extraction module, configured to extract a knowledge fusion vector of sample keywords in the sample text and a knowledge fusion vector of the sample search text through the feature extraction model;

[0034] The adjustment module is used to adjust the model parameters of the feature extraction model based on the difference information between the similarity between the knowledge fusion vector of the sample keyword and the knowledge fusion vector of the sample search text and the sample similarity.

[0035] In one possible implementation, the knowledge text acquisition module is used to search for a target word that is the same as the first keyword in a knowledge text library, where the knowledge text library stores multiple words and multiple knowledge texts corresponding to each of the words; and acquire the multiple knowledge texts corresponding to the target word as multiple knowledge texts of the first keyword.

[0036] In a possible implementation, the first keyword acquisition means includes:

[0037] A first word segmentation module is used to segment the target text into words to obtain a plurality of reference words of the target text;

[0038] The first determination module is configured to determine any reference word among the plurality of reference words as the first keyword in response to the fact that the reference word is identical to any word in a knowledge text library, wherein the knowledge text library stores a plurality of words and a plurality of knowledge texts corresponding to each of the words.

[0039] In a possible implementation, the word segmentation module is used to segment the target text using different methods to obtain multiple reference word sequences corresponding to the different methods, each reference word sequence includes multiple reference words in the target text, different reference words in the same reference word sequence have the same number of characters, and the number of characters of reference words in different reference word sequences is different; in response to multiple reference words belonging to different reference word sequences being respectively the same as multiple words in the knowledge text base, the reference word with the largest number of characters among the multiple reference words belonging to different reference word sequences is obtained as the first keyword.

[0040] In a possible implementation, the device for acquiring the feature vectors of the plurality of knowledge texts includes:

[0041] A second input module is used to input any knowledge text into a feature extraction model;

[0042] The encoding module is used to perform attention encoding on multiple words in any knowledge text through the feature extraction model to obtain a feature vector of any knowledge text.

[0043] In one possible embodiment, the encoding module is used to obtain the third query vector, the third key vector and the third value vector of any word among the multiple words in the any knowledge text; obtain the fourth key vector and the fourth value vector of the other words among the multiple words in the any knowledge text except the any word; normalize the product of the third query vector and the third key vector and the product of the third query vector and the fourth key vector to obtain the third attention weight of the any word and the fourth attention weight of the other words to the any word; add the product of the third attention weight and the third value vector and the product of the fourth attention weight and the fourth value vector to obtain the feature vector of the any word; and fuse the feature vectors of the multiple words in the any knowledge text to obtain the feature vector of the any knowledge text.

[0044] In a possible implementation, the text acquisition module is configured to determine any search text as a search text corresponding to the target text in response to the similarity between the knowledge fusion vector of any search text and the knowledge fusion vector of the first keyword meeting a target similarity condition.

[0045] In a possible implementation, the device for acquiring the knowledge fusion vector of the search text includes:

[0046] A second word segmentation module is used to segment at least one of the title or introduction of the search text into words to obtain a plurality of reference words of the search text;

[0047] a second determining module configured to determine any reference word among the plurality of reference words in the search text as a second keyword in response to the fact that the reference word is identical to any word in a knowledge text library, wherein the knowledge text library stores a plurality of words and a plurality of knowledge texts corresponding to the plurality of words;

[0048] The knowledge text acquisition module is further configured to acquire a plurality of knowledge texts corresponding to the second keyword from the knowledge text library;

[0049] The feature vector acquisition module is further configured to acquire a feature vector of the second keyword based on the second keyword and other text in the search text except the second keyword;

[0050] The feature vector fusion module is also used to fuse the feature vector of the second keyword with the feature vectors of multiple knowledge texts corresponding to the second keyword based on the similarity between the feature vector of the second keyword and the feature vectors of multiple knowledge texts corresponding to the second keyword to obtain the knowledge fusion vector of the search text.

[0051] On the one hand, a computer device is provided, comprising one or more processors and one or more memories, wherein at least one computer program is stored in the one or more memories, and the computer program is loaded and executed by the one or more processors to implement the text search method.

[0052] In one aspect, a computer-readable storage medium is provided, wherein at least one computer program is stored in the computer-readable storage medium, and the computer program is loaded and executed by a processor to implement the text search method.

[0053] On the one hand, a computer program product or computer program is provided, which includes program code, which is stored in a computer-readable storage medium. A processor of a computer device reads the program code from the computer-readable storage medium, and the processor executes the program code, so that the computer device performs the above-mentioned text search method.

[0054] Through the technical solution provided in the embodiment of the present application, knowledge text is introduced in the process of feature extraction of the first keyword, and the semantics carried in the feature vector of the first keyword is supplemented by the knowledge text. The obtained knowledge fusion vector can more completely represent the semantics of the first keyword in the target text, thereby improving the accuracy of subsequent search texts obtained based on the knowledge fusion vector. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0056] Figure 1 is a schematic diagram of an implementation environment of a text search method provided in an embodiment of the present application;

[0057] Figure 2 This is a schematic diagram of an interface provided by an embodiment of the present application;

[0058] Figure 3 This is a schematic diagram of an interface provided by an embodiment of the present application;

[0059] Figure 4 This is a schematic diagram of an interface provided by an embodiment of the present application;

[0060] Figure 5 This is a schematic diagram of an interface provided by an embodiment of the present application;

[0061] Figure 6 This is a flowchart of a text search method provided by an embodiment of the present application;

[0062] Figure 7 This is a flowchart of a text search method provided by an embodiment of the present application;

[0063] Figure 8 This is a schematic diagram of a knowledge graph provided in an embodiment of the present application;

[0064] Figure 9 This is a flow chart of a method for obtaining a first keyword provided in an embodiment of the present application;

[0065] Figure 10 This is a flow chart of a method for determining a first keyword fusion vector provided by an embodiment of the present application;

[0066] Figure 11 Schematic diagram of a method for training a feature extraction model provided in an embodiment of the present application;

[0067] Figure 12 Schematic diagram of a method for training a feature extraction model provided in an embodiment of the present application;

[0068] Figure 13 This is a structural diagram of a text search device provided in an embodiment of the present application;

[0069] Figure 14 This is a schematic diagram of the structure of a terminal provided in an embodiment of the present application;

[0070] Figure 15 This is a structural diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION

[0071] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.

[0072] In this application, the terms "first", "second", etc. are used to distinguish identical or similar items with substantially the same effects and functions. It should be understood that there is no logical or temporal dependency between "first", "second", and "nth", nor is there any limitation on the quantity and execution order.

[0073] In this application, the term "at least one" means one or more, and the term "plurality" means two or more. For example, a plurality of reference facial images refers to two or more reference facial images.

[0074] Artificial Intelligence (AI) refers to the theories, methods, techniques, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that seeks to understand the essence of intelligence and produce new intelligent machines that can respond in a manner similar to human intelligence. AI also studies the design principles and implementation methods of various intelligent machines, enabling them to possess the capabilities of perception, reasoning, and decision-making.

[0075] Artificial intelligence (AI) technology is a comprehensive discipline encompassing a wide range of fields, encompassing both hardware and software technologies. Foundational AI technologies generally include sensors, specialized AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, speech processing, natural language processing, and machine learning / deep learning.

[0076] Machine learning (ML) is a multidisciplinary field that encompasses probability theory, statistics, approximation theory, convex analysis, and algorithmic complexity theory. It specifically studies how computers can simulate or implement human learning behaviors to acquire new knowledge or skills and reorganize existing knowledge sub-models to continuously improve their performance. Machine learning is at the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications span all areas of AI. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and learning through demonstration.

[0077] Normalization: Mapping sequences of numbers with different value ranges to the interval (0, 1) facilitates data processing. In some cases, the normalized values ​​can be directly implemented as probabilities.

[0078] Embedded Coding: Embedded coding mathematically represents a correspondence, where data in the X space is mapped to the Y space through a function F, where the function F is an injective function. The mapping result is structural preservation. The injective function indicates that the data after mapping is uniquely corresponding to the data before mapping. Structural preservation means that the size relationship of the data before mapping is the same as the size relationship of the data after mapping. For example, before mapping, there are data X1 and X2, and after mapping, the data corresponding to X1 is Y1 and the data corresponding to X2 is Y2. If the data before mapping X1 is greater than X2, then the data after mapping Y1 is greater than Y2. For words, this means mapping the words to another space to facilitate subsequent machine learning and processing.

[0079] Attention weight: This indicates the importance of a piece of data during training or prediction. Importance indicates the impact of the input data on the output data. Highly important data has a higher attention weight, while lowly important data has a lower attention weight. Data importance varies in different scenarios, and the process of training a model's attention weights is also the process of determining data importance.

[0080] Knowledge graph: A semantic network that describes the relationships between entities, usually represented by triples. A knowledge graph triple consists of two entities (nodes in the semantic network) and a relationship (edge ​​in the semantic network). For example, "Beijing" is an entity, "China" is an entity, and "Beijing" is the "capital" of "China." Then "capital" is a relationship; the triple is represented as (Beijing, capital, China), which is (entity 1, relationship, entity 2). Knowledge graph is an effective way to represent knowledge, helping to advance applied research in many areas, such as model reasoning, intelligent search, question-answering systems, and social networks.

[0081] Semantic matching: This involves calculating the semantic relevance between two text segments. If the relevance is high, the two segments are considered a match. Many natural language processing tasks can be transformed into semantic matching problems. For example, web search can be abstracted into the problem of matching the relevance of user queries and webpage content. Automatic question answering can be abstracted into the problem of matching the satisfaction of questions and candidate answers. Text deduplication can be abstracted into the problem of matching the similarity between texts.

[0082] Chinese word segmentation: refers to the process of breaking a Chinese text sequence into individual words. Word segmentation is the process of recombining a continuous sequence of characters into a word sequence according to certain specifications.

[0083] A text vector is a method for converting a variable-length text into a fixed-length numerical vector. Vectors can be divided into two forms: high-dimensional sparse vectors, which typically use the length of the vocabulary as the vector's length. Each dimension represents a word, and only the dimensions corresponding to the word have non-zero values; most dimensions are zero. Low-dimensional dense vectors are used to input text into models such as neural networks, which are trained to output vector representations. Each dimension of the vector is essentially non-zero, lacking a clear physical meaning, but generally performs better than high-dimensional sparse vectors.

[0084] Bigram data: In the context of text matching, a bigram consists of two texts and a label (0 or 1). Suppose the two texts are A and B. If they match, the bigram data is (A, B, 1); if they do not match, the bigram data is (A, B, 0).

[0085] Fully connected layers are one of the fundamental structures in artificial neural networks. Each layer is composed of multiple artificial neurons. Each neuron in the current layer is connected to all neurons in the previous layer. Non-neighboring neurons in the fully connected layer have no connection. In deep learning, neural network models used for classification tasks often use fully connected layers at the end to effectively map hidden layer features to the sample label space, improving training effectiveness.

[0086] Pooling layer: A fundamental structure in artificial neural networks, its primary function is to reduce the number of model parameters and mitigate overfitting. Commonly used pooling layers are average pooling and max pooling. Both types convert the feature vectors extracted by the previous neural network layer into lower-dimensional feature vectors. The difference is that the average pooling layer calculates the average value within a set dimensional range, while the max pooling layer calculates the maximum value.

[0087] Attention Mechanism: The Attention mechanism draws on human attentional thinking and was first applied to the image field. When viewing an image, the human eye first quickly scans and acquires the target area of ​​interest. It then devotes more attention to this target area, capturing its details and suppressing insignificant information from other, less important areas. This approach helps humans utilize limited attention to filter high-value information from a large amount of information. The attention mechanism is also crucial in natural language processing. Because text contains many low-value words (such as stop words), indiscriminate feature representation reduces the impact of important words and affects model accuracy. To address this issue, the Attention mechanism can be used for selective feature extraction and representation.

[0088] Vertical search: Vertical search is a professional search engine for a certain industry. It is a subdivision and extension of the search engine. It integrates a certain type of specialized information in the database, extracts the required data by targeted fields, processes it, and then returns it to the user in some form.

[0089] Figure 1 This is a schematic diagram of an implementation environment of a text search method provided in an embodiment of the present application, see Figure 1 , the implementation environment may include a terminal 110 and a server 140.

[0090] The terminal 110 is connected to the server 140 via a wireless network or a wired network. Optionally, the terminal 110 is a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto. The terminal 110 has an application installed and running that supports image display.

[0091] Optionally, server 140 is an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, distribution networks (Content Delivery Network, CDN), and big data and artificial intelligence platforms.

[0092] Optionally, the terminal 110 generally refers to one of multiple terminals, and the embodiment of the present application only takes the terminal 110 as an example.

[0093] Those skilled in the art will appreciate that the number of terminals may be greater or less. For example, there may be only one terminal, or there may be dozens, hundreds, or even more terminals, in which case the implementation environment may also include other terminals. The embodiments of this application do not limit the number or device types of terminals.

[0094] After introducing the implementation environment of the embodiments of the present application, the application scenarios of the embodiments of the present application are introduced below.

[0095] The embodiments of the present application can be applied in various text search scenarios, for example, in text search scenarios provided by social applications, or in text search scenarios of search engines, or in music search or video search scenarios, but the embodiments of the present application do not limit this.

[0096] In the context of text search provided by social applications, text search can also be called content search. Social applications can provide a content search interface through which users can search based on target text to obtain the content they want to view. For example, see Figure 2 , Figure 2 The first figure in the figure shows a variety of function controls provided by social applications. When a user clicks on different function controls, the social application can display the corresponding function interface. In some embodiments, the function control 201 is a function control that switches to a content search interface. In response to detecting a click operation on the function control 201, the terminal displays a content search interface 202 corresponding to the function control 201. An example of a content search interface is Figure 2 The second figure in the figure. The content search interface 202 includes a text input area 2021 and a text search control 2022. The user can enter the text to be searched in the text input area 2021 and click the text search control 222 to search for the input content. For the terminal, in response to detecting a click operation on the text search control 222, the text in the text input area 2021 is sent to the server. The server searches the text through the technical solution provided by the embodiment of the present application, sends the search results to the terminal, and the terminal displays the search results to the user. See Figure 3 After receiving the search results sent by the server, the terminal can switch the content search interface 202 to the content display interface 301. The content display interface 301 displays the text 3011 entered by the user in the text input area 2021 and can also display the search results display area 3012. In some embodiments, the content display interface 301 also displays a search range switching control 302. In response to detecting a click operation on the search range switching control 302, the terminal can display the search results within the search range corresponding to the search range switching control 302 in the search results display area 3012. In some embodiments, in addition to displaying the text input area 2021 and the text search control 2022, the content search interface 202 can also display a search text type selection area 2023 and a content recommendation area 2024. The type selection area 2023 is used to select the scope of the search. For example, the type selection area 2023 contains the options "Finance", "Sports" and "Technology". After the user selects any option in the type selection area 2023, enters text through the text input area 2021, and searches through the text search control 2022, the search results returned are the content within the range. If the user selects the option "Finance", then the returned content is also the "Finance" category content. In some embodiments, the method of selecting the search scope through the type selection area 2023 can also be called vertical search. A plurality of hot search texts are provided in the content recommendation area 2024. In some embodiments, the hot search text is the search text whose search quantity exceeds the search threshold. After the user clicks on any hot search text, the terminal can display the content corresponding to the hot search text.

[0097] In the text search scenario of a search engine, users can enter the target text in the search box of the search engine and click the search control of the search engine to perform text search. For example, see Figure 4 , the user can enter the target text in the search box 402 in the search interface 401 of the search engine. After entering the target text, the user can click the search control 403 of the search engine to obtain the search results based on the target text entered in the search box. For the terminal, in response to detecting the click operation on the search control 403, the terminal sends a text search request to the server, and the text search request carries the target text in the search box 402. In response to receiving the text search request, the server obtains the target text from the text search request, and through the technical solution provided by the embodiment of the present application, searches based on the target text to obtain search results, sends the search results to the terminal, and the terminal displays the search results to the user.

[0098] In the music search or video search scenario, users can enter the target text in the search box of the music search interface and click the search control of the music search interface to perform text search. For example, see Figure 5 , the user can enter the target text in the search box 502 in the music search interface 501. In some embodiments, the target text is the title of music or video. After entering, clicking the search control 503 of the music search interface 501 can obtain search results based on the target text entered in the search box. For the terminal, in response to detecting the click operation on the search control 503, the terminal sends a text search request to the server, and the text search request carries the target text in the search box 502. In response to receiving the text search request, the server obtains the target text from the text search request, and through the technical solution provided in the embodiment of the present application, searches based on the target text to obtain search results, sends the search results to the terminal, and the terminal displays the search results to the user.

[0099] It should be noted that the embodiments of the present application are only described using the above-mentioned application scenarios as examples. In other possible implementations, the technical solutions provided in the embodiments of the present application can be applied to other text search scenarios, and the embodiments of the present application do not limit this.

[0100] After describing the application scenarios of the embodiments of the present application, the technical solutions provided by the embodiments of the present application are described below.

[0101] In the following description of the technical solutions provided in the embodiments of the present application, a computer device is used as an example server. In other possible implementations, the following technical solutions can also be executed by a terminal or through cooperation between a terminal and a server. The embodiments of the present application do not limit the type of the executing entity.

[0102] Figure 6 This is a flowchart of a text search method provided in an embodiment of the present application, see Figure 6 , methods include:

[0103] 601. The server obtains multiple knowledge texts of a first keyword in a target text, where the multiple knowledge texts are used to represent different semantics of the first keyword.

[0104] The first keyword is a word with different semantics in different contexts. For example, the first keyword "apple" can refer to both a fruit "apple" and a company "Apple Inc." One knowledge text can represent one semantic meaning of the first keyword. Similarly, multiple knowledge texts can represent texts with different semantic meanings of the first keyword.

[0105] 602. The server obtains a feature vector of the first keyword based on the first keyword and other text in the target text except the first keyword.

[0106] Among them, since the first keyword is a word with different semantics in different contexts, and the context is also determined by other texts in the target text and the first keyword, the feature vector of the first keyword obtained based on the first keyword itself and other texts can reflect the semantics of the first keyword in the target text to a certain extent.

[0107] 603. The server fuses the feature vector of the first keyword with the feature vectors of the multiple knowledge texts based on the similarity between the feature vector of the first keyword and the feature vectors of the multiple knowledge texts to obtain a knowledge fusion vector of the first keyword.

[0108] Among them, since multiple knowledge texts can represent multiple semantics of the first keyword, based on the similarity between the feature vector of the first keyword and the feature vectors of multiple knowledge texts, the feature vector of the first keyword is fused with the feature vectors of multiple knowledge texts, which can supplement external knowledge in the feature vector of the first keyword. The obtained knowledge fusion vector of the first keyword can more completely represent the semantics of the first keyword in the target text.

[0109] 604. The server obtains the search text corresponding to the target text based on the knowledge fusion vector.

[0110] Among them, since the knowledge fusion vector can more completely represent the semantics of the first keyword in the target text, the search text obtained based on the knowledge fusion vector can be closer to the user's search needs, thereby improving the accuracy of text search.

[0111] Since the first keyword may correspond to different semantics in different texts, the technical solution provided in the embodiment of the present application introduces knowledge text in the process of feature extraction of the first keyword, and different knowledge texts can represent different semantics of the first keyword. Through the correlation between the feature vector of the knowledge text and the feature vector of the first keyword, the feature vector of the knowledge text is fused with the feature vector of the first keyword, that is, the semantic information carried in the feature vector of the first keyword is supplemented, so that the knowledge fusion vector can more accurately represent the semantics of the first keyword in the target text, thereby improving the accuracy of the subsequent search text obtained based on the knowledge fusion vector.

[0112] Figure 7 This is a flowchart of a text search method provided in an embodiment of the present application, see Figure 7 , methods include:

[0113] 701. The server obtains a first keyword from the target text.

[0114] In one possible implementation, the server performs word segmentation on the target text to obtain multiple reference words of the target text. In response to any reference word in the multiple reference words being identical to any word in a knowledge text library, the server determines the reference word as a first keyword. The knowledge text library stores multiple words and multiple knowledge texts corresponding to each word.

[0115] The target text is the text entered by the user on the terminal, and the user can perform text search through the target text. The knowledge text library stores multiple words and multiple knowledge texts corresponding to each word in the form of structured data, that is, multiple words are used as keys (Key) and the knowledge text corresponding to each word (Key) is used as the value (Value) for storage. The server can search for the corresponding knowledge text (Value) based on the word (Key). In some embodiments, the server can generate a knowledge text library based on a knowledge graph. For an example of a knowledge graph, see Figure 8 801 is a keyword input by the user, and 802 is a knowledge text corresponding to the keyword. In some embodiments, the keyword is also called an "entity", which may be a person's name, an organization's name, or a business name.

[0116] In this implementation, the server can search for multiple reference words in the knowledge text library based on word segmentation of the target text, thereby determining the first keyword in the target text. The acquisition efficiency of the first keyword is relatively high.

[0117] For example, the server is carried out word segmentation to the target text at fixed intervals, obtains comprising a plurality of reference words of the same character number.The server is respectively searched in the knowledge text base with a plurality of reference words, and when determining that any reference word in a plurality of reference words is identical with any word in the knowledge text base, the server is determined as the first key word by this reference word.For example, for the target text " AB12 price ", wherein AB is the name of the product, and 12 is the model of the product. In addition, AB can also be the name of a kind of fruit except being the name of the product. In other words, "AB12 price " is similar to "AB price ".If the server is carried out word segmentation to the target text at fixed intervals 2, the target text " AB12 price " can be divided into 6 reference words " AB ", " B1 ", " 12 ", " 2 more ", " how much " and " little money ".The server can search for 6 reference words in the knowledge text base, and when there is word " AB " in the knowledge text base, the server can be determined as the first key word of the target text by the reference word " AB ".

[0118] In one possible implementation, the server uses different methods to segment the target text into words, obtaining multiple reference word sequences corresponding to the different methods. Each reference word sequence includes multiple reference words in the target text, different reference words in the same reference word sequence have the same number of characters, and reference words in different reference word sequences have different numbers of characters. In response to multiple reference words belonging to different reference word sequences being identical to multiple words in the knowledge text base, the reference word with the largest number of characters among the multiple reference words belonging to different reference word sequences is obtained as the first keyword.

[0119] See also Figure 9Taking the target text "AB12 price" as an example, the terminal can use One-Gram (single word segmentation), Bi-Gram (two-word segmentation), and Tri-Gram (three-word segmentation) methods to segment the target text. Among them, One-Gram can divide the target text into single words, that is, the target text "AB12 price" is divided into three reference words "AB", "12", and "price". "AB", "12", and "price" constitute a reference word sequence for One-Gram. Bi-Gram can divide the target text into a combination of two words, that is, the target text "AB12 price" is divided into the reference words "AB12" and "12 price". "AB12" and "12 price" constitute a reference word sequence for Bi-Gram. Tri-Gram can divide the target text into a combination of three words, that is, the target text "AB12 price" is divided into the reference word "AB12 price". "AB12 price" constitutes a reference word sequence for Tri-Gram. If "AB" in the One-Gram reference word sequence is identical to a word in the knowledge text library, and "AB12" in the Bi-Gram reference word sequence is identical to another word in the knowledge text library, since the number of characters in "AB12" is greater than the number of characters in "AB", the server can determine "AB12" as the first keyword in the target text. In some embodiments, the process of the server determining the first keyword from multiple reference words belonging to different reference word sequences can be implemented by the knowledge discovery layer 901 of the feature extraction model.

[0120] 702. The server obtains multiple knowledge texts of the first keyword in the target text, where the multiple knowledge texts are used to represent different semantics of the first keyword.

[0121] In a possible implementation, the server searches the knowledge text library for a target word that is the same as the first keyword, and obtains multiple knowledge texts corresponding to the target word as multiple knowledge texts of the first keyword.

[0122] Under this implementation, the server can quickly obtain multiple knowledge texts of the first keyword from the knowledge text library, and subsequently obtain the knowledge fusion vector of the first keyword based on the multiple knowledge texts, thereby more accurately expressing the semantics of the first keyword in the target text.

[0123] For example, taking the target text as "AB12 price", where "AB" is the name of an electronic product, "12" is the model of the electronic product, and the first keyword of the target text is "AB12", the server can search for the target word "AB12" that is the same as the first keyword "AB12" in the knowledge text library. If the target word "AB12" corresponds to the three knowledge texts "Release date is XX month XX day", "Using YY processor" and "Adopting ZZ system", then the server can determine the three knowledge texts "Release date is XX month XX day", "Using YY processor" and "Adopting ZZ system" as the knowledge texts of the first keyword "AB12".

[0124] 703. The server obtains a feature vector of the first keyword based on the first keyword and other text in the target text except the first keyword.

[0125] In a possible implementation, the server inputs the first keyword and other text into a feature extraction model, and performs attention encoding on the first keyword and other text through the feature extraction model to obtain a feature vector of the first keyword.

[0126] Under this implementation, since the first keyword can only reflect the semantics of the first keyword in the target text when combined with other texts, the server can perform attention encoding on the first keyword and other texts, and obtain the feature vector of the first keyword based on the attention encoding, so that the feature vector of the first keyword used can fully represent the semantics of the first keyword.

[0127] For example, the server inputs the first keyword and other texts into the feature extraction model respectively. The server obtains the first query vector, the first key vector and the first value vector of the first keyword through the feature extraction model. The server obtains the second key vector and the second value vector of the other texts through the feature extraction model. The server normalizes the product of the first query vector and the first key vector and the product of the first query vector and the second key vector to obtain the first attention weight of the first keyword and the second attention weight of the other texts to the first keyword. The server adds the product of the first attention weight and the first value vector and the product of the second attention weight and the second value vector to obtain the feature vector of the first keyword. In some embodiments, the first query vector and the first key vector are used to obtain the first attention weight of the first keyword, the first value vector is used to represent the first keyword, and the first attention weight and the first value vector are used to obtain the feature vector of the first keyword.

[0128] In order to explain the above embodiment more clearly, the following provides examples based on the above examples and in combination with some numerical values.

[0129] Taking the target text as "AB12 price" and the first keyword as "AB" as an example, the server maps the first keyword "AB" to a first embedding vector, such as (1, 2, 3), and maps multiple words in other texts to multiple second embedding vectors, such as mapping "12" to a second embedding vector (1, 3, 2), and mapping "price" to a second embedding vector (2, 1, 5). The server inputs the first embedding vector (1, 2, 3) and the two second embedding vectors (1, 3, 2) and (2, 1, 5) into the feature extraction model. The server uses the feature extraction model to extract the first embedding vector (1, 2, 3) and the two second embedding vectors (1, 3, 2) and (2, 1, 5). as well as Among them, the linear transformation matrix Query vector for obtaining the first keyword, linear transformation matrix Used to obtain the key vector and linear transformation matrix of the first keyword Used to obtain the value vector of the first keyword. The server multiplies the first embedding vector (1, 2, 3) of the first keyword with the three linear transformation matrices respectively to obtain the first query vector (9, 2, 8), the first key vector (11, 4, 8) and the first value vector (6, 3, 4) of the first keyword. The server obtains the second key vector and the second value vector of the two words in the other text through the feature extraction model, that is, the second embedding vector (1, 3, 2) corresponding to "12" is multiplied with the linear transformation matrix respectively. as well as Multiply them together to get the second key vector (8, 6, 9) and the second value vector (9, 4, 3) corresponding to "12". The second embedding vector (2, 1, 5) corresponding to "price" is respectively multiplied by the linear transformation matrix as well as Multiplying them, we get the second key vector (19, 2, 9) and the second value vector (3, 3, 7) corresponding to “price”. The server obtains the product 123 of the first query vector (9, 2, 8) and the first key vector (11, 4, 8). The server obtains the product 156 of the first query vector (9, 2, 8) and the second key vector (8, 6, 9) corresponding to “12”. The server obtains the product 247 of the first query vector (9, 2, 8) and the second key vector (19, 2, 9) corresponding to “money”. The server normalizes the product 123, the product 156, and the product 247 using the SoftMax function, and obtains the first attention weight of the first keyword “AB” as 0.2, the second attention weight of the word “12” as 0.3, and the second attention weight of the word “” as 0.5. The server multiplies the first attention weight 0.2 by the first value vector (6, 3, 4) of the first keyword to obtain the vector (1.2, 0.6, 0.8). The server multiplies the second attention weight of the word "12" (0.3) by the second value vector of the word "12" (9, 4, 3) to obtain the vector (2.7, 1.2, 0.9). The server multiplies the second attention weight of "price" (0.5) by the second value vector of "price" (3, 3, 7) to obtain the vector (1.5, 1.5, 3.5). The server adds the vectors (1.2, 0.6, 0.8), (2.7, 1.2, 0.9), and (1.5, 1.5, 3.5) to obtain the feature vector of the first keyword (5.4, 3.3, 5.2).

[0130] 704. The server fuses the feature vector of the first keyword with the feature vectors of the multiple knowledge texts based on the similarity between the feature vector of the first keyword and the feature vectors of the multiple knowledge texts to obtain a knowledge fusion vector of the first keyword.

[0131] In one possible implementation, the server determines, using a feature extraction model, multiple first association weights between the feature vector of the first keyword and the feature vectors of the multiple knowledge documents based on similarities between the feature vector of the first keyword and the feature vectors of the multiple knowledge documents. The first association weights are used to indicate the degree of relevance between the corresponding knowledge documents and the first keyword. Based on the multiple first association weights, the server fuses the feature vector of the first keyword with the feature vectors of the multiple knowledge documents to obtain a knowledge fusion vector for the first keyword.

[0132] Under this embodiment, the server can determine the first association weight based on the similarity between the feature vector of the first keyword and the feature vectors of multiple knowledge texts through the feature extraction model. That is, when the similarity between the feature vector of the first keyword and the feature vector of a knowledge text is high, it indicates that the knowledge text is closer to the semantics of the first keyword in the target text. The server can set the first association weight between the feature vector of the first keyword and the feature vector of the knowledge text higher, thereby supplementing the semantic information carried in the feature vector of the first keyword. The obtained knowledge fusion vector can more accurately represent the semantics of the first keyword in the target text.

[0133] In order to describe the above implementation more clearly, the above implementation will be described in two parts below. The first part describes the method for obtaining the first association weight, and the second part describes the method for obtaining the knowledge fusion vector.

[0134] Part 1. In a possible implementation, the server inputs the feature vector of the first keyword and the feature vectors of multiple knowledge texts into a feature extraction model. The feature extraction model obtains the similarity between the feature vector of the first keyword and the feature vectors of the multiple knowledge texts through the following formula (1), and determines multiple first association weights between the feature vector of the first keyword and the feature vectors of the multiple knowledge texts through the following formula (2).

[0135] e i =σ(E entity ,E ki )=tanh(W entity ·E entity +W k ·E ki ) (1)

[0136]

[0137] Among them, e i is the intermediate variable, σ() is the function for similarity calculation, E entity is the feature vector of the first keyword, E ki is the feature vector of the knowledge text, i is the serial number of the knowledge text. tanh() is the tangent function, W entity and W k is the parameter matrix, generated during the training of the feature extraction model, a i is the first attention weight.

[0138] Since the feature vector E of the first keyword entityIt contains the context information of the target text, so the above formula (1) and formula (2) can well obtain the role of each knowledge text in the current context.

[0139] In a possible embodiment, the first association weight is proportional to the similarity between the feature vector of the first keyword and the feature vector of the knowledge text, that is, the higher the similarity between the feature vector of the first keyword and the feature vector of a certain knowledge text, the greater the numerical value of the first association weight between the feature vector of the first keyword and the feature vector of the knowledge text. Correspondingly, the higher the similarity between the feature vector of the first keyword and the feature vector of another knowledge text, the smaller the numerical value of the first association weight between the feature vector of the first keyword and the feature vector of the knowledge text. Taking the first keyword corresponding to the three knowledge texts "Release date is XX month XX day", "Using YY processor" and "Adopting ZZ system", the feature vector of the first keyword is (5.4, 3.3, 5.2). For the convenience of calculation, the feature vector is rounded to obtain the rounded feature vector (5, 3, 5). The feature vectors corresponding to the three knowledge texts are (1, 0, 1), (1, 1, 1) and (0, 0, 1) as an example for explanation. The server can obtain, through the feature extraction model, the cosine similarities of 0.92, 0.97, and 0.65 between the feature vector (5.4, 3.3, 5.2) of the first keyword and the three feature vectors (1, 0, 1), (1, 1, 1), and (0, 0, 1) respectively. In some embodiments, the server can determine the cosine similarity of 0.92 as the first association weight between the feature vector (5, 3, 5) of the first keyword and the feature vector (1, 0, 1) of the knowledge text "the release date is XX month XX day", determine the cosine similarity of 0.97 as the first association weight between the feature vector (5, 3, 5) of the first keyword and the feature vector (1, 1, 1) of the knowledge text "using YY processor", and determine the cosine similarity of 0.65 as the first association weight between the feature vector (5, 3, 5) of the first keyword and the feature vector (0, 0, 1) of the knowledge text "adopting ZZ system". In addition, in some embodiments, the server can normalize the three cosine similarities 0.92, 0.97, and 0.65 through a feature extraction model to obtain three first association weights 0.36, 0.38, and 0.26.

[0140] Part 2, in a possible implementation, the server uses a feature extraction model to perform weighted summation on the feature vector of the first keyword and the feature vectors of multiple knowledge texts based on multiple first association weights to obtain a fusion vector of the first keyword. The server uses the feature extraction model to perform multi-head attention encoding on the fusion vector to obtain multiple attention encoding vectors of the first keyword. The server uses the feature extraction model to obtain the knowledge fusion vector of the first keyword based on multiple attention encoding vectors. Among them, multi-head attention encoding is the process of encoding the knowledge fusion vector using different linear transformation matrices. Multi-head attention encoding can capture the features of the knowledge fusion vector at a deeper level, thereby improving the feature expression ability of the knowledge fusion vector.

[0141] In order to explain the second part more clearly, the second part will be divided into three branches for introduction below. In the first branch, the method of obtaining the fusion vector of the first keyword is explained; in the second branch, the method of obtaining multiple attention encoding vectors of the first keyword is explained; in the third branch, the method of obtaining the knowledge fusion vector of the first keyword is explained.

[0142] In the first branch of the second part, in a possible implementation, the server can obtain the fusion vector of the first keyword through the following formula (3).

[0143]

[0144] Among them, E e-k is the fusion vector of the first keyword.

[0145] The following will be combined Figure 10 The above formulas (1) to (3) illustrate how the server obtains the fusion vector of the first keyword based on the feature vector of the first keyword and the feature vectors of multiple knowledge texts.

[0146] See also Figure 10 The server inputs the first keyword and multiple knowledge texts into the encoding layer 1001 of the feature extraction model, and the encoding layer 1001 encodes the first keyword and multiple knowledge texts k1-k n Encode and get the feature vector E of the first keyword entity And the feature vectors E of multiple knowledge texts k1 -E kn The server takes the feature vector E of the first keyword entity And the feature vectors E of multiple knowledge texts k1 -E knThe first association weight determination layer 1002 of the input feature extraction model obtains a plurality of first association weights a1-a based on the above formula (1) and formula (2). n In some embodiments, the first association weight determination layer 1002 is also called the attention layer. The server multiplies the first association weight by the corresponding feature vector through the feature extraction model, and inputs the multiplied vector into the fully connected layer 1003 of the feature extraction model. The fully connected layer 1003 obtains the fusion vector E of the first keyword based on the above formula (3). e-k .

[0147] In a possible implementation, the first keyword corresponds to three knowledge texts "Release date is XX month XX day", "Using YY processor" and "Adopting ZZ system", the feature vector of the first keyword is (5.4, 3.3, 5.2), the feature vectors corresponding to the three knowledge texts are (1, 0, 1), (1, 1, 1) and (0, 0, 1), and the first association weights corresponding to the three knowledge texts are 0.92, 0.97 and 0.65 respectively. For convenience of calculation, the feature vector is rounded to obtain the rounded feature vector (5, 3, 5). Through the feature extraction model, the server, based on a first association weight of 0.92, fuses the feature vector (5, 3, 5) of the first keyword with the feature vector (1, 0, 1) corresponding to "the release date is XX month XX day", that is, adds the feature vector (5, 3, 5) with the product of the first association weight of 0.92 and the feature vector (1, 0, 1) to obtain the vector (5.92, 3, 5.92). Similarly, through the feature extraction model, the server adds the feature vector (5, 3, 5) with the product of the first association weight of 0.97 and the feature vector (1, 1, 1) to obtain the vector (5.97, 3.97, 5.97), and adds the feature vector (5, 3, 5) with the product of the first association weight of 0.65 and the feature vector (0, 0, 1) to obtain the vector (5, 3, 5.65). The server uses a feature extraction model to add the three vectors (5.92, 3, 5.92), the vector (5.97, 3.97, 5.97), and the vector (5, 3, 5.65) to obtain a fusion vector (16.89, 9.97, 17.54) of the first keyword.

[0148] The second branch of the second part takes the example of multi-head attention encoding as three-head attention encoding. For the convenience of description, the three heads are named attention head A, attention head B and attention head C. For the three attention heads, each attention head corresponds to three linear change matrices WQ, WK and WV. In some embodiments, the three linear change matrices corresponding to attention head A are as well as The three linear change matrices corresponding to the attention head B are as well as Attention head C pairs

[0149] The corresponding three linear change matrices are as well as

[0150] For the convenience of calculation, the fusion vector (16.89, 9.97, 17.54) of the first keyword determined in the first branch of the second part is rounded to obtain the rounded fusion vector (17, 10, 18). The following description is based on the rounded fusion vector (17, 10, 18).

[0151] For attention head A, the server uses the feature extraction model to combine the fusion vector (17, 10, 18) of the first keyword with the three linear transformation matrices as well as Multiplying them together, we get the query vector (63, 10, 56), key vector (88, 20, 55), and value vector (30, 27, 35) of the fused vector (17, 10, 18). The server uses the feature extraction model to transform the query vector (63, 10, 56) and the key vector (88, 20, 55) into a transposed value. T Multiplying them together, we get a value of 8824. Normalizing the value 8824, we get the attention weight of the first keyword, for example, 0.5. The server multiplies the attention weight 0.5 by the value vector (30, 27, 35) of the first keyword to get an attention encoding vector (15, 13.5, 17.5) for the first keyword.

[0152] For attention head B, the server uses the feature extraction model to combine the fusion vector (17, 10, 18) of the first keyword with the three linear transformation matrices as well as Multiplying them together, we get the query vector (53, 10, 18), key vector (88, 20, 35), and value vector (0, 27, 35) of the fused vector (17, 10, 18). The server uses the feature extraction model to transform the query vector (53, 10, 18) and the key vector (88, 20, 35) into a single vector. T Multiplying them together, we get a value of 5494. Normalizing the value 5494, we get the attention weight of the first keyword, for example, 0.3. The server multiplies the attention weight 0.3 by the value vector (0, 27, 35) of the first keyword to get an attention encoding vector (0, 8.1, 10.5) for the first keyword.

[0153] For the attention head C, the server uses the feature extraction model to combine the fusion vector (17, 10, 18) of the first keyword with the three linear transformation matrices as well as Multiplying them together, we get the query vector (35, 10, 35), key vector (87, 20, 45) and value vector (47, 0, 35) of the fusion vector (17, 10, 18). The server uses the feature extraction model to multiply the query vector (35, 10, 35) and the key vector (87, 20, 45) T Multiplying them together, we get a value of 4820. Normalizing the value 4820, we get the attention weight of the first keyword, for example, 0.2. The server multiplies the attention weight 0.2 by the value vector (47, 0, 35) of the first keyword to get an attention encoding vector (9.4, 0, 7) for the first keyword.

[0154] In the third branch of the second part, the server concatenates multiple attention encoding vectors using a feature extraction model to obtain an attention encoding matrix. The server also performs dimensionality reduction on the attention encoding matrix using the feature extraction model to obtain the knowledge fusion vector for the first keyword.

[0155] The server uses the feature extraction model to concatenate the attention encoding vector (15, 13.5, 17.5) of the first keyword, the attention encoding vector (0, 8.1, 10.5) and the attention encoding vector (9.4, 0, 7) to obtain the attention encoding matrix. The server uses the feature extraction model to encode the attention matrix Perform full connection processing, that is, the attention encoding matrix and the fully connected weight vector (0, 1, -1) T After multiplication, it is combined with the fully connected bias vector (1, 0, 1) T Add them together to get the knowledge fusion vector of the first keyword (-3, -2.4, -6) T .

[0156] The following describes how the server obtains feature vectors of multiple knowledge texts:

[0157] In one possible implementation, for any knowledge text, the server inputs the knowledge text into a feature extraction model, and performs attention encoding on multiple words in the knowledge text through the feature extraction model to obtain a feature vector for the knowledge text.

[0158] For example, for any word among multiple words in any knowledge text, the server obtains the third query vector, third key vector and third value vector of the word through the feature extraction model. The server obtains the fourth key vector and fourth value vector of the other words in the multiple words in the knowledge text except the word through the feature extraction model. The server normalizes the product of the third query vector and the third key vector and the product of the third query vector and the fourth key vector through the feature extraction model to obtain the third attention weight of the word and the fourth attention weight of the other words to the word. The server adds the product of the third attention weight and the third value vector and the product of the fourth attention weight and the fourth value vector through the feature extraction model to obtain the feature vector of the word. The server fuses the feature vectors of multiple words in the knowledge text through the feature extraction model to obtain the feature vector of the knowledge text.

[0159] The following is an example of the knowledge text "using YY processor". In some embodiments, the server can segment the knowledge text "using YY processor" into two words, "using YY" and "processor". For the word "using YY", the server embeds the word "using YY" to obtain the embedding vector of the word "using YY", for example, (1, -1, 2). The server inputs the embedding vector (1, -1, 2) of "using YY" into the feature extraction model, and the feature extraction model is transformed into the embedding vector (1, -1, 2) through the three linear transformation matrices of the feature extraction model. as well as Multiplying them with the embedding vector (1, -1, 2) respectively, we get the third query vector (4, 1, -4), the third key vector (8, 2, 3) and the third value vector (4, 0, -3) of the word "use YY". The server extracts the embedding vector of another word "processor" in the knowledge text, for example (1, 0, -2). The server inputs the embedding vector (1, 0, -2) of "processor" into the feature extraction model, and uses the three linear transformation matrices of the feature extraction model to extract the word "processor". as well as Multiplying them with the embedding vector (1, 0, -2) respectively, the fourth query vector (4, 2, -1), the fourth key vector (6, 0, 4), and the fourth value vector (3, 1, 2) of the word "processor" are obtained. The server obtains the product 20 of the third query vector (4, 1, -4) and the third key vector (8, 2, 3) through the feature extraction model, and obtains the product 8 of the third query vector (4, 1, -4) and the fourth key vector (6, 0, 4). The server normalizes the product 20 and the product 8 through the feature extraction model to obtain the third attention weight of 0.7 for the word "use YY" and the fourth attention weight of 0.3 for the word "processor" to the word "use YY". The server multiplies the third attention weight of 0.7 for the word "use YY" by the third value vector (4, 0, -3) of the word "use YY" through the feature extraction model to obtain a vector (2.8, 0, -2.1). The server uses the feature extraction model to multiply the fourth attention weight of the word "processor" on the word "use YY" (0.3) by the fourth value vector of the word "processor" (3, 1, 2), resulting in a vector of (0.9, 0.3, 0.6). The server uses the feature extraction model to add the vector (2.8, 0, -2.1) to the vector (0.9, 0.3, 0.6), resulting in a feature vector of (3.7, 0.3, -1.5) for the word "use YY."

[0160] For the word "processor," the server uses the feature extraction model to obtain the product 20 of the fourth query vector (4, 2, -1) and the fourth key vector (6, 0, 4). The server also obtains the product 33 of the fourth query vector (4, 2, -1) and the third key vector (8, 2, 3). The server uses the feature extraction model to normalize the product 20 and the product 33 to obtain a third attention weight of 0.38 for the word "processor" and a fourth attention weight of 0.62 for the word "use YY" on the word "processor." The server uses the feature extraction model to multiply the third attention weight of 0.38 for the word "processor" by the fourth value vector (3, 1, 2) of the word "processor," resulting in a vector of (1.14, 0.38, 0.76). The server uses the feature extraction model to multiply the fourth attention weight of the word "use YY" on the word "processor" (0.62) by the third value vector (4, 0, -3) of the word "use YY" to obtain the vector (2.48, 0, 1.86). The server uses the feature extraction model to add the vector (1.14, 0.38, 0.76) to the vector (2.48, 0, 1.86) to obtain the feature vector (3.62, 0.38, 2.62) for the word "processor".

[0161] The server uses a feature extraction model to add the feature vector of "use YY" (3.7, 0.3, -1.5) and the feature vector of "processor" (3.62, 0.38, 2.62) to obtain the feature vector of the knowledge text "use YY processor" (7.32, 0.68, 1.25).

[0162] 705. The server obtains the search text corresponding to the target text based on the knowledge fusion vector.

[0163] In a possible implementation, in response to the similarity between the knowledge fusion vector of any search text and the knowledge fusion vector of the first keyword meeting the target similarity condition, the server determines the search text as the search text corresponding to the target text.

[0164] Here, the similarity meeting the target similarity condition means that the similarity is greater than or equal to the similarity threshold.

[0165] In this implementation, the server can determine the search text corresponding to the target text based on the similarity between the knowledge fusion vector of the first keyword and the knowledge fusion vector of the search text, and the search text determination efficiency is high.

[0166] Taking three search texts as an example, if the knowledge fusion vector of the first keyword is (-3, -2.4, -6) T , the knowledge fusion vectors of the three search texts are (-1, -3, -1) T 、(-2,2,3) T and (1, 4, 5) T , the server determines the knowledge fusion vector of the first keyword (-3, -2.4, -6) T , and the knowledge fusion vectors of the three search texts are (-1, -3, -1) T 、(-2,2,3) T and (1, 4, 5) T The cosine similarity between them is 0.69, -0.58 and -0.93. If the similarity threshold is 0.6, then the server can merge the knowledge vector (-1, -3, -1) T The corresponding search text is determined as the search text corresponding to the target text.

[0167] The following describes how the server obtains the knowledge fusion vector of the search text:

[0168] In a possible embodiment, the server performs word segmentation on at least one item in the title or introduction of the search text to obtain multiple reference words of the search text. In response to any reference word in the multiple reference words of the search text being the same as any word in the knowledge text library, the server determines any reference word as a second keyword, and the knowledge text library stores multiple words and multiple knowledge texts corresponding to the multiple words. The server obtains multiple knowledge texts corresponding to the second keyword from the knowledge text library. The server obtains a feature vector of the second keyword based on the second keyword and other texts in the search text except the second keyword. Based on the similarity between the feature vector of the second keyword and the feature vectors of the multiple knowledge texts corresponding to the second keyword, the server fuses the feature vector of the second keyword with the feature vectors of the multiple knowledge texts corresponding to the second keyword to obtain a knowledge fusion vector of the search text.

[0169] It should be noted that the above steps 701-705 are described with the server as the execution subject as an example. In other possible implementations, the above steps can also be executed by the terminal as the execution subject, and the embodiment of the present application does not limit this.

[0170] All of the above optional technical solutions can be combined in any way to form optional embodiments of the present application, and will not be described in detail here.

[0171] Since the first keyword may correspond to different semantics in different texts, the technical solution provided in the embodiment of the present application introduces knowledge text in the process of feature extraction of the first keyword, and different knowledge texts can represent different semantics of the first keyword. Through the correlation between the feature vector of the knowledge text and the feature vector of the first keyword, the feature vector of the knowledge text is fused with the feature vector of the first keyword, that is, the semantic information carried in the feature vector of the first keyword is supplemented, so that the knowledge fusion vector can more accurately represent the semantics of the first keyword in the target text, thereby improving the accuracy of the subsequent search text obtained based on the knowledge fusion vector.

[0172] After introducing the text search method provided in the embodiment of the present application, the training method of the feature extraction model provided in the embodiment of the present application is described below.

[0173] See also Figure 11 and Figure 12 , methods include:

[0174] 1101. The server obtains sample data, where the sample data includes sample text, sample search text, and sample similarity between the sample text and the sample search text.

[0175] In some embodiments, the server can use 1 and 0 to represent the sample similarity between the sample text and the sample search text, where 1 indicates a high similarity between the sample text and the sample search text, that is, the sample text and the sample search text match, and 0 indicates a low similarity between the sample text and the sample search text, that is, the sample text and the sample search text do not match. In the above-mentioned text search method, the sample text is the target text when performing a text search, and the sample search text is the search text obtained after searching based on the target text.

[0176] 1102. The server inputs the sample text and the sample search text into the feature extraction model.

[0177] See also Figure 12 , that is, inputting the sample text Query and the search text Document into the feature extraction model 1201.

[0178] 1103. The server extracts the knowledge fusion vector of the sample key words in the sample text and the knowledge fusion vector of the sample search text through the feature extraction model.

[0179] In one possible implementation, the server uses a feature extraction model to obtain sample keywords from the sample text. The server uses the feature extraction model to obtain search keywords from the sample search text. The server uses the feature extraction model to obtain multiple knowledge texts for the sample keywords and multiple knowledge texts for the search keywords. The server uses the feature extraction model to obtain knowledge fusion vectors for the sample keywords and the knowledge fusion vector for the sample search text.

[0180] For example, see Figure 12 The server obtains sample keywords from the sample text through the knowledge discovery layer 1202 (Knowledge Lookup Layer) of the feature extraction model, obtains multiple knowledge texts corresponding to the sample keywords from the knowledge text library, and extracts the feature vector e1 of the sample keyword and the feature vectors k1-k of the multiple knowledge texts. n The server obtains the search keyword from the sample search text through the knowledge lookup layer 1202 of the feature extraction model, obtains multiple knowledge texts corresponding to the search keyword from the knowledge text library, and extracts the feature vector e2 of the search keyword and the feature vectors l1-l of the multiple knowledge texts. n The server takes the feature vector e1 of the sample keyword and the feature vectors k1-k of multiple knowledge texts. n The self-attention layer 1203 of the input feature extraction model is used to convert the feature vector e1 of the sample keyword and the feature vectors k1-k of multiple knowledge texts inton The server searches for the feature vector e2 of the keyword and the feature vectors l1-l of the multiple knowledge texts. n The self-attention layer 1203 of the input feature extraction model is used to convert the feature vector e2 of the search keyword and the feature vectors l1-l of multiple knowledge texts into n The server then performs fusion to obtain a fusion vector for the search keyword. The server inputs the fusion vector of the sample keyword and the fusion vector of the search keyword into the multi-head attention layer 1204 of the feature extraction model. The multi-head attention layer 1204 performs multi-head attention encoding on the fusion vector of the sample keyword to obtain multiple attention encoding vectors corresponding to the fusion vector of the sample keyword. The multi-head attention layer 1204 also performs multi-head attention encoding on the fusion vector of the search keyword to obtain multiple attention encoding vectors corresponding to the fusion vector of the search keyword. The server inputs the multiple attention encoding vectors corresponding to the fusion vector of the sample keyword into the fully connected layer 1205 of the feature extraction model. The fully connected layer 1205 performs fully connected processing on the multiple attention encoding vectors corresponding to the fusion vector of the sample keyword to obtain a knowledge fusion vector for the sample keyword. The server inputs the multiple attention encoding vectors corresponding to the fusion vector of the search keyword into the fully connected layer 1205 of the feature extraction model. The fully connected layer 1205 performs fully connected processing on the multiple attention encoding vectors corresponding to the fusion vector of the search keyword to obtain a knowledge fusion vector for the search keyword. Based on the knowledge vector of the search keyword, a knowledge fusion vector for the sample search text is obtained.

[0181] 1104. The server adjusts the model parameters of the feature extraction model based on the difference information between the similarity between the knowledge fusion vector of the sample keyword and the knowledge fusion vector of the sample search text and the sample similarity.

[0182] For example, the server can construct a loss function as shown in formula (4) to adjust the model parameters of the feature extraction model.

[0183]

[0184] Wherein, L is the loss function of the feature extraction model. In some embodiments, L is also called contrastive loss function (Contrastive Loss), T is the total number of sample texts, y is the similarity between the sample text and the search text, wherein 1 indicates that the sample text and the sample search text have a high similarity, that is, the sample text and the sample search text match, 0 indicates that the sample text and the sample search text have a low similarity, that is, the sample text and the sample search text do not match, γ is a hyperparameter, which represents the ideal maximum similarity between the sample text and the search text, and is set by technical personnel according to actual conditions, and d represents the similarity between the knowledge fusion vector of the sample keyword and the knowledge fusion vector of the sample search text. If E is used qm Represents the knowledge fusion vector of sample keywords, using E dm Represents the knowledge fusion vector of search keywords, then Wherein, M is the dimension of the vector. In some embodiments, M=1.

[0185] Because the first keyword may correspond to different semantics in different texts, the technical solution provided in the embodiments of this application introduces knowledge texts during the training of the feature extraction model. Different knowledge texts can represent different semantics of the first keyword. By using knowledge texts to supplement the feature vectors of the sample keyword and the semantics carried by the search keyword, the two resulting knowledge fusion vectors can more completely represent the semantics of the sample keyword in the sample text and the semantics of the search keyword in the search text, thereby improving the feature extraction capability of the feature extraction model.

[0186] Figure 13 This is a structural diagram of a text search device provided in an embodiment of the present application, see Figure 13 The device includes: a knowledge text acquisition module 1301, a feature vector acquisition module 1302, a feature vector fusion module 1303 and a text acquisition module 1304.

[0187] The knowledge text acquisition module 1301 is used to acquire multiple knowledge texts of the first keyword in the target text, where the multiple knowledge texts are used to represent different semantics of the first keyword.

[0188] The feature vector acquisition module 1302 is configured to acquire a feature vector of the first keyword based on the first keyword and other text in the target text except the first keyword.

[0189] The feature vector fusion module 1303 is configured to fuse the feature vector of the first keyword with the feature vectors of the plurality of knowledge texts based on the similarity between the feature vector of the first keyword and the feature vectors of the plurality of knowledge texts to obtain a knowledge fusion vector of the first keyword.

[0190] The text acquisition module 1304 is configured to acquire the search text corresponding to the target text based on the knowledge fusion vector.

[0191] In one possible implementation, the feature vector acquisition module is configured to input the first keyword and other text into a feature extraction model, and perform attention encoding on the first keyword and other text through the feature extraction model to obtain a feature vector for the first keyword.

[0192] In one possible embodiment, a feature vector acquisition module is configured to acquire a first query vector, a first key vector, and a first value vector for a first keyword. A second key vector and a second value vector for other texts are acquired. The product of the first query vector and the first key vector and the product of the first query vector and the second key vector are normalized to obtain a first attention weight for the first keyword and a second attention weight for the other texts to the first keyword. The product of the first attention weight and the first value vector and the product of the second attention weight and the second value vector are added to obtain a feature vector for the first keyword.

[0193] In one possible implementation, the feature vector fusion module is configured to perform the following steps using a feature extraction model:

[0194] Based on the similarity between the feature vector of the first keyword and the feature vectors of multiple knowledge texts, multiple first association weights between the feature vector of the first keyword and the feature vectors of multiple knowledge texts are determined, and the first association weights are used to represent the degree of relevance between the corresponding knowledge text and the first keyword.

[0195] Based on the multiple first association weights, the feature vector of the first keyword is fused with the feature vectors of the multiple knowledge texts to obtain a knowledge fusion vector of the first keyword.

[0196] In one possible implementation, the feature vector fusion module is configured to perform a weighted summation of the feature vector of the first keyword and the feature vectors of the plurality of knowledge texts based on a plurality of first association weights to obtain a fusion vector of the first keyword. Multi-head attention encoding is performed on the fusion vector to obtain a plurality of attention encoding vectors of the first keyword. Based on the plurality of attention encoding vectors, a knowledge fusion vector of the first keyword is obtained.

[0197] In one possible implementation, the feature vector fusion module is configured to concatenate multiple attention encoding vectors to obtain an attention encoding matrix, and perform dimensionality reduction processing on the attention encoding matrix to obtain a knowledge fusion vector of the first keyword.

[0198] In one possible implementation, the feature extraction model training device includes:

[0199] The sample data acquisition module is used to acquire sample data, where the sample data includes sample text, sample search text, and sample similarity between the sample text and the sample search text.

[0200] The first input module is used to input the sample text and the sample search text into the feature extraction model.

[0201] The feature extraction module is used to extract the knowledge fusion vector of the sample key words in the sample text and the knowledge fusion vector of the sample search text through the feature extraction model.

[0202] The adjustment module is used to adjust the model parameters of the feature extraction model based on the difference information between the similarity between the knowledge fusion vector of the sample keyword and the knowledge fusion vector of the sample search text and the sample similarity.

[0203] In one possible implementation, the knowledge text acquisition module is configured to search a knowledge text library for a target word identical to a first keyword, wherein the knowledge text library stores a plurality of words and a plurality of knowledge texts corresponding to each word, and acquire the plurality of knowledge texts corresponding to the target word as the plurality of knowledge texts corresponding to the first keyword.

[0204] In a possible implementation, the means for acquiring the first keyword includes:

[0205] The first word segmentation module is used to segment the target text into words to obtain a plurality of reference words of the target text.

[0206] The first determination module is configured to determine any reference word among a plurality of reference words as a first keyword in response to the fact that any reference word is identical to any word in a knowledge text library, wherein the knowledge text library stores a plurality of words and a plurality of knowledge texts corresponding to each word.

[0207] In one possible implementation, the word segmentation module is configured to segment the target text using different methods to obtain multiple reference word sequences corresponding to the different methods, each reference word sequence including multiple reference words in the target text, different reference words in the same reference word sequence having the same number of characters, and reference words in different reference word sequences having different numbers of characters. In response to multiple reference words belonging to different reference word sequences being identical to multiple words in the knowledge text base, the reference word with the largest number of characters among the multiple reference words belonging to the different reference word sequences is obtained as the first keyword.

[0208] In a possible implementation, the device for acquiring feature vectors of multiple knowledge texts includes:

[0209] The second input module is used to input any knowledge text into the feature extraction model.

[0210] The encoding module is used to perform attention encoding on multiple words in any knowledge text through a feature extraction model to obtain a feature vector of any knowledge text.

[0211] In one possible embodiment, the encoding module is used to obtain the third query vector, the third key vector and the third value vector of any word among multiple words in any knowledge text. The fourth key vector and the fourth value vector of the other words except any word among the multiple words in any knowledge text are obtained. The product of the third query vector and the third key vector and the product of the third query vector and the fourth key vector are normalized to obtain the third attention weight of any word and the fourth attention weight of other words to any word. The product of the third attention weight and the third value vector and the product of the fourth attention weight and the fourth value vector are added to obtain the feature vector of any word. The feature vectors of multiple words in any knowledge text are fused to obtain the feature vector of any knowledge text.

[0212] In a possible implementation, the text acquisition module is configured to determine any search text as a search text corresponding to a target text in response to the similarity between the knowledge fusion vector of any search text and the knowledge fusion vector of the first keyword meeting a target similarity condition.

[0213] In a possible implementation, the device for acquiring the knowledge fusion vector of the search text includes:

[0214] The second word segmentation module is used to segment at least one item in the title or introduction of the search text into words to obtain multiple reference words of the search text.

[0215] The second determination module is used to determine any reference word among multiple reference words in the search text as a second keyword in response to the fact that any reference word is the same as any word in the knowledge text library, where the knowledge text library stores multiple words and multiple knowledge texts corresponding to the multiple words.

[0216] The knowledge text acquisition module is further used to acquire multiple knowledge texts corresponding to the second keyword from the knowledge text library.

[0217] The feature vector acquisition module is further configured to acquire a feature vector of the second keyword based on the second keyword and other texts in the search text except the second keyword.

[0218] The feature vector fusion module is also used to fuse the feature vector of the second keyword with the feature vectors of multiple knowledge texts corresponding to the second keyword based on the similarity between the feature vector of the second keyword and the feature vectors of multiple knowledge texts corresponding to the second keyword to obtain a knowledge fusion vector of the search text.

[0219] Since the first keyword may correspond to different semantics in different texts, the technical solution provided in the embodiment of the present application introduces knowledge text in the process of feature extraction of the first keyword, and different knowledge texts can represent different semantics of the first keyword. Through the correlation between the feature vector of the knowledge text and the feature vector of the first keyword, the feature vector of the knowledge text is fused with the feature vector of the first keyword, that is, the semantic information carried in the feature vector of the first keyword is supplemented, so that the knowledge fusion vector can more accurately represent the semantics of the first keyword in the target text, thereby improving the accuracy of the subsequent search text obtained based on the knowledge fusion vector.

[0220] The present application embodiment provides a computer device for executing the above method. The computer device can be implemented as a terminal or a server. The structure of the terminal is first introduced below:

[0221] Figure 14 1400 is a schematic diagram of a terminal structure provided in an embodiment of the present application. The terminal 1400 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto.

[0222] Typically, the terminal 1400 includes one or more processors 1401 and one or more memories 1402 .

[0223] The processor 1401 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1401 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), or PLA (Programmable Logic Array). The processor 1401 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1401 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1401 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0224] Memory 1402 may include one or more computer-readable storage media, which may be non-transitory. Memory 1402 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in memory 1402 is used to store at least one computer program, which is executed by processor 1401 to implement the text search method provided in the method embodiment of the present application.

[0225] In some embodiments, terminal 1400 may optionally include a peripheral device interface 1403 and at least one peripheral device. Processor 1401, memory 1402, and peripheral device interface 1403 may be connected via a bus or signal lines. Each peripheral device may be connected to peripheral device interface 1403 via a bus, signal lines, or circuit boards. Specifically, the peripheral device may include at least one of a radio frequency circuit 1404, a display screen 1405, a camera assembly 1406, an audio circuit 1407, and a power supply 1408.

[0226] The peripheral device interface 1403 can be used to connect at least one I / O (Input / Output)-related peripheral device to the processor 1401 and the memory 1402. In some embodiments, the processor 1401, the memory 1402, and the peripheral device interface 1403 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1401, the memory 1402, and the peripheral device interface 1403 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.

[0227] RF circuit 1404 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. RF circuit 1404 communicates with communication networks and other communication devices via electromagnetic signals. RF circuit 1404 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. RF circuit 1404 may optionally include an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a subscriber identity module card, and the like.

[0228] Display screen 1405 is used to display a UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When display screen 1405 is a touch screen display, display screen 1405 also has the ability to collect touch signals on or above the surface of display screen 1405. The touch signals can be input as control signals to processor 1401 for processing. In this case, display screen 1405 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards.

[0229] The camera assembly 1406 is used to collect images or videos. Optionally, the camera assembly 1406 includes a front camera and a rear camera. Typically, the front camera is set on the front panel of the terminal, and the rear camera is set on the back of the terminal.

[0230] The audio circuit 1407 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals that are input to the processor 1401 for processing, or input to the radio frequency circuit 1404 for voice communication.

[0231] The power supply 1408 is used to supply power to various components in the terminal 1400. The power supply 1408 can be alternating current, direct current, a disposable battery, or a rechargeable battery.

[0232] In some embodiments, the terminal 1400 further includes one or more sensors 1409 , including but not limited to: an acceleration sensor 1410 , a gyroscope sensor 1411 , a pressure sensor 1412 , an optical sensor 1413 , and a proximity sensor 1414 .

[0233] The acceleration sensor 1410 can detect acceleration magnitudes on three coordinate axes of a coordinate system established with the terminal 1400 .

[0234] The gyroscope sensor 1411 can detect the body direction and rotation angle of the terminal 1400 . The gyroscope sensor 1411 can cooperate with the acceleration sensor 1410 to collect the user's 3D actions on the terminal 1400 .

[0235] The pressure sensor 1412 can be provided on the side frame of the terminal 1400 and / or below the display screen 1405. When the pressure sensor 1412 is provided on the side frame of the terminal 1400, it can detect the user's gripping signal of the terminal 1400, and the processor 1401 can perform left-hand or right-hand recognition or shortcut operations based on the gripping signal collected by the pressure sensor 1412. When the pressure sensor 1412 is provided below the display screen 1405, the processor 1401 controls the operable controls on the UI interface based on the user's pressure operation on the display screen 1405.

[0236] The optical sensor 1413 is used to collect ambient light intensity. In one embodiment, the processor 1401 can control the display brightness of the display screen 1405 according to the ambient light intensity collected by the optical sensor 1413.

[0237] The proximity sensor 1414 is used to collect the distance between the user and the front of the terminal 1400 .

[0238] Those skilled in the art will understand that Figure 14 The structure shown in the figure does not constitute a limitation on the terminal 1400, and the terminal 1400 may include more or fewer components than shown in the figure, or combine certain components, or adopt a different component arrangement.

[0239] The above-mentioned computer device can also be implemented as a server. The structure of the server is introduced below:

[0240] Figure 15This is a structural diagram of a server provided in an embodiment of the present application. The server 1500 may have relatively large differences due to different configurations or performances, and may include one or more processors (Central Processing Units, CPU) 1501 and one or more memories 1502, wherein the one or more memories 1502 store at least one computer program, and the at least one computer program is loaded and executed by the one or more processors 1501 to implement the methods provided in the above-mentioned various method embodiments. Of course, the server 1500 may also have components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output. The server 1500 may also include other components for implementing device functions, which will not be described in detail here.

[0241] In an exemplary embodiment, a computer-readable storage medium is also provided, such as a memory including a computer program. The computer program can be executed by a processor to perform the text search method in the above embodiment. For example, the computer-readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a compact disc (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, or the like.

[0242] In an exemplary embodiment, a computer program product or computer program is also provided, which includes program code, which is stored in a computer-readable storage medium. A processor of a computer device reads the program code from the computer-readable storage medium, and the processor executes the program code, so that the computer device performs the above-mentioned text search method.

[0243] Those skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware, or may be accomplished by a program to instruct the relevant hardware, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0244] The above are only optional embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.

Claims

1. A text search method, characterized in that: The method comprises: Acquire multiple knowledge texts of a first keyword in a target text, where the first keyword is a word with different semantics in different contexts, and the multiple knowledge texts are used to represent the different semantics of the first keyword; Obtaining a feature vector of the first keyword based on the first keyword and other text in the target text except the first keyword; Based on the similarity between the feature vector of the first keyword and the feature vectors of the plurality of knowledge texts, the feature vector of the first keyword is fused with the feature vectors of the plurality of knowledge texts to obtain a knowledge fusion vector of the first keyword; Acquire a search text corresponding to the target text based on the knowledge fusion vector; The step of fusing the feature vector of the first keyword with the feature vectors of the plurality of knowledge texts based on the similarity between the feature vector of the first keyword and the feature vectors of the plurality of knowledge texts to obtain a knowledge fusion vector of the first keyword includes: The feature extraction model performs the following steps: determining, based on similarities between the feature vector of the first keyword and the feature vectors of the plurality of knowledge texts, a plurality of first association weights between the feature vector of the first keyword and the feature vectors of the plurality of knowledge texts, the first association weights being used to represent a degree of relevance between the corresponding knowledge text and the first keyword; fusing the feature vector of the first keyword with the feature vectors of the plurality of knowledge texts based on the plurality of first association weights to obtain a knowledge fusion vector of the first keyword; The training method of the feature extraction model includes: Acquire sample data, the sample data including sample text, sample search text, and sample similarity between the sample text and the sample search text; Inputting the sample text and the sample search text into the feature extraction model; Extracting the knowledge fusion vector of the sample key words in the sample text and the knowledge fusion vector of the sample search text by the feature extraction model; Based on the difference information between the similarity between the knowledge fusion vector of the sample keyword and the knowledge fusion vector of the sample search text and the sample similarity, the following loss function is used to adjust the model parameters of the feature extraction model: Wherein, L is the loss function of the feature extraction model, T is the total number of the sample texts, y is the sample similarity between the sample text and the sample search text, wherein 1 indicates that the sample text matches the sample search text, 0 indicates that the sample text does not match the sample search text, γ is a hyperparameter representing the ideal maximum similarity between the sample text and the sample search text, d represents the similarity between the knowledge fusion vector of the sample keyword and the knowledge fusion vector of the sample search text, E qm Represents the knowledge fusion vector of the sample keywords, E dm The knowledge fusion vector representing the search keyword, M is the dimension of the vector.

2. The method according to claim 1, characterized in that The acquiring of a feature vector of the first keyword based on the first keyword and other text in the target text except the first keyword includes: Inputting the first keyword and the other text into the feature extraction model; Attention encoding is performed on the first keyword and the other texts through the feature extraction model to obtain a feature vector of the first keyword.

3. The method according to claim 2, characterized in that The performing attention encoding on the first keyword and the other text to obtain a feature vector of the first keyword includes: Obtaining a first query vector, a first key vector, and a first value vector for the first keyword; Obtain a second key vector and a second value vector of the other text; Normalizing the product of the first query vector and the first key vector and the product of the first query vector and the second key vector to obtain a first attention weight of the first keyword and a second attention weight of the other text to the first keyword; The product of the first attention weight and the first value vector is added to the product of the second attention weight and the second value vector to obtain a feature vector of the first keyword.

4. The method according to claim 1, wherein The step of fusing the feature vector of the first keyword with the feature vectors of the plurality of knowledge texts based on the plurality of first association weights to obtain a knowledge fusion vector of the first keyword includes: Based on the multiple first association weights, performing weighted summation on the feature vector of the first keyword and the feature vectors of the multiple knowledge texts to obtain a fusion vector of the first keyword; Performing multi-head attention encoding on the fusion vector to obtain multiple attention encoding vectors of the first keyword; Based on the multiple attention encoding vectors, a knowledge fusion vector of the first keyword is obtained.

5. The method according to claim 4, characterized in that The obtaining of the knowledge fusion vector of the first keyword based on the multiple attention encoding vectors includes: Concatenate the multiple attention encoding vectors to obtain an attention encoding matrix; Perform dimensionality reduction processing on the attention encoding matrix to obtain a knowledge fusion vector of the first keyword.

6. The method according to claim 1, characterized in that The plurality of knowledge texts for obtaining the first keyword in the target text include: Searching for a target word identical to the first keyword in a knowledge text library, wherein the knowledge text library stores a plurality of words and a plurality of knowledge texts corresponding to each of the words; The multiple knowledge texts corresponding to the target word are obtained as the multiple knowledge texts of the first keyword.

7. The method according to claim 1, characterized in that The method for obtaining the first keyword includes: Segmenting the target text into words to obtain a plurality of reference words of the target text; In response to any reference word among the plurality of reference words being identical to any word in a knowledge text library, the any reference word is determined as the first keyword. The knowledge text library stores a plurality of words and a plurality of knowledge texts corresponding to each of the words.

8. The method according to claim 7, characterized in that The step of segmenting the target text into words to obtain a plurality of reference words of the target text includes: Segmenting the target text into words using different methods to obtain a plurality of reference word sequences corresponding to the different methods, each reference word sequence including a plurality of reference words in the target text, different reference words in the same reference word sequence having the same number of characters, and reference words in different reference word sequences having different numbers of characters; In response to any reference word among the plurality of reference words being identical to any word in the knowledge text base, determining the any reference word as the first keyword includes: In response to a plurality of reference words belonging to different reference word sequences being respectively identical to a plurality of words in the knowledge text library, a reference word with the largest number of characters among the plurality of reference words belonging to different reference word sequences is obtained as the first keyword.

9. The method according to any one of claims 1 to 8, characterized in that The method for obtaining the feature vectors of the plurality of knowledge texts includes: For any knowledge text, input the knowledge text into the feature extraction model; By using the feature extraction model, attention encoding is performed on multiple words in any knowledge text to obtain a feature vector of any knowledge text.

10. The method according to claim 9, characterized in that The performing attention encoding on a plurality of words in any one of the knowledge texts to obtain a feature vector of the any one of the knowledge texts comprises: For any word among the multiple words in the any knowledge text, obtaining a third query vector, a third key vector, and a third value vector of the any word; Obtaining fourth key vectors and fourth value vectors of other words in the plurality of words in the any one knowledge text except the any one word; Normalizing a product of the third query vector and the third key vector and a product of the third query vector and the fourth key vector to obtain a third attention weight of the any word and a fourth attention weight of the other words to the any word; Adding the product of the third attention weight and the third value vector and the product of the fourth attention weight and the fourth value vector to obtain a feature vector of the any word; The feature vectors of multiple words in any one of the knowledge texts are fused to obtain the feature vector of any one of the knowledge texts.

11. The method according to any one of claims 1 to 8, characterized in that The acquiring of the search text corresponding to the target text based on the knowledge fusion vector includes: In response to the similarity between the knowledge fusion vector of any search text and the knowledge fusion vector of the first keyword meeting a target similarity condition, the any search text is determined as a search text corresponding to the target text.

12. The method according to any one of claims 1 to 8, characterized in that The method for obtaining the knowledge fusion vector of the search text includes: Segmenting at least one of the title or introduction of the search text into words to obtain a plurality of reference words of the search text; In response to any reference word among the plurality of reference words in the search text being identical to any word in a knowledge text library, determining the any reference word as a second keyword, the knowledge text library storing a plurality of words and a plurality of knowledge texts corresponding to the plurality of words; Acquire a plurality of knowledge texts corresponding to the second keyword from the knowledge text library; Obtaining a feature vector of the second keyword based on the second keyword and other text in the search text except the second keyword; Based on the similarity between the feature vector of the second keyword and the feature vectors of multiple knowledge texts corresponding to the second keyword, the feature vector of the second keyword and the feature vectors of multiple knowledge texts corresponding to the second keyword are fused to obtain a knowledge fusion vector of the search text.

13. A text search device, characterized in that: The device comprises: a knowledge text acquisition module, configured to acquire a plurality of knowledge texts of a first keyword in a target text, wherein the first keyword is a word having different semantics in different contexts, and the plurality of knowledge texts are used to represent the different semantics of the first keyword; a feature vector acquisition module, configured to acquire a feature vector of the first keyword based on the first keyword and other text in the target text except the first keyword; a feature vector fusion module, configured to fuse the feature vector of the first keyword with the feature vectors of the plurality of knowledge texts based on similarities between the feature vector of the first keyword and the feature vectors of the plurality of knowledge texts to obtain a knowledge fusion vector of the first keyword; A text acquisition module, configured to acquire a search text corresponding to the target text based on the knowledge fusion vector; The feature vector fusion module is used to perform the following steps through the feature extraction model: determining, based on similarities between the feature vector of the first keyword and the feature vectors of the plurality of knowledge texts, a plurality of first association weights between the feature vector of the first keyword and the feature vectors of the plurality of knowledge texts, the first association weights being used to represent a degree of relevance between the corresponding knowledge text and the first keyword; Based on a plurality of first association weights, the feature vector of the first keyword is fused with the feature vectors of the plurality of knowledge texts to obtain a knowledge fusion vector of the first keyword; The training device of the feature extraction model includes: A sample data acquisition module is used to acquire sample data, wherein the sample data includes a sample text, a sample search text, and a sample similarity between the sample text and the sample search text; A first input module, configured to input the sample text and the sample search text into the feature extraction model; A feature extraction module, configured to extract a knowledge fusion vector of sample keywords in the sample text and a knowledge fusion vector of the sample search text through the feature extraction model; An adjustment module is configured to adjust the model parameters of the feature extraction model based on the difference information between the similarity between the knowledge fusion vector of the sample keyword and the knowledge fusion vector of the sample search text and the sample similarity, using the following loss function: Wherein, L is the loss function of the feature extraction model, T is the total number of the sample texts, y is the sample similarity between the sample text and the sample search text, wherein 1 indicates that the sample text matches the sample search text, 0 indicates that the sample text does not match the sample search text, γ is a hyperparameter representing the ideal maximum similarity between the sample text and the sample search text, d represents the similarity between the knowledge fusion vector of the sample keyword and the knowledge fusion vector of the sample search text, E qm Represents the knowledge fusion vector of the sample keywords, E dm The knowledge fusion vector representing the search keyword, M is the dimension of the vector.

14. The device according to claim 13, characterized in that The feature vector acquisition module is used to input the first keyword and the other text into the feature extraction model; through the feature extraction model, the first keyword and the other text are attention encoded to obtain the feature vector of the first keyword.

15. The device according to claim 14, characterized in that The feature vector acquisition module is configured to acquire a first query vector, a first key vector, and a first value vector of the first keyword; acquire a second key vector and a second value vector of the other text; and perform normalization processing on the product of the first query vector and the first key vector and the product of the first query vector and the second key vector to obtain a first attention weight of the first keyword and a second attention weight of the other text to the first keyword; The product of the first attention weight and the first value vector is added to the product of the second attention weight and the second value vector to obtain a feature vector of the first keyword.

16. The device according to claim 13, characterized in that The feature vector fusion module is configured to perform a weighted summation of the feature vector of the first keyword and the feature vectors of the plurality of knowledge texts based on the plurality of first association weights to obtain a fusion vector of the first keyword; and perform multi-head attention encoding on the fusion vector to obtain a plurality of attention encoding vectors of the first keyword; Based on the multiple attention encoding vectors, a knowledge fusion vector of the first keyword is obtained.

17. The device according to claim 16, characterized in that The feature vector fusion module is used to splice the multiple attention coding vectors to obtain an attention coding matrix; and perform dimensionality reduction processing on the attention coding matrix to obtain the knowledge fusion vector of the first keyword.

18. The device according to claim 13, characterized in that The knowledge text acquisition module is used to search for a target word that is the same as the first keyword in a knowledge text library, where the knowledge text library stores multiple words and multiple knowledge texts corresponding to each of the words; and acquire the multiple knowledge texts corresponding to the target word as multiple knowledge texts of the first keyword.

19. The device according to claim 13, characterized in that The first keyword acquisition device includes: A first word segmentation module is used to segment the target text into words to obtain a plurality of reference words of the target text; The first determination module is configured to determine any reference word among the plurality of reference words as the first keyword in response to the fact that the reference word is identical to any word in a knowledge text library, wherein the knowledge text library stores a plurality of words and a plurality of knowledge texts corresponding to each of the words.

20. The device according to claim 19, characterized in that The word segmentation module is configured to segment the target text using different methods to obtain a plurality of reference word sequences corresponding to the different methods, each reference word sequence including a plurality of reference words in the target text, different reference words in the same reference word sequence having the same number of characters, and reference words in different reference word sequences having different numbers of characters; In response to a plurality of reference words belonging to different reference word sequences being respectively identical to a plurality of words in the knowledge text library, a reference word with the largest number of characters among the plurality of reference words belonging to different reference word sequences is obtained as the first keyword.

21. The device according to any one of claims 13 to 20, characterized in that The device for acquiring the feature vectors of the plurality of knowledge texts includes: A second input module is used to input any knowledge text into a feature extraction model; The encoding module is used to perform attention encoding on multiple words in any knowledge text through the feature extraction model to obtain a feature vector of any knowledge text.

22. The device according to claim 21, characterized in that The encoding module is configured to obtain, for any word among the multiple words in the any knowledge text, a third query vector, a third key vector, and a third value vector of the any word; obtain fourth key vectors and fourth value vectors of other words among the multiple words in the any knowledge text except the any word; and perform normalization processing on the product of the third query vector and the third key vector and the product of the third query vector and the fourth key vector to obtain a third attention weight of the any word and a fourth attention weight of the other words to the any word; Add the product of the third attention weight and the third value vector and the product of the fourth attention weight and the fourth value vector to obtain the feature vector of any one of the words; and fuse the feature vectors of multiple words in any one of the knowledge texts to obtain the feature vector of any one of the knowledge texts.

23. The device according to any one of claims 13 to 20, characterized in that The text acquisition module is configured to determine any search text as a search text corresponding to the target text in response to the similarity between the knowledge fusion vector of any search text and the knowledge fusion vector of the first keyword meeting a target similarity condition.

24. The device according to any one of claims 13 to 20, characterized in that The device for acquiring the knowledge fusion vector of the search text includes: A second word segmentation module is used to segment at least one of the title or introduction of the search text into words to obtain a plurality of reference words of the search text; a second determining module configured to determine any reference word among the plurality of reference words in the search text as a second keyword in response to the fact that the reference word is identical to any word in a knowledge text library, wherein the knowledge text library stores a plurality of words and a plurality of knowledge texts corresponding to the plurality of words; The knowledge text acquisition module is further configured to acquire a plurality of knowledge texts corresponding to the second keyword from the knowledge text library; The feature vector acquisition module is further configured to acquire a feature vector of the second keyword based on the second keyword and other text in the search text except the second keyword; The feature vector fusion module is also used to fuse the feature vector of the second keyword with the feature vectors of multiple knowledge texts corresponding to the second keyword based on the similarity between the feature vector of the second keyword and the feature vectors of multiple knowledge texts corresponding to the second keyword to obtain the knowledge fusion vector of the search text.

25. A computer device, characterized in that: The computer device includes one or more processors and one or more memories, wherein at least one computer program is stored in the one or more memories, and the computer program is loaded and executed by the one or more processors to implement the text search method according to any one of claims 1 to 12.

26. A computer-readable storage medium, characterized in that The computer-readable storage medium stores at least one computer program, and the computer program is loaded and executed by a processor to implement the text search method according to any one of claims 1 to 12.

27. A computer program product, characterized in that The computer program product includes a program code, which is stored in a computer-readable storage medium. A processor of a computer device reads the program code from the computer-readable storage medium and executes the program code, so that the computer device performs the text search method according to any one of claims 1 to 12.