Text generation method and device based on large language model
By semantic recognition and knowledge base query of medical-related problem texts, relevant and accurate reply texts are generated, and problems of insufficient relevance and accuracy of answers in the prior art are solved, and more efficient answers to medical problems are achieved.
Patent Information
- Application Number
- CN202311761020.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-20
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2043-12-20
AI Technical Summary
When prior art is difficult to generate answers to medical-related questions, the relevance of the answers, comprehensiveness and accuracy of the coverage content are insufficient.
By semantic recognition of the problem text, multiple subject words and problem types are obtained, and the reference text corresponding to the problem text is determined from the target knowledge base based on these subject words. Then, the question type, question text, and reference text are processed to generate the question text for the answer. The goal knowledge base is constructed based on medical-related historical texts.
It improves the relevance between the reply text and the question text and the comprehensiveness of the coverage content, thereby improving the accuracy of the reply.
Smart Images

Figure CN117743539B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, in particular to deep learning, large language model technology, and AI (Artificial Intelligence) medical fields, and specifically to a text generation method, device, electronic device, storage medium, and program product based on a large language model. Background Art
[0002] LLM (Large Language Model) refers to a deep learning model trained with a large amount of text data that can generate natural language text or understand the meaning of language text.
[0003] For different application scenarios, you can fine-tune or adjust the prompt input (Prompt) of the large language model and use the large language model to process a variety of natural language tasks, such as question answering, text classification, etc. Summary of the invention
[0004] The present disclosure provides a method, device, electronic device, storage medium and program product for text generation based on a large language model.
[0005] According to one aspect of the present disclosure, a text generation method is provided, comprising: performing semantic recognition on a question text to obtain a plurality of subject words and question types, wherein the question text includes medical-related content; determining a reference text corresponding to the question text from a target knowledge base based on the plurality of subject words, wherein the target knowledge base is constructed based on medical-related historical texts; and processing the question type, question text, and reference text to generate a reply text for replying to the question text.
[0006] According to another aspect of the present disclosure, a text generation device is provided, comprising: a semantic recognition module, a first determination module and a generation module. The semantic recognition module is used to perform semantic recognition on a question text to obtain a plurality of subject words and question types, wherein the question text includes medical-related content. The first determination module is used to determine a reference text corresponding to the question text from a target knowledge base based on a plurality of subject words, wherein the target knowledge base is constructed based on medical-related historical texts. The generation module is used to process the question type, question text and reference text to generate a reply text for replying to the question text.
[0007] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described above.
[0008] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method described above.
[0009] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the method described above is implemented.
[0010] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0012] Figure 1 An exemplary system architecture to which the text generation method and apparatus according to an embodiment of the present disclosure can be applied is schematically shown;
[0013] Figure 2 A flowchart of a text generation method according to an embodiment of the present disclosure is schematically shown;
[0014] Figure 3 The schematic diagram schematically shows the principle of the text generation method according to the embodiment of the present disclosure;
[0015] Figure 4 A schematic diagram schematically shows a method of generating a reply text for an opinion-type question according to an embodiment of the present disclosure;
[0016] Figure 5 A schematic diagram schematically shows a method of generating a reply text for a difference type question according to an embodiment of the present disclosure;
[0017] Figure 6 A block diagram schematically shows a text generation device according to an embodiment of the present disclosure; and
[0018] Figure 7 A block diagram of an electronic device suitable for implementing a text generation method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0019] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0020] The user groups that AI medical care targets have different knowledge reserves, so the flexibility and freedom of the questions raised by users are relatively high.
[0021] For example, a question from a patient who has been suffering from a chronic disease for a long time might be “Can a certain drug be taken by a patient with high blood pressure?”
[0022] For example, when researchers need to conduct research on a medical topic, they usually need to consult a large amount of literature and read and understand the research process and research results of the literature as the basis for the research of the medical topic. The question raised by the researcher may be "Will the efficacy of a certain antibody against a certain virus be affected by the mutation of the virus?"
[0023] For the above problems, it is difficult to obtain answers that are highly relevant, comprehensive and accurate based on templated question-answer pairs (QA).
[0024] In view of this, the embodiment of the present disclosure provides a text generation method, which obtains multiple keywords and question types by semantically identifying the question text. Then, based on the multiple keywords, a reference text corresponding to the question text is determined from the target knowledge base. The question type, question text and reference text are then processed to generate a reply text. Since the target knowledge base is constructed based on historical texts related to medical care, the relevance of the reply text to the question text and the comprehensiveness of the coverage content can be effectively improved, thereby improving the accuracy of the reply.
[0025] Figure 1 An exemplary system architecture to which the text generation method and apparatus according to an embodiment of the present disclosure can be applied is schematically shown.
[0026] It should be noted that Figure 1 The examples shown are only examples of system architectures to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but do not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios. For example, in another embodiment, the exemplary system architecture to which the text generation method and apparatus can be applied may include a terminal device, but the terminal device may implement the text generation method and apparatus provided by the embodiments of the present disclosure without interacting with the server.
[0027] like Figure 1 As shown, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.
[0028] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as knowledge reading applications, web browser applications, search applications, instant messaging tools, email clients and / or social platform software, etc. (only as examples).
[0029] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0030] The server 105 may be a server that provides various services, such as a background management server (only an example) that provides support for the content browsed by the user using the terminal devices 101, 102, and 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0031] It should be noted that the text generation method provided in the embodiment of the present disclosure can generally be executed by the terminal device 101, 102, or 103. Accordingly, the text generation apparatus provided in the embodiment of the present disclosure can also be set in the terminal device 101, 102, or 103.
[0032] Alternatively, the text generation method provided in the embodiment of the present disclosure may also be generally executed by the server 105. Accordingly, the text generation device provided in the embodiment of the present disclosure may generally be arranged in the server 105. The text generation method provided in the embodiment of the present disclosure may also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the text generation device provided in the embodiment of the present disclosure may also be arranged in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105.
[0033] For example, when a user reads an e-book online, the terminal devices 101, 102, and 103 can obtain the target content in the e-book pointed by the user's sight, and then send the obtained target content to the server 105, which analyzes the target content to determine the characteristic information of the target content; predicts the content that the user is interested in based on the characteristic information of the target content; and extracts the content that the user is interested in. Alternatively, a server or server cluster that can communicate with the terminal devices 101, 102, 103 and / or the server 105 analyzes the target content and finally extracts the content that the user is interested in.
[0034] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0035] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision, disclosure and application of user personal information involved comply with the provisions of relevant laws and regulations, take necessary confidentiality measures, and do not violate public order and good morals.
[0036] In the technical solution of the present disclosure, the user's authorization or consent is obtained before obtaining or collecting the user's personal information.
[0037] Figure 2 The flowchart of the text generation method according to the embodiment of the present disclosure is schematically shown.
[0038] like Figure 2 As shown, the method 200 includes operations S210 to S230.
[0039] In operation S210, semantic recognition is performed on the question text to obtain a plurality of subject words and question types.
[0040] In operation S220, a reference text corresponding to the question text is determined from a target knowledge base according to the plurality of subject words, wherein the target knowledge base is constructed according to medical-related historical texts.
[0041] In operation S230, the question type, question text, and reference text are processed to generate a reply text for replying the question text.
[0042] According to an embodiment of the present disclosure, the question text includes medical-related content. Semantic recognition is performed on the question text to obtain multiple subject words and question types. The subject words can be words that can reflect the question intention corresponding to the question text.
[0043] For example, the question text may be "What is the difference between the usage of drug M and drug N?", where M and N may represent the names of two drugs. By performing semantic recognition on the question text, it can be determined that the question intention is about the difference in usage of the two drugs, and therefore, it can be determined that the subject words include: M, N, usage, and difference.
[0044] According to an embodiment of the present disclosure, the question type may correspond to the questioning intention of the question text, and may be configured in the configuration information according to the mapping relationship between certain words included in the question text and the question type. For example: for question texts including words such as "is" and "what", it may be configured as a closed-type question. For question texts including words such as "difference", "distinction", and "difference", it may be configured as a difference-type question. For question texts including words such as "how" and "can", it may be configured as an opinion-type question.
[0045] For example, question 1 may be “What is ‘bad’ cholesterol?” Question 1 includes “what” and “is”, so it can be determined that the question type of question 1 is a closed question.
[0046] For example, question 2 can be “Is there a difference in the dosage of these two types of drugs?” Question 2 includes “difference”, so it can be determined that the question type of question 2 is a difference question.
[0047] For example, question 3 can be “Can a certain drug treat a certain disease?”. Question 3 includes “can”, which means that the question type of question 3 is an opinion question.
[0048] According to the embodiment of the present disclosure, the target knowledge base is constructed based on historical texts related to medical treatment. Historical texts related to medical treatment include, but are not limited to, the following: drug instructions, medical professional books, research papers, expert consensus in the medical field, etc. Expert consensus in the medical field can refer to clinical practice guidelines, operating instructions, etc. jointly issued by authoritative experts in the medical field for a certain research.
[0049] According to an embodiment of the present disclosure, the target knowledge base may include index information, an ES (Elastic Search) library, and a vector library.
[0050] According to an embodiment of the present disclosure, the index information may be as shown in Table 1:
[0051]
[0052] According to an embodiment of the present disclosure, the index information may include the following contents: text ID (Identity document), text name, text type, text summary, text conclusion, drug name, department and disease. The text ID indicates the storage location identifier of the text in the target knowledge base. The text name may be the title of the text, for example: XX research report. The text type may include drug instructions, disease guidelines, expert consensus, research literature, etc. The text summary may be the content of the summary part of the historical text. The text conclusion may be the content of the conclusion part of the historical text. The drug name, department and disease may all be generated after parsing the content of the historical text, for example: the drug name in the drug instructions, etc. For example: hypertension belongs to cardiovascular and cerebrovascular diseases and belongs to the Department of Neurology.
[0053] According to the embodiments of the present disclosure, the text information stored in the ES library and the vector library is the same. Since the large language model only supports vectorized text input, the text information that is the same as that in the ES library is vectorized and stored in the vector library, and the step of vectorizing the reference text can be omitted, thereby improving the efficiency of generating the reply text.
[0054] According to an embodiment of the present disclosure, the reference text represents a text having a relevance to a plurality of subject words greater than a predetermined relevance threshold.
[0055] According to an embodiment of the present disclosure, the question type and reference text can be input into a large language model as an input prompt (Prompt) together with the question text, and the natural language understanding ability of the large language model can be used to answer the question text based on the reference text and according to the question type to generate a reply text. The large language model may be any type of model that can process text data, such as the ERNIE model or the Generative Pre-trained Transformer model (GPT). The embodiment of the present disclosure does not specifically limit the type of the large language model.
[0056] According to the embodiment of the present disclosure, multiple keywords and question types are obtained by semantically identifying the question text. Then, based on the multiple keywords, a reference text corresponding to the question text is determined from the target knowledge base. The question type, question text and reference text are then processed to generate a reply text. Since the target knowledge base is constructed based on historical texts related to medical care, the relevance of the reply text to the question text and the comprehensiveness of the coverage content can be effectively improved, thereby improving the accuracy of the reply.
[0057] Historical texts in the medical field generally have strong logic between paragraphs. Therefore, when creating a target knowledge base based on historical texts, the logical relationship between the initial text paragraphs in the historical text can be retained to improve retrieval efficiency.
[0058] According to the embodiments of the present disclosure, historical content can be segmented according to paragraph features of the historical text to obtain multiple text paragraphs; semantic analysis of the multiple text paragraphs can be performed to obtain multiple paragraph topics corresponding to the multiple text paragraphs; and a target knowledge base can be constructed based on the multiple paragraph topics and the multiple text paragraphs.
[0059] According to an embodiment of the present disclosure, paragraph features can characterize the hierarchical progressive relationship between paragraphs in a historical text. For example, a historical text can be a paper, which can include an abstract, a main text, and a conclusion. The main text can include three parts: research background, experimental content, and data representation. The experimental content can include three text paragraphs. The data representation can include two text paragraphs. The abstract, research background, and conclusion are each one text paragraph.
[0060] According to an embodiment of the present disclosure, when performing paragraph segmentation, segmentation can be performed according to the initial natural paragraphs in the historical text to retain the original logical relationship between the paragraphs in the paper.
[0061] According to the embodiments of the present disclosure, semantic analysis can be performed on each text paragraph in turn to obtain a paragraph theme corresponding to each text paragraph. The paragraph theme is used to represent the core content of the text paragraph.
[0062] According to an embodiment of the present disclosure, based on multiple paragraph topics and multiple text paragraphs, an index table can be constructed based on the paragraph topics and the storage location identifiers of the text paragraphs corresponding to the paragraph topics, and the text paragraphs are stored in the ES library. At the same time, after the text paragraphs are vectorized, the vectorized text is stored in the vector library.
[0063] According to the embodiments of the present disclosure, the historical content is segmented according to the paragraph features of the historical text, and the initial logical relationship between the paragraphs in the historical text can be retained to improve the retrieval efficiency. Through the semantic analysis of multiple text paragraphs, multiple paragraph topics corresponding to the multiple text paragraphs are obtained, and a target knowledge base is constructed based on the multiple paragraph topics and the multiple text paragraphs. It can save the user's time for manual reading and comprehension of the historical text, provide the user with content that is highly relevant to the question text, and improve the user experience.
[0064] Given the industry specificity of the medical field, the credibility of historical texts from different channels varies. For example, drugs can only be sold after passing multiple standards review, so the credibility of drug instructions is relatively high. Research papers are generally based on the results of experimental research and have certain accidental factors, so the credibility of research papers is relatively low.
[0065] In an embodiment of the present disclosure, the priority of the historical text can be determined based on the source of the historical text; and in response to at least two text paragraphs having the same paragraph subject, priority tags can be configured for the at least two text paragraphs based on the priority of the historical text corresponding to the at least two text paragraphs.
[0066] For example, historical texts can include drug instructions, disease guidelines, expert consensus, and research papers. Based on the sources of historical texts, the order of priority can be determined as follows: drug instructions > disease guidelines > expert consensus > research papers.
[0067] For example, a paragraph topic may be "Contraindications of taking drug M", and texts related to the paragraph topic may include the instructions for drug M and the content text about adverse reactions of patients with a certain disease after taking drug M in "Research progress in treating a certain disease". The priority tags that can be configured are: the priority of the instructions for drug M is level I, and the priority of the content text about adverse reactions of patients with a certain disease after taking drug M is level II.
[0068] According to an embodiment of the present disclosure, priority can be used to search based on the subject word, and the search can be performed according to the priority of the text. For example, for the subject word "M drug", when the target knowledge base includes the M drug instructions, the content in the M drug instructions is searched first.
[0069] According to the embodiments of the present disclosure, the priority can also be used as a screening criterion for reference texts. For example, for the same subject word, if multiple candidate texts matching the subject word are retrieved, the candidate text with a high priority can be used as the reference text.
[0070] Reference below Figure 3 to Figure 5 , combined with specific embodiments Figure 2 The method shown is further explained.
[0071] Figure 3 The schematic diagram schematically shows the principle of the text generation method according to the embodiment of the present disclosure.
[0072] like Figure 3 As shown, in embodiment 300, multiple keywords 302 and question types 307 are obtained by performing semantic recognition on question 301.
[0073] According to the embodiments of the present disclosure, semantic relevance of adjacent words in the question text and question intention can be obtained by performing semantic recognition on the question text; based on the semantic relevance, the question text is segmented to obtain multiple subject words; and the question type is determined according to the question intention.
[0074] For example, the question text may be "How long is the injection cycle of the antibody vaccine against the T virus?" Through semantic analysis of the question text, the semantic relevance of adjacent words and the question intention can be obtained.
[0075] According to the embodiments of the present disclosure, the semantic relevance of adjacent words can effectively reduce the problem that the subject words destroy the semantics of the original question, resulting in increased retrieval noise. For example, if "injection cycle" is split into two subject words "injection" and "cycle", then in the retrieval process, "injection dose", "intramuscular injection" and the like will be used as candidate texts, increasing the difficulty of reference text screening.
[0076] According to an embodiment of the present disclosure, based on the question intention, the question type can be determined in order to determine the specific search scope, thereby determining the text most relevant to the question as the reference text, which can reduce the input amount of redundant information of the large language model.
[0077] In operation S310, it is determined whether the plurality of subject words 302 include the predetermined subject word 303. In response to the plurality of subject words 302 including the predetermined subject word 303, a reference text 306 is determined from the target knowledge base according to the predetermined subject word.
[0078] According to an embodiment of the present disclosure, the target knowledge base 310 may include a first knowledge base and a second knowledge base. The first knowledge base may be an ES library 311, which may include a mapping relationship between a paragraph theme of a candidate text and a paragraph content of the candidate text. The second knowledge base may be a vector library 312, which may include a mapping relationship between a semantic feature of a paragraph theme of a candidate text and a paragraph content of the candidate text.
[0079] According to an embodiment of the present disclosure, the predetermined subject word may be a drug name, and based on the predetermined subject word, a first candidate text may be determined from a first knowledge base based on a mapping relationship between a paragraph subject of the candidate text and a paragraph content of the candidate text. Based on the predetermined subject word and the second candidate text, a second correlation between the predetermined subject word and the second candidate text is obtained; and based on the first correlation and the second correlation, a reference text is determined from the first candidate text and the second candidate text.
[0080] For example, the predetermined subject word may be "XX" (XX represents the name of a drug), and the paragraph topics of the candidate text may include "Usage of XX", "Indications of XX", "Efficacy of XY" (XY represents the name of another drug with a similar name to XX). The paragraph topics that include the predetermined subject word in the paragraph topics may be used as the paragraph topics related to the question. Then, based on the mapping relationship between the paragraph topics of the candidate text and the paragraph content of the candidate text, the paragraph content corresponding to the paragraph topics "Usage of XX" and "Indications of XX" is determined as the first candidate text.
[0081] It should be noted that for drugs with the same active ingredient content, since drug names are usually directly translated from different languages and are not easy to remember, many drug names can include some common names that are more suitable for public memory in addition to professional names in the medical field. In order to improve the comprehensiveness of the reference text coverage, the paragraph topic can be retrieved by configuring the matching threshold between the predetermined subject words and the paragraph topic.
[0082] According to an embodiment of the present disclosure, a predetermined keyword can be matched with paragraph topics of multiple candidate texts in a first knowledge base to obtain a first matching probability; based on the first matching probability, a first paragraph topic is determined from the paragraph topics of the multiple candidate texts; and based on a mapping relationship between the paragraph topics and the paragraph content of the candidate texts, the paragraph content corresponding to the first paragraph topic is determined as the first candidate text.
[0083] For example, the predetermined subject word may be "XX", the matching probability of the paragraph subject "Usage of XX" with the predetermined subject word may be 95%, the matching probability of "Indications of XX" (XX represents an alias of XX) with the predetermined subject word may be 90%, and the matching probability of "Efficacy of XY" with the predetermined subject word may be 60%. The matching threshold may be 85%, so the paragraph content corresponding to "Usage of XX" and "Indications of XX" may be used as the first candidate text.
[0084] Since the second knowledge base includes a mapping relationship between the semantic features of the paragraph topics of the candidate text and the paragraph content of the candidate text, the predetermined subject words cannot be directly matched with the paragraph topics of the candidate text in the second knowledge base. Determining the second candidate text from the second knowledge base based on the predetermined subject words may include the following operations: extracting the semantic features of the predetermined subject words; matching the semantic features of the predetermined subject words with the semantic features of the paragraph topics of multiple candidate texts in the second knowledge base to obtain a second matching probability; determining the second paragraph topic from the paragraph topics of multiple candidate texts based on the second matching probability; and determining the paragraph content corresponding to the second paragraph topic as the second candidate text based on the mapping relationship between the paragraph topic and the semantic features of the paragraph content of the candidate text.
[0085] For example, by extracting the semantic features of the predetermined subject words, the semantic features of the predetermined subject words and the semantic features of the paragraph topic can be processed based on the similarity algorithm to obtain the similarity between the semantic features of the predetermined subject words and the semantic features of the paragraph topic. And the similarity is used as the second matching probability. By configuring the matching threshold, the paragraph content corresponding to the paragraph topic with the second matching probability greater than or equal to the matching threshold is determined as the second candidate text.
[0086] According to an embodiment of the present disclosure, the first candidate text and the second candidate text are obtained by matching the predetermined subject words with the paragraph theme and the semantic features of the paragraph theme, respectively, so as to improve the comprehensiveness of the content covered by the reference text.
[0087] It should be noted that in order to improve the accuracy of the reply text generated by the large language model, the first candidate text and the second candidate text need to be further screened to improve the relevance of the reference text to the question text.
[0088] According to an embodiment of the present disclosure, a first correlation between the question text and the first candidate text can be obtained based on the question text and the first candidate text; a second correlation between the question text and the second candidate text can be obtained based on the question text and the second candidate text; and a reference text can be determined from the first candidate text and the second candidate text based on the first correlation and the second correlation.
[0089] According to the embodiments of the present disclosure, the first entity words "M", "hypertension", and "applicable" can be extracted from the question text "Is drug M suitable for patients with hypertension?"; the second entity words "M", "hypertension", and "adverse reactions" can be extracted from the first candidate text "Drug M has adverse reactions on patients with hypertension"; and the third entity words "hypertension", "M", and "prohibited" can be extracted from the second candidate text "Patients with hypertension are prohibited from taking certain types of drugs, such as: M". Then, based on a similarity algorithm, such as Euclidean distance, the similarity between the first entity word and the second entity word is calculated to obtain a first correlation, and the similarity between the first entity word and the third entity word is calculated to obtain a second correlation. Finally, the candidate texts ranked in the top 3 from the first candidate text and the second candidate text can be determined as reference texts by sorting the correlation from high to low.
[0090] According to an embodiment of the present disclosure, the candidate texts are screened based on the relevance between the question text and the candidate texts, which can improve the relevance between the reference text and the question text, thereby improving the accuracy of the reply text.
[0091] In the foregoing description, it is proposed that the priority tags of the text paragraphs of the historical text in the target knowledge base can be used to determine the reference text. Therefore, the relevance and priority can be combined to achieve targeted selection of the reference text to improve the relevance of the reference text to the question text.
[0092] According to an embodiment of the present disclosure, the weight of a first candidate text and the weight of a second candidate text are determined based on the source of the candidate texts; a first relevance score between the first candidate text and a plurality of subject words is obtained based on the first relevance and the weight of the first candidate text; a second relevance score between the second candidate text and a plurality of subject words is obtained based on the second relevance and the weight of the second candidate text; and a reference text is determined from the first candidate text and the second candidate text based on the first relevance score and the second relevance score.
[0093] For example, the source of the candidate text can determine that the weight of the drug instruction can be 0.6, and the weight of the research paper can be 0.2. The first relevance between the first candidate text and the question text can be 90%, and the source of the first candidate text can be the drug instruction, so the first relevance score can be 0.54. The candidate texts with the top 3 relevance scores can be determined as reference texts by sorting the relevance scores.
[0094] According to an embodiment of the present disclosure, since the source of the candidate text can determine the credibility of the text content, a relevance score is obtained based on the source of the candidate text and the relevance of the candidate text to the question text to determine the reference text, which can improve the credibility of the reference text and thus improve the accuracy of the reply text.
[0095] like Figure 3 As shown, in response to the fact that the subject words do not include the predetermined subject words, the text type 304 to be queried is determined according to the subject words 302; and the reference text 306 is determined from the target knowledge base 310 according to the text type 304 to be queried and multiple subject words 302.
[0096] According to an embodiment of the present disclosure, determining the type of text to be queried based on multiple subject words may include the following operations: performing semantic analysis on the multiple subject words to obtain query intent; and determining the type of text to be queried based on the query intent.
[0097] For example, the question text may be "Is the efficacy of neutralizing antibodies in treating T virus affected by virus mutation?" By performing semantic analysis on the question text, the multiple subject terms obtained may include at least "neutralizing antibodies", "efficacy", "T virus", "mutation", etc. It can be determined that the query intention of the question is to query research progress related to clinical research. Therefore, it can be determined that the type of text to be queried is a research paper.
[0098] According to an embodiment of the present disclosure, determining a reference text from a target knowledge base based on a text type to be queried and a plurality of subject words may include the following operations: determining a target candidate text corresponding to the text type to be queried from the target knowledge base based on the text type to be queried; and determining a reference text from the target candidate texts based on a plurality of subject words.
[0099] According to an embodiment of the present disclosure, in the ES library 311, according to the text type in the index information, for example, a research paper, the target candidate text can be determined from the target knowledge base as a research paper, thereby narrowing the search scope. Then, according to multiple keywords, a reference text 306 is determined from the target candidate text.
[0100] According to an embodiment of the present disclosure, similar to the method of retrieving a target knowledge base based on predetermined words described above, multiple subject words can be matched with multiple paragraph topics corresponding to the target candidate text to obtain a matching probability; based on the matching probability, a target paragraph topic is determined from the multiple paragraph topics; and based on the mapping relationship between the paragraph topic and the paragraph content, the paragraph content corresponding to the target paragraph topic is determined as the reference text.
[0101] For example, a paragraph topic whose matching probability is greater than or equal to a predetermined matching threshold value may be determined as a target paragraph topic, and further, the paragraph content corresponding to the target paragraph topic may be determined as a reference text.
[0102] It should be noted that, since the type of text to be queried narrows the search scope, it may happen that no candidate text is found. Therefore, operation S320 may be performed to determine whether candidate text 305 is found. If candidate text 305 is not found, the entire knowledge of the target knowledge base may be searched based on multiple keywords 302 to obtain candidate text 305.
[0103] According to an embodiment of the present disclosure, the method of selecting the reference text 306 from the candidate text 305 is the same as the method of determining the reference text from the first candidate text and the second candidate text described above, and is not described in detail here.
[0104] According to the embodiments of the present disclosure, the search scope is narrowed by determining the type of text to be queried, which can effectively improve the search efficiency.
[0105] It should be noted that, since the large language model supports vectorized input, the reference text is obtained by searching the ES library 311 according to the text type 304 and the keyword 302 to be queried. The reference text at this time is non-vectorized, and since the text paragraphs in the ES library 311 are the same as the text paragraphs in the vector library 312, they also have a one-to-one correspondence. Therefore, after determining the reference text, the vectorized reference text can be determined from the vector library 312 according to the correspondence between the text paragraphs in the ES library 311 and the text paragraphs in the vector library 312, so as to input the large language model. It is also possible to extract the semantic features of the keyword 302 based on the description above, and retrieve the text paragraphs in the vector library 312 based on the semantic features of the keyword to obtain the reference text.
[0106] For example, the vectorized reference text 306 and the question type 307 may be input into the LLM 320 together with the prompt and the question 301 to generate the answer 308 for answering the question 301 .
[0107] According to an embodiment of the present disclosure, question types, question texts and reference texts are processed to generate a reply text for replying to the question text, which may include the following operations: extracting target content for generating the reply text from the reference text according to the question type; extracting text features of the question text and text features of the target content respectively; and processing the text features of the question text and the text features of the target content to generate the reply text.
[0108] According to an embodiment of the present disclosure, opinion questions and difference questions are typical question types commonly seen in the AI medical field, and are question types for which it is difficult to generate accurate answer texts based on standard QA.
[0109] Combine the following Figure 4 and Figure 5 The process of generating response text for opinion-type questions and difference-type questions is explained in detail respectively.
[0110] According to an embodiment of the present disclosure, a reply to an opinion-type question may include two parts: an opinion and arguments supporting the opinion.
[0111] Figure 4 The diagram schematically shows a schematic diagram of generating a reply text for an opinion-type question according to an embodiment of the present disclosure.
[0112] like Figure 4 As shown, in the embodiment 400, the opinion question 401 may be "Can patients with hypertension be served with M medicine?" The question includes the name of the medicine, and the reference text 402 may be determined from the target knowledge base based on the name of the medicine, or may be determined from the target knowledge base based on the name of the medicine and other subject words.
[0113] The reference text 402 may include the drug instructions 4021 and the disease guide 4022 of drug M. The first content "Contraindications: Pregnant women, diabetics, and hypertensive patients" used to illustrate the viewpoint can be extracted from the drug instructions 4021 of drug M, and the second content "Hypertensive patients are prone to adverse reactions to XX drugs, such as drug M" used to illustrate the viewpoint can be extracted from the disease guide 4022. Based on the context information of the first content, the second content corresponding to the viewpoint is extracted from the drug instructions 4021 of drug M and the disease guide 4022, respectively. For example: "Because... will have adverse reactions to XX drug."
[0114] Then, the first content and the second content can be used as target content. The text features of the target content and the text features of the question text are extracted respectively. The text features of the question text and the text features of the target content are processed to generate a reply text 403. For example: "No. Because hypertensive patients are prone to adverse reactions to macrolide drugs due to..., the drug instructions of M drug clearly state that hypertensive patients are prohibited from taking M drug."
[0115] For opinion questions, when the question text is about the research progress of a certain topic, the reference text can be the conclusion of each research paper. It may be difficult to directly extract effective information for generating the answer content from the conclusion of each research paper. In this case, the natural language processing capabilities of the large language model can be used to merge the text features of the conclusion of each research paper to generate a comprehensive conclusion.
[0116] For example: when the target content includes multiple text paragraphs, the text features of the contents corresponding to the multiple text paragraphs can be spliced to obtain fused text features; and the text features of the question text and the fused text features can be processed to generate a reply text.
[0117] According to the embodiments of the present disclosure, by fusing the text features of the contents of multiple text paragraphs, the comprehensiveness of the content of the reply text is improved, saving the user's time in reading and understanding paper-type documents.
[0118] Figure 5 The diagram schematically shows a schematic diagram of generating a reply text for difference-type questions according to an embodiment of the present disclosure.
[0119] like Figure 5 As shown, in embodiment 500, the difference type question 501 may be "Is there any difference in the method of taking drug M and drug N?" The question includes the name of the drug, and the reference text 502 may be determined from the target knowledge base based on the drug name, or the reference text 502 may be determined from the target knowledge base based on the drug name and other keywords.
[0120] The reference text 502 may include a drug instruction sheet 5021 for drug M and a drug instruction sheet 5022 for drug N. The third content "Dosage: 2 mg / time, 12 hours between two consecutive doses" may be extracted from the drug instruction sheet 5021 for drug M based on the first subject words "Drug M" and "Dosage". The fourth content "Dosage: 0.5 mg / time, 8 hours between two consecutive doses" may be extracted from the drug instruction sheet 5022 for drug N based on the second subject words "Drug N" and "Dosage".
[0121] Then, the third content and the fourth content can be used as the target content. The text features of the target content and the text features of the question text are extracted respectively. The text features of the question text and the text features of the target content are then processed to generate a reply text 503. For example: "The method of taking drug M is: 2 mg / time, and there must be a 12-hour interval between two consecutive doses. The method of taking drug N is: 0.5 mg / time, and there must be an 8-hour interval between two consecutive doses. The single dosage and the interval between two consecutive doses of drug M and drug N are different in the method of taking the drug."
[0122] According to the embodiments of the present disclosure, the question type is also used as an input prompt for the large language model, so that the large language model can generate a reply text according to the actual needs of the user. While meeting the user's demand for the accuracy of the reply content, the diversity of the reply form is improved to meet the user's personalized needs and improve the user experience.
[0123] Figure 6 A block diagram of a text generation device according to an embodiment of the present disclosure is schematically shown.
[0124] like Figure 6 As shown, the text generating device 600 may include: a semantic recognition module 610 , a first determination module 620 and a generation module 630 .
[0125] The semantic recognition module 610 is used to perform semantic recognition on the question text to obtain multiple keywords and question types, wherein the question text includes medical-related content.
[0126] The first determination module 620 is used to determine the reference text corresponding to the question text from the target knowledge base according to multiple subject words, wherein the target knowledge base is constructed based on historical texts related to medical treatment.
[0127] The generation module 630 is used to process the question type, question text and reference text to generate a reply text for replying the question text.
[0128] According to an embodiment of the present disclosure, the first determination module may include: a first determination submodule, a second determination submodule and a third determination submodule. The first determination submodule is used to determine a reference text from a target knowledge base based on a predetermined subject word and a question text in response to a plurality of subject words including a predetermined subject word. The second determination submodule is used to determine a text type to be queried based on a plurality of subject words in response to a plurality of subject words not including a predetermined subject word. The third determination submodule is used to determine a reference text from a target knowledge base based on a text type to be queried and a plurality of subject words.
[0129] According to an embodiment of the present disclosure, the second determination submodule may include: an analysis unit and a first determination unit. The analysis unit is used to perform semantic analysis on multiple subject words to obtain query intent. The first determination unit is used to determine the type of text to be queried according to the query intent.
[0130] According to an embodiment of the present disclosure, the first determination unit may include: a first determination subunit and a second determination subunit. The first determination subunit is used to determine, from a target knowledge base, target candidate texts corresponding to the text type to be queried. The second determination subunit is used to determine, from a target knowledge base, a reference text based on a plurality of subject words.
[0131] According to an embodiment of the present disclosure, the target knowledge base includes a mapping relationship between paragraph topics and paragraph contents of candidate texts; the second determination subunit is used to: match multiple keywords with multiple paragraph topics corresponding to the target candidate text to obtain a matching probability; based on the matching probability, determine a target paragraph topic from the multiple paragraph topics; and based on the mapping relationship between the paragraph topic and the paragraph content, determine the paragraph content corresponding to the target paragraph topic as a reference text.
[0132] According to an embodiment of the present disclosure, the target knowledge base includes a first knowledge base and a second knowledge base; the first determination submodule includes: a second determination unit, a third determination unit and a fourth determination unit.
[0133] The second determining unit is used to determine the first candidate text from the first knowledge base according to the predetermined subject word, wherein the first knowledge base includes a mapping relationship between the paragraph subject of the candidate text and the paragraph content of the candidate text.
[0134] The third determination unit is used to determine the second candidate text from the second knowledge base according to the predetermined subject word, wherein the second knowledge base includes the mapping relationship between the semantic features of the paragraph theme of the candidate text and the paragraph content of the candidate text.
[0135] The fourth determining unit is used to determine the reference text from the first candidate text and the second candidate text according to the semantic relevance between the first candidate text, the second candidate text and the question text.
[0136] According to an embodiment of the present disclosure, the fourth determining unit may include: a first correlation obtaining subunit, a second correlation obtaining subunit and a third determining subunit.
[0137] The first relevance obtaining subunit is used to obtain a first relevance between the question text and the first candidate text according to the question text and the first candidate text.
[0138] The second relevance obtaining subunit is used to obtain a second relevance between the question text and the second candidate text according to the question text and the second candidate text.
[0139] The third determining subunit is used to determine the reference text from the first candidate text and the second candidate text according to the first relevance and the second relevance.
[0140] According to an embodiment of the present disclosure, the third determination subunit is used to: determine the weight of the first candidate text and the weight of the second candidate text according to the source of the candidate text; obtain a first relevance score between the first candidate text and multiple subject words according to the first relevance and the weight of the first candidate text; obtain a second relevance score between the second candidate text and multiple subject words according to the second relevance and the weight of the second candidate text; and determine a reference text from the first candidate text and the second candidate text according to the first relevance score and the second relevance score.
[0141] According to an embodiment of the present disclosure, the second determination unit includes: a first matching subunit, a fourth determination subunit and a fifth determination subunit. The first matching subunit is used to match a predetermined subject word with paragraph topics of multiple candidate texts in the first knowledge base to obtain a first matching probability. The fourth determination subunit is used to determine a first paragraph topic from the paragraph topics of multiple candidate texts based on the first matching probability. The fifth determination subunit is used to determine the paragraph content corresponding to the first paragraph topic as the first candidate text based on the mapping relationship between the paragraph topic and the paragraph content of the candidate text.
[0142] According to an embodiment of the present disclosure, the third determination unit includes: an extraction subunit, a second matching subunit, a sixth determination subunit, and a seventh determination subunit.
[0143] The extraction subunit is used to extract the semantic features of the predetermined subject words.
[0144] The second matching subunit is used to match the semantic features of the predetermined subject word with the semantic features of the paragraph topics of multiple candidate texts in the second knowledge base to obtain a second matching probability.
[0145] The sixth determination subunit is used to determine a second paragraph topic from paragraph topics of a plurality of candidate texts based on a second matching probability.
[0146] The seventh determination subunit is used to determine the paragraph content corresponding to the second paragraph topic as the second candidate text according to the mapping relationship between the paragraph topic and the semantic features of the paragraph content of the candidate text.
[0147] According to an embodiment of the present disclosure, the generation module may include: a first extraction submodule, a second extraction submodule and a generation submodule. The first extraction submodule is used to extract the target content for generating the reply text from the reference text according to the question type. The second extraction submodule is used to extract the text features of the question text and the text features of the target content respectively. The generation submodule is used to process the text features of the question text and the text features of the target content to generate the reply text.
[0148] According to an embodiment of the present disclosure, the first extraction submodule includes: a first extraction unit, a second extraction unit and a first acquisition unit. The first extraction unit is used to extract a first content for explaining the viewpoint from a reference text in response to the question type being a viewpoint question. The second extraction unit is used to extract a second content corresponding to the viewpoint from the context information based on the context information of the first content, wherein the second content is used to explain the reason for the viewpoint. The first acquisition unit is used to obtain the target content based on the first content and the second content.
[0149] According to an embodiment of the present disclosure, the first extraction submodule includes: a second extraction unit, a comparison unit, and a second acquisition unit. The second extraction unit is used to extract the third content corresponding to the first subject word and the fourth content corresponding to the second subject word from the reference text in response to the question type being a difference type question. The comparison unit is used to compare the third content and the fourth content to obtain the difference content. The second acquisition unit is used to obtain the target content based on the third content, the fourth content, and the difference content.
[0150] According to an embodiment of the present disclosure, the target content includes content corresponding to multiple text paragraphs; the generation submodule includes: a splicing unit and a processing unit. The splicing unit is used to splice the text features of the content corresponding to the multiple text paragraphs to obtain fused text features. The processing unit is used to process the text features of the question text and the fused text features to generate a reply text.
[0151] According to an embodiment of the present disclosure, the semantic recognition module includes: a recognition submodule, a word segmentation submodule and a fourth determination submodule. The recognition submodule is used to perform semantic recognition on the question text to obtain the semantic relevance and question intention of adjacent words in the question text. The word segmentation submodule is used to perform word segmentation on the question text based on the semantic relevance to obtain multiple subject words. The fourth determination submodule is used to determine the question type according to the question intention.
[0152] According to an embodiment of the present disclosure, the device further includes: a segmentation module, an analysis module and a construction module. The segmentation module is used to segment the historical content according to the paragraph features of the historical text to obtain multiple text paragraphs. The analysis module is used to perform semantic analysis on the multiple text paragraphs to obtain multiple paragraph topics corresponding to the multiple text paragraphs. The construction module is used to construct a target knowledge base based on the multiple paragraph topics and the multiple text paragraphs.
[0153] According to an embodiment of the present disclosure, the device further includes: a second determination module and a configuration module. The second determination module is used to determine the priority of the historical text according to the source of the historical text. The configuration module is used to configure priority tags for the at least two text paragraphs according to the priority of the historical text corresponding to the at least two text paragraphs in response to the fact that the paragraph topics of the at least two text paragraphs are the same.
[0154] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0155] According to an embodiment of the present disclosure, an electronic device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method as described above.
[0156] According to an embodiment of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause a computer to execute the method as described above.
[0157] According to an embodiment of the present disclosure, a computer program product includes a computer program, and when the computer program is executed by a processor, the computer program implements the method as described above.
[0158] Figure 7 A schematic block diagram of an example electronic device 700 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0159] like Figure 7As shown, the device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0160] A number of components in the device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the device 700 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0161] The computing unit 701 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 701 performs the various methods and processes described above, such as the text generation method. For example, in some embodiments, the text generation method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the text generation method described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform the text generation method in any other appropriate manner (e.g., by means of firmware).
[0162] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0163] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0164] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0165] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0166] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0167] A computer system may include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises through computer programs running on respective computers and having a client-server relationship to each other. The server may be a cloud server, a server in a distributed system, or a server combined with a blockchain.
[0168] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0169] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A text generation method, comprising: Performing semantic recognition on the question text to obtain multiple subject words and question types, wherein the question text includes medical-related content; In response to the plurality of subject words including a predetermined subject word, determining a candidate text from a target knowledge base based on the predetermined subject word by matching with a paragraph topic of a historical text and a semantic feature of the paragraph topic; wherein the target knowledge base is constructed based on medical-related historical texts; Determining a reference text corresponding to the question text from the candidate texts according to the source of the candidate texts and the relevance of the candidate texts to the question text; and The question type, the question text and the reference text are processed to generate a reply text for replying the question text.
2. The method according to claim 1, wherein: The method further comprises: In response to the plurality of subject words not including a predetermined subject word, determining a text type to be queried based on the plurality of subject words; and The reference text is determined from the target knowledge base according to the type of the text to be queried and the multiple subject words.
3. The method according to claim 2, wherein: Determining the type of text to be queried based on the multiple subject words includes: Performing semantic analysis on the multiple subject words to obtain query intent; and According to the query intent, the type of text to be queried is determined.
4. The method according to claim 2, wherein: Determining the reference text from the target knowledge base according to the type of the text to be queried and the multiple subject words includes: According to the type of the text to be queried, determining target candidate texts corresponding to the type of the text to be queried from the target knowledge base; and The reference text is determined from the target candidate texts according to the multiple subject words.
5. The method according to claim 4, wherein: The target knowledge base includes a mapping relationship between paragraph topics and paragraph contents of candidate texts; and determining the reference text from the target candidate texts according to the multiple subject words includes: Matching the multiple subject words with the multiple paragraph topics corresponding to the target candidate text to obtain a matching probability; Based on the matching probability, determining a target paragraph topic from the plurality of paragraph topics; and Based on the mapping relationship between the paragraph topic and the paragraph content, the paragraph content corresponding to the target paragraph topic is determined as the reference text.
6. The method according to claim 1, wherein: The target knowledge base includes a first knowledge base and a second knowledge base; the step of determining candidate texts from the target knowledge base according to the predetermined subject words includes: Determine a first candidate text from the first knowledge base according to the predetermined subject word, wherein the first knowledge base includes a mapping relationship between paragraph topics of the candidate text and paragraph contents of the candidate text; According to the predetermined subject words, a second candidate text is determined from the second knowledge base, wherein the second knowledge base includes a mapping relationship between semantic features of paragraph topics of the candidate text and paragraph contents of the candidate text.
7. The method according to claim 6, wherein: The step of determining a reference text corresponding to the question text from the candidate texts according to the source of the candidate texts and the relevance between the candidate texts and the question texts comprises: Obtaining a first correlation between the question text and the first candidate text according to the question text and the first candidate text; Obtaining a second correlation between the question text and the second candidate text according to the question text and the second candidate text; Determining a weight of the first candidate text and a weight of the second candidate text according to the source of the candidate text; Obtaining a first relevance score between the first candidate text and the plurality of subject words according to the first relevance and the weight of the first candidate text; Obtaining a second relevance score between the second candidate text and the plurality of subject words according to the second relevance and the weight of the second candidate text; and The reference text is determined from the first candidate text and the second candidate text according to the first relevance score and the second relevance score.
8. The method according to claim 6, wherein: The determining of the first candidate text from the first knowledge base according to the predetermined subject word includes: Matching the predetermined subject word with paragraph subjects of a plurality of candidate texts in the first knowledge base to obtain a first matching probability; Based on the first matching probability, determining a first paragraph topic from the paragraph topics of the plurality of candidate texts; and According to the mapping relationship between paragraph topics and paragraph contents of the candidate texts, the paragraph content corresponding to the first paragraph topic is determined as the first candidate text.
9. The method according to claim 6, wherein: Determining a second candidate text from the second knowledge base according to the predetermined subject word includes: Extracting semantic features of the predetermined subject words; Matching the semantic features of the predetermined subject word with the semantic features of the paragraph topics of a plurality of candidate texts in the second knowledge base to obtain a second matching probability; Based on the second matching probability, determining a second paragraph topic from the paragraph topics of the plurality of candidate texts; and According to the mapping relationship between the paragraph topic and the semantic features of the paragraph content of the candidate text, the paragraph content corresponding to the second paragraph topic is determined as the second candidate text.
10. The method according to claim 1, wherein: The step of processing the question type, the question text and the reference text to generate a reply text for replying the question text comprises: Extracting target content for generating the answer text from the reference text according to the question type; extracting text features of the question text and text features of the target content respectively; and The text features of the question text and the text features of the target content are processed to generate the reply text.
11. The method according to claim 10, wherein: The step of extracting target content for generating the answer text from the reference text according to the question type includes: In response to the question type being an opinion-related question, extracting a first content for elaborating an opinion from the reference text; Based on the context information of the first content, extracting second content corresponding to the viewpoint from the context information, wherein the second content is used to explain the reason for generating the viewpoint; and The target content is obtained according to the first content and the second content.
12. The method according to claim 10, wherein: The step of extracting target content for generating the answer text from the reference text according to the question type includes: In response to the question type being a difference question, extracting a third content corresponding to the first subject word and a fourth content corresponding to the second subject word from the reference text respectively; Comparing the third content with the fourth content to obtain difference content; and The target content is obtained according to the third content, the fourth content and the difference content.
13. The method according to claim 10, wherein: The target content includes content corresponding to a plurality of text paragraphs, and the processing of the text features of the question text and the text features of the target content to generate the reply text includes: splicing the text features of the contents corresponding to the multiple text paragraphs to obtain fused text features; and The text features of the question text and the fused text features are processed to generate the reply text.
14. The method according to claim 1, wherein: The semantic recognition of the question text is performed to obtain multiple subject words and question types, including: Performing semantic recognition on the question text to obtain semantic relevance and question intention of adjacent words in the question text; Based on the semantic relevance, segmenting the question text to obtain the multiple subject words; and The question type is determined according to the question intention.
15. The method according to claim 1, further comprising: According to the paragraph features of the historical text, the historical content is segmented to obtain a plurality of text paragraphs; Semantically analyzing the multiple text paragraphs to obtain multiple paragraph topics corresponding to the multiple text paragraphs; as well as The target knowledge base is constructed according to the multiple paragraph topics and the multiple text paragraphs.
16. The method according to claim 15, wherein: Also includes: Determine the priority of historical texts according to their sources; In response to at least two text paragraphs having the same paragraph subject, priority tags are configured for the at least two text paragraphs according to the priorities of the historical texts corresponding to the at least two text paragraphs.
17. A text generation device, comprising: A semantic recognition module, used for performing semantic recognition on the question text to obtain a plurality of subject words and question types, wherein the question text includes medical-related content; A first determination module is configured to, in response to the multiple subject words including a predetermined subject word, determine a candidate text from a target knowledge base based on the predetermined subject word by matching the paragraph theme of the historical text and the semantic features of the paragraph theme; and select a reference text corresponding to the question text from the candidate text according to the source of the candidate text and the relevance of the candidate text to the question text, wherein the target knowledge base is constructed based on medical-related historical texts; and A generation module is used to process the question type, the question text and the reference text to generate a reply text for replying the question text.
18. The device according to claim 17, wherein: The first determining module comprises: A second determination submodule is configured to determine the type of text to be queried based on the multiple subject words in response to the multiple subject words not including the predetermined subject word; and The third determination submodule is used to determine the reference text from the target knowledge base according to the type of the text to be queried and the multiple subject words.
19. The device according to claim 18, wherein: The second determining submodule includes: An analysis unit, configured to perform semantic analysis on the plurality of subject words to obtain query intent; and The first determining unit is used to determine the type of text to be queried according to the query intention.
20. The device according to claim 19, wherein The first determining unit includes: a first determining subunit, configured to determine, from the target knowledge base, target candidate texts corresponding to the type of text to be queried, according to the type of text to be queried; and The second determining subunit is used to determine the reference text from the target candidate texts according to the multiple subject words.
21. The device according to claim 20, wherein: The target knowledge base includes a mapping relationship between paragraph topics and paragraph contents of the candidate texts; the second determining subunit is used for: Matching the multiple subject words with the multiple paragraph topics corresponding to the target candidate text to obtain a matching probability; Based on the matching probability, determining a target paragraph topic from the multiple paragraph topics; as well as Based on the mapping relationship between the paragraph topic and the paragraph content, the paragraph content corresponding to the target paragraph topic is determined as the reference text.
22. The device according to claim 18, wherein The target knowledge base includes a first knowledge base and a second knowledge base; The first determining module comprises: A second determining unit is used to determine a first candidate text from the first knowledge base according to the predetermined subject word, wherein the first knowledge base includes a mapping relationship between a paragraph topic of the candidate text and a paragraph content of the candidate text; The third determination unit is used to determine the second candidate text from the second knowledge base according to the predetermined subject word, wherein the second knowledge base includes a mapping relationship between the semantic features of the paragraph theme of the candidate text and the paragraph content of the candidate text.
23. The device according to claim 22, wherein: The first determining module comprises: A first relevance obtaining subunit, configured to obtain a first relevance between the question text and the first candidate text according to the question text and the first candidate text; A second relevance obtaining subunit, configured to obtain a second relevance between the question text and the second candidate text according to the question text and the second candidate text; Determining a weight of the first candidate text and a weight of the second candidate text according to the source of the candidate text; Obtaining a first relevance score between the first candidate text and the plurality of subject words according to the first relevance and the weight of the first candidate text; Obtaining a second relevance score between the second candidate text and the plurality of subject words according to the second relevance and the weight of the second candidate text; and The reference text is determined from the first candidate text and the second candidate text according to the first relevance score and the second relevance score.
24. The device according to claim 22, wherein: The second determining unit includes: A first matching subunit, used for matching the predetermined subject word with paragraph subjects of a plurality of candidate texts in the first knowledge base to obtain a first matching probability; a fourth determining subunit, configured to determine a first paragraph topic from the paragraph topics of the plurality of candidate texts based on the first matching probability; and The fifth determining subunit is used to determine the paragraph content corresponding to the first paragraph topic as the first candidate text according to the mapping relationship between the paragraph topic and the paragraph content of the candidate text.
25. The device according to claim 22, wherein: The third determining unit includes: An extraction subunit, used for extracting the semantic features of the predetermined subject word; A second matching subunit is used to match the semantic features of the predetermined subject word with the semantic features of the paragraph topics of the plurality of candidate texts in the second knowledge base to obtain a second matching probability; a sixth determining subunit, configured to determine a second paragraph topic from the paragraph topics of the plurality of candidate texts based on the second matching probability; and The seventh determination subunit is used to determine the paragraph content corresponding to the second paragraph topic as the second candidate text according to the mapping relationship between the paragraph topic and the semantic features of the paragraph content of the candidate text.
26. The device according to claim 17, wherein: The generation module comprises: A first extraction submodule, configured to extract target content for generating the answer text from the reference text according to the question type; A second extraction submodule, used to extract text features of the question text and text features of the target content respectively; and The generation submodule is used to process the text features of the question text and the text features of the target content to generate the reply text.
27. The device according to claim 26, wherein: The first extraction submodule comprises: A first extraction unit, configured to extract first content for elaborating a point of view from the reference text in response to the question type being a point of view question; a second extraction unit, configured to extract, based on the context information of the first content, second content corresponding to the viewpoint from the context information, wherein the second content is used to explain the reason for generating the viewpoint; and The first obtaining unit is configured to obtain the target content according to the first content and the second content.
28. The device according to claim 26, wherein The first extraction submodule comprises: A second extraction unit is used for extracting, in response to the question type being a difference type question, a third content corresponding to the first subject word and a fourth content corresponding to the second subject word from the reference text respectively; a comparing unit, configured to compare the third content and the fourth content to obtain difference content; and The second obtaining unit is configured to obtain the target content according to the third content, the fourth content and the difference content.
29. The device according to claim 26, wherein: The target content includes content corresponding to a plurality of text paragraphs; the generating submodule includes: a splicing unit, configured to splice text features of contents corresponding to the plurality of text paragraphs to obtain fused text features; and A processing unit is used to process the text features of the question text and the fused text features to generate the reply text.
30. The apparatus of claim 17, wherein: The semantic recognition module comprises: The recognition submodule is used to perform semantic recognition on the question text to obtain the semantic relevance and question intention of adjacent words in the question text; A word segmentation submodule is used to segment the question text based on the semantic relevance to obtain the multiple subject words; and The fourth determination submodule is used to determine the question type according to the question intention.
31. The apparatus of claim 17, further comprising: A segmentation module, used to segment the historical content according to the paragraph features of the historical text to obtain multiple text paragraphs; An analysis module, configured to perform semantic analysis on the plurality of text paragraphs to obtain a plurality of paragraph topics corresponding to the plurality of text paragraphs; as well as A construction module is used to construct the target knowledge base according to the multiple paragraph topics and the multiple text paragraphs.
32. The apparatus of claim 31 , further comprising: A second determination module, used to determine the priority of the historical text according to the source of the historical text; as well as The configuration module is used to configure priority tags for the at least two text paragraphs according to the priorities of the historical texts corresponding to the at least two text paragraphs in response to the paragraph topics of the at least two text paragraphs being the same.
33. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 16.
34. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-16.
35. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 16.
Citation Information
Patent Citations
Information retrieval method, device and equipment
CN110851560A
Method for identifying entity data in a data set
US20230316791A1