Document retrieval method and device, electronic equipment and computer readable storage medium
By converting the query statement into a query vector and inputting the policy network to generate a search strategy, the problem of insufficient efficiency and accuracy in complex queries and dynamic environments is solved, and high accuracy and personalized document retrieval effects are achieved.
Patent Information
- Application Number
- CN202411978617.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-05-06
AI Technical Summary
When existing information retrieval systems handle complex queries or dynamic information environments, their search efficiency and accuracy are insufficient and cannot meet actual needs.
By converting the query statement into a query vector and entering the policy network to generate a search policy, it is decided whether to generate an answer directly or continue to perform in-depth information retrieval. If searching continues, query keyword vectors to input advanced semantics to execute the network to match the target document.
It realizes accurate response to different document retrieval needs, improves the accuracy and personalization of document retrieval, and significantly improves the efficiency and quality of file retrieval in complex retrieval environments.
Smart Images

Figure CN119938831A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and specifically to a document retrieval method and device, an electronic device, and a computer-readable storage medium. Background Art
[0002] In current information retrieval systems, due to the use of fixed retrieval algorithms, the main challenges faced by open-domain question answering and other knowledge-intensive tasks are insufficient information relevance and system adaptability. When processing complex queries or dynamic information environments, the retrieval efficiency and accuracy cannot meet actual needs. Summary of the invention
[0003] To solve the above technical problems, the embodiments of the present application respectively provide a document retrieval method, a document retrieval device, an electronic device, a computer-readable storage medium, and a computer program product.
[0004] According to one aspect of an embodiment of the present application, a document retrieval method is provided, comprising: converting a query statement used to indicate the retrieval of a document into a query vector; inputting the query vector into a policy network to obtain a retrieval strategy output by the policy network, wherein the retrieval strategy includes a query keyword vector; if the detection strategy indicates to directly generate an answer for the query statement, then directly generating an answer corresponding to the query statement; if the retrieval strategy indicates to continue to perform deep information retrieval, inputting the query keyword vector into a high-level semantic execution network to obtain a target document output by the high-level semantic execution network that matches the query statement.
[0005] In another exemplary embodiment, the strategy network includes a multi-head self-attention network layer, an information filtering network layer and a decision network layer, and the decision network layer is composed of multiple nonlinear transformation layers and activation layers; the strategy network performs the following steps to obtain the retrieval strategy: capturing the fine-grained dependencies in the query statement based on the query vector through the multi-head self-attention network layer; extracting the query keyword vector corresponding to the query statement based on the fine-grained dependencies through the information filtering network layer; generating the retrieval strategy based on the query keyword vector through the decision network layer.
[0006] In another exemplary embodiment, the process of the decision network layer generating the retrieval strategy based on the query keyword vector is expressed as the following formula:
[0007] π θ (a|s)=σ(LN(W2·ReLU(W1·h(s)+b1)+b2))
[0008] Among them, π θ(a|s) represents the probability of taking action a in the current system state s, θ represents the set of network parameters (such as W1, W2, b1, b2), σ represents the sigmoid function, LN represents the layer normalization operation, W1 and W2 represent the weight matrix of the network layer, b1 and b2 represent the offset vector of the network layer, ReLU represents the linear rectification function, and h(s) represents the high-dimensional representation of state s in the network.
[0009] In another exemplary embodiment, the high-level semantic execution network performs the following steps to obtain a target document that matches the query statement: searching for candidate documents containing the query keyword vector; converting the query keyword vector into a retrieval semantic vector, and converting the document vector of the candidate document into a document semantic vector; determining a degree of match between the query statement and the candidate document based on the retrieval semantic vector and the document semantic vector, so as to determine a target document that matches the query statement based on the degree of match.
[0010] In another exemplary embodiment, the matching degree between the query statement and the candidate document is calculated by the following formula:
[0011]
[0012] Rel(d,q) represents the matching degree between the query statement used to indicate the retrieval document and the document, q represents the query keyword vector, N represents the number of query keyword vectors, and q i represents the i-th query keyword vector, w i represents the weight of the i-th query keyword vector, vec(q i ) represents the retrieval semantic vector obtained by converting the i-th query keyword vector, d represents the document vector, M represents the number of document vectors, d j represents the j-th document vector, vec(d j ) represents the document semantic vector obtained by converting the j-th document vector, |·| 2 Represents calculating the square of the Euclidean distance between vectors.
[0013] In another exemplary embodiment, the method also includes: presenting the target document to the user as an answer corresponding to the query statement, and obtaining corresponding user feedback information and resource feedback information; calculating environmental feedback parameters based on the user feedback information and the resource feedback information, and adjusting the network parameters of the policy network and the high-level semantic execution network based on the environmental feedback parameters.
[0014] In another exemplary embodiment, the environmental feedback parameter is calculated using the following formula:
[0015]
[0016] Where R(s,a) represents the reward function calculated based on the current state s of the system and the action a taken to obtain the environmental feedback parameter, γ represents the impact of adjusting future rewards on the current value, α and β are coefficients used to balance the accuracy of the answer and the cost of the operation. The accuracy of the answer is calculated by To evaluate, y represents the true value, represents the predicted value, the operation cost is evaluated by (∫Cost(a,r)dr), which represents the resource consumption of action a, and r represents the resource type.
[0017] According to one aspect of an embodiment of the present application, a document retrieval device is provided, comprising: a preprocessing module, configured to convert a query statement used to indicate the retrieval of a document into a query vector; a decision module, configured to input the query vector into a policy network to obtain a retrieval strategy output by the policy network, wherein the retrieval strategy includes a query keyword vector; a retrieval module, configured to directly generate an answer corresponding to the query statement if the detection strategy indicates to directly generate an answer for the query statement; and if the retrieval strategy indicates to continue to perform deep information retrieval, input the query keyword vector into a high-level semantic execution network to obtain a target document output by the high-level semantic execution network that matches the query statement.
[0018] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the electronic device implements the document retrieval method as described above.
[0019] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a computer, the computer executes the document retrieval method as described above.
[0020] According to one aspect of an embodiment of the present application, a computer program product is also provided, including a computer program, which implements the document retrieval method as described above when executed by a processor.
[0021] The technical solution provided in the embodiment of the present application first uses a policy network to determine whether the retrieval strategy is to directly generate an answer or continue to perform deep information retrieval after converting the query statement used to indicate the retrieval document into a query vector, and then performs corresponding retrieval processing according to the retrieval strategy output by the policy network. This can achieve accurate response to different document retrieval needs and improve the accuracy and personalization level of document retrieval.
[0022] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0024] Figure 1 It is a schematic diagram of the implementation environment involved in this application;
[0025] Figure 2 is a flowchart of a document retrieval method shown in an exemplary embodiment of the present application;
[0026] Figure 3 A schematic diagram of an exemplary process of outputting a retrieval strategy by a strategy network is shown;
[0027] Figure 4 A schematic diagram of a process of outputting a target document matching a query statement by an exemplary high-level semantic execution network is shown;
[0028] Figure 5 is a flowchart of a document retrieval method shown in another exemplary embodiment of the present application;
[0029] Figure 6 A schematic diagram of an exemplary document retrieval process is shown;
[0030] Figure 7 is a block diagram of a document retrieval device shown in another exemplary embodiment of the present application;
[0031] Figure 8 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION
[0032] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.
[0033] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0034] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0035] The term "multiple" as used in this application refers to two or more than two. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the related objects are in an "or" relationship.
[0036] First see Figure 1 , Figure 1 1 is a schematic diagram of an implementation environment involved in the present application. The implementation environment is specifically a document retrieval system, including a terminal 110, a server 120 and a database 130, and the terminal 110 and the server 120, as well as the server 120 and the database 130 communicate with each other via wired or wireless means.
[0037] The terminal 110 is used to obtain the query statement input by the user, and the query statement also reflects the document retrieval intention of the user. This embodiment does not limit the specific way in which the terminal 110 obtains the query statement. For example, the query statement can be input by the user through an external device connected to the terminal 110 such as a keyboard or a mouse, or can be input by voice or other means.
[0038] A large number of documents are stored in the database 130. The terminal 110 can upload a query statement to the server 120, so that the server 120 can retrieve target documents matching the query statement from the search database 130 for the query statement, and return the search result to the terminal 110 as an answer corresponding to the query statement, so that the user can obtain the query result through the terminal 110.
[0039] Exemplarily, the server 120 is configured with a policy network and a high-level semantic execution network. After receiving a query statement for instructing to retrieve a document, the server 120 inputs the query vector into the policy network to obtain a retrieval strategy output by the policy network, wherein the retrieval strategy includes a query keyword vector; if the detection strategy indicates to directly generate an answer for the query statement, the server 120 directly generates an answer corresponding to the query statement; if the retrieval strategy indicates to continue to perform deep information retrieval, the server 120 inputs the query keyword vector into the high-level semantic execution network to obtain a target document matching the query statement output by the high-level semantic execution network, and returns the target document as an answer corresponding to the query statement to the terminal 110. This can achieve accurate responses to different document retrieval needs, improve the accuracy and personalization level of document retrieval, and significantly improve the efficiency and quality of file retrieval in complex retrieval environments.
[0040] It should be noted that the terminal 110 can be a smart phone, a tablet, a laptop, a computer, a smart home appliance, a smart terminal and other devices, which are not limited here. The server 120 can be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services, which are not limited here. The database 130 can be a relational database such as MySQL, PostgreSQL, Oracle, etc., or a distributed file system such as Hadoop HDFS, HBase, etc., which are not limited here.
[0041] See also Figure 2 , Figure 2 is a flowchart of a document retrieval method shown in an exemplary embodiment of the present application. The method can be applied to Figure 1 The implementation environment shown, for example, can be specifically executed by the server 120, can also be specifically executed by the terminal 110, or can be jointly executed by the terminal 110 and the server 120. Of course, the method can also be applied to other implementation environments, and can be executed by a terminal or a server in other implementation environments, or can be jointly executed by a terminal and a server in other implementation environments, and this embodiment is not limited thereto.
[0042] like Figure 2 As shown, in an exemplary embodiment, the document retrieval method includes S210-S240, which are described in detail as follows:
[0043] S210: Convert a query statement for instructing to retrieve documents into a query vector.
[0044] First, it should be noted that the purpose of converting the query statement into a query vector in this embodiment is to obtain a vector format that can be parsed by a computer. For example, the query statement can be converted into a query vector by performing word segmentation processing, semantic normalization processing, etc. on the query statement, which is not limited here.
[0045] S220, inputting the query vector into the policy network to obtain a retrieval strategy output by the policy network, wherein the retrieval strategy includes the query keyword vector.
[0046] The policy network combines deep sequence analysis with a network architecture that highlights information focus. It can not only understand the query problem on the surface, but also deeply explore the intentions and needs behind it, and output a retrieval strategy of whether to directly generate an answer or continue to execute deep information retrieval.
[0047] In some exemplary embodiments, the policy network includes a multi-head self-attention network layer, an information filtering network layer, and a decision network layer connected in sequence. The multi-head self-attention network layer is used to capture fine-grained dependencies in query statements through a multi-head self-attention mechanism. The multi-head self-attention mechanism enables the model to focus on different parts of the input sequence at the same time, thereby capturing complex relationships within the sequence. The information filtering network layer is used to strengthen the information fragments that are most relevant to the current query. The information filtering network layer can also be a network that uses an attention mechanism, which uses the attention mechanism to evaluate the relevance of each information fragment to the current query. By calculating the attention weight, the model can pay more attention to the information fragments that are most relevant to the query. The decision network layer is composed of multiple nonlinear transformation layers and activation layers, and the final decision output is generated through a series of nonlinear transformation layers and activation functions.
[0048] For example, see Figure 3 The process diagram of the strategy network outputting the retrieval strategy shown in the figure may include the following steps:
[0049] S221, captures fine-grained dependencies in query statements based on query vectors through a multi-head self-attention network layer;
[0050] S222, extracting a query keyword vector corresponding to the query statement based on the fine-grained dependency relationship through the information filtering network layer;
[0051] S223, generating a retrieval strategy based on the query keyword vector through the decision network layer.
[0052] As an exemplary implementation, the decision network layer may consider multiple information dimensions to decide whether to directly generate an answer corresponding to the query statement. For example, the following examples may lead to a decision to directly generate an answer corresponding to the query statement:
[0053] (1) When the query statement corresponds to a simple query requirement, that is, the query statement is very direct and the required data can be directly retrieved from the database without complex semantic analysis, so the corresponding answer can be generated directly for the query statement.
[0054] (2) When the query statement is a standard SQL (Structured Query Language) statement and directly corresponds to the table structure and data in the database, the database system can directly parse the query statement and generate a corresponding execution plan to obtain data without performing in-depth semantic analysis. Therefore, the query statement can also be directly executed and an answer can be generated.
[0055] (3) If the query statement is generated based on predefined templates, then these templates usually contain sufficient context information so that the database system can directly execute the query without additional semantic processing, and can also directly output the answer to the query statement.
[0056] (4) In some cases, in order to improve query performance, you may choose to skip the high-level semantic execution network. For example, in real-time data analysis or high-throughput application scenarios, quickly responding to query requests may be more important than fully understanding the semantics of the query, so the query execution path can be optimized to reduce unnecessary semantic analysis steps.
[0057] (5) When using restricted query languages, such as certain domain-specific data query languages (DSL), these languages may have been designed to be easy to parse and execute without the need for complex semantic analysis. In this case, these restricted query statements can also be directly parsed and answers generated.
[0058] (6) If the architecture and data schema of the database system are known and fixed, then the parsing and execution of query statements can be more straightforward, so query execution can be optimized for these known schemas.
[0059] It should be noted that the retrieval strategy finally output by the policy network contains not only conclusion information but also query keyword vectors. The conclusion information indicates whether to generate an answer directly for the query statement or to continue to perform deep information retrieval. The query keyword vector is used as input information for continuing the deep information retrieval stage, which helps to accurately obtain the target document that matches the query statement.
[0060] As another exemplary implementation, the process of the decision network outputting the retrieval strategy can be expressed as the following formula:
[0061] π θ(a|s)=σ(LN(W2·ReLU(W1·h(s)+b1)+b2))
[0062] Among them, π θ (a|s) represents the probability of taking action a in the current system state s, θ represents the set of network parameters (such as W1, W2, b1, b2), σ represents the sigmoid function, LN represents the layer normalization operation, W1 and W2 represent the weight matrix of the network layer, b1 and b2 represent the offset vector of the network layer, ReLU represents the linear rectification function, and h(s) represents the high-dimensional representation of state s in the network. It can be understood that taking action a in the current system state s also refers to the current document retrieval operation. This not only enhances the system's predictive ability, but also improves the stability of the decision-making process and the adaptability of the system.
[0063] S230: If the detection strategy indicates to directly generate an answer for the query statement, then directly generate an answer corresponding to the query statement.
[0064] When the retrieval strategy indicates to directly generate an answer to the query statement, the target document matching the query statement can be directly retrieved from the database without being processed by the high-level semantic execution network.
[0065] S240: If the search strategy indicates to continue to perform deep information search, the query keyword vector is input into the high-level semantic execution network to obtain a target document output by the high-level semantic execution network that matches the query statement.
[0066] When the retrieval strategy instructs to continue deep information retrieval, the advanced semantic execution network uses advanced indexing mechanisms such as hybrid inverted indexing and high-dimensional semantic mapping to deeply explore the complex semantics between the query statement and the candidate documents in the database, and optimize the information relevance, thereby accurately retrieving the target documents that match the query statement.
[0067] For example, see Figure 4 The flowchart of the high-level semantic execution network outputting the target document matching the query statement is shown. The high-level semantic execution network obtains the target document matching the query statement by executing the following steps:
[0068] S241, searching for candidate documents containing the query keyword;
[0069] S242, converting the query keyword vector into a retrieval environment semantic vector, and converting the document vector of the candidate document into a document environment semantic vector;
[0070] S243, determining the matching degree between the query statement and the candidate documents based on the retrieval environment semantic vector and the document environment semantic vector, so as to determine the target document matching the query statement based on the matching degree.
[0071] In the above process, a traditional inverted index and a text vector-based index are pre-generated at the same time. The inverted index is used to quickly locate documents containing specific keywords, while the text vector index is used to calculate the similarity between the query vector and the document vector. When searching, the inverted index is first used to quickly filter out the document set containing the query keywords. Then, in this filtered document set, the vector search technology is used to further calculate the similarity between the query vector and each document vector to obtain the final retrieval result. Among them, the document vector of the candidate document is also obtained in the same way as the query vector.
[0072] As a result, when processing large-scale document collections, the retrieval speed and accuracy can be significantly improved. When users need to perform complex queries containing multiple keywords, they can first quickly narrow the search scope through the inverted index, and then further accurately locate the search through vector search technology, making it more suitable for query scenarios that require real-time response.
[0073] This embodiment first searches for candidate documents containing query keywords from the database based on a pre-built inverted index. Then, the query keyword vector is mapped to a high-dimensional semantic vector space, that is, the query keyword vector is converted into a retrieval semantic vector, and the document vector of the candidate document also needs to be mapped to the same high-dimensional semantic vector space, that is, the document vector of the candidate document is converted into a document semantic vector. Finally, based on the matching degree between the retrieval semantic vector and the document semantic vector after high-dimensional semantic mapping, the target document matching the query statement is selected from the candidate documents, such as selecting the candidate document with the highest matching degree as the target document matching the query statement, or sorting different candidate documents in descending order based on the matching degree, and selecting multiple candidate documents with the highest ranking as the target documents matching the query statement, which is not limited here.
[0074] As an exemplary implementation, the vector similarity between the retrieval semantic vector and the document semantic vector may be calculated, and the vector similarity may be used as the matching degree between the query statement and the corresponding candidate document.
[0075] As another exemplary implementation, a complex model can be used to calculate the vector similarity between the retrieval semantic vector and the document semantic vector, and based on this vector similarity, the best document can be selected as the target document matching the query statement. This complex model can be expressed as the following formula:
[0076]
[0077] Rel(d,q) represents the matching degree between the query statement used to indicate the retrieval document and the document, q represents the query keyword vector, N represents the number of query keyword vectors, and q i represents the i-th query keyword vector, w i represents the weight of the i-th query keyword vector, vec(q i ) represents the retrieval semantic vector obtained by converting the i-th query keyword vector, d represents the document vector, M represents the number of document vectors, d j represents the j-th document vector, vec(d j ) represents the document semantic vector obtained by converting the j-th document vector.
[0078] From the above formula, we can see that each query keyword vector has its own weight, and the weight is used to highlight its importance in the query. The advanced semantic execution network also has adjustment parameters for sensitivity and importance of each dimension to refine the query process. In this way, by combining the use of high-dimensional vector mapping and exponential decay, the relevance and accuracy of the retrieval are effectively improved, ensuring that the information that best meets the query requirements is screened out from a large amount of data.
[0079] In general, after converting the query statement used to indicate the retrieval document into a query vector, the technical solution provided in this embodiment first uses a policy network to determine whether the retrieval strategy is to directly generate an answer or continue to perform deep information retrieval, and then performs corresponding retrieval processing according to the retrieval strategy output by the policy network. This can achieve accurate response to different document retrieval needs, improve the accuracy and personalization level of document retrieval, and significantly improve the efficiency and quality of file retrieval in complex retrieval environments.
[0080] In another exemplary embodiment, in order to further solve the problem that the current information retrieval system lacks an effective adaptive optimization mechanism and is unable to self-improve from user feedback, resulting in the system's performance being difficult to improve over time, the embodiment of the present application also combines an environmental feedback mechanism to propose a retrieval system that is continuously optimized based on user feedback, so as to achieve a technical solution for more efficient, accurate and personalized information acquisition.
[0081] It is important to understand that environmental feedback refers to a technical means of providing a basis for system optimization by collecting information such as user interaction, query background, and external environmental factors in real time during information retrieval and data processing. This method uses feedback data to dynamically adjust the system's retrieval strategy and processing flow, thereby improving the system's ability to respond to user needs and ensuring the accuracy and personalization of information output. This approach can enhance the system's adaptability, effectively improve the efficiency and relevance of information processing, and provide more precise assistance for decision support in complex environments.
[0082] Please continue reading Figure 5 , Figure 5 FIG. 1 is a flowchart of a document retrieval method shown in another exemplary embodiment of the present application. Figure 2 Based on the embodiment shown, it further includes S510-S520, which are described in detail as follows:
[0083] S510: present the target document to the user as an answer corresponding to the query statement, and obtain corresponding user feedback information and resource feedback information.
[0084] This embodiment further presents the target document matching the query statement to the user as the answer corresponding to the query statement, so that the user can provide corresponding feedback on the target document. For example, the target document will be displayed in the form of a list on the interface of the user terminal, and the user can trigger the selection of the corresponding document on this interface, and this selection operation can be used as a form of user feedback. For another example, the interface of the user terminal is also provided with an area for collecting user evaluations on the target document. By detecting the input information in this area, the corresponding user feedback information can be obtained, and the specific method of obtaining the user feedback information is not limited here. It can be seen that the user feedback information can reflect to a certain extent whether the target document is recognized by the user as the answer corresponding to the query statement, thereby reflecting the correctness of the retrieval result.
[0085] The resource feedback information is used to reflect the resource consumption of the target document during the retrieval and / or answering process. The types of resources consumed may be, for example, CPU (Central Processing Unit), memory and other resources, which are not limited here.
[0086] Therefore, this embodiment evaluates the environmental feedback parameters based on the correctness of the retrieval results and the resource consumption, and adjusts the network parameters of the policy network and the high-level semantic execution network based on the environmental feedback parameters, so that the overall system can adapt to the ever-changing user needs and information environment to meet the growing information retrieval and processing needs.
[0087] S520, calculating environment feedback parameters according to the user feedback information and the resource feedback information, and adjusting network parameters of the policy network and the high-level semantic execution network based on the environment feedback parameters.
[0088] This embodiment uses a reward function to calculate environmental feedback parameters. A complex reward function allows the system to continuously self-learn and adapt to improve decision-making efficiency and retrieval accuracy. The reward function not only considers the correctness of the answer, but also evaluates the resource consumption of the retrieval and answering process to ensure that the system maintains cost-effectiveness while meeting high performance.
[0089] For example, the reward function can integrate multiple evaluation levels to ensure accurate measurement of various operation dynamics. For example, the reward function can be expressed as follows:
[0090]
[0091] Where R(s,a) represents the reward function calculated based on the action a taken by the current state s of the system to obtain the environmental feedback parameter, γ represents the impact of adjusting future rewards on the current value, α and β are coefficients used to balance the accuracy of the answer and the cost of the operation. The accuracy of the answer is calculated by To evaluate, y represents the true value, represents the predicted value, and the operation cost is evaluated by (∫Cost(a,r)dr), which represents the resource consumption of action a, and r represents the resource type. Similarly, the current state of the system s and the action a taken also refer to the document retrieval operation currently being performed.
[0092] It should also be noted that the resource consumption of action a is expressed in the form of integral, which increases the calculation depth of the reward function and helps the reward function obtain a more accurate reward value.
[0093] Figure 6 A schematic diagram of an exemplary document retrieval process is shown. Figure 6 As shown in the figure, after the user inputs a query statement, the query statement is first preprocessed to convert the query statement into a query vector, and then the query vector is input into the policy network to obtain the retrieval strategy output by the policy network. When the retrieval strategy indicates to continue to perform deep information retrieval, the target document matching the query statement is retrieved through the high-level semantic execution network. At the same time, the parameters of the policy network and the high-level semantic execution network are adjusted based on the reinforcement learning adjustment mechanism.
[0094] It should be noted that the policy network uses a special policy-oriented semantic analysis architecture, combined with a composite adaptive sequence processing layer, to provide power for deep semantic decoding and core information extraction. It implements advanced semantic preprocessing for initial user input, including complex semantic segmentation and standardization, and dynamically adjusts the strategy through layer-by-layer deepening of information processing logic to optimize the retrieval and answering process, ensuring high accuracy of the output.
[0095] The advanced semantic execution network responds to refined policy-oriented instructions and uses integrated hybrid inverted indexing and advanced semantic mapping technology to quickly and accurately locate key documents. It not only performs basic keyword matching, but also uses deep semantic structure optimization technology to enhance all-round information relevance, significantly improving retrieval accuracy and information relevance.
[0096] The reinforcement learning optimization mechanism adjusts the operating parameters of the policy network and data retrieval module in real time by analyzing environmental feedback. This mechanism continuously improves the system's processing efficiency for complex data streams and the accuracy of the decision-making process through optimization algorithms, ensuring that the system can continue to adapt to dynamically changing user needs and changing information environments, thereby promoting an all-round improvement in capabilities from basic data extraction to advanced problem solving. The implementation of this framework significantly enhances the system's response accuracy and operational efficiency when dealing with highly complex queries.
[0097] Through the collaborative work of these network modules, it is possible to analyze user queries and external environment feedback in real time, adaptively adjust retrieval strategies, and achieve efficient and accurate information acquisition. It effectively improves the processing of open domain question and answer and knowledge-intensive tasks in complex information environments, significantly improves the response speed and output quality of the retrieval system, and provides users with more efficient and personalized information services.
[0098] Please continue reading Figure 7 , Figure 7 is a block diagram of a document retrieval device shown in another exemplary embodiment of the present application. The device can be applied to Figure 1 The implementation environment shown, for example, can be configured on the server 120, can also be configured on the terminal 110, or can be configured on both the terminal 110 and the server 120. Of course, the method can also be applied to other implementation environments, and can be configured on a terminal or server in other implementation environments, or can be configured on a terminal and a server in other implementation environments, and this embodiment is not limited thereto.
[0099] like Figure 7 As shown, in an exemplary embodiment, the document retrieval device includes:
[0100] A preprocessing module 710, configured to convert a query statement for indicating a retrieved document into a query vector;
[0101] A decision module 720 is configured to input the query vector into the policy network to obtain a search strategy output by the policy network, wherein the search strategy includes the query keyword vector;
[0102] The retrieval module 730 is configured to directly generate an answer corresponding to the query statement if the detection strategy indicates to directly generate an answer for the query statement; if the retrieval strategy indicates to continue to perform deep information retrieval, the query keyword vector is input into the high-level semantic execution network to obtain a target document output by the high-level semantic execution network that matches the query statement.
[0103] In another exemplary embodiment, the policy network includes a multi-head self-attention network layer, an information filtering network layer and a decision network layer, and the decision network layer is composed of a plurality of nonlinear transformation layers and activation layers connected; the decision module 720 is further configured to perform the following steps:
[0104] Capture fine-grained dependencies in query sentences based on query vectors through a multi-head self-attention network layer;
[0105] The query keyword vector corresponding to the query statement is extracted based on the fine-grained dependency relationship through the information filtering network layer;
[0106] Generate a retrieval strategy based on the query keyword vector through the decision network layer.
[0107] In another exemplary embodiment, the decision module 720 generates a search strategy by the following formula:
[0108] π θ (a|s)=σ(LN(W2·ReLU(W1·h(s)+b1)+b2))
[0109] Among them, π θ (a|s) represents the probability of taking action a in the current system state s, θ represents the set of network parameters (such as W1, W2, b1, b2), σ represents the sigmoid function, LN represents the layer normalization operation, W1 and W2 represent the weight matrix of the network layer, b1 and b2 represent the offset vector of the network layer, ReLU represents the linear rectification function, and h(s) represents the high-dimensional representation of state s in the network.
[0110] In another exemplary embodiment, the retrieval module 730 is further configured to perform the following steps:
[0111] Search for candidate documents that contain the query keyword vector;
[0112] Convert the query keyword vector into a retrieval semantic vector, and convert the document vector of the candidate document into a document semantic vector;
[0113] Based on the retrieval semantic vector and the document semantic vector, the matching degree between the query statement and the candidate document is determined, so as to determine the target document matching the query statement based on the matching degree.
[0114] In another exemplary embodiment, the retrieval module 730 obtains the matching degree between the query statement and the candidate document through the following steps:
[0115]
[0116] Rel(d,q) represents the matching degree between the query statement used to indicate the retrieval document and the document, q represents the query keyword vector, N represents the number of query keyword vectors, and q i represents the i-th query keyword vector, w i represents the weight of the i-th query keyword vector, vec(q i ) represents the retrieval semantic vector obtained by converting the i-th query keyword vector, d represents the document vector, M represents the number of document vectors, d j represents the j-th document vector, vec(d j ) represents the document semantic vector obtained by converting the j-th document vector, |·| 2 Represents calculating the square of the Euclidean distance between vectors.
[0117] In another exemplary embodiment, the document retrieval device further includes an environment feedback module, and the environment feedback module is configured to perform the following steps:
[0118] Display the target document to the user as the answer to the query statement, and obtain corresponding user feedback information and resource feedback information;
[0119] Environmental feedback parameters are calculated according to user feedback information and resource feedback information, and network parameters of the policy network and the high-level semantic execution network are adjusted based on the environmental feedback parameters.
[0120] In another exemplary embodiment, the environment feedback module obtains the environment feedback parameter by the following formula:
[0121]
[0122] Among them, R(s,a) represents the reward function calculated based on the current state s of the system and the action a taken to obtain the environmental feedback parameter, γ represents the impact of adjusting future rewards on the current value, α and β are coefficients used to balance the accuracy of the answer and the cost of the operation. The accuracy of the answer is calculated by To evaluate, y represents the true value, represents the predicted value, the operation cost is evaluated by (∫Cost(a,r)dr), which represents the resource consumption of action a, and r represents the resource type.
[0123] It should be noted that the document retrieval device provided in the above embodiment and the document retrieval method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment, and will not be repeated here. In actual application, the device provided in the above embodiment can distribute the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.
[0124] The above-mentioned document retrieval device can analyze user queries and external environment feedback in real time, adaptively adjust the retrieval strategy, realize efficient and accurate information acquisition, effectively improve the processing effect of open domain question answering and knowledge-intensive tasks in complex information environments, significantly improve the response speed and output quality of the retrieval system, and provide users with more efficient and personalized information services.
[0125] An embodiment of the present application also provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the electronic device implements the document retrieval method provided in the above-mentioned embodiments.
[0126] Figure 8 The structure diagram of the computer system suitable for implementing the electronic device of the embodiment of the present application is shown. It should be noted that: Figure 8 The computer system 800 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0127] like Figure 8 As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 802 or the program loaded from the storage part 808 to the random access memory (RAM) 803, such as executing the method described in the above embodiment. In the RAM 803, various programs and data required for system operation are also stored. The CPU 801, ROM 802 and RAM 803 are connected to each other through a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0128] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed so that a computer program read therefrom is installed into the storage section 808 as needed.
[0129] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 809, and / or installed from a removable medium 811. When the computer program is executed by a central processing unit (CPU) 801, various functions defined in the system of the present application are executed.
[0130] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal can take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. A computer program contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0131] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0132] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0133] Another aspect of the present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the method described above is implemented. The computer-readable storage medium may be included in the electronic device described in the above embodiment, or may exist independently without being assembled into the electronic device.
[0134] Another aspect of the present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the method provided in each of the above embodiments.
[0135] The above content is only a preferred exemplary embodiment of the present application and is not intended to limit the implementation scheme of the present application. A person skilled in the art can easily make corresponding changes or modifications based on the main concept and spirit of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection required by the claims.
Claims
1. A document retrieval method, characterized in that: The method comprises: Converting a query sentence for indicating a retrieved document into a query vector; Inputting the query vector into a policy network to obtain a search strategy output by the policy network, wherein the search strategy includes a query keyword vector; If the detection strategy indicates to directly generate an answer for the query statement, then directly generate an answer corresponding to the query statement; If the retrieval strategy indicates to continue to perform deep information retrieval, the query keyword vector is input into the high-level semantic execution network to obtain a target document output by the high-level semantic execution network that matches the query statement.
2. The method according to claim 1, characterized in that The strategy network includes a multi-head self-attention network layer, an information filtering network layer and a decision network layer, wherein the decision network layer is composed of a plurality of nonlinear transformation layers and an activation layer connected together; the strategy network performs the following steps to obtain the retrieval strategy: Capturing fine-grained dependencies in the query sentence based on the query vector through the multi-head self-attention network layer; Extracting a query keyword vector corresponding to the query statement based on the fine-grained dependency relationship through the information filtering network layer; The retrieval strategy is generated based on the query keyword vector through the decision network layer.
3. The method according to claim 1, characterized in that: The process of the decision network layer generating the retrieval strategy based on the query keyword vector is expressed as the following formula: π θ (a|s)=σ(LN(W2·ReLU(W1·h(s)+b1)+b2)) Among them, π θ (a|s) represents the probability of taking action a in the current system state s, θ represents the set of network parameters (such as W1, W2, b1, b2), σ represents the sigmoid function, LN represents the layer normalization operation, W1 and W2 represent the weight matrix of the network layer, b1 and b2 represent the offset vector of the network layer, ReLU represents the linear rectification function, and h(s) represents the high-dimensional representation of state s in the network.
4. The method according to claim 1, characterized in that: The high-level semantic execution network performs the following steps to obtain a target document matching the query statement: Searching for candidate documents containing the query keyword vector; Converting the query keyword vector into a retrieval semantic vector, and converting the document vector of the candidate document into a document semantic vector; Based on the retrieval semantic vector and the document semantic vector, the matching degree between the query statement and the candidate document is determined, so as to determine the target document matching the query statement based on the matching degree.
5. The method according to claim 4, characterized in that The matching degree between the query statement and the candidate document is calculated by the following formula: Rel(d,q) represents the matching degree between the query statement used to indicate the retrieval document and the document, q represents the query keyword vector, N represents the number of query keyword vectors, and q i represents the i-th query keyword vector, w i represents the weight of the i-th query keyword vector, vec(q i ) represents the retrieval semantic vector obtained by converting the i-th query keyword vector, d represents the document vector, M represents the number of document vectors, d j represents the j-th document vector, vec(d j ) represents the document semantic vector obtained by converting the j-th document vector, |·| 2 Represents calculating the square of the Euclidean distance between vectors.
6. The method according to claim 1, characterized in that The method further comprises: The target document is presented to the user as an answer corresponding to the query statement, and corresponding user feedback information and resource feedback information are obtained; An environmental feedback parameter is calculated according to the user feedback information and the resource feedback information, and network parameters of the policy network and the high-level semantic execution network are adjusted based on the environmental feedback parameter.
7. The method according to claim 6, characterized in that The environmental feedback parameter is calculated using the following formula: Where R(s,a) represents the reward function calculated based on the current state s of the system and the action a taken to obtain the environmental feedback parameter, γ represents the impact of adjusting future rewards on the current value, α and β are coefficients used to balance the accuracy of the answer and the cost of the operation. The accuracy of the answer is calculated by To evaluate, y represents the true value, represents the predicted value, the operation cost is evaluated by (∫Cost(a,r)dr), which represents the resource consumption of action a, and r represents the resource type.
8. A document retrieval device, characterized in that: The device comprises: A preprocessing module configured to convert a query sentence for indicating a retrieved document into a query vector; A decision module, configured to input the query vector into a policy network to obtain a search strategy output by the policy network, wherein the search strategy includes a query keyword vector; The retrieval module is configured to directly generate an answer corresponding to the query statement if the detection strategy indicates to directly generate an answer for the query statement; if the retrieval strategy indicates to continue to perform deep information retrieval, input the query keyword vector into the high-level semantic execution network to obtain a target document output by the high-level semantic execution network that matches the query statement.
9. An electronic device, characterized in that: include: one or more processors; A storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, enables the electronic device to implement the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Computer-readable instructions are stored thereon, and when the computer-readable instructions are executed by a processor of a computer, the computer is caused to execute the method according to any one of claims 1 to 7.
Citation Information
Cited By
Method and device for adjusting query system, electronic equipment, medium and product
CN120296036A
Server retrieval result generation method and device, computer equipment and medium
CN120541277A
Method and device for obtaining law article, computer readable medium and electronic equipment
CN122262190A