Text generation method, device, electronic device and readable storage medium
By combining the user's pending query request and corresponding query conditions, the target material text with semantic matching is determined from the material text collection, and the problem of low accuracy in the production of material text in the prior art is solved, achieving higher accuracy and better answering effects.
Patent Information
- Application Number
- CN202411751676.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-04-01
AI Technical Summary
The prior art has low accuracy when generating the determined material text and cannot effectively deal with the query conditions in the query, resulting in low accuracy of recalled materials.
By obtaining the user's pending query request, the query conditions corresponding to the query request are determined, and the target material text is determined from the material text collection based on these query conditions and query requests. The target material text matches the query request semantics or feature words, and matches the query condition semantics.
The accuracy of the generated target material text is improved, thereby improving the accuracy of the reply text and enhancing the response effect of the query request to be identified with query conditions.
Smart Images

Figure CN119739845A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and more specifically, to a text generation method, device, electronic device and readable storage medium. Background Art
[0002] At present, with the development of electronic information technology, the material text matching the query request of the user can be determined by electronic equipment. However, the accuracy of the material text generated and determined at present is low. Summary of the invention
[0003] The present application proposes a text generation method, device, electronic device and readable storage medium to improve the above-mentioned defects.
[0004] In a first aspect, an embodiment of the present application provides a text generation method, comprising: obtaining a user's pending query request; determining a query condition corresponding to the pending query request; determining a target material text from a material text set based on the query condition and the pending query request, wherein the target material text has a semantic match or a feature word match with the pending query request, and the target material text has a semantic match with the query condition.
[0005] In the second aspect, an embodiment of the present application also provides a text generation device, including: an acquisition unit, a first determination unit and a second determination unit, the acquisition unit is used to acquire the user's pending query request; the first determination unit is used to determine the query conditions corresponding to the pending query request; the second determination unit is used to determine the target material text from the material text set based on the query conditions and the pending query request, wherein the target material text has a semantic match or a feature word match with the pending query request, and the target material text has a semantic match with the query condition.
[0006] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: one or more processors; a memory; and one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method described in the first aspect.
[0007] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a program code executable by a processor, and when the program code is executed by the processor, the processor executes the above method.
[0008] The text generation method, device, electronic device and readable storage medium provided by the present application first obtain the user's pending query request; then determine the query conditions corresponding to the pending query request; thereby determining the target material text from the material text set based on the query conditions and the pending query request. Among them, the target material text has a semantic match or a feature word match with the pending query request, and the target material text has a semantic match with the query condition. It can be seen that in the present application, the material text set is not recalled based solely on the semantics or feature words of the pending query request, but the material text set is recalled in combination with the query conditions corresponding to the pending query request, so that the obtained target material text has a higher accuracy.
[0009] Other features and advantages of the embodiments of the present application will be described in the subsequent description, and partly become apparent from the description, or can be understood by practicing the embodiments of the present application. The purposes and other advantages of the embodiments of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0011] Figure 1 A method flow chart of a text generation method provided by an embodiment of the present application is shown;
[0012] Figure 2 A method flow chart of a text generation method provided by another embodiment of the present application is shown;
[0013] Figure 3 A method flow chart of a text generation method provided by another embodiment of the present application is shown;
[0014] Figure 4 A method flow chart of a text generation method provided by another embodiment of the present application is shown;
[0015] Figure 5 A structural block diagram of a text generation device provided in an embodiment of the present application is shown;
[0016] Figure 6 A structural block diagram of an electronic device provided in an embodiment of the present application is shown;
[0017] Figure 7 A structural block diagram of a computer-readable storage medium provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0018] In order to make those skilled in the art better understand the present application scheme, the technical scheme in the present application embodiment will be clearly and completely described below in conjunction with the drawings in the present application embodiment. Obviously, the described embodiment is only a part of the present application embodiment, rather than all the embodiments. The components of the present application embodiment usually described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the present application for protection, but merely represents the selected embodiment of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0019] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0020] At present, with the development of electronic information technology, electronic equipment can be used to determine the material text that matches the user's query request to generate a reply text for replying the user's query request. However, the material text determined by the currently generated reply text has a low accuracy. How to improve the accuracy of the obtained reply text is a problem that needs to be solved urgently.
[0021] Currently, query requests can be matched based on semantic vectors to retrieve materials matching the query request from a material collection; query requests can also be matched based on keywords to retrieve materials matching the query request from a material collection, and then a reply text for the query request can be generated based on the retrieved materials.
[0022] However, the inventors found in their research that matching query requests based on semantic vectors or keywords cannot recall the query conditions in the query, resulting in low accuracy of the recalled materials.
[0023] Therefore, in order to overcome the above-mentioned defects, the present application provides a text generation method, device, electronic device and readable storage medium.
[0024] See also Figure 1 , Figure 1The text generation method provided by the embodiment of the present application is shown. The text generation method can be applied to an electronic device, and specifically, the processor of the electronic device can be used as the execution subject of the text generation method. The text generation method can include steps S110 to S140.
[0025] The text generation method provided in the embodiments of the present application can be applied to electronic devices. Exemplary electronic devices may be smart phones, smart tablet computers, laptop computers, wearable devices, servers, and the like.
[0026] Step S110: Obtain the user's pending query request.
[0027] The query request to be processed may include multiple characters, and the multiple characters may form different participles and further form a sentence. For example, the query request to be processed may be "What was the weather like yesterday?"
[0028] In some embodiments, a user may input a pending query request (query) through an electronic device, so that the electronic device may obtain the pending query request. Exemplarily, the electronic device may run a specified application, so that the user may input the pending query request on the display interface of the specified application of the electronic device, for example, inputting the pending query request through an input component of the electronic device. Specifically, for example, the input component may be a touch screen, so that the user may input the pending query request by clicking on the touch screen; for another example, the input component may be a microphone, so that the user may speak, the electronic device may collect the user's voice through the microphone, and then convert the language into user text, thereby obtaining the pending query request.
[0029] In addition, the electronic device may also establish a communication connection with other devices, so that the user may send a pending query request to the electronic device through other devices, so that the electronic device obtains the pending query request.
[0030] Step S120: Determine the query condition corresponding to the query request to be processed.
[0031] It is understandable that the pending query request may include query conditions, which can reduce the amount of subsequently recalled material texts, thereby obtaining more accurate recalled material texts to provide more accurate and high-quality response texts for the pending query request.
[0032] In the embodiments provided in the present application, the query request may include target time text, target location text or target object text, etc. Exemplarily, the target time text may include absolute time, such as x year x month x day; it may also include relative time, such as last week, last year; it may also include holidays, such as Mid-Autumn Festival, National Day, etc. The location condition may include the abbreviation, alias or nickname of the location, such as East China, Southwest, etc.; it may also include the full name of the location, such as Chengdu, Shenzhen, etc. The target object may include a target entity, such as a cow, a person, a flower, glasses, etc.
[0033] Therefore, after obtaining the pending query request, the query condition corresponding to the pending query request can be determined. As can be seen from the above introduction, the query condition can include different types, such as time type, location type and object type. For different types of query conditions, the query request can be obtained in a corresponding manner. For a detailed introduction, please refer to the subsequent embodiments. Among them, the user can specify the type of query condition, for example, by specifying the type of query condition by specifying an application.
[0034] Step S130: determining a target material text from a material text set based on the query condition and the query request to be processed, wherein the target material text has a semantic match or a feature word match with the query request to be processed, and the target material text has a semantic match with the query condition.
[0035] After obtaining the query conditions and pending query requests, the target material text can be recalled from the material text set. The material text set may include multiple material texts, and the material text may include text contents such as words, phrases, sentences, and paragraphs, and the text content is composed of characters. For example, the characters in a text document can be used as material text; for example, the title of a note corresponding to a document can also be used as material text.
[0036] The target material text has a semantic match or a feature word match with the query request to be processed, and the target material text has a semantic match with the query condition.
[0037] Thus, in some embodiments, at least one material text can be firstly recalled from a material text set based on semantic matching or feature word matching through a pending query request, and then a material text that semantically matches the query condition can be screened from at least one material text that has been recalled based on semantic matching to obtain a target material text. In other embodiments, at least one material text that semantically matches the query condition can be firstly recalled from a material text set based on semantic matching, and then a material text that semantically matches the query condition can be screened from at least one material text that has been recalled based on semantic matching or feature word matching through a pending query request to obtain a target material text. For a detailed description, please refer to the subsequent embodiments.
[0038] Optionally, after obtaining the target material text, the target material text can also be adjusted based on the reply format corresponding to the query request to be processed to obtain the adjusted reply text. The reply text is the text used to reply to the query request to be processed. Since the target material text obtained by the text generation method provided in the embodiment of the present application has a high accuracy, the accuracy of the reply text can also be improved, thereby improving the answer effect of the query request to be identified with the query condition.
[0039] Exemplarily, the query requests to be processed can be classified, and then the reply formats corresponding to the various types of query requests to be processed can be predetermined, so that after obtaining the target material text, the target material text can be adjusted based on the reply formats corresponding to the query requests to be processed to generate adjusted reply text.
[0040] Exemplarily, the target material text may also be adjusted in combination with a large language model to obtain an adjusted reply text. For a detailed description, please refer to the subsequent embodiments.
[0041] The text generation method provided by the present application first obtains the user's pending query request; then determines the query conditions corresponding to the pending query request; thereby determining the target material text from the material text set based on the query conditions and the pending query request. The target material text has a semantic match or a feature word match with the pending query request, and the target material text has a semantic match with the query conditions. It can be seen that in the present application, the material text set is not recalled based solely on the semantics or feature words of the pending query request, but the material text set is recalled in combination with the query conditions corresponding to the pending query request, so that the target material text obtained has a higher accuracy.
[0042] See also Figure 2 , Figure 2The text generation method provided by the embodiment of the present application is shown. The text generation method can be applied to an electronic device, and specifically, the processor of the electronic device can be used as the execution subject of the text generation method. The text generation method can include steps S210 to S250.
[0043] Step S210: Obtain the user's pending query request.
[0044] Step S220: Determine the query condition corresponding to the query request to be processed.
[0045] Among them, step S210 and step S220 have been introduced in detail in the above embodiments and will not be repeated here.
[0046] Step S230: Recalling the first material text from the material text set that has a semantic match or a feature word match with the query request to be processed.
[0047] First, the first material text that matches the semantics or feature words of the query request to be processed may be recalled from the material text set. Specifically, step S230 may include steps S231 to S233.
[0048] Step S231: based on lexical matching, at least one material text matching the feature word of the query request to be processed is recalled from the material text set as a second material text.
[0049] In some implementations, the material texts matching the query request to be processed may be retrieved from the material text collection by means of lexical matching or semantic matching.
[0050] In some implementations, at least one material text matching the query request feature word to be processed may be recalled from the material text set as the second material text based on lexical matching, wherein lexical matching may generally include steps such as word segmentation, inverted indexing, and scoring.
[0051] First, the query request to be processed may be segmented. The query request to be processed is generally composed of multiple consecutive characters, and word segmentation refers to dividing the multiple consecutive characters into several separate word blocks.
[0052] It is understandable that the query request to be processed is a Chinese text, and the Chinese text is a sequence of Chinese characters. There is generally no obvious separator between the characters, and it is usually impossible to segment them by symbol rules such as spaces. Specific algorithms can be used, for example, the specific algorithms can be Hidden Markov Model (HMM) algorithm and Viterbi algorithm. Among them, the Hidden Markov Model algorithm is a probabilistic graph model of the time sequence of characters. Exemplarily, the relationship such as the transition probability of characters in common language statements can be learned and fitted by the Hidden Markov Model algorithm; and then the maximum probability path between characters can be derived by the Viterbi algorithm to determine the first word segmentation combination, and the first word segmentation combination is the result of word segmentation of the query request to be processed.
[0053] Optionally, the query request to be processed may be segmented based on a word segmenter to obtain the first word segmentation combination. For example, Chinese word segmenters may include jieba, pyltp, thulac, pkuseg, IKAnalyzer, etc., and English word segmenters may include NLTK, SpaCy, StanfordCoreNLP, ElasticSearchTextAnalyzer, etc.
[0054] For example, for the query request to be processed is "Nanjing Yangtze River Bridge", the first word segmentation combination can be obtained through word segmentation, including "Nanjing", "Mayor", "Yangtze River", "Bridge", "Nanjing City" and "Yangtze River Bridge". Among them, each phrase in the first word segmentation combination is a word segmentation, that is, a feature word of the query request to be processed.
[0055] Further, each material text in the material text set can also be segmented to obtain the second segmentation combination corresponding to each material text, wherein each phrase in the second segmentation combination is a segmentation. Then, each segmentation in the second segmentation combination can be associated with the material text containing the segmentation by means of an inverted index. For example, an index can be established for each segmentation in the second segmentation, wherein the index corresponding to each segmentation is used to record the material text in which the segmentation has appeared. Exemplarily, the index generally includes the segmentation corresponding to the index, and a list of pointers to the material text containing the segmentation. Optionally, the index corresponding to the segmentation can also be stored. Exemplarily, the index can be stored in the form of a key-value pair, wherein the key is each segmentation, and the value is a list of material texts containing the segmentation.
[0056] Therefore, the inverted index can be used to quickly locate all material texts containing a certain word; in addition, it can save storage space and facilitate queries, such as Boolean queries (AND, OR, NOT) and other complex queries.
[0057] Therefore, at least one material text matching the feature word of the query request to be processed can be found based on the inverted index as the second material text.
[0058] Optionally, at least one material text matched with the feature word of the query request to be processed may be sorted, so as to construct a second material text having an arrangement order. Exemplarily, each material text may be scored by a term frequency-inverse document frequency (TFIDF) algorithm or a best match 25 (BM25) algorithm, and then sorted based on the scores corresponding to each material text to construct the second material text.
[0059] Among them, the term frequency-inverse document frequency algorithm can include term frequency (TermFrequency, TF), that is, the term frequency of the segmented word w in the material text d, that is, the ratio of the number of times the segmented word w appears in the material text d count(w,d) and the total number of segmented words size(d) in the material text d, which can be represented by the following formula (1).
[0060] tf(w,d)=count(w,d) / size(d) (1)
[0061] The term frequency-inverse document frequency algorithm can also include the inverse document frequency (IDF), that is, the inverse material frequency of the word segment w in the material text set, that is, the logarithm of the ratio of the total number of material texts n to the number of documents docs(w,D) in which the word segment w appears, which can be represented by the following formula (2).
[0062] idf=log(n / docs(w,D)) (2)
[0063] Therefore, the term frequency-inverse document frequency algorithm can calculate a weight for each source text d and the query string q composed of each word segment w[1]…w[k] according to the term frequency and inverse document frequency, which is used to represent the matching degree between the query string q and the source text d, and can be represented by the following formula (3).
[0064] tf-idf(q,d)=sum{i=1..k|tf-
[0065] idf(w[i],d)}=sum{i=1..k|tf(w[i],d)*idf(w[i])} (3)
[0066] Among them, the best match 25 algorithm is usually used for search relevance scoring. For example, the correlation between the query request to be processed and each material text in the material text set D can be calculated. The correlation can be, for example, a logical correlation. Exemplarily, the query request to be processed can be represented by Q. For example, Q can be a sentence composed of multiple participles. After Q is segmented as shown above, a first participle combination can be obtained. Specifically, each participle in the first participle combination can be represented by q1, q2, ... qt. If a material text d∈material file set D is given, the score between Q and d is calculated to represent the correlation between the query request to be processed and each material text. The specific expression can be as follows (4).
[0067]
[0068] Among them, wi is used to represent the weight of qi, R(qi,d) is the correlation between qi and d, and Score(Q,d) is the weighted sum of the correlation between each word segment qi and d. There are many ways to calculate wi, which can be expressed by the word frequency-inverse document frequency algorithm. N represents the total number of texts in the material text set, and n(qi) represents the number of texts containing the word qi.
[0069] Then wi can be represented by the following formula (5).
[0070]
[0071] Among them, 0.5 is mainly used for smoothing. i ,d) can be represented by the following formula (6).
[0072]
[0073] Wherein, K in formula (6) can be represented by the following formula (7).
[0074]
[0075] In the above formula, fi is the frequency of qi appearing in the material text d, qfi is the frequency of qi appearing in the pending query request Q, k1, k2, b are all adjustable parameters, dl, avgdl are the length of the material text d and the average length of all material texts in the material text set D respectively. For example, k1 = 2, b = 0.75 are usually set. The function of parameter b is mainly to adjust the impact of text length on relevance.
[0076] Thus, the Score (Q ,d) sorting the material texts that match the feature words of the query request to be processed, for example, selecting the top K material texts that are ranked first as the second material texts.
[0077] Step S232: Based on semantic matching, at least one material text semantically matching the query request to be processed is recalled from the material text set as a third material text.
[0078] In some other implementations, at least one material text semantically matching the query request to be processed may be recalled from the material text set based on semantic matching as the third material text. Semantic matching may generally include steps such as vector conversion, similarity calculation, result sorting and return.
[0079] First, the query request to be processed and each material text in the material text set can be converted into a vector representation. For example, a pre-trained model or algorithm can be used to map the query request to be processed and each material text to a vector space to obtain feature text vectors corresponding to the query request to be processed and each material text. Exemplarily, the model can be trained based on a pre-trained related deep learning model such as a bidirectional long short-term memory network (Bidirectional Long Short-Term Memory, BiLSTM) or a transformer model (Transformer).
[0080] Then, the similarity between the feature text vector corresponding to the query request to be processed and the feature text vector corresponding to each material text is calculated. Exemplarily, commonly used similarity calculation methods include cosine similarity or Euclidean distance.
[0081] Among them, cosine similarity measures the cosine value of the angle between vectors. The closer the cosine value of the angle is to 1, the more similar the vectors are; Euclidean distance calculates the geometric distance between vectors. The closer the distance is, the more similar the vectors are.
[0082] Optionally, in order to facilitate the comparison of similarities between vectors with slightly different moduli and to enhance stability and generalization capabilities, the vectors may be normalized before similarity calculation.
[0083] Thus, the results can be sorted and returned according to the result of similarity calculation. Specifically, according to the result of similarity calculation, the feature text vectors corresponding to the first k material texts with the highest similarity to the feature text vector corresponding to the query request to be processed can be returned as the search result, and the material texts corresponding to the k feature text vectors can be used as the third material text, where k is the number of returned results specified by the user.
[0084] Optionally, similarity calculation can be implemented in combination with the vector index method. Among them, the vector index is a data structure used to quickly retrieve and match vector data, and plays a key role in the vector database. In ordinary indexes, the keys are some specific identifiers or attributes, while the keys in vector indexes are vectors. That is, the vector index can be constructed by the feature text vectors corresponding to each material text obtained above, so that the similarity between the feature text vector corresponding to the query request to be processed and the feature text vector corresponding to each material text can be calculated based on the vector index. The advantages of vector indexes are that they can improve query speed, save storage space, provide sorting functions, facilitate data maintenance and management, etc. Among them, vector indexes can include partition-based indexes, tree-based indexes, hash-based indexes, or graph-based indexes, etc.
[0085] Among them, the partition-based index can be, for example, an inverted file index (IVF), in which the vector space can be divided into several subspaces, each of which has a centroid. When searching for a vector, first query the distance between the vector and each centroid, find the nearest centroid, and then search for the vector only in the subspace corresponding to the centroid. This method can reduce the search range and improve query efficiency, but there may be a situation where the closest centroid is inaccurate, and usually multiple nearest centroids are required to solve it.
[0086] In addition, the tree-based index can be a binary search tree-based structure, which makes similar vectors more likely to appear in the same subtree, so as to find approximate vectors more quickly. However, this index structure works better for low-dimensional data, but it is easy to degenerate into linear scanning for high-dimensional data, and the accuracy is reduced.
[0087] Hash-based indexes can be locality sensitive hashing (LSH), which can convert high-dimensional data into low-dimensional hash codes, so that similar vectors are more likely to be mapped to the same bucket, and dissimilar vectors are less likely to be mapped to the same bucket. Its advantage is that it is fast when processing large amounts of data, but the accuracy of search results is relatively low.
[0088] Furthermore, graph-based indexing can form a graph with nodes and edges for each vector in the vector space. Nodes represent the value of the vector, and edges represent the similarity between vectors. The search algorithm finds approximate vectors by efficiently traversing the graph. For example, the search algorithm can be a Hierarchical Navigable Small World (HNSW) algorithm, which has good performance and memory efficiency in high-dimensional data.
[0089] Thus, the result of similarity calculation can be obtained by the above-mentioned vector indexing method. Similarly, the results can be sorted and returned according to the result of similarity calculation. Specifically, according to the result of similarity calculation, the feature text vectors corresponding to the first k material texts with the highest similarity to the feature text vector corresponding to the query request to be processed can be returned as the retrieval result, and the material texts corresponding to the k feature text vectors can be used as the third material text, where k is the number of return results specified by the user.
[0090] Step S233: sorting each material text based on the logical association degree of each material text in the second material text and the third material text with respect to the query request to be processed, and constructing the first material text.
[0091] Furthermore, after obtaining the second material text and the third material text, each material text can be sorted based on the degree of logical association of each material text in the second material text and the third material text with respect to the query request to be processed to construct the first material text.
[0092] In some implementations, each source text may be ranked based on a reciprocal rank fusion (RRF) algorithm to construct the first source text. The reciprocal rank fusion algorithm may be used to fuse ranking results generated by multiple different sources or different search strategies to obtain a better comprehensive ranking.
[0093] From the foregoing introduction, it can be seen that each material text in the second material text and the third material text has been obtained through a certain sorting. Therefore, the higher the sorting of the material text in the second material text and the third material text, the higher the importance of the material text relative to the query request to be processed, that is, the stronger the logical association program with the query request to be processed.
[0094] The fusion score corresponding to each material text can be calculated respectively through the reciprocal ranking fusion algorithm, and then the ranking is determined according to the fusion score corresponding to each material text to construct the first material text.
[0095] For example, for a material text d, if the ranking of the material text in the second material text or the third material text is defined as r i (d), the fusion score RRFscore(d∈D) of each material text can be represented by the following formula (8).
[0096]
[0097] Here, k is a constant, which is usually set to 60. It should be noted that the material text d shown above is each material text included in the second material text and the third material text.
[0098] From formula (7), it can be seen that the material text fusion score is a function of the sum of inverses, that is, the inverse of the ranking of the material document in the second material text or the third material text to which it belongs is taken, and then summed, and the inverse of the constant k is added. It can be seen that the higher the ranking, the larger the inverse value, so that the fusion score of the material text is higher. The higher the fusion score, the higher the logical correlation between the material text and the query request to be processed.
[0099] Therefore, the topK material texts corresponding to the highest fusion scores may be screened and sorted to construct the first material text.
[0100] Optionally, when calculating the fusion score, different weight values may be added to the material texts belonging to the second material text or the third material text, respectively, so as to adjust the priority of the recall results obtained through semantic matching or lexical matching.
[0101] Step S240: performing a specified operation on the first material text based on the semantics of the query condition to obtain the target material text.
[0102] Then, a specified operation can be performed on the first material text based on the semantics of the query conditions to obtain the target material text, wherein the specified operation includes an enhancement operation or a filtering operation, the enhancement operation is used to set different priorities for the first material text that semantically matches the query conditions and the first material text that does not semantically match the query conditions, and the filtering operation is used to filter out the first material text that does not semantically match the query conditions.
[0103] For some implementations, if the designated operation includes an enhancement operation and the first material text is multiple, then step S240 may include step S241.
[0104] Step S241: Prioritize the plurality of first material texts based on whether they semantically match the query condition to obtain the target material text.
[0105] At this time, it can be determined whether each first material text matches the semantics of the query condition, and then the plurality of first material texts are prioritized based on the results of whether the first material text matches the semantics of the query condition to obtain the target material text.
[0106] For some implementations, the priority of each first material text can be set by whether the first material text matches the query condition semantics, and then the first material text is sorted based on the priority to obtain the target material text. Specifically, the priority of the first material text that matches the query condition semantics can be determined as the first priority, and the priority of the first material text that does not match the query condition semantics can be determined as the second priority, wherein the first priority is higher than the second priority.
[0107] In some embodiments, the query condition may include a target time text, a target location text, or a target object text. Exemplarily, in the case where the query condition includes a target time text, it may be determined based on the semantics of each first material text whether the first material text is within the time interval corresponding to the target time text. Furthermore, the first material text within the time interval corresponding to the target time text is determined as the first material text that matches the semantics of the query condition; and the first material text outside the time interval corresponding to the target time text is determined as the first material text that does not match the semantics of the query condition.
[0108] Exemplarily, in the case where the query condition includes the target location text, it can be determined based on the semantics of each first material text whether the first material text includes text for representing the target location text. Thus, the first material text including text for representing the target location text is determined to be the first material text that matches the semantics of the query condition; and the first material text that does not include text for representing the target location text is determined to be the first material text that does not match the semantics of the query condition. It can be understood that the target location text may correspond to multiple locations, so the first material text only needs to include at least one location in the target location text to be considered that the first material text includes text for representing the target location text.
[0109] Exemplarily, in the case where the query condition includes the target object text, it can be determined based on the semantics of each first material text whether the first material text includes text for representing the target object text. Thus, the first material text including text for representing the target object text is determined to be the first material text that matches the semantics of the query condition; and the first material text that does not include text for representing the target object text is determined to be the first material text that does not match the semantics of the query condition. It can be understood that the target object text may correspond to multiple objects, so the first material text only needs to include at least one object in the target object text to be considered that the first material text includes text for representing the target object text.
[0110] Then, based on the degree of logical relevance of the first material text to the query request to be processed, the first material texts of the first priority and the first material texts of the second priority are sorted respectively to construct the target material text, wherein each first material text of the first priority in the first material text is before each first material text of the second priority.
[0111] Similarly, sorting the first material text of the first priority and the first material text of the second priority based on the degree of logical relevance of the first material text to the query request to be processed can be achieved through a reciprocal ranking fusion algorithm. For a detailed introduction, please refer to the aforementioned steps, which will not be repeated here.
[0112] It should be noted that the first material text of the first priority and the first material text of the second priority can be sorted respectively by the inverse ranking fusion algorithm, so as to obtain the first sorting corresponding to the first material text of the first priority and the second sorting corresponding to the first material text of the second priority, and then the first material text of the first sorting is placed before the first material text of the second sorting, so as to construct the target material text.
[0113] For some implementations, if the specified operation includes a filtering operation and there are multiple first material texts, step S240 may include step S243 and step S244.
[0114] Step S233: retaining the first material text that semantically matches the query condition.
[0115] Step S244: Sort the retained first material texts based on the degree of logical association of the retained first material texts with the query request to be processed to obtain the target material texts.
[0116] Similarly, at this time, it can be determined whether each first material text matches the semantics of the query condition, and then only the first material text that matches the semantics of the query condition is retained. For a detailed introduction, please refer to the introduction of the above steps, which will not be repeated here.
[0117] Then, the retained first material text is sorted based on the logical association degree of the retained first material text with the query request to be processed to obtain the target material text. Similarly, the sorting of the retained first material text can be achieved by a reciprocal ranking fusion algorithm. For a detailed introduction, please refer to the above steps, which will not be repeated here.
[0118] Optionally, in order to ensure the number of material texts in the target material text, the first material text may be controlled to include at least a first number of material texts. For example, if the target material text needs to include a second number of material texts, the first number may be set to N times the second number, for example, N may be set to 2 to 10.
[0119] In some implementations, the first material text that semantically matches or matches the feature word of the query request to be processed is first recalled from the material text set, and then the target material text is determined through the query condition and the first material text, which is also called a post-condition query method.
[0120] Step S250: adjusting the target material text based on the reply format corresponding to the query request to be processed, and generating an adjusted reply text.
[0121] Therefore, after obtaining the target material text, the target material text can be adjusted based on the reply format corresponding to the query request to be processed to generate an adjusted reply text.
[0122] In some implementations, the target material text may be adjusted based on the reply format corresponding to the query request to be processed through a deep learning neural network model, thereby generating an adjusted reply text.
[0123] In some other implementations, the reply text may also be obtained through a large language model. Specifically, step S250 may also include step S251.
[0124] Step S251: adjusting the target material text based on the reply format corresponding to the query request to be processed by a large language model to generate an adjusted reply text.
[0125] The target material text can be adjusted based on the reply format corresponding to the pending query request through a large language model to generate an adjusted reply text, and the adjusted reply text is the reply text used to reply to the pending query request.
[0126] Among them, the reply format corresponding to the pending query request can be automatically generated by the large language model based on the pending query request, so that the content of the target material text can be adjusted according to the reply format corresponding to the pending query request to generate a reply text for replying to the pending query request.
[0127] Exemplarily, "determine the corresponding reply format according to the query request to be processed, and then adjust the content of the target material text according to the reply format corresponding to the query request to be processed, so as to generate a reply text for replying the query request to be processed" can be input into the large language model as a prompt of the large language model, and at the same time, the query request to be processed and the target material text are both input into the large language model to generate the reply text through the large language model.
[0128] Optionally, when the acquired target material text includes multiple material texts, the target material text can be further screened by the large language model. Exemplarily, prompt words can be generated by the Chain of Thought (CoT) method. For example, the prompt words can be "analyze each material text in the target material text, and give whether the material is related to the query request to be identified, whether it supports answering the query request to be identified, and give a reason analysis. You decide whether to keep each material text", so that the target material text can be further screened by the large language model.
[0129] Then, the large language model generates the reply text from the filtered target material text. For example, "generating reply text from filtered target material text" is input into the large language model as a prompt word.
[0130] Optionally, after the reply text is generated, the material text used to support the reply text can be displayed, so that the user can directly view the material text. For example, the material text used in the process of generating the reply text can be displayed in the form of a list through a large language model. It should be noted that the material text used to support the reply text is the target material whose content has been adjusted based on the reply format.
[0131] It should be noted that the text generation method provided in the present application obtains the reply text, which can also be called Retrieval Augmented Generation (RAG).
[0132] In the text generation method provided in the embodiment of the present application, the first material text that matches the semantics or feature words of the query request to be processed can be first recalled from the material text set; and then the first material text is subjected to a specified operation based on the semantics of the query condition to obtain the target material text. That is, the first material text is screened by the semantics of the query condition to be part of the material text in the material text set that has been recalled, thereby reducing the computing resources required for the subsequent acquisition of the target material text without negatively affecting the accuracy of the acquired target material text, and improving the accuracy of the reply text. The problem of low accuracy of recalling the material text corresponding to the query request to be identified with the query condition through lexical and semantic matching in the general retrieval enhancement generation scheme is solved.
[0133] See also Figure 3 , Figure 3 The text generation method provided by the embodiment of the present application is shown. The text generation method can be applied to an electronic device, and specifically, the processor of the electronic device can be used as the execution subject of the text generation method. The text generation method can include steps S310 to S350.
[0134] Step S310: Obtain the user's pending query request.
[0135] Step S320: Determine the query condition corresponding to the query request to be processed.
[0136] Among them, step S310 and step S320 have been introduced in detail in the above embodiments and will not be repeated here.
[0137] Step S330: Recalling a fourth material text that semantically matches the query condition from the material text set.
[0138] Step S340: constructing the target material text based on the material text in the fourth material text that has a semantic match or a feature word match with the query request to be processed.
[0139] In some implementations, a fourth material text semantically matching the query condition may be firstly recalled from the material text set. Specifically, a material text semantically matching the query condition may be firstly recalled from the material text set as the fourth material text.
[0140] In some implementations, the query condition may include a target time text, a target location text, or a target object text. The specific method of recalling the fourth material text that semantically matches the query condition from the material text set is similar to the method of determining whether each first material text semantically matches the query condition in the aforementioned embodiment, and will not be described in detail here.
[0141] Then, the target material text is constructed based on the material text in the fourth material text that matches the semantics or features of the query request to be processed. The specific method based on the material text in the fourth material text that matches the semantics or features of the query request to be processed is similar to the method of recalling the first material text that matches the semantics or features of the query request to be processed from the material text set described above, and will not be repeated here.
[0142] In some implementations, the method of first recalling the fourth material text that semantically matches the query condition from the material text set and then obtaining the target material text based on the query request to be processed and the fourth material text can also be called a precondition query method.
[0143] Compared with the post-condition query method, the pre-condition query method is less likely to have empty recall results, while the pre-condition query method has the disadvantage of not being convenient for using vector indexes. Therefore, when the amount of data is not too large, high-complexity vector indexes can be avoided.
[0144] Step S350: adjusting the target material text based on the reply format corresponding to the query request to be processed, and generating an adjusted reply text.
[0145] Among them, step S350 has been introduced in detail in the above embodiment and will not be repeated here.
[0146] The text generation method provided in the embodiment of the present application recalls the fourth material text that semantically matches the query condition from the material text set; and constructs the target material text based on the material text that semantically matches or matches the feature word of the query request to be processed in the fourth material text. It is not easy to have the recalled target material text result be empty, which improves the stability of generating the target material text.
[0147] See also Figure 4 , Figure 4 The text generation method provided by the embodiment of the present application is shown. The text generation method can be applied to an electronic device, and specifically, the processor of the electronic device can be used as the execution subject of the text generation method. The text generation method can include steps S410 to S440.
[0148] Step S410: Obtain the user's pending query request.
[0149] Among them, step S410 has been introduced in detail in the above embodiment and will not be repeated here.
[0150] Step S420: determining a query condition corresponding to the query request to be processed, wherein the query condition includes a target time text, a target location text or a target object text.
[0151] As can be seen from the above introduction, the query conditions can include different types, such as time type, location type and object type. Therefore, the condition information corresponding to the material text in the material text set can also be obtained, for example, the corresponding time information, location information, object information, etc. can be determined based on the semantics of the material text. Optionally, index information including various condition information can also be established.
[0152] In the case where the query condition includes the target time text, step S420 may include step S421 and step S422.
[0153] Step S421: searching the query request to be processed for a first text that matches a preset standard time format.
[0154] Step S422: adjusting the first text based on the standard time format to obtain the target time text.
[0155] The first text matching the preset standard time format can be first searched from the pending query request. The standard time format can be pre-set, and exemplary, the standard time format can include an absolute time format, for example, it can include multiple formats in the order of small to large time interval range. For example, "x year x month x day", "x day / x number", "x year x month", "x month" and "x year". The standard time format can also include a relative time format, for example, it can include multiple formats in the order of small to large time interval range. For example, "day level: such as yesterday, within 7 days, 7 days ago, etc.", "week level: such as last week, this week, 6 weeks ago, etc.", "month level: such as last month, within 12 months", "season level: such as this summer, last winter, winter", "year level: such as the past 3 years". The standard time format can also include a holiday time format, for example, it can include various public holidays. For example, "National Day: x year x month x day to x year x month x day".
[0156] It should be noted that the above-mentioned "x" only refers to a reasonable value, and each "x" can be a different value.
[0157] In some implementations, a text matching the standard time format can be found from the query request to be processed by regular matching as the first text. Further, the first text can be adjusted based on the standard time format to obtain the target time text. Optionally, the first text can also be found in combination with the index information obtained above.
[0158] It is understandable that the time included in the first text may have overlapping repeated time intervals, so the repeated time intervals in the first text may be merged and the non-repeated time intervals may be retained. For example, if the first text includes three times, time 1 is from 8 am to 6 pm; time 2 is from 10 am to 11 am; and time 3 is from 10 pm to 11 pm. After merging, the time intervals are from 8 am to 6 pm and from 10 pm to 11 pm.
[0159] In addition, adjusting the first text based on the standard time format to obtain the target time text may be a text representation method of mapping the first text to the standard time format. For example, if the first text is "November 11, 2024", the target time text obtained after mapping is "2024 / 11 / 11 00:00~2024 / 11 / 11 23:59:59".
[0160] As can be seen from the above introduction, the standard time format includes a variety of different time intervals. Therefore, in the process of finding text matching the standard time format from the query request to be processed by regular matching, for each time interval, once the text is matched by regular matching, it returns to perform matching on another time interval, thereby avoiding repeated matching. The target time text obtained can be used as the query condition.
[0161] In the case where the query condition includes the target location text, step S420 may include step S423 and step S424.
[0162] Step S423: searching the query request to be processed for a second text including a location text.
[0163] Step S424: mapping the second text to the target location text based on a pre-acquired location mapping relationship, wherein the location mapping relationship includes at least one reference text and a reference location text to which each reference text is mapped.
[0164] First, the second text including the location text can be searched from the query request to be processed. Similarly, the text including the location can be searched from the query request to be processed by regular matching as the second text. Optionally, in the process of searching the second text including the location text from the query request to be processed by regular matching, the second text can also be searched in combination with the index information obtained above.
[0165] It is understandable that the second text included in the query request to be processed may be an abbreviation, alias or nickname of a place, that is, a text including non-standard place information. For example, the second text may be "Western Sichuan", "Central China", etc. Therefore, in order to obtain a target place text including standard place information, a place mapping relationship may be established in advance. Among them, the place mapping relationship may include at least one reference text, and a reference place text mapped by each reference text. For some embodiments, the reference text may be an abbreviation, alias or nickname of a place, and the reference place text corresponding to the reference text is a text including standard place information. Exemplarily, the location mapping relationship may include multiple reference texts, namely "West Sichuan", "East China", "North China", "South China", "Central China", "Northeast", "Northwest", and "Southwest", and the reference location text mapped by each reference text may be respectively: "West Sichuan: Sichuan", "East China: Shanghai, Jiangsu, Zhejiang, Anhui, Fujian, Jiangxi, Shandong", "North China: Beijing, Tianjin, Hebei, Shanxi, Inner Mongolia", "South China: Guangdong, Guangxi, Hainan", "Central China: Henan, Hubei, Hunan", "Northeast: Liaoning, Jilin, Heilongjiang", "Northwest: Shaanxi, Gansu, Qinghai, Ningxia, Xinjiang", and "Southwest: Sichuan, Guizhou, Yunnan, Tibet, Chongqing".
[0166] Therefore, if the second text includes "Sichuan West", the second text can be mapped to the target location text based on the pre-acquired location mapping relationship, that is, the target location text is "Sichuan".
[0167] Optionally, the second text may also include text of standard location information and text of non-standard location information, for example, the second text includes "Western Sichuan" and "Beijing". Therefore, the second text is mapped to the target location text based on the pre-acquired location mapping relationship, and the text of non-standard location information included in the second text can be mapped to the text of standard location information through the location mapping relationship, and then the mapped text of standard location information is merged with the text of standard location information originally included in the second text, so as to obtain the target location information.
[0168] For example, based on the example that the second text includes "Sichuan West" and "Beijing", the text of the non-standard location information in the second text is "Sichuan West", and the text of the non-standard location information can be mapped to obtain the text of the standard location information "Sichuan". In addition, the text of the standard location information originally included in the second text is "Beijing", so "Sichuan" and "Beijing" can be merged to obtain the target location information, and the target location information can be used as the query condition.
[0169] In the case where the query condition includes the target object text, step S420 may include step S425.
[0170] Step S425: searching for a third text including the target object from the query request to be processed as the target object text.
[0171] Similarly, a third text including the target object can be queried from the pending query request by regular matching as the target object text. It should be noted that the target object can be a specific object such as a cow, a person, a flower, a tree, etc., and the target object text is a text used to describe the target object.
[0172] Optionally, in the process of searching for the third text including the target object from the query request to be processed by regular matching, the third text can be found in combination with the index information obtained above, and the obtained third text can be used as the query condition.
[0173] Step S430: determining a target material text from a material text set based on the query condition and the query request to be processed, wherein the target material text has a semantic match or a feature word match with the query request to be processed, and the target material text has a semantic match with the query condition.
[0174] Step S440: adjusting the target material text based on the reply format corresponding to the query request to be processed, and generating an adjusted reply text.
[0175] Among them, step S430 and step S440 have been introduced in detail in the above embodiments and will not be repeated here.
[0176] The text generation method provided in the embodiment of the present application obtains query conditions from the query request to be processed by means of regular matching, wherein the query conditions include target time text, target location text or target object text. The problem of low accuracy of recalling the material text corresponding to the query request to be identified with the query condition through lexical and semantic matching in the general retrieval enhancement generation scheme is solved. In the present application, the accuracy of the recalled target material text is high, so that the subsequent use of the recalled target material text to answer the query can improve the accuracy of the answer and improve the effect of answering the query request to be identified with the query condition.
[0177] See also Figure 5 , which shows a structural block diagram of a text generation device 500 provided in an embodiment of the present application, including: an acquisition unit 510, a first determination unit 520 and a second determination unit 530.
[0178] The acquisition unit 510 is used to acquire the user's query request to be processed.
[0179] The first determining unit 520 is configured to determine a query condition corresponding to the query request to be processed.
[0180] Optionally, the first determination unit 520 may also be configured to search the query request to be processed for a first text that matches a preset standard time format; and adjust the first text based on the standard time format to obtain the target time text.
[0181] Optionally, the first determination unit 520 can also be used to search for a second text including a location text from the query request to be processed; and map the second text to the target location text based on a pre-acquired location mapping relationship, wherein the location mapping relationship includes at least one reference text and a reference location text mapped by each reference text.
[0182] Optionally, the first determining unit 520 may also be configured to search for a third text including the target object from the query request to be processed as the target object text.
[0183] The second determination unit 530 is used to determine a target material text from a material text set based on the query condition and the query request to be processed, wherein the target material text has a semantic match or a feature word match with the query request to be processed, and the target material text has a semantic match with the query condition.
[0184] Optionally, the second determination unit 530 can also be used to recall the first material text that matches the semantics or feature words of the query request to be processed from the material text set; perform a specified operation on the first material text based on the semantics of the query condition to obtain the target material text.
[0185] Optionally, the second determining unit 530 may also be configured to prioritize the plurality of first material texts based on whether they semantically match the query condition to obtain the target material text.
[0186] Optionally, the second determination unit 530 can also be used to retain the first material text that semantically matches the query condition; sort the retained first material text based on the degree of logical association of the retained first material text with the query request to be processed, to obtain the target material text.
[0187] Optionally, the second determination unit 530 can also be used to recall at least one material text that matches the feature word of the query request to be processed from the material text set based on lexical matching as the second material text; recall at least one material text that semantically matches the query request to be processed from the material text set based on semantic matching as the third material text; and sort each material text based on the degree of logical association of each material text in the second material text and the third material text with the query request to be processed to construct the first material text.
[0188] Optionally, the second determination unit 530 can also be used to recall a fourth material text that semantically matches the query condition from the material text set; and construct the target material text based on the material text in the fourth material text that semantically matches or matches the feature word of the query request to be processed.
[0189] Optionally, the text generation device 500 may further include a text generation unit, which is used to adjust the target material text based on the reply format corresponding to the query request to be processed, and generate an adjusted reply text.
[0190] Optionally, the text generation unit may also be configured to adjust the target material text based on the reply format corresponding to the query request to be processed through a large language model to generate an adjusted reply text.
[0191] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and units can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.
[0192] In several embodiments provided in the present application, the coupling between the units may be electrical, mechanical or other forms of coupling.
[0193] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0194] See also Figure 6 , Figure 6The structural block diagram of an electronic device provided in an embodiment of the present application is shown. The electronic device 110 may be a smart phone or a tablet computer, etc. The electronic device 110 in the present application may include one or more of the following components: a processor 111, a memory 112, and one or more application programs, wherein the processor 111 is electrically connected to the memory 112, and the one or more program configurations are used to execute the methods described in the aforementioned embodiments.
[0195] The processor 111 may include one or more processing cores. The processor 111 uses various interfaces and lines to connect various parts of the entire electronic device 110, and executes various functions and processes data of the electronic device 110 by running or executing instructions, programs, code sets or instruction sets stored in the memory 112, and calling data stored in the memory 112. Optionally, the processor 111 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 111 can integrate one or a combination of a central processing unit, an image processor, and a modem. Among them, the CPU mainly processes the operating system, the user interface, and the computer program; the GPU is responsible for rendering and drawing the display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 111, and it may be implemented separately through a communication chip. Specifically, the method described in the above embodiment can be executed by one or more processors 111.
[0196] For some embodiments, the memory 112 may include a random access memory (RAM) or a read-only memory (ROM). The memory 112 may be used to store instructions, programs, codes, code sets, or instruction sets. The memory 112 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function, instructions for implementing the following various method embodiments, etc. The data storage area may also store data created by the electronic device 110 during use, etc.
[0197] Please refer to Figure 7 , which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 700 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.
[0198] The computer readable storage medium 700 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 700 includes a non-transitory computer-readable storage medium. The computer readable storage medium 700 has storage space for program code 710 that performs any method step in the above method. These program codes can be read from or written to one or more computer program products. The program code 710 can be compressed, for example, in an appropriate form.
[0199] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A text generation method, characterized in that: include: Get the user's pending query request; Determining a query condition corresponding to the query request to be processed; A target material text is determined from a material text set based on the query condition and the query request to be processed, wherein the target material text has a semantic match or a feature word match with the query request to be processed, and the target material text has a semantic match with the query condition.
2. The method according to claim 1, characterized in that After determining the target material text from the material text set based on the query condition and the query request to be processed, the method further includes: The target material text is adjusted based on the reply format corresponding to the query request to be processed to generate an adjusted reply text.
3. The method according to claim 2, characterized in that The step of adjusting the target material text based on the reply format corresponding to the query request to be processed to generate an adjusted reply text includes: The target material text is adjusted based on the reply format corresponding to the query request to be processed through a large language model to generate an adjusted reply text.
4. The method according to claim 1, characterized in that The determining the target material text from the material text set based on the query condition and the query request to be processed includes: Recalling a first material text from the material text set that has a semantic match or a feature word match with the query request to be processed; A specified operation is performed on the first material text based on the semantics of the query condition to obtain the target material text, wherein the specified operation includes an enhancement operation or a filtering operation.
5. The method according to claim 4, characterized in that The specified operation includes an enhancement operation, the first material text is multiple, and the specified operation is performed on the first material text based on the semantics of the query condition, including: The plurality of first material texts are prioritized based on whether they semantically match the query condition to obtain the target material text.
6. The method according to claim 4, characterized in that The specified operation includes a filtering operation, there are multiple first material texts, and the specified operation is performed on the first material text based on the semantics of the query condition, including: retaining the first material text that semantically matches the query condition; The retained first material texts are sorted based on the degree of logical association of the retained first material texts with respect to the query request to be processed to obtain the target material texts.
7. The method according to claim 4, characterized in that The step of recalling the first material text that matches the semantic meaning or the characteristic word of the query request to be processed from the material text set includes: Recalling at least one material text matching the feature word of the query request to be processed from the material text set based on lexical matching as a second material text; Based on semantic matching, recalling at least one material text semantically matching the query request to be processed from the material text set as a third material text; Based on the degree of logical association of each material text in the second material text and the third material text with respect to the query request to be processed, each material text is sorted to construct the first material text.
8. The method according to claim 1, characterized in that The determining the target material text from the material text set based on the query condition and the query request to be processed includes: Recalling a fourth material text that semantically matches the query condition from the material text set; The target material text is constructed based on the material text in the fourth material text that has a semantic match or a feature word match with the query request to be processed.
9. The method according to claim 1, characterized in that: The query condition includes a target time text, and the determining of the query condition corresponding to the query request to be processed includes: Searching for a first text matching a preset standard time format from the query request to be processed; The first text is adjusted based on the standard time format to obtain the target time text.
10. The method according to claim 1, characterized in that The query condition includes a target location text, and the determining of the query condition corresponding to the query request to be processed includes: Searching for a second text including a location text from the query request to be processed; The second text is mapped to the target location text based on a pre-acquired location mapping relationship, wherein the location mapping relationship includes at least one reference text and a reference location text to which each reference text is mapped.
11. The method according to claim 1, characterized in that: The query condition includes a target object text, and the determining of the query condition corresponding to the query request to be processed includes: A third text including the target object is searched from the query request to be processed as the target object text.
12. A text generation device, characterized in that: include: An acquisition unit, used to acquire a user's pending query request; A first determining unit, configured to determine a query condition corresponding to the query request to be processed; The second determination unit is used to determine a target material text from a material text set based on the query condition and the query request to be processed, wherein the target material text has a semantic match or a feature word match with the query request to be processed, and the target material text has a semantic match with the query condition.
13. An electronic device, characterized in that: include: one or more processors; Memory; One or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method according to any one of claims 1-11.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program code, which can be called by a processor to execute the method according to any one of claims 1 to 11.