Text rewriting method, model training method, query method and related devices
By constructing a word relationship diagram between query statements and document collections in search engines, and coding query statements using attention mechanisms, the search recall problems caused by user knowledge background and language differences are solved, and the user experience and recall accuracy are improved.
Patent Information
- Application Number
- CN202311102598.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-30
- Publication Date
- 2025-03-04
AI Technical Summary
In search engines, due to different knowledge backgrounds and language expression habits of different users, there are differences in the description of the same content, which makes it difficult to improve the completeness and accuracy of document recalls.
By constructing a word relationship diagram between the original query statement and the recall document collection, the two are tied in the same semantic space, and the attention mechanism is used to encode the original query statement, integrating the expression of the effective document, and finally obtaining the rewritten query statement through decoding.
Rewriting query statements is more in line with the essential purpose of rewriting query statements, improving the user experience in search and recommendation scenarios, and improving the integrity and accuracy of document recalls.
Smart Images

Figure CN119558282A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a text rewriting method, a model training method, a query method and related devices. Background Art
[0002] Users use query statements (queries) on search engines to search for desired documents (doc), such as searching for user-generated content on social platforms. However, due to the knowledge background and language expression habits of different users, the same content often has completely different descriptions, making it difficult to achieve ideal results in terms of the completeness and accuracy of document recall. Therefore, a query statement rewriting technology is needed to improve the user experience in search and recommendation scenarios. Summary of the invention
[0003] In order to solve the above problems, the present application provides a text rewriting method, a model training method, a query method and related devices.
[0004] The first aspect of the present application discloses a text rewriting method for an electronic device, the method comprising:
[0005] Get the original text;
[0006] Based on the original text, a document collection is obtained;
[0007] Performing text encoding on the original text to obtain a text encoding result of the original text;
[0008] Based on the word relationship graph between the original text and the document set, graph encoding is performed on the original text to obtain a graph encoding result of the original text;
[0009] The text encoding result and the image encoding result of the original text are decoded to obtain a rewritten text.
[0010] Optionally, the original text and all documents in the document collection are respectively segmented to obtain a first word set from the original text and a second word set from all documents in the document collection, wherein in the word relationship graph between the original text and the document collection, the first word set serves as a first node set, the second word set serves as a second node set, and each first node in the first node set includes one or more adjacent second nodes.
[0011] Optionally, based on the word relationship graph between the original text and the document set, graph encoding is performed on the original text to obtain a graph encoding result of the original text, including:
[0012] For any first node in the first node set, determine one or more adjacent second nodes of the first node;
[0013] Based on the word vector of the first word corresponding to the first node and the word vector of the second word corresponding to each adjacent second node, the first node is encoded using an attention mechanism to obtain a node vector of the first node, wherein the node vectors of all first nodes in the first node set are used as the graph encoding result of the original text.
[0014] Optionally, performing text encoding on the original text to obtain a text encoding result of the original text includes:
[0015] The original text is taken as an input sequence, and a neural network is used to encode the input sequence to obtain an output sequence, wherein the output sequence serves as the text encoding result of the original text.
[0016] Optionally, decoding the text encoding result and the image encoding result of the original text to obtain the rewritten text includes:
[0017] Adopting an attention mechanism to decode the text encoding result and the graph encoding result of the original text respectively, to obtain a context vector based on text encoding and a context vector based on graph encoding;
[0018] Concatenating the text-encoded context vector and the graph-encoded context vector to obtain a concatenated context vector;
[0019] Based on the concatenated context vector, the rewritten text is obtained.
[0020] Optionally, the original text includes an original query statement, and the document collection is recalled by querying with the original query statement, wherein the document collection includes a valid document subset, and for any first node in the first node set, one or more second words corresponding to one or more adjacent second nodes of the first node are all from the valid document subset.
[0021] A second aspect of the present application discloses a training method for a text rewriting model, which is used in an electronic device, and the method comprises:
[0022] Acquire training data, wherein the training data includes original text and a document set obtained based on the original text;
[0023] The text rewriting model performs text encoding on the original text to obtain a text encoding result of the original text;
[0024] The text rewriting model performs graph encoding on the original text based on a word relationship graph between the original text and the document set to obtain a graph encoding result of the original text;
[0025] The text rewriting model decodes the text encoding result and the image encoding result of the original text to obtain a rewritten text;
[0026] Based on the rewritten text, a loss function is used to update the model parameters of the text rewriting model.
[0027] The third aspect of the present application discloses a query method based on text rewriting, which is used in an electronic device. The method includes:
[0028] Receiving an original query statement as raw text;
[0029] Using the original text as input of a text rewriting model and outputting a rewritten text;
[0030] Recalling a document collection by querying the rewritten text,
[0031] Wherein, the text rewriting model is trained according to the method described in the second aspect of the present application.
[0032] A fourth aspect of the present application discloses a text rewriting device, the device comprising:
[0033] An acquisition module, configured to acquire original text;
[0034] The acquisition module is further configured to obtain a document set based on the original text;
[0035] A text encoding module is configured to perform text encoding on the original text to obtain a text encoding result of the original text;
[0036] A graph encoding module is configured to perform graph encoding on the original text based on a word relationship graph between the original text and the document set to obtain a graph encoding result of the original text;
[0037] The decoding module is configured to decode the text encoding result and the image encoding result of the original text to obtain a rewritten text.
[0038] A fifth aspect of the present application discloses a training device for a text rewriting model, the device comprising:
[0039] An acquisition module is configured to acquire training data, wherein the training data includes an original text and a document set obtained based on the original text;
[0040] A text encoding module, configured to perform text encoding on the original text by the text rewriting model to obtain a text encoding result of the original text;
[0041] A graph encoding module is configured to perform graph encoding on the original text based on a word relationship graph between the original text and the document set by the text rewriting model to obtain a graph encoding result of the original text;
[0042] A decoding module, configured to decode the text encoding result and the image encoding result of the original text by the text rewriting model to obtain a rewritten text;
[0043] The training module is configured to update the model parameters of the text rewriting model using a loss function based on the rewritten text.
[0044] A sixth aspect of the present application discloses a query device based on text rewriting, the device comprising:
[0045] A receiving module is configured to receive an original query sentence as original text;
[0046] A rewriting module, configured to take the original text as an input of a text rewriting model and output a rewritten text;
[0047] A query module is configured to use the rewritten text to perform a query and recall a document collection,
[0048] Wherein, the text rewriting model is trained according to the method described in the second aspect of the present application.
[0049] The seventh aspect of the present application discloses an electronic device, which includes a memory and a processor storing computer-executable instructions; when the computer-executable instructions are executed by the processor, the electronic device implements the method according to the first aspect of the present application, or implements the method according to the second aspect of the present application, or implements the method according to the third aspect of the present application.
[0050] The eighth aspect of the present application discloses a computer-readable medium, which stores one or more programs, and the one or more programs can be executed by one or more processors to implement the method according to the first aspect of the present application, or the method according to the second aspect of the present application, or the method according to the third aspect of the present application.
[0051] The ninth aspect of the present application discloses a computer program product, including a computer program, which, when executed by a processor, implements the method according to the first aspect of the present application, or implements the method according to the second aspect of the present application, or implements the method according to the third aspect of the present application.
[0052] According to the text rewriting method and the training method of the text rewriting model of the present application, a word relationship graph is constructed between the original query statement and the recalled document set, which can closely link the two together and bring them into the same semantic space; the original query statement is encoded based on the attention mechanism of the graph, and a representation based on the document of interest is obtained for each word in the original query statement, thereby integrating the expression of the valid document into the original query statement; the rewritten query statement obtained by decoding based on the attention mechanism is more in line with the essential purpose of query statement rewriting, and improves the user experience in search and recommendation scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the technical solution of the present application, the following is a brief introduction to the drawings required for use in the embodiments or prior art descriptions. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0054] Figure 1 is a flowchart of a text rewriting method 100 according to an embodiment of the present application;
[0055] Figure 2 is a flowchart of a training method 200 for a text rewriting model according to an embodiment of the present application;
[0056] Figure 3 is a flowchart of a query method 300 based on text rewriting according to an embodiment of the present application;
[0057] Figure 4 is a schematic diagram of a text rewriting device 400 according to an embodiment of the present application;
[0058] Figure 5 is a schematic diagram of a training device 500 for a text rewriting model according to an embodiment of the present application;
[0059] Figure 6 is a schematic diagram of a query device 600 based on text rewriting according to an embodiment of the present application;
[0060] Figure 7 It is a schematic diagram of the structure of an electronic device 700 according to an embodiment of the present application. DETAILED DESCRIPTION
[0061] The present application is further described below in conjunction with specific embodiments and accompanying drawings. It is to be understood that the specific embodiments described herein are only for the purpose of explaining the present application, rather than limiting the present application. In addition, for ease of description, only some, but not all, structures or processes related to the present application are shown in the accompanying drawings.
[0062] The following specific embodiments illustrate the implementation of the present application, and those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. Although the description of the present application will be introduced in conjunction with the preferred embodiment, this does not mean that the features of this invention are limited to this implementation. On the contrary, the purpose of introducing the invention in conjunction with the implementation is to cover other options or modifications that may extend based on the claims of the present application. In order to provide a deep understanding of the present application, the following description will include many specific details. The present application can also be implemented without using these details. In addition, in order to avoid confusion or blurring the focus of the present application, some specific details will be omitted in the description. It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.
[0063] Furthermore, various operations will be described as multiple discrete operations in a manner that is most helpful for understanding the illustrative embodiments; however, the order of description should not be construed as implying that these operations are necessarily order dependent. In particular, these operations do not need to be performed in the order presented.
[0064] First, the usage scenario of this application is described.
[0065] Users use query statements (queries) on search engines to search for desired documents (doc), such as searching for user-generated content on social platforms. However, due to the knowledge background and language expression habits of different users, the same content often has completely different descriptions, making it difficult to achieve ideal results in terms of the completeness and accuracy of document recall. Therefore, a query statement rewriting technology is needed to improve the user experience in search and recommendation scenarios.
[0066] As an example, a deep learning model can be used to rewrite query statements. This model is a text rewriting model based on a sequence-to-sequence framework. First, the original query statement-rewritten query statement is mined as training data, the original query statement is modeled on the encoder side, and the rewritten query statement is modeled on the decoder side. The model parameters of the model are updated using a loss function. However, the text rewriting model trained by this training method only learns the mapping relationship between the original query statement and the rewritten query statement, which is not completely consistent with the essential purpose of query statement rewriting. The essential purpose of query statement rewriting is to change the user's query statement into a relevant description in the document. Therefore, the above example does not introduce document information, but simply maps between two short sentences, and cannot directly align the difference between the query statement and the document.
[0067] Based on the above reasons, this application designs a text rewriting method and a text rewriting model training method, which aligns the original query statement and the recalled document set in the same semantic space, and integrates the expression of valid documents into the original query statement, which is more in line with the essential purpose of query statement rewriting and improves the user experience in search and recommendation scenarios.
[0068] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.
[0069] Figure 1 It is a flowchart of a text rewriting method 100 according to an embodiment of the present application.
[0070] like Figure 1 As shown, in S101, the original text is obtained.
[0071] As an example, in the usage scenario described above, the original text may include an original query sentence, wherein the original query sentence refers to the original words input by the user during the search, such as brand A lipstick, etc.
[0072] In S102, a document set is obtained based on the original text.
[0073] Continuing with the above example, a document collection may be retrieved by querying the original query statement, and multiple documents in the document collection may be pushed to the user for viewing.
[0074] Optionally, each document may include a document title and / or document content, wherein the document title refers to the title of the document retrieved based on the query statement and displayed to the user, and the document content refers to the body of the document, and wherein the body may include text from text content or text from image content via optical character recognition (OCR).
[0075] Since the essential purpose of query rewriting is to change the user's query into a relevant description in the document, the present application takes into account the document set recalled based on the original query when rewriting the original query, so as to align the differences between the query and the document.
[0076] Optionally, the document collection may include a valid document subset, wherein the valid document subset refers to documents that the user is interested in, for example, corresponding documents that the user stays on for a long time during browsing of recalled documents, corresponding documents that the user clicks to view, corresponding documents that the user chooses to view later, and corresponding documents that the user likes, comments on, and / or collects, etc. It is understandable that the number of all valid documents in the valid document subset may be less than or equal to the number of all documents in the document collection.
[0077] In S103, text encoding is performed on the original text to obtain a text encoding result of the original text.
[0078] Optionally, the original text may be used as an input sequence, and a neural network may be used to encode the input sequence to obtain an output sequence, wherein the output sequence is the text encoding result of the original text.
[0079] As an example, the neural network can be various neural networks based on a sequence-to-sequence framework, including but not limited to convolutional neural networks (CNN), recurrent neural networks (RNN), bidirectional recurrent neural networks (BiRNN), gated recurrent units (GRU), and long short-term memory (LSTM).
[0080] For example, when the neural network is an RNN, the hidden layer state at the current moment is determined by the hidden layer state at the previous moment and the input at the current moment. After obtaining the hidden layer state at each moment, all hidden layer states are summarized to generate the final semantic vector, or simply the final hidden layer state is used as the semantic vector, which is the text encoding result of the output sequence or the original text.
[0081] In S104, based on the word relationship graph between the original text and the document set, graph encoding is performed on the original text to obtain a graph encoding result of the original text.
[0082] A graph is a mathematical structure that includes nodes and edges. A node is an abstraction of an "object". For example, in this application, a word is a node. Different words can constitute different nodes, and each node can be represented by a multidimensional vector. An edge is an abstraction of a "relationship". For example, in this application, if there is a certain relationship between two words (such as a co-occurrence relationship), there is an edge between the two nodes corresponding to the two words, and the two nodes can also constitute each other's adjacent nodes. Furthermore, for example, in this application, if two words come from the original text and the valid document respectively, there is an edge between the two nodes corresponding to the two words, and the two nodes can also constitute each other's adjacent nodes.
[0083] First, the original text and all documents in the document collection can be word-separated respectively to obtain a first word set from the original text and a second word set from all documents in the document collection, wherein, in the word relationship graph between the original text and the document collection, the first word set serves as a first node set, the second word set serves as a second node set, and each first node in the first node set includes one or more adjacent second nodes, and wherein, for any first node in the first node set, one or more second words corresponding to one or more adjacent second nodes of the first node are from a valid document subset.
[0084] As an example, the original text is "B's latest movie". After being segmented, the first word set from the original text may include the first word "B", the first word "latest" and the first word "movie", and correspond to the three first nodes in the word relationship graph between the original text and the document set.
[0085] One of the valid documents in the valid document subset is "C's latest movie was released on * day, this movie..." After being segmented, the second word set from the valid document may include the second word "C", the second word "latest", the second word "movie", the second word "released" and the second word "this movie", and corresponds to five second nodes in the word relationship graph between the original text and the document set.
[0086] Considering that the second word sets are all from valid documents, as described above, there can be an edge between each first node and all five second nodes. Further, for any first node in the first node set, the one or more second words corresponding to one or more adjacent second nodes of the first node are all from the valid document subset. Further, for any first node in the first node set, the one or more second words corresponding to one or more adjacent second nodes of the first node are all second words from the second word sets of all valid documents in the valid document subset.
[0087] Thus, for any first node in the first node set, one or more adjacent second nodes of the first node can be determined. Based on the word vector of the first word corresponding to the first node and the word vector of the second word corresponding to each adjacent second node, the first node can be encoded using an attention mechanism to obtain a node vector of the first node, wherein the node vectors of all first nodes in the first node set are used as the graph encoding result of the original text.
[0088] Continuing with the above example, the original text and the recalled document set can be aligned in the same semantic space, and the expressions of the valid documents can be integrated into the original text. In fact, the second word "C" from the valid document is a semantically related word of the first word "B" from the original text. By integrating the expression of the second word "C" into the first word "B", it helps the text rewriting model learn the mapping relationship between the two, so that the first word "B" can be rewritten as the second word "C" in the subsequent rewriting, thereby improving the completeness and accuracy of document recall.
[0089] As an example, for any first node i in the first node set, all adjacent second nodes j are determined, and the adjacent second nodes j are adjacent second node sets N j The nodes in the adjacent second node set N j A second set of words corresponding to all valid documents from the subset of valid documents.
[0090] Using the following formula 1 and formula 2, the node vector V of the first node i can be calculated: i .
[0091]
[0092] a ij =attention(v i ,v j ) Formula 2
[0093] Among them, v i is the word vector of the first word corresponding to the first node i, vj is the word vector of the second word corresponding to the adjacent second node j, a ij is the attention coefficient of the adjacent second node j to the first node i, and Wv is a weight matrix.
[0094] In S105, the text encoding result and the image encoding result of the original text are decoded to obtain a rewritten text.
[0095] First, the attention mechanism can be used to decode the text encoding result and the graph encoding result of the original text respectively, and obtain the context vector based on text encoding and the context vector based on graph encoding. Among them, the context vector refers to the word vector with the context weight assigned by the attention mechanism, indicating that there is a contextual relationship between the word vector and other word vectors.
[0096] Continuing with the above example, the decoding process at time t is used to illustrate the original text. The graph encoding result is the first node set N i The node vector V of all first nodes i in i .
[0097] Using the following formulas 3 and 4, the context vector c based on graph encoding can be calculated: g .
[0098]
[0099] a i =attention(h t ,V i ) Formula 4
[0100] Among them, h t is the output of decoding at time t, a i is the node vector V of the first node i i The attention coefficient of the decoded output at time t, and W G is a weight matrix.
[0101] Similarly, based on the output sequence encoded by the neural network on the encoder side, considering its attention coefficient on the output decoded at time t, the context vector c based on the text encoding can be calculated s .
[0102] In this way, the context vector c based on text encoding can be s and the graph-encoded context vector c g Concatenate and use the following formula 5 to get the concatenated context vector c t .
[0103] ct =[c s ||c g ] Formula 5
[0104] And, based on the concatenated context vector c t , and use the formula 6 listed below to get a word in the rewritten text, and recursively repeat the process to get the rewritten text.
[0105] p=σ(W[h t ||c t ]+b) Formula 6
[0106] Where p is the probability of the output word, W is a weight matrix, and b is an updateable parameter.
[0107] Figure 2 It is a flowchart of a training method 200 for a text rewriting model according to an embodiment of the present application.
[0108] like Figure 2 As shown, in S201, training data is obtained, and the training data includes original text and a document set obtained based on the original text.
[0109] In S202, the text rewriting model performs text encoding on the original text to obtain a text encoding result of the original text.
[0110] In S203, the text rewriting model performs graph encoding on the original text based on the word relationship graph between the original text and the document set to obtain a graph encoding result of the original text.
[0111] In S204, the text rewriting model decodes the text encoding result and the image encoding result of the original text to obtain a rewritten text.
[0112] Understandably, Figure 2 Steps S201 to S204 and Figure 1 Steps S101 to S105 belong to the same inventive concept, and their specific implementation processes are detailed in the corresponding embodiments, which will not be repeated here.
[0113] In S205 , based on the rewritten text, a loss function is used to update the model parameters of the text rewriting model.
[0114] The training data also includes rewritten texts obtained through manual annotation or practice, and the rewritten texts obtained by the text rewriting model can be compared with the corresponding manually annotated rewritten texts or practice rewritten texts, and the model parameters of the text rewriting model can be updated by minimizing the loss function. Specifically, through iterative training, the model training is stopped when the result of the loss function is less than or equal to the loss threshold, or when the number of iterations reaches the number threshold. As an example, the loss function includes but is not limited to the cross entropy loss function.
[0115] According to the text rewriting method and the training method of the text rewriting model of the present application, a word relationship graph is constructed between the original query statement and the recalled document set, which can closely link the two together and bring them into the same semantic space; the original query statement is encoded based on the attention mechanism of the graph, and a representation based on the document of interest is obtained for each word in the original query statement, thereby integrating the expression of the valid document into the original query statement; the rewritten query statement obtained by decoding based on the attention mechanism is more in line with the essential purpose of query statement rewriting, and improves the user experience in search and recommendation scenarios.
[0116] Figure 3 It is a flowchart of a query method 300 based on text rewriting according to an embodiment of the present application.
[0117] like Figure 3 As shown, in S301, an original query statement is received as original text.
[0118] In S302, the original text is used as input of the text rewriting model, and the rewritten text is output.
[0119] In S303, the rewritten text is used to perform a query and retrieve a document collection.
[0120] Among them, the text rewriting model is based on Figure 2 The method shown is trained.
[0121] Figure 4 4 is a schematic diagram of a text rewriting device 400 according to an embodiment of the present application.
[0122] like Figure 4 As shown, the text rewriting device 400 includes:
[0123] The acquisition module 401 is configured to acquire the original text;
[0124] The acquisition module 401 is further configured to obtain a document set based on the original text;
[0125] The text encoding module 402 is configured to perform text encoding on the original text to obtain a text encoding result of the original text;
[0126] A graph encoding module 403 is configured to perform graph encoding on the original text based on a word relationship graph between the original text and the document set to obtain a graph encoding result of the original text;
[0127] The decoding module 404 is configured to decode the text encoding result and the image encoding result of the original text to obtain the rewritten text.
[0128] Figure 4 Modules 401 to 404 may be used to perform Figure 1 The implementation principles and technical effects of steps S101 to S105 are similar and will not be repeated here.
[0129] Figure 5 is a schematic diagram of a training device 500 for a text rewriting model according to an embodiment of the present application.
[0130] like Figure 5 As shown, the training device 500 of the text rewriting model includes:
[0131] An acquisition module 501 is configured to acquire training data, where the training data includes an original text and a document set obtained based on the original text;
[0132] The text encoding module 502 is configured to perform text encoding on the original text by using the text rewriting model to obtain a text encoding result of the original text;
[0133] The graph encoding module 503 is configured to perform graph encoding on the original text based on the word relationship graph between the original text and the document set by the text rewriting model to obtain the graph encoding result of the original text;
[0134] The decoding module 504 is configured to decode the text encoding result and the image encoding result of the original text by the text rewriting model to obtain the rewritten text;
[0135] The training module 505 is configured to update the model parameters of the text rewriting model using a loss function based on the rewritten text.
[0136] Figure 5 Modules 501 to 505 may be used to perform Figure 2 The implementation principles and technical effects of steps S201 to S205 are similar and will not be repeated here.
[0137] Figure 6 is a schematic diagram of a query device 600 based on text rewriting according to an embodiment of the present application.
[0138] like Figure 6 As shown, the query device 600 based on text rewriting includes:
[0139] The receiving module 601 is configured to receive an original query sentence as an original text;
[0140] The rewriting module 602 is configured to take the original text as input of the text rewriting model and output the rewritten text;
[0141] The query module 603 is configured to retrieve a document set by querying the rewritten text.
[0142] Among them, the text rewriting model is based on Figure 2 The method shown is trained.
[0143] Figure 6 Modules 601 to 603 may be used to perform Figure 3 The implementation principle and technical effect of steps S301 to S303 are similar and will not be repeated here.
[0144] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software calling through processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software calling through processing elements, and some modules can be implemented in the form of hardware. The implementation of other modules is similar. In addition, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
[0145] Figure 7 It is a schematic diagram of the structure of an electronic device 700 according to an embodiment of the present application.
[0146] like Figure 7 As shown, the electronic device 700 may include one or more processors 702, a system control logic 708 connected to at least one of the processors 702, a system memory 704 connected to the system control logic 708, a non-volatile memory (NVM) 706 connected to the system control logic 708, and a communication interface 710 connected to the system control logic 708.
[0147] The processor 702 may include one or more single-core or multi-core processors. The processor 702 may include any combination of general-purpose processors and special-purpose processors (e.g., graphics processors, application processors, baseband processors, etc.). In the embodiments of the present invention, the processor 702 may be configured to execute the following operations: Figure 1 or Figure 2 or Figure 3 One or more of the various embodiments shown.
[0148] In some embodiments, system control logic 708 may include any suitable interface controller to provide any suitable interface to at least one of processors 702 and / or any suitable device or component in communication with system control logic 708 .
[0149] In some embodiments, the system control logic 708 may include one or more memory controllers to provide an interface to the system memory 704. The system memory 704 may be used to load and store data and / or instructions. In some embodiments, the memory 704 of the electronic device 700 may include any suitable volatile memory, such as a suitable dynamic random access memory (DRAM).
[0150] NVM / memory 706 may include one or more tangible, non-transitory computer-readable media for storing data and / or instructions. In some embodiments, NVM / memory 706 may include any suitable non-volatile memory such as flash memory and / or any suitable non-volatile storage device, such as at least one of a HDD (Hard Disk Drive), a CD (Compact Disc) drive, and a DVD (Digital Versatile Disc) drive.
[0151] NVM / storage 706 may include a portion of storage resources installed on a device of electronic device 700, or it may be accessible by the device but not necessarily a part of the device. For example, NVM / storage 706 may be accessed over a network via communication interface 710.
[0152] In particular, system memory 704 and NVM / storage 706 may include, respectively, a temporary copy and a permanent copy of instructions 720. Instructions 720 may include instructions that, when executed by at least one of processors 702, cause electronic device 700 to implement the following: Figure 1 or Figure 2 or Figure 3 In some embodiments, instructions 720, hardware, firmware and / or software components thereof may additionally / alternatively be placed in system control logic 708, communication interface 710 and / or processor 702.
[0153] The communication interface 710 may include a transceiver for providing a radio interface for the electronic device 700, thereby communicating with any other suitable device (such as a front-end module, an antenna, etc.) through one or more networks. In some embodiments, the communication interface 710 may be integrated with other components of the electronic device 700. For example, the communication interface 710 may be integrated with at least one of the processor 702, the system memory 704, the NVM / storage 706, and a firmware device (not shown) having instructions. When at least one of the processors 702 executes the instructions, the electronic device 700 implements Figure 1 or Figure 2 or Figure 3 The methods described in one or more of the various embodiments shown.
[0154] The communication interface 710 may further include any suitable hardware and / or firmware to provide a multiple-input multiple-output radio interface. For example, the communication interface 710 may be a network adapter, a wireless network adapter, a telephone modem and / or a wireless modem.
[0155] In one embodiment, at least one of the processors 702 may be packaged together with logic for one or more controllers of the system control logic 708 to form a system in package (SiP). In one embodiment, at least one of the processors 702 may be integrated on the same die with logic for one or more controllers of the system control logic 708 to form a system on a chip (SoC).
[0156] The electronic device 700 may further include an input / output (I / O) device 712. The I / O device 712 may include a user interface to enable a user to interact with the electronic device 700; the design of the peripheral component interface enables the peripheral components to interact with the electronic device 700. In some embodiments, the electronic device 700 further includes a sensor for determining at least one of an environmental condition and location information related to the electronic device 700.
[0157] In some embodiments, the user interface may include, but is not limited to, a display (e.g., an LCD display, a touch screen display, etc.), a speaker, a microphone, one or more cameras (e.g., a still image camera and / or a video camera), a flashlight (e.g., an LED flash), and a keyboard.
[0158] In some embodiments, the peripheral component interface may include, but is not limited to, a non-volatile memory port, an audio jack, and a power interface.
[0159] In some embodiments, the sensors may include, but are not limited to, gyroscope sensors, accelerometers, proximity sensors, ambient light sensors, and positioning units. The positioning unit may also be part of or interact with the communication interface 710 to communicate with components of a positioning network (e.g., global positioning system (GPS) satellites).
[0160] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 700. In other embodiments of the present application, the electronic device 700 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0161] Program code can be applied to input instructions to perform the functions described herein and generate output information. The output information can be applied to one or more output devices in a known manner. For purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.
[0162] Program code can be implemented with high-level programming language or object-oriented programming language to communicate with the processing system. When necessary, program code can also be implemented with assembly language or machine language. In fact, the mechanism described herein is not limited to the scope of any specific programming language. In either case, the language can be a compiled language or an interpreted language.
[0163] One or more aspects of at least one embodiment may be implemented by representative instructions stored on a computer-readable storage medium, which represent various logic in a processor, and when the instructions are read by a machine, cause the machine to fabricate logic for performing the techniques described herein. These representations, known as "IP cores," may be stored on a tangible computer-readable storage medium and supplied to multiple customers or manufacturing facilities to load into a manufacturing machine that actually manufactures the logic or processor.
[0164] An embodiment of the present application discloses a computer-readable medium, which stores one or more programs, and the one or more programs can be executed by one or more processors to implement Figure 1 or Figure 2 or Figure 3 method.
[0165] An embodiment of the present application discloses a computer program product, including a computer program, which is executed by a processor to implement Figure 1 or Figure 2 or Figure 3 method.
[0166] Unless the context dictates otherwise, the terms "comprising," "having," and "including" are synonymous. The phrase "A / B" means "A or B." The phrase "A and / or B" means "(A and B) or (A or B)."
[0167] As used herein, the term "module" or "unit" may refer to, be or include: an application specific integrated circuit (ASIC), an electronic circuit, a (shared, dedicated or group) processor and / or memory that executes one or more software or firmware programs, a combinational logic circuit and / or other suitable components that provide the described functionality.
[0168] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, instructions may be distributed over a network or by other computer-readable media. Therefore, machine-readable media may include any mechanism for storing or transmitting information in a machine (e.g., computer) readable form, but not limited to, floppy disks, optical disks, optical disks, read-only memories (CD-ROMs), magneto-optical disks, read-only memories (ROMs), random access memories (RAMs), erasable programmable read-only memories (EPROMs), electrically erasable programmable read-only memories (EEPROMs), magnetic or optical cards, flash memory, or a tangible machine-readable memory for transmitting information through the Internet via electrical, optical, acoustic, or other forms of propagation signals (e.g., carrier waves, infrared signals, digital signals, etc.). Therefore, machine-readable media include any type of machine-readable media suitable for storing or transmitting electronic instructions or information in a machine (e.g., computer) readable form.
[0169] In the accompanying drawings, some structural or method features are shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be required. In some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. In addition, the inclusion of structural or method features in a specific figure does not mean that such features are required in all embodiments, and in some embodiments, these features may not be included or may be combined with other features.
[0170] It should be understood that although the terms "first", "second", etc. may be used here to describe various units or data, these units or data should not be limited by these terms. These terms are used only to distinguish one feature from another. For example, without departing from the scope of the exemplary embodiment, a first feature may be referred to as a second feature, and similarly, a second feature may be referred to as a first feature.
[0171] It should be noted that in this specification, similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
Claims
1. A text rewriting method, used in electronic equipment, characterized in that: The method comprises: Get the original text; Based on the original text, a document collection is obtained; Performing text encoding on the original text to obtain a text encoding result of the original text; Based on the word relationship graph between the original text and the document set, graph encoding is performed on the original text to obtain a graph encoding result of the original text; The text encoding result and the image encoding result of the original text are decoded to obtain a rewritten text.
2. The method according to claim 1, characterized in that The original text and all documents in the document collection are respectively segmented to obtain a first word set from the original text and a second word set from all documents in the document collection, wherein in the word relationship graph between the original text and the document collection, the first word set serves as a first node set, the second word set serves as a second node set, and each first node in the first node set includes one or more adjacent second nodes.
3. The method according to claim 2, characterized in that Based on the word relationship graph between the original text and the document set, the original text is graph-encoded to obtain the graph encoding result of the original text, including: For any first node in the first node set, determine one or more adjacent second nodes of the first node; Based on the word vector of the first word corresponding to the first node and the word vector of the second word corresponding to each adjacent second node, the first node is encoded using an attention mechanism to obtain a node vector of the first node, wherein the node vectors of all first nodes in the first node set are used as the graph encoding result of the original text.
4. The method according to claim 1, characterized in that: The original text is encoded to obtain a text encoding result of the original text, including: The original text is taken as an input sequence, and a neural network is used to encode the input sequence to obtain an output sequence, wherein the output sequence serves as the text encoding result of the original text.
5. The method according to any one of claims 1 to 4, characterized in that Decoding the text encoding result and the image encoding result of the original text to obtain a rewritten text includes: Adopting an attention mechanism to decode the text encoding result and the graph encoding result of the original text respectively, to obtain a context vector based on text encoding and a context vector based on graph encoding; Concatenating the text-encoded context vector and the graph-encoded context vector to obtain a concatenated context vector; Based on the concatenated context vector, the rewritten text is obtained.
6. The method according to claim 2, characterized in that The original text includes an original query statement, and the document collection is recalled by querying with the original query statement, wherein the document collection includes a valid document subset, and for any first node in the first node set, one or more second words corresponding to one or more adjacent second nodes of the first node are all from the valid document subset.
7. A text rewriting model training method for electronic equipment, characterized in that: The method comprises: Acquire training data, wherein the training data includes original text and a document set obtained based on the original text; The text rewriting model performs text encoding on the original text to obtain a text encoding result of the original text; The text rewriting model performs graph encoding on the original text based on a word relationship graph between the original text and the document set to obtain a graph encoding result of the original text; The text rewriting model decodes the text encoding result and the image encoding result of the original text to obtain a rewritten text; Based on the rewritten text, a loss function is used to update the model parameters of the text rewriting model.
8. A query method based on text rewriting, used in electronic equipment, characterized in that: The method comprises: Receiving an original query statement as raw text; Using the original text as input of a text rewriting model and outputting a rewritten text; Recalling a document collection by querying the rewritten text, Wherein, the text rewriting model is trained according to the method according to claim 7.
9. A text rewriting device, characterized in that: The device comprises: An acquisition module, configured to acquire original text; The acquisition module is further configured to obtain a document set based on the original text; A text encoding module is configured to perform text encoding on the original text to obtain a text encoding result of the original text; A graph encoding module is configured to perform graph encoding on the original text based on a word relationship graph between the original text and the document set to obtain a graph encoding result of the original text; The decoding module is configured to decode the text encoding result and the image encoding result of the original text to obtain a rewritten text.
10. A training device for a text rewriting model, characterized in that: The device comprises: An acquisition module is configured to acquire training data, wherein the training data includes an original text and a document set obtained based on the original text; A text encoding module, configured to perform text encoding on the original text by the text rewriting model to obtain a text encoding result of the original text; A graph encoding module is configured to perform graph encoding on the original text based on a word relationship graph between the original text and the document set by the text rewriting model to obtain a graph encoding result of the original text; A decoding module, configured to decode the text encoding result and the image encoding result of the original text by the text rewriting model to obtain a rewritten text; The training module is configured to update the model parameters of the text rewriting model using a loss function based on the rewritten text.
11. A query device based on text rewriting, characterized in that: The device comprises: A receiving module is configured to receive an original query sentence as original text; A rewriting module, configured to take the original text as an input of a text rewriting model and output a rewritten text; A query module is configured to use the rewritten text to perform a query and recall a document collection, Wherein, the text rewriting model is trained according to the method according to claim 7.
12. An electronic device, characterized in that: The electronic device includes a memory storing computer-executable instructions and a processor; when the computer-executable instructions are executed by the processor, the electronic device implements the method according to any one of claims 1 to 6, or implements the method according to claim 7, or implements the method according to claim 8.
13. A computer readable medium, characterized in that The computer-readable medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the method according to any one of claims 1 to 6, or the method according to claim 7, or the method according to claim 8.
14. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented, or the method according to claim 7 is implemented, or the method according to claim 8 is implemented.
Citation Information
Cited By
Query method and electronic equipment
CN120705290A