Method and device for medicine knowledge dialog, electronic apparatus, and storage medium
The question-and-answer method and device address the complexity of pharmaceutical instructions by using a drug knowledge base and natural language processing to provide accurate and concise answers, enhancing user understanding and reducing medication errors.
Patent Information
- Application Number
- JP2024099047
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-03-04
- Filing Date
- 2024-06-19
- Publication Date
- 2024-11-21
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Current pharmaceutical instructions are complex and lengthy, making it difficult for consumers to understand and use medications correctly, leading to potential errors and misunderstandings due to time constraints and incomplete information.
A question-and-answer method and device that utilizes a drug knowledge base to search for accurate answers and instruction manuals, incorporating natural language processing and large-scale language models to rewrite and understand user queries, ensuring precise matching and retrieval of relevant information.
Enhances user comprehension of medication usage by providing accurate and concise answers, improving the recall rate and accuracy of responses, and reducing the risk of errors through efficient information retrieval.
Smart Images

Figure 2024163110000001_ABST
Abstract
Description
[Technical field]
[0001] The present disclosure relates to the field of artificial intelligence technology, specifically to technical fields such as computer vision, image processing, deep learning, large-scale language models, and smart medicine, and in particular to a method, device, electronic device, and storage medium for pharmaceutical knowledge questioning. [Background technology]
[0002] Current paper instructions for medicines are sometimes too complicated for general consumers to understand the actual usage of the medicines. This not only inconveniences patients, but also leads to mistakes and misunderstandings in the use of medicines. In addition, for some medicines, the text content of the instructions is large and long, consuming a lot of the reader's time. In the fast-paced modern living environment, many users cannot take a lot of time to read complex and long medicine instructions, which may cause them to ignore important information about the use of medicines. At the same time, existing medicine instructions may omit text explanations of some contents, which makes the information received by users incomplete, which may lead to misunderstandings about those medicines and affect the correct use of medicines. Summary of the Invention
[0003] The present disclosure provides a pharmaceutical knowledge question and answer method, device, electronic device, and storage medium.
[0004] According to a first aspect of the present disclosure, there is provided a pharmaceutical knowledge question and answer method, the method comprising: Obtaining a pharmaceutical question text; Searching for a question answer text in a pharmaceutical knowledge base based on the pharmaceutical question text to obtain an answer text corresponding to the pharmaceutical question text; Searching for drug instructions in the drug knowledge base based on the drug question text to obtain an instruction text corresponding to the drug question text; and generating a response text corresponding to the pharmaceutical question text based on the answer text and the instruction text.
[0005] According to a second aspect of the present disclosure, there is provided a pharmaceutical knowledge question and answer device, the device comprising: an acquisition module configured to acquire a pharmaceutical question text; A first search module configured to search a question answer text in a pharmaceutical knowledge base based on the pharmaceutical question text, and obtain an answer text corresponding to the pharmaceutical question text; A second search module configured to search a drug instruction manual in the drug knowledge base based on the drug question text to obtain an instruction manual text corresponding to the drug question text; and a generation module configured to generate a response text corresponding to the pharmaceutical question text based on the answer text and the instruction text.
[0006] According to a third aspect of the present disclosure, there is provided an electronic device, comprising: At least one processor; and a memory communicatively coupled to the at least one processor, wherein: The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enable the at least one processor to perform a method according to any one of the above-mentioned technical solutions.
[0007] According to a fourth aspect of the present application, there is provided a non-transitory computer-readable storage medium having stored thereon computer instructions for causing a computer to execute a method according to any one of the above technical solutions.
[0008] According to a fifth aspect of the present application, there is provided a computer program product including a computer program which, when executed by a processor, implements the method according to any one of the above technical solutions.
[0009] It should be understood that the subject matter described in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to limit the scope of the disclosure. Other features of the disclosure will be readily apparent from the following specification. [Brief description of the drawings]
[0010] The drawings are for a better understanding of the present invention and do not constitute limitations to the present disclosure. [Figure 1] FIG. 2 is a schematic diagram showing steps of a pharmaceutical knowledge question and answer method in an embodiment of the present disclosure. [Diagram 2] FIG. 2 is a schematic diagram showing steps of another pharmaceutical knowledge question and answer method in an embodiment of the present disclosure. [Diagram 3] FIG. 2 is a schematic diagram showing specific steps of step S103 of the pharmaceutical knowledge question-and-answer method in the embodiment of the present disclosure. [Figure 4] FIG. 11 is a schematic diagram showing specific steps of step S1033 of the pharmaceutical knowledge question and answer method in the embodiment of the present disclosure. [Diagram 5] 1 is a schematic diagram showing the overall flow of evidence search in an embodiment of the present disclosure. [Figure 6] FIG. 2 is a schematic diagram showing specific steps of step S104 of the pharmaceutical knowledge question-and-answer method in the embodiment of the present disclosure. [Figure 7] 1 is a block diagram showing the principle of a drug question and answer device according to an embodiment of the present disclosure; [Figure 8] FIG. 13 is a principle block diagram showing another drug question and answer device according to an embodiment of the present disclosure. [Figure 9] FIG. 13 is a principle block diagram showing a second search module in an embodiment of the present disclosure. [Figure 10] FIG. 2 is a principle block diagram showing a text extraction unit in an embodiment of the present disclosure. [Figure 11] FIG. 2 is a principle block diagram showing a generation module in an embodiment of the present disclosure. [Figure 12]FIG. 2 is a block diagram of an electronic device for implementing a pharmaceutical question-and-answer method according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0011] Hereinafter, exemplary embodiments of the present disclosure will be described in conjunction with the drawings. In order to facilitate understanding, various details of the embodiments of the present disclosure are included therein, but they should be considered as merely exemplary. Therefore, as can be recognized by those skilled in the art, various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for clarity and conciseness, the following description omits descriptions of known functions and structures.
[0012] The current first pharmaceutical knowledge question and answer system is usually manually answered by experts or medical experts, that is, the user asks a question in the question and answer system, the system assigns the question to different experts, and the system returns it to the user after the experts finish writing the answer. Such a question and answer system requires a certain number of experts or medical experts, and in addition to the high labor costs, problems such as inefficiency and delay in answering by humans lead to a slow response of the system and a bad user experience.
[0013] The current second pharmaceutical knowledge question and answer system answers based on a question and answer library, where a user asks a question in the question and answer system, and the system matches the user's question with a question in the question and answer library, and if there is a match, the system returns the answer corresponding to the question in the question and answer library to the user, and if there is no match, it gives a default answer or an expert or medical expert answers artificially. Therefore, this question and answer system needs to excavate or artificially organize a series of questions and answers in advance and build a question and answer library, which not only results in high labor costs, but also in poor matching algorithm between user questions and questions in the question and answer library, resulting in low answer accuracy and recall.
[0014] In response to the above technical problems, the present disclosure provides a pharmaceutical knowledge question and answer method, as shown in FIG. 1, the method includes: A step S101 of acquiring a pharmaceutical question text; Step S102 of searching for a question answer text in the drug knowledge base based on the drug question text to obtain an answer text corresponding to the drug question text; Step S103: searching for drug instructions in the drug knowledge base based on the drug question text to obtain an instruction text corresponding to the drug question text; and step S104 of generating a response text corresponding to the medicine question text based on the answer text and the instruction text.
[0015] Specifically, the pharmaceutical question text in this embodiment refers to a query input by a user, such as "What is the best medicine for headaches?", "What are the side effects of this medicine?", etc. The question answer text refers to a QA pair, and each QA pair includes a question and a corresponding answer. For example, for the question "What are the side effects of ibuprofen?", the corresponding answer is "The side effects of ibuprofen can cause gastrointestinal disorders such as nausea, vomiting, abdominal pain, burning sensation, mild indigestion, gastrointestinal ulcers, bleeding, and sometimes rash, hives, etc." In step S102, first, QA pair matching can be performed, and if the corresponding question Q is matched, the corresponding answer A is directly returned as the answer text.
[0016] In step S102, if the answer text does not match, in step S103, the drug manual can be further matched, and the drug manual corresponding to the drug name included in the query is found, and related drug knowledge is searched from the corresponding drug manual and returned to the user. Usually, the content of the drug manual is large, and only the drug knowledge related to the query can be returned to the user through the search. For example, when the user inputs "What are the side effects of this medicine?", only the paragraph about side effects in the drug manual needs to be extracted as the instruction text, thereby realizing accurate matching.
[0017] The present disclosure combines two methods, namely, searching question answer text and searching drug instruction manual paragraphs. By searching question answer text, answers related to user queries can be quickly and accurately searched. When no exact answers are found, drug instruction manual paragraphs can be searched as supplements, ensuring the recall rate of the question and answer system and improving the system's answer accuracy rate and recall rate.
[0018] As an optional embodiment, in step S102 of searching the question answer text in the drug knowledge base based on the drug question text and obtaining the answer text corresponding to the drug question text, a conventional search algorithm, such as the TF-IDF algorithm, or a vector search method may be selected. The most relevant content is reproduced by calculating the cosine similarity between the user query vector and the content vector of the drug instruction manual, for example, by calculating the similarity based on the query and the Q in the QA library, sorting according to the similarity score, and selecting the top 5 QA pairs with the highest similarity score, thereby achieving accurate matching to the user question.
[0019] As an optional embodiment, in step S102, before searching the question answer text in the pharmaceutical knowledge base based on the pharmaceutical question text, as shown in FIG. The method further includes a step S101a of rewriting the medicine question text.
[0020] Specifically, as shown in FIG. 2, the pharmaceutical knowledge question and answer method in this embodiment is as follows: A step S101 of acquiring a pharmaceutical question text; A step S101a of rewriting the drug question text; Step S102: searching for a question answer text in the drug knowledge base based on the rewritten drug question text to obtain a corresponding answer text; Step S103: searching for drug instructions in the drug knowledge base based on the rewritten drug question text to obtain the corresponding instruction text; and step S104 of generating a response text corresponding to the rewritten drug question text based on the answer text and the instruction text.
[0021] When users query for drug information, they may use various languages and expression methods to describe their needs, such as "What is the best medicine for headaches?" or "What are the side effects of this medicine?". In conventional natural language processing techniques, the user query needs to be subjected to operations such as word splitting and stop word removal, or rewritten according to pre-set rules. In this embodiment, this can be realized by using the prompt word technology of a large language model (LLM). The specific method is to assemble the context history dialogue information queried by the user and the question entered by the user this time into a complete context dialogue, and then use the dialogue content and the prompt word request as inputs to the LLM to make the model generate a more standard user query (including information such as specific drug names and specific user intentions) (i.e., the rewritten drug question text), and ensure that the rewritten query has the same semantics as the current query. Rewriting into the drug question text helps the system understand the drug question text entered by the user, thereby improving the accuracy of the question-answering system.
[0022] In an optional embodiment, rewriting the medicine query text comprises: This includes obtaining historical dialogue information related to the drug question text, and rewriting the drug question text based on the drug information in the historical dialogue information.
[0023] Specifically, the present disclosure provides a method for rewriting a user query, which supplements the user's final query with drug information through context information from multiple rounds of dialogue, for example, if the user queries "What is the best medicine for headaches?" in the first round of dialogue and learns that the medicine is ibuprofen, the current user query "What are the side effects of this medicine?" is rewritten to "What are the side effects of ibuprofen?", thereby improving the accuracy rate of the question-answering system. Then, the user's natural language query is converted into a machine-understandable format through methods such as entity recognition, thereby improving the accuracy rate of the query.
[0024] As an optional embodiment, in step S103, searching for drug instructions in the drug knowledge base based on the drug question text and obtaining the instruction text corresponding to the drug question text can be performed as shown in FIG. A step S1031 of performing entity recognition on the drug question text and acquiring a drug name corresponding to the drug question text; A step S1032 of searching a drug knowledge base by the drug name to obtain a drug instruction manual corresponding to the drug question text; The method includes a step S1033 of extracting and acquiring, from the drug instructions, an instruction text corresponding to the drug question text.
[0025] Specifically, in order to improve the accuracy of the search, the medicine mentioned in the query needs to be entity recognized, and the entity recognition step can be completed during the query rewriting process. The medicine entity is used to filter out content other than this medicine, thereby improving the accuracy of the extracted content. Entity recognition can use traditional Name Entity Recognition (NER) technology, or can use keyword matching to identify the medicine name. The medicine name is identified and obtained, the corresponding medicine instructions are searched for and obtained by the medicine name, and then the instructions text corresponding to the query is extracted and obtained from the medicine instructions. For example, if the drug question text is "What are the side effects of ibuprofen?", in step S1031, the drug question text is subjected to entity recognition to obtain that the drug name is "ibuprofen", in step S1032, the drug instructions for ibuprofen are searched and obtained in the drug knowledge base using the drug name "ibuprofen", and in step S1033, the instructions text regarding "side effects" is extracted and obtained from the drug instructions for ibuprofen to answer the user's question, thereby improving the accuracy of the question-and-answer system.
[0026] In an optional embodiment, performing entity recognition on the medicine question text and obtaining a medicine name corresponding to the medicine question text includes: The method includes obtaining a drug name corresponding to the drug question text by scanning a two-dimensional code corresponding to the drug packaging box or by identifying characters in the acquired image of the drug packaging box.
[0027] In the present disclosure, the digital human can provide vivid answers to the user's questions about medicines. For example, when the user uses a mobile phone to scan the two-dimensional code on the medicine packaging box, the mobile phone will display a digital human with some usage instructions. When the user enters a question about the medicine into a dialogue box, the digital human will provide answers, making it easy for the user to use.
[0028] As an optional embodiment, in step S1033, extracting and obtaining the instruction text corresponding to the drug question text from the drug instruction manual can be performed as shown in FIG. A step S1033a of identifying the intention of the medicine question text and obtaining an intention identification result; and step S1033b of extracting corresponding instruction text from the medicine instruction manual based on the intention identification result.
[0029] In this disclosure, machine learning technology is used to classify the intent of a user query, where the intent can be divided into multiple categories, such as dosage and administration, interactions, basic information, adverse reactions, contraindications, efficacy, and precautions, and the role of intent identification is to determine which part of the content of the drug instructions the user's query intent belongs to, and then locate and search the corresponding part, thereby improving the accuracy and efficiency of the search. For example, if a user queries "What are the side effects of this medicine?", the part "adverse reactions" in the drug instructions will be searched.
[0030] Specifically, the intent classification model adopts a general-purpose text classification model, such as a CNN (Convolutional Neural Network), an RNN (Recurrent Neural Network), or a Transformer model, connects a softmax layer to the output layer, calculates the cross-entropy loss, and then optimizes the model using gradient descent to complete model training.
[0031] In an optional embodiment, in step S1032, searching the drug knowledge base by the drug name to obtain the drug instructions corresponding to the drug question text includes: Calculating the similarity based on the drug name corresponding to the drug question text and each drug description in the drug knowledge base, and obtaining the most similar drug description; In step S1033, extracting and acquiring the instruction text corresponding to the drug question text from the drug instruction manual is This includes selecting the corresponding instruction text from the medicine instructions having the highest similarity according to the intention identification result.
[0032] In this embodiment, step S103 identifies the drug name, calculates the similarity score according to the drug name and the drug name in the drug instruction manual, and selects the drug instruction manuals of the top 5 drugs with the highest similarity score by sorting according to the similarity score. The principle of similarity cannot guarantee that the searched drug instruction manual and the drug in the user query are the same drug, so filtering is required. Traverse the top 5 drug instruction manuals and determine whether the drug name in the user query is a substring of the drug name in the drug instruction manual. If so, it is considered to be the same drug, the content of the drug instruction manual is reserved, and the traversal is stopped; otherwise, the content of the drug instruction manual is discarded. When a drug instruction manual is searched, the instruction manual text corresponding to the intent of the query can be reserved based on the intent of the query.
[0033] For example, as shown in FIG. 5, the complete evidence search flow in this embodiment includes: in step S101, after obtaining the drug question text, the system searches and obtains the evidence text through two parallel branches: the first branch is a branch for searching the QA library and obtaining the top 5 QA pairs with the highest similarity scores in step S102; and the second branch is a branch for searching the drug instructions and obtaining the corresponding instructions text in step S103.
[0034] Step S103 shown in FIG. 5 specifically includes step S1031 of identifying the drug name, then step S1032 of searching for the corresponding drug instructions based on the drug name, and step S1033 of extracting the drug instructions and obtaining the corresponding instructions text according to the user's intention.
[0035] Step S1032 shown in FIG. 5 further includes step S1032a of traversing the Top 5 drug instructions and filtering the drug instructions, step S1032b of determining whether the drug name in the user query is a substring of the drug name in the drug instructions, and if so, it is considered to be the same drug, the content of the drug instructions is retained, and the traversal stops, and step S1032c of the system returning the matched drug instructions.
[0036] As an optional embodiment, in step S104, generating a response text corresponding to the drug question text based on the answer text and the instruction text can be performed as follows, as shown in FIG. Step S104a of combining the answer text and the instruction text to obtain evidence text; Step S104b of constructing a prompt text (prompt) according to the drug question text, the evidence text and the text format requirements; and step S104c of inputting the prompt text into a large-scale language model and outputting and generating a response text corresponding to the medicine question text by the large-scale language model.
[0037] In steps S102 and S103, after retrieving the answer text and the instruction text respectively, in this embodiment, in step S104a, the QA pair and the content of the retrieved drug instruction manual are combined to obtain the final evidence text, and further, in step S104b, a prompt is constructed based on the combined evidence text, and in step S104c, the prompt is input into a large-scale language model, and the large-scale language model outputs a response text based on the prompt, thereby improving the answer accuracy and recall of the question and answer system.
[0038] Specifically, prompt construction is a relatively skillful part. Proper construction of prompts can reduce the illusion of LLM's answers and improve the accuracy of answers. In the pharmaceutical Q&A scene, the accuracy of answers must be fully considered to avoid harming users. Therefore, to better utilize the capabilities of large-scale language models, the inventors have introduced a one-shot mode, relying on the carrier of json format to structure thoughts, strengthen logic, and improve the accuracy of answers of large-scale models.
[0039] In step S104b, the main basis for constructing the prompt is three parts: the user query after rewriting, the evidence text obtained by searching, and the format request for the text output by the question-and-answer system. Here, the first part, query rewriting and drug name identification: It is necessary to determine whether to use the history dialogue. If the answer depends on the history dialogue, the history_use field is true, and considering the context reference, the regenerated question is placed in the query_rephrase field, the analysis is placed in the history_use_reason field, and the drug name of the current query is placed in the drug_name field. The second part, evidence understanding and answer: The answer content is placed in the response field, the cited search evidence points are placed in the cite_list list field, the cite_content field stores the quoted content of each paragraph (the number of omitted characters in it can be replaced by an ellipsis), and reason_for_cite is used to store the thoughts and analysis of citing the content of this paragraph. If the reference evidence provided is irrelevant to the question, it is placed in the unrelevant field, and the reason is explained. The format request of the third part may adopt a one-shot mode: the overall idea is to provide a return example to the large-scale language model, which corresponds to the above description, and the exemplary output format is as follows: { “history_use”: “true / false”, “query_rephrase”: “xxxx”, ”history_use_reason”:”xxxx”, "unrelevant": "xxxx", ``cite_use'': ``true / false'', ”cite_list”:[ {”cite_content”:”[1]xxxx”,”reason_for_cite”:”The content of this paragraph refers to xxxx, which can answer the question posed”} ], ”response”:”Answer content” }
[0040] The above steps include: whether to use history dialogue, what is the regenerated query, analysis to regenerate the query, what is the reference evidence provided that is unrelated to the question, whether to cite evidence, what search evidence points the risk includes, what content to cite, thoughts and analysis citing the content of this paragraph, and answering the query. The construction of the prompt can allow the large-scale language model to better understand the user's question and generate more understandable text to answer the user's question.
[0041] In an optional embodiment, before searching the question answer text in the pharmaceutical knowledge base based on the pharmaceutical question text in step S102, The method further includes parsing the question and answer data as question and answer text and storing the same in a pharmaceutical knowledge base.
[0042] Specifically, before using the question-and-answer system, the database needs to be preprocessed to obtain a drug knowledge base. The present disclosure uses natural language processing technology to structure and process the drug instructions, extract key information such as the drug name, ingredients, indications, dosage and administration, and adverse reactions, and store them in a database. In particular, the unstructured drug instructions text is structured and processed according to rules such as keywords such as the drug name and drug ingredients, and the text structure of these keywords (e.g., in the first line of a paragraph), and stored in the database. In addition, in order to improve the generalization ability of the question-and-answer system, the question-and-answer data is comprehensively analyzed into <question, answer> pairs (i.e., QA pairs), stored in a database, and a drug knowledge base is constructed.
[0043] The present disclosure further provides a pharmaceutical knowledge question and answer apparatus 700, as shown in FIG. 7, which comprises: An acquisition module 701 configured to acquire a medicine question text; A first search module 702 configured to search a question answer text in a medicine knowledge base according to the medicine question text, and obtain an answer text corresponding to the medicine question text; A second search module 703 configured to search a drug instruction manual in the drug knowledge base based on the drug question text, and obtain an instruction manual text corresponding to the drug question text; and a generating module 704 configured to generate a response text corresponding to the medicine question text based on the answer text and the instruction text.
[0044] Specifically, the pharmaceutical question text in this embodiment refers to a query input by a user, such as "What is the best medicine for headaches?", "What are the side effects of this medicine?", etc. The question answer text refers to a QA pair, and each QA pair includes a question and a corresponding answer. For example, for the question "What are the side effects of ibuprofen?", the corresponding answer is "The side effects of ibuprofen can cause gastrointestinal disorders such as nausea, vomiting, abdominal pain, burning sensation, and mild indigestion, gastrointestinal ulcers, bleeding, and sometimes rash, hives, urticaria, etc." The first search module 702 can first perform QA pair matching, and if the corresponding question Q is matched, the corresponding answer A is directly returned as the answer text.
[0045] In the first search module 702, if the answer text cannot be matched, the second search module 703 can further match the drug manual, find the drug manual corresponding to the drug name included in the query, search for related drug knowledge from the corresponding drug manual, and return it to the user. Usually, the content of the drug manual is large, and only the drug knowledge related to the query can be returned to the user through the search. For example, when the user inputs "What are the side effects of this medicine?", only the paragraph about side effects in the drug manual needs to be extracted as the instruction text, thereby realizing accurate matching.
[0046] The present disclosure combines two methods, namely, searching question answer text and searching drug instruction manual paragraphs. By searching question answer text, answers related to user queries can be quickly and accurately searched. When an exact answer cannot be matched, drug instruction manual paragraphs can be searched as supplements, thereby ensuring the recall rate of the question and answer system and improving the system's answer accuracy rate and recall rate.
[0047] As an optional embodiment, in the first search module 702, which searches the question answer text in the drug knowledge base based on the drug question text and obtains the answer text corresponding to the drug question text, a conventional search algorithm, such as the TF-IDF algorithm, may be selected, or a vector search method may be selected. The most relevant content is reproduced by calculating the cosine similarity between the user query vector and the content vector of the drug instruction manual, for example, by calculating the similarity based on the query and the Q in the QA library, sorting according to the similarity score, and selecting the top 5 QA pairs with the highest similarity score, thereby achieving accurate matching to the user question.
[0048] As an optional embodiment, as shown in FIG. 8, the drug knowledge question and answer apparatus 700 further includes: The pharmaceutical system further includes a rewriting module 705 configured to rewrite the pharmaceutical question text before searching for the question answer text in the pharmaceutical knowledge base based on the pharmaceutical question text.
[0049] Specifically, when users query for drug information, they use various languages and expression methods to describe their needs, such as "What is the best medicine for headaches?" or "What are the side effects of this medicine?". In conventional natural language processing technology, the user query needs to be subjected to operations such as word splitting and stop word removal, or rewritten according to pre-set rules. In this embodiment, this can be realized by the prompt word technology of the large-scale language model. The specific method is to assemble the context history dialogue information queried by the user and the question entered by the user this time into a complete context dialogue, and then use the dialogue content and the prompt word request as inputs to the LLM to generate a more standard user query (i.e., the rewritten drug question text), which includes information such as a specific drug name and a specific user intent, and ensure that the rewritten query has the same semantics as the current query. Rewriting the drug question text helps the system understand the drug question text entered by the user, thereby improving the accuracy of the question-answering system.
[0050] In an optional embodiment, rewriting the medicine query text in the rewriting module 705 includes: This includes obtaining historical dialogue information related to the drug question text, and rewriting the drug question text based on the drug information in the historical dialogue information.
[0051] Specifically, the present disclosure provides a method for rewriting a user query, which supplements the user's final query with drug information through context information from multiple rounds of dialogue, for example, if the user queries "What is the best medicine for headaches?" in the first round of dialogue and learns that the medicine is ibuprofen, the current user query "What are the side effects of this medicine?" is rewritten to "What are the side effects of ibuprofen?", thereby improving the accuracy rate of the question-answering system. Then, the user's natural language query is converted into a machine-understandable format through methods such as entity recognition, thereby improving the accuracy rate of the query.
[0052] As an optional embodiment, as shown in FIG. 9, the second search module 703: An entity recognition unit 7031 configured to perform entity recognition on the medicine question text and obtain a medicine name corresponding to the medicine question text; A search unit 7032 configured to search a drug knowledge base according to a drug name to obtain a drug description corresponding to the drug query text; and a text extraction unit 7033 configured to extract and obtain instruction text corresponding to the drug question text from the drug instruction manual.
[0053] Specifically, in order to improve the accuracy of the search, the medicine mentioned in the query needs to be entity recognized, and the step of entity recognition can be completed during the query rewriting process. The medicine entity is used to filter out contents other than the medicine, thereby improving the accuracy of the extracted contents. The entity recognition may use traditional NER technology, or may use keyword matching to identify the medicine name. The medicine name is identified and obtained, the corresponding medicine instruction manual is searched and obtained by the medicine name, and then the instruction text corresponding to the query is extracted and obtained from the medicine instruction manual. For example, the medicine question text is "What are the side effects of ibuprofen?", the entity recognition unit 7031 performs entity recognition on the medicine question text, obtains that the medicine name is "ibuprofen", the search unit 7032 searches and obtains the medicine instruction manual for ibuprofen in the medicine knowledge base with the medicine name "ibuprofen", and the text extraction unit 7033 extracts and obtains the instruction text for "side effects" from the medicine instruction manual for ibuprofen to answer the user's question, thereby improving the accuracy of the question-and-answer system.
[0054] As an optional embodiment, in the entity recognition unit 7031, performing entity recognition on the medicine question text and obtaining a medicine name corresponding to the medicine question text is: The method includes obtaining a drug name corresponding to the drug question text by scanning a two-dimensional code corresponding to the drug packaging box or by identifying characters in the acquired image of the drug packaging box.
[0055] In the present disclosure, the digital human can provide lively answers to the user's questions about medicines. For example, when a user uses a mobile phone to scan the two-dimensional code on a medicine packaging box, a digital human will appear on the mobile phone with some usage instructions. The user can enter questions about the medicine into a dialogue box, and the digital human will provide answers.
[0056] In an optional embodiment, as shown in FIG. 10, the text extraction unit 7033 includes: An intent identification subunit 7033a configured to perform intent identification on the medicine question text and obtain an intent identification result; and an extraction subunit 7033b configured to extract corresponding instruction text from the medicine instruction manual according to the intention identification result.
[0057] In this disclosure, machine learning technology is used to classify the intent of a user query, where the intent can be divided into multiple categories, such as dosage, interactions, basic information, adverse reactions, contraindications, efficacy, and precautions, and the role of intent identification is to determine which part of the content of the drug instructions the user's query intent belongs to, and locate and search the corresponding part. For example, if a user queries "What are the side effects of this drug?", the part "adverse reactions" in the drug instructions will be searched.
[0058] Specifically, the intent classification model may adopt a general-purpose text classification model, such as a CNN, RNN, Transformer, etc., and by connecting a softmax layer to the output layer and calculating the cross-entropy loss, the model can be optimized by gradient descent to complete model training.
[0059] As an optional embodiment, in the searching unit 7032, searching the drug knowledge base by the drug name to obtain the drug instructions corresponding to the drug query text is Calculating a similarity based on the drug name corresponding to the drug question text and each drug description in the drug knowledge base, and obtaining the drug description with the highest similarity; In the text extraction unit 7033, extracting and acquiring the instruction text corresponding to the drug question text from the drug instruction manual is This includes selecting the corresponding instruction text from the medicine instructions having the highest similarity according to the intention identification result.
[0060] In this embodiment, the search unit 7032 identifies the drug name, calculates the similarity score according to the drug name and the drug name in the drug instruction manual, and selects the drug instruction manuals of the top 5 drugs with the highest similarity score by sorting according to the similarity score. The principle of similarity cannot guarantee that the searched drug instruction manual and the drug in the user query are the same drug, so filtering is required. Traverse the top 5 drug instruction manuals and determine whether the drug name in the user query is a substring of the drug name in the drug instruction manual. If so, it is considered to be the same drug, the content of the drug instruction manual is reserved, and the traversal is stopped; if not, the content of the drug instruction manual is discarded. When the drug instruction manual is searched, the text extraction unit 7033 only needs to extract the instruction text corresponding to the intent of the query based on the intent of the query and reserve it.
[0061] In an optional embodiment, as shown in FIG. 11, the generation module 704 may include: a combination unit 704a configured to combine the answer text and the instruction text to obtain an evidence text; A prompt text constructing unit 704b configured to construct a prompt text according to the medicine question text, the evidence text and the format requirements of the text; and a generating unit 704c configured to input the prompt text into the large-scale language model, and generate, by the large-scale language model, an answer text corresponding to the medicine question text as an output.
[0062] After the first search module 702 and the second search module 703 respectively search for the answer text and the instruction text, in this embodiment, the system uses a combination unit 704a to combine the QA pair with the content of the searched drug instruction manual to obtain a final evidence text, and then a prompt text construction unit 704b constructs a prompt based on the combined evidence text, and a generation unit 704c inputs the prompt into a large-scale language model, and the large-scale language model outputs a response text based on the prompt, thereby improving the answer accuracy and recall of the question and answer system.
[0063] Specifically, prompt construction is a relatively skillful part. Proper construction of prompts can reduce the illusion of LLM's answers and improve the accuracy of answers. In the pharmaceutical Q&A scene, the accuracy of answers must be fully considered to avoid harming users. Therefore, to better utilize the capabilities of large-scale language models, the inventors have introduced a one-shot mode, relying on the carrier of json format to structure thoughts, strengthen logic, and improve the accuracy of answers of large-scale models.
[0064] The main basis of the specific method of constructing prompts is three parts: the user query after rewriting, the evidence text obtained by searching, and the format request for the text output by the question-and-answer system. Here, the first part, query rewriting and drug name identification: It is necessary to determine whether to use the history dialogue. If the answer depends on the history dialogue, the history_use field is true, and the regenerated question is placed in the query_rephrase field, the analysis is placed in the history_use_reason field, and the drug name of the current query is placed in the drug_name field, taking into account the context reference. The second part, evidence understanding and answer: The answer content is placed in the response field, the cited search evidence points are placed in the cite_list list field, the cite_content field stores the quoted content of each paragraph (the number of omitted characters in it can be replaced by an ellipsis), and reason_for_cite is used to store the thoughts and analysis of citing the content of this paragraph. If the reference evidence provided is irrelevant to the question, it is placed in the unrelevant field, and the reason is explained. The format request of the third part may adopt a one-shot mode: the overall idea is to provide a return example to the large-scale language model, which corresponds to the above description, and the exemplary output format is as follows: { “history_use”: “true / false”, “query_rephrase”: “xxxx”, ”history_use_reason”:”xxxx”, "unrelevant": "xxxx", ``cite_use'': ``true / false'', ”cite_list”:[ {”cite_content”:”[1]xxxx”,”reason_for_cite”:”The content of this paragraph refers to xxxx, which can answer the question posed”} ], ”response”:”Answer content” }
[0065] The above steps include: whether to use history dialogue, what is the regenerated query, analysis to regenerate the query, what is the reference evidence provided that is unrelated to the question, whether to cite evidence, what search evidence points the risk includes, what content to cite, thoughts and analysis citing the content of this paragraph, and answering the query. The construction of the prompt can allow the large-scale language model to better understand the user's question and generate more understandable text to answer the user's question.
[0066] As an optional embodiment, the pharmaceutical knowledge query apparatus 700 further comprises: The first search module 702 includes a data processing module configured to analyze the question and answer data as a question and answer text and store it in the drug knowledge base before searching the question and answer text in the drug knowledge base based on the drug question text.
[0067] Specifically, before using the question-and-answer system, the database needs to be preprocessed to obtain a drug knowledge base. The present disclosure uses natural language processing technology to structure and process the drug instructions, extract key information such as the drug name, ingredients, indications, dosage and administration, and adverse reactions, and store them in a database. In particular, the unstructured drug instructions text is structured and processed according to rules such as keywords such as the drug name and drug ingredients, and the text structure of these keywords (e.g., in the first line of a paragraph), and stored in the database. In addition, in order to improve the generalization ability of the question-and-answer system, the question-and-answer data is comprehensively analyzed into <question, answer> pairs (i.e., QA pairs), stored in a database, and a drug knowledge base is constructed.
[0068] In the technical solution disclosed herein, the acquisition, storage and application of relevant user personal information shall conform to the provisions of relevant laws and regulations and shall not violate public order and good customs.
[0069] According to an embodiment of the present disclosure, the present disclosure further provides an electronic device, a readable storage medium, and a computer program product.
[0070] 12, a schematic block diagram of an exemplary electronic device 1200 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computing devices, such as laptop computers, desktop computers, stages, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, mobile phones, intelligent phones, wearable devices, and other similar computing devices. The components, their connections, and their functions shown herein are merely exemplary and are not intended to limit the implementation of the present disclosure as described and / or claimed herein.
[0071] As shown in Fig. 12, the device 1200 includes a computing unit 1201, which can perform various suitable operations and processes according to a computer program stored in a read-only memory (ROM) 1202 or loaded from a storage unit 1208 into a random access memory (RAM) 1203. The RAM 1203 may further store various programs and data necessary for operating the device 1200. The computing unit 1201, the ROM 1202 and the RAM 1203 are connected to each other via a bus 1204. An input / output (I / O) interface 1205 is also connected to the bus 1204.
[0072] Several components in the device 1200 are connected to an I / O interface 1205, including an input unit 1206, e.g. a keyboard, a mouse, etc., an output unit 1207, e.g. various types of displays, speakers, etc., a storage unit 1208, e.g. a magnetic disk, an optical disk, etc., and a communication unit 1209, e.g. a network card, a modulator-demodulator, a wireless communication transceiver, etc. The communication unit 1209 enables the device 1200 to exchange information / data with other devices via a computer network, e.g. the Internet, and / or various telecommunication networks.
[0073] The computing unit 1201 may be various general-purpose and / or special-purpose processing components having processing and computing capabilities. Some examples of the computing unit 1201 may 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 for executing machine learning objective function algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 1201 executes each of the methods and processes described above, such as the drug knowledge questioning method. For example, in some embodiments, the drug knowledge questioning method may be implemented as a computer software program and tangibly included in a machine-readable medium, such as the storage unit 1208. In some embodiments, some or all of the computer program may be loaded and / or installed in the device 1200 via the ROM 1202 and / or the communication unit 1209. When the computer program is loaded into the RAM 1203 and executed by the computing unit 1201, one or more steps of the drug knowledge questioning method described above may be executed. Alternatively, in another embodiment, the computing unit 1201 may be configured (eg, by firmware) to execute the drug knowledge questioning method in any other suitable manner.
[0074] Various embodiments of the systems and techniques described herein above may be implemented in digital electronic circuitry 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), software hardware, firmware, software, and / or combinations thereof. These various embodiments may include: embodied in one or more computer programs that may be executed and / or interpreted by a programmable system including at least one programmable processor, which may be a special purpose or general purpose programmable processor, and may receive data and instructions from and transmit data and instructions to a storage system, at least one input device, and at least one output device;
[0075] The program codes for implementing the methods 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 apparatus, so that when the program codes are executed by the processor or controller, the functions / operations specified in the flowcharts and / or block diagrams are performed. The program codes may be fully executed on a machine, partially executed on a machine, partially executed on a machine and partially executed on a remote machine as a separate software package, or fully executed on a remote machine or server.
[0076] In the context of this disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use in or in conjunction with an instruction execution system, apparatus, or device. 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, apparatus, or device, or any suitable combination of the above. More specific examples of machine-readable storage media include an electrical connection by one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0077] To provide interaction with a user, the systems and techniques described herein may be implemented in a computer having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user, and a keyboard and pointing device (e.g., a mouse or trackball) by which the user may provide input to the computer. Other types of devices may also be provided for providing interaction with a user. For example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback), and input from the user may be received in any form (including audio input, voice input, tactile input).
[0078] The systems and techniques described herein may be implemented in a computing system including background components (e.g., a data server), a computing system including middleware components (e.g., an application server), a computing system including front-end components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with embodiments of the systems and techniques described herein), or any combination of such background, middleware, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communications network). Examples of communications networks include a local area network (LAN), a wide area network (WAN), and the Internet.
[0079] The computer system may include a client and a server. The client and the server are generally remote from each other and usually interact with each other via a communication network. The client-server relationship is created by executing computer programs in the corresponding computers that have a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
[0080] It should be understood that steps may be reordered, added, or removed using the various types of flows shown above, for example, the steps described in this disclosure may be performed in parallel, sequentially, or in a different order, and the present disclosure is not limited thereto as long as the technical solution of the present disclosure can achieve the desired results.
[0081] The above-mentioned specific embodiments do not constitute limitations on the scope of protection of the present disclosure. It should be understood that those skilled in the art can make various modifications, combinations, sub-combinations and substitutions according to design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principle of the present disclosure should be included in the scope of protection of the present disclosure.
Claims
1. A pharmaceutical knowledge question and answer method, the method comprising: Obtaining a pharmaceutical question text; Searching for a question answer text in a pharmaceutical knowledge base based on the pharmaceutical question text to obtain an answer text corresponding to the pharmaceutical question text; Searching for drug instructions in the drug knowledge base based on the drug question text to obtain an instruction text corresponding to the drug question text; A pharmaceutical knowledge question and answer method comprising: generating a response text corresponding to the pharmaceutical question text based on the answer text and the instruction text.
2. Before searching for a question answer text in a pharmaceutical knowledge base based on the pharmaceutical question text, The method of claim 1 , further comprising rewriting the medication query text.
3. Rewriting the pharmaceutical question text includes: The method of claim 2 , comprising obtaining historical dialogue information related to the drug question text and rewriting the drug question text based on drug information in the historical dialogue information.
4. Searching for drug instructions in the drug knowledge base based on the drug question text to obtain an instruction text corresponding to the drug question text, performing entity recognition on the medicine question text to obtain a medicine name corresponding to the medicine question text; Searching the drug knowledge base by the drug name to obtain a drug description corresponding to the drug question text; and extracting and obtaining the instruction text corresponding to the drug question text from the drug instruction manual.
5. The drug question text is subjected to entity recognition, and a drug name corresponding to the drug question text is obtained. The method according to claim 4, further comprising: obtaining a drug name corresponding to the drug question text by scanning a two-dimensional code corresponding to the drug packaging box or by identifying characters in the acquired image of the drug packaging box.
6. Extracting and acquiring the instruction text corresponding to the drug question text from the drug instruction manual, Purpose-identifying the medicine question text and obtaining a purpose-identification result; The method of claim 4 , further comprising: extracting the corresponding instruction text from the pharmaceutical instruction manual according to the intention identification result.
7. searching the drug knowledge base by the drug name and obtaining a drug description corresponding to the drug question text; Calculating a similarity based on the drug name corresponding to the drug question text and each drug description in the drug knowledge base, and obtaining the drug description with the highest similarity; Extracting and acquiring the instruction text corresponding to the drug question text from the drug instruction manual, The method of claim 6 , further comprising: selecting the corresponding instruction text from the pharmaceutical instruction text with the highest similarity according to the intention identification result.
8. generating a response text corresponding to the pharmaceutical question text based on the answer text and the instruction text; Combining the answer text and the explanation text to obtain a proof text; constructing a prompt text according to the drug question text, the evidence text and a text format requirement; 2. The method of claim 1, further comprising: inputting the prompt text into a large-scale language model; and generating, as output, the response text corresponding to the pharmaceutical question text through the large-scale language model.
9. Before searching for a question answer text in a pharmaceutical knowledge base based on the pharmaceutical question text, The method of claim 1 , further comprising parsing question and answer data as the question and answer text and storing it in the pharmaceutical knowledge base.
10. A pharmaceutical knowledge question and answer device, an acquisition module configured to acquire a pharmaceutical question text; A first search module configured to search a question answer text in a pharmaceutical knowledge base based on the pharmaceutical question text to obtain an answer text corresponding to the pharmaceutical question text; A second search module configured to search a drug instruction manual in the drug knowledge base based on the drug question text to obtain an instruction manual text corresponding to the drug question text; A pharmaceutical knowledge question and answer apparatus comprising: a generating module configured to generate a response text corresponding to the pharmaceutical question text based on the answer text and the instruction text.
11. The apparatus of claim 10 , further comprising a rewriting module configured to rewrite the medicine question text before the first search module searches for a question answer text in a medicine knowledge base based on the medicine question text.
12. The rewriting module rewriting the medicine query text comprises: The apparatus of claim 11 , further comprising obtaining historical dialogue information regarding the medicine question text, and rewriting the medicine question text based on medicine information in the historical dialogue information.
13. The second search module: an entity recognition unit configured to perform entity recognition on the medicine question text and obtain a medicine name corresponding to the medicine question text; A search unit configured to search the drug knowledge base according to the drug name to obtain a drug description corresponding to the drug question text; and a text extraction unit configured to extract and obtain the instruction text corresponding to the drug question text from the drug instruction manual.
14. The entity recognition unit performs entity recognition on the medicine question text and obtains a medicine name corresponding to the medicine question text, The device of claim 13, further comprising: acquiring a drug name corresponding to the drug question text by scanning a two-dimensional code corresponding to a drug packaging box or by identifying characters in the acquired image of the drug packaging box.
15. The text extraction unit includes: An intent identification subunit configured to perform intent identification on the medicine question text and obtain an intent identification result; and an extraction subunit configured to extract the corresponding instruction text from the pharmaceutical instruction manual according to the intention identification result.
16. The searching unit searches the drug knowledge base by the drug name to obtain a drug description corresponding to the drug question text. Calculating a similarity based on the drug name corresponding to the drug question text and each drug description in the drug knowledge base, and obtaining the drug description with the highest similarity; The text extraction unit extracts and obtains an instruction text corresponding to the drug question text from the drug instruction manual, The apparatus of claim 15, further comprising: selecting the corresponding instruction text from the pharmaceutical instruction text having the highest similarity according to the intention identification result.
17. The generating module includes: a combination unit configured to combine the answer text and the instruction text to obtain an evidence text; a prompt text constructing unit configured to construct a prompt text according to the medicine question text, the evidence text and a text format requirement; and a generation unit configured to input the prompt text into a large-scale language model and generate, through the large-scale language model, the response text corresponding to the medicine question text.
18. The device according to claim 10, further comprising a data processing module configured to analyze question and answer data as the question answer text and store it in the drug knowledge base before searching for a question answer text in the drug knowledge base based on the drug question text.
19. An electronic device, At least one processor; and a memory communicatively coupled to the at least one processor, wherein: An electronic device, wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform a method according to any one of claims 1 to 9.
20. A non-transitory computer readable storage medium having computer instructions stored thereon, the computer instructions being used to cause a computer to perform the method of any one of claims 1 to 9.
21. 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 9.
Citation Information
Patent Citations
Drug knowledge retrieval method and device
CN117370596A
Drug knowledge question and answer method and device, storage medium and equipment
CN117390162A
Text generation device and text generation method
JP7313757B1
Application of natural language processing to facilitate responses to regulatory questions
WO2023069401A1
Cited By
Data analysis method based on large-scale language model
CN119358682A
Corpus mining method, device and equipment for field large model and medium
CN122412676A
system
JP2026155716A
