Medical question and answer method, device, equipment and product

By selecting relevant candidate knowledge text segments from multiple sources of medical knowledge as search enhanced data, the problem of low accuracy of medical Q&A models in complex problems is solved, and more accurate and reliable reply generation is achieved.

CN120407729APending Publication Date: 2025-08-01ANHUI IFLYHEALTH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510367972.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-26
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

When facing complex medical questions and answers, the existing medical Q&A model has low answer accuracy and is difficult to meet users' health consultation needs.

Method used

Find candidate knowledge text segments related to the input text from multiple medical knowledge sources, enhance data by selecting and retrieval, improve data diversity and reliability, and generate reply text using medical Q&A model.

Benefits of technology

The data is enhanced through the search of diversity and reliability, and the accuracy and reliability of the medical Q&A model to generate reply texts is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120407729A_ABST
    Figure CN120407729A_ABST
Patent Text Reader

Abstract

The invention provides a medical question answering method and device, equipment and a medium, and is applied to the technical field of natural languages. The medical question and answer method comprises the following steps: obtaining a to-be-answered input text; searching medical knowledge related to the input text from a plurality of medical knowledge sources to obtain candidate knowledge text segments respectively corresponding to the plurality of medical knowledge sources; selecting retrieval enhancement data of the input text from the candidate knowledge text segments respectively corresponding to the plurality of medical knowledge sources; and according to the input text and the retrieval enhancement data, generating a reply text corresponding to the input text through the medical question and answer model. Therefore, diversified and reliable retrieval enhancement data are obtained from multiple medical knowledge sources, and the accuracy of the reply text generated by the medical question and answer model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application is applied to the field of natural language technology, and particularly relates to a medical question-answering method, device, equipment and product. Background Art

[0002] With the development of artificial intelligence technology, the application of large language models in the medical field has become increasingly mature and is expected to become an effective tool for patients to easily obtain professional medical guidance at home.

[0003] In related technologies, through a large amount of data in the medical field, a large language model is trained into a medical question-answering model. The medical question-answering model can meet the user's health consultation needs to a certain extent: the user inputs a medical-related question into the medical question-answering model and obtains an answer output by the medical question-answering model.

[0004] However, with the continuous deepening of the application of large language models in the field of medical question answering, the medical question-answering model will face more complex medical problems and more intensive medical knowledge. In this case, the accuracy of the answers generated by the medical question-answering model in the above manner is relatively low. Summary of the Invention

[0005] To solve the above problems, this application proposes a medical question-answering method, device, equipment and product, which can improve the accuracy of answering medical questions through a medical question-answering model.

[0006] The first aspect of this application provides a medical question-answering method, including: obtaining an input text to be answered; searching for medical knowledge related to the input text from multiple medical knowledge sources to obtain candidate knowledge text segments corresponding to the multiple medical knowledge sources respectively; selecting retrieval enhanced data of the input text from the candidate knowledge text segments corresponding to the multiple medical knowledge sources respectively; and generating a reply text corresponding to the input text through a medical question-answering model according to the input text and the retrieval enhanced data.

[0007] In some embodiments, the multiple medical knowledge sources include offline knowledge sources and / or online knowledge sources. The searching for medical knowledge related to the input text from multiple medical knowledge sources to obtain candidate knowledge text segments corresponding to the multiple medical knowledge sources respectively includes: searching for medical knowledge related to the input text in the medical knowledge base corresponding to the offline knowledge source to obtain the candidate knowledge text segment corresponding to the offline knowledge source; and / or, searching for medical knowledge related to the input text in the access address of the online knowledge source to obtain the candidate knowledge text segment corresponding to the online knowledge source.

[0008] In some embodiments, searching for medical knowledge related to the input text in the medical knowledge base corresponding to the offline knowledge source to obtain a candidate knowledge text segment corresponding to the offline knowledge source includes: extracting text features of the input text; determining the similarity between the input text and multiple knowledge text segments in the medical knowledge base according to the text features of the input text and the text features respectively corresponding to the multiple knowledge text segments in the medical knowledge base, where the medical knowledge base includes the multiple knowledge text segments and the text features respectively corresponding to the multiple knowledge text segments; and selecting the candidate knowledge text segment corresponding to the offline knowledge source from the multiple knowledge text segments according to the similarity between the input text and the multiple knowledge text segments.

[0009] In some embodiments, in the medical knowledge base, the multiple knowledge text segments are clustered into multiple clusters. The step of selecting the candidate knowledge text segment corresponding to the offline knowledge source from the multiple knowledge text segments according to the similarity between the input text and the multiple knowledge text segments includes: selecting multiple first knowledge text segments from the multiple knowledge text segments according to the similarity between the input text and the multiple knowledge text segments, where the similarity between the input text and the multiple first knowledge text segments meets a set condition; and selecting the candidate knowledge text segment from the multiple first knowledge text segments according to the clusters where the multiple first knowledge text segments are located.

[0010] In some embodiments, the step of selecting the candidate knowledge text segment from the multiple first knowledge text segments according to the clusters where the multiple first knowledge text segments are located includes: if the number of knowledge text segments belonging to different clusters among the multiple first knowledge text segments is greater than or equal to N, then selecting N knowledge text segments belonging to different clusters as the candidate knowledge text segments from the multiple first knowledge text segments in the order of the similarity between the input text and the multiple first knowledge text segments from high to low, where N is greater than 1; if the number of knowledge text segments belonging to different clusters among the multiple first knowledge text segments is less than N, then selecting the candidate knowledge text segments from the multiple first knowledge text segments in the order of the similarity between the input text and the multiple first knowledge text segments from high to low, and the number of the candidate knowledge text segments is N.

[0011] In some embodiments, the data processing process of the medical knowledge base includes: storing the knowledge data from the offline knowledge source as multiple knowledge text segments in the medical knowledge base corresponding to the offline knowledge source according to the medical knowledge source; generating corresponding titles for the multiple knowledge text segments; extracting features from the multiple knowledge text segments and the titles respectively corresponding to the multiple knowledge text segments to obtain the text features respectively corresponding to the multiple knowledge text segments; and storing the titles respectively corresponding to the multiple knowledge text segments and the text features respectively corresponding to the multiple knowledge text segments in the medical knowledge base.

[0012] In some embodiments, the extracting features from the multiple knowledge text segments and the titles respectively corresponding to the multiple knowledge text segments to obtain the text features respectively corresponding to the multiple knowledge text segments includes: extracting features from the second knowledge text segment and the title of the second knowledge text segment through a first large language model to obtain the output features of the last hidden layer of the first large language model, where the second knowledge text segment is one of the multiple knowledge text segments; and determining the text feature of the second knowledge text segment as the output features.

[0013] In some embodiments, after the extracting features from the multiple knowledge text segments and the titles respectively corresponding to the multiple knowledge text segments to obtain the text features respectively corresponding to the multiple knowledge text segments, the data processing process of the medical knowledge base further includes: clustering the multiple knowledge text segments according to the text features respectively corresponding to the multiple knowledge text segments to obtain multiple clusters.

[0014] In some embodiments, the clustering the multiple knowledge text segments according to the text features respectively corresponding to the multiple knowledge text segments to obtain multiple clusters includes: in the i-th clustering process, determining the clusters to which the multiple knowledge text segments respectively belong according to the text features respectively corresponding to the multiple knowledge text segments and the centroid features respectively corresponding to the multiple clusters, where i is greater than or equal to 1; adjusting the centroid features respectively corresponding to the multiple clusters according to the text features of the knowledge text segments respectively included in the multiple clusters to obtain adjusted centroid features; if the i-th clustering meets the clustering end condition, ending the clustering of the multiple knowledge text segments, otherwise performing the (i + 1)-th clustering according to the adjusted centroid features.

[0015] In some embodiments, finding medical knowledge related to the input text in the access address of the online knowledge source to obtain a candidate knowledge text segment corresponding to the online knowledge source includes: finding medical knowledge related to the input text in the access address to obtain a search result, where the search result includes: a plurality of third knowledge text segments and the degree of relevance between the input text and the plurality of third knowledge text segments; and selecting the candidate knowledge text segment corresponding to the online knowledge source from the plurality of third knowledge text segments according to the degree of relevance between the input text and the plurality of third knowledge text segments and the similarity between the plurality of third knowledge text segments.

[0016] In some embodiments, selecting the candidate knowledge text segment corresponding to the online knowledge source from the plurality of third knowledge text segments according to the degree of relevance between the input text and the plurality of third knowledge text segments and the similarity between the plurality of third knowledge text segments includes: selecting, as the first candidate knowledge text segment corresponding to the online knowledge source, the knowledge text segment with the highest degree of relevance to the input text among the plurality of third knowledge text segments according to the degree of relevance between the input text and the plurality of third knowledge text segments; in the (j + 1)-th selection, determining the similarity between the j-th candidate knowledge text segment corresponding to the online knowledge source and the unselected knowledge text segments among the plurality of third knowledge text segments, where j is greater than or equal to 1; and selecting, as the (j + 1)-th candidate knowledge text segment corresponding to the online knowledge source, the knowledge text segment with the lowest similarity to the j-th candidate knowledge text segment among the unselected knowledge text segments, and repeating the selection multiple times until M candidate knowledge text segments corresponding to the online knowledge source are selected, where M is greater than 1.

[0017] In some embodiments, selecting the retrieval enhancement data for the input text from the candidate knowledge text segments corresponding to the plurality of medical knowledge sources includes: binning the candidate knowledge text segments corresponding to the plurality of medical knowledge sources respectively to obtain a plurality of bins, where each of the plurality of bins contains a plurality of candidate knowledge text segments; sorting the candidate knowledge text segments in the plurality of bins within each bin; and selecting the retrieval enhancement data from the plurality of bins after the within-bin sorting.

[0018] In some embodiments, in the plurality of bins, the candidate knowledge text segments in each bin come from different medical knowledge sources, and binning the candidate knowledge text segments corresponding to the plurality of medical knowledge sources respectively to obtain a plurality of bins includes: for the plurality of medical knowledge sources, dividing the candidate knowledge text segments with the same sorting position in different medical knowledge sources into the same bin to obtain the plurality of bins.

[0019] In some embodiments, the in-bucket sorting of the candidate knowledge text segments in the multiple buckets includes: sorting the candidate knowledge text segments in the multiple buckets from an evaluation dimension by a second large language model, where the evaluation dimension includes at least one of the following: the degree of relevance between the candidate knowledge text segment and the input text, the text quality of the candidate knowledge text segment, and the reliability of the candidate knowledge text segment.

[0020] The second aspect of this application provides a medical Q&A device, including: an acquisition unit configured to acquire an input text to be answered; a search unit configured to search for medical knowledge related to the input text from multiple medical knowledge sources to obtain candidate knowledge text segments respectively corresponding to the multiple medical knowledge sources; a selection unit configured to select retrieval enhancement data for the input text from the candidate knowledge text segments respectively corresponding to the multiple medical knowledge sources; and a reply generation unit configured to generate a reply text corresponding to the input text through a medical Q&A model according to the input text and the retrieval enhancement data.

[0021] The third aspect of this application provides an electronic device, including a memory and a processor; the memory is connected to the processor and is configured to store a program; the processor is configured to implement the medical Q&A method as described in the first aspect or any one of the embodiments of the first aspect by running the program in the memory.

[0022] The fourth aspect of this application provides a chip, including a processor and a data interface, where the processor reads and runs a program stored on a memory through the data interface to execute the medical Q&A method as described in the first aspect or any one of the embodiments of the first aspect.

[0023] The fifth aspect of this application provides a computer program product, including a computer program, where the computer program, when executed by a processor, implements the medical Q&A method as described in the first aspect or any one of the embodiments of the first aspect.

[0024] The sixth aspect of this application provides a storage medium, where a computer program is stored on the storage medium, and when the computer program is run by a processor, it implements the medical Q&A method as described in the first aspect or any one of the embodiments of the first aspect.

[0025] A medical Q&A method, device, equipment and medium proposed according to the present application search for medical knowledge related to the input text from multiple medical knowledge sources, obtain candidate knowledge text segments corresponding to the multiple medical knowledge sources respectively, and select retrieval enhancement data for the input text from these candidate knowledge text segments. While ensuring that the retrieval enhancement data is relevant to the input text, the diversity and reliability of the retrieval enhancement data are improved through multiple medical knowledge sources. After obtaining the retrieval enhancement data, based on the input text and the retrieval enhancement data, a reply text is generated through a medical Q&A model, realizing medical knowledge Q&A based on retrieval enhancement generation technology. Through the retrieval enhancement data with diversity and reliability and the retrieval enhancement generation technology, the accuracy of the reply text is improved. Description of the Drawings

[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required to be used in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained according to the provided drawings.

[0027] Figure 1 It is a schematic diagram of the implementation environment related to the embodiments of the present application;

[0028] Figure 2 It is a flowchart of the medical Q&A method provided by the embodiments of the present application Figure 1 ;

[0029] Figure 3 It is a flowchart of the medical Q&A method provided by the embodiments of the present application Figure 2 ;

[0030] Figure 4 It is a structural example diagram of a re-ranking model based on a cross-encoder;

[0031] Figure 5 It is an example diagram of candidate knowledge text segments corresponding to multiple medical knowledge sources;

[0032] Figure 6 It is an example diagram of bucketing, in-bucket sorting and retrieval enhancement data selection for candidate knowledge text segments corresponding to multiple medical knowledge sources;

[0033] Figure 7 It is a flowchart example diagram of the data processing process of the medical knowledge base provided by the embodiments of the present application;

[0034] Figure 8 It is an example diagram of feature extraction through a first large language model;

[0035] Figure 9 It is a process example diagram for obtaining retrieval-enhanced data from data processing in a medical knowledge base to the medical Q&A process;

[0036] Figure 10 It is a schematic structural diagram of a medical Q&A device provided according to an embodiment of the present application;

[0037] Figure 11 It is a schematic structural diagram of an electronic device provided according to an embodiment of the present application. Detailed implementation manners

[0038] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0039] When dealing with knowledge-intensive tasks in specific fields, large language models gradually show some limitations. For example, large language models may generate inaccurate information, rely on outdated databases, have an opaque reasoning process, and an untraceable reasoning process, etc.

[0040] The retrieval-enhanced generation technology can enhance the ability of large language models to handle complex tasks and is one of the ways to solve the above limitations. Taking the medical Q&A field as an example, the core idea of the retrieval-enhanced generation technology is: retrieve medical materials related to a medical question, use the medical materials as retrieval-enhanced data (such as prompt information) for the medical question, and output them together with the medical question to a large language model for processing.

[0041] For the application of the retrieval-enhanced generation technology in the medical Q&A field, how to obtain better retrieval-enhanced data is one of the key issues to improve the accuracy of the responses generated by large language models.

[0042] The embodiments of the present application propose a medical Q&A method, device, equipment and medium, which search for medical knowledge related to the input text from multiple medical knowledge sources and select retrieval-enhanced data for the input text from the found medical knowledge. On the one hand, it ensures the relevance degree between the retrieval-enhanced data and the input text; on the other hand, through multiple medical knowledge sources, it improves the diversity of the retrieval-enhanced data. Medical knowledge from different medical knowledge sources can complement and verify each other, improving the comprehensiveness, reliability and authority of the retrieval-enhanced data. With retrieval-enhanced data having relevance degree, diversity, comprehensiveness, reliability and authority, it provides a high-quality information basis for the medical Q&A model and improves the accuracy of the response text generated by the medical Q&A model.

[0043] Exemplary implementation environment

[0044] Please refer to Figure 1 , Figure 1 which is a schematic diagram of the implementation environment related to the embodiments of the present application. In the implementation environment related to the present application, it includes a plurality of medical knowledge sources 110 and a medical question-answering device 120, and a medical question-answering model 121 is deployed on the medical question-answering device 120.

[0045] During the medical question-answering process, the medical question-answering device 120 can receive the input text to be answered, search for relevant knowledge of the input text in the plurality of medical knowledge sources 110, and obtain a return result; select retrieval-enhanced data from the return result, and generate a corresponding reply text according to the retrieval-enhanced data and the input text.

[0046] Among them, the medical question-answering device 120 can be a terminal or a server. Figure 1 Taking the medical question-answering device 120 as a server as an example. When the medical question-answering device 120 is a server, the implementation environment may further include a user terminal 130. The medical question-answering device 120 can receive the input text sent by the user terminal 130. The user terminal 130 sends the input text to the medical question-answering device 120. In the medical question-answering device 120, a reply text is generated through the medical question-answering model and output to the user terminal 130.

[0047] Exemplary method

[0048] Please refer to Figure 2 , in an exemplary embodiment, a medical question-answering method is provided. The medical question-answering method includes the following steps:

[0049] S201, obtain the input text to be answered.

[0050] Among them, the input text can be a sentence, a paragraph composed of multiple sentences, multiple paragraphs, a word, or multiple words. For example, the input text is a question asking about the cause and symptoms of a disease. Another example is that the input text is a medical term in the medical field to request an explanation of the term.

[0051] In one example, the input text to be answered sent by the user terminal can be obtained.

[0052] In another example, for the medical question-answering model, it may be necessary to process medical question-answering requests from different users. The medical question-answering requests can be stored in a task list, and the task list contains multiple medical question-answering requests to be executed. The medical question-answering request to be executed next can be obtained from the task list, and the input text to be answered can be obtained from the medical question-answering request.

[0053] In another example, the medical Q&A model is deployed on the user terminal and can obtain the input text of the user. This input text is the input text to be answered, and the user can input it in the form of voice or text.

[0054] S202. Search for medical knowledge related to the input text from multiple medical knowledge sources to obtain candidate knowledge text segments corresponding to the multiple medical knowledge sources respectively.

[0055] Among them, medical knowledge sources can be distinguished according to different carriers of medical knowledge. For example, the multiple medical knowledge sources include newspapers, textbooks, meeting records, industry standards, popular science articles, etc.

[0056] Among them, the medical knowledge related to the input text refers to the medical knowledge that is associated with the input text. For example, the medical knowledge that contains the key information in the input text, or the medical knowledge whose similarity to the input text is greater than a certain similarity threshold.

[0057] Among them, the knowledge text segment refers to a text that is relatively complete in semantics and sentence structure and can independently describe the content of medical knowledge. The candidate knowledge text segment is the candidate text for retrieval-enhanced data.

[0058] In this embodiment, for each medical knowledge source, using the input text as the keyword, search for medical knowledge related to the input text from the knowledge data corresponding to the medical knowledge source. The medical knowledge found is presented as one or more candidate knowledge text segments, that is, one medical knowledge source corresponds to one or more candidate knowledge text segments.

[0059] S203. Select the retrieval-enhanced data of the input text from the candidate knowledge text segments corresponding to the multiple medical knowledge sources respectively.

[0060] Among them, the retrieval-enhanced data may include multiple candidate knowledge text segments. These multiple candidate knowledge text segments are selected from the candidate knowledge text segments corresponding to the multiple medical knowledge sources respectively, and these multiple candidate segments may correspond to at least two medical knowledge sources.

[0061] In this embodiment, the candidate knowledge text segments respectively corresponding to multiple medical knowledge sources vary in performance in multiple dimensions. For example, the text quality is different, the source reliability is different, the degree of relevance to the input text is different, etc. Moreover, there may be candidate knowledge text segments with duplicate content among the candidate knowledge text segments respectively corresponding to multiple medical knowledge sources. One or more candidate knowledge text segments can be selected from the candidate knowledge text segments respectively corresponding to multiple medical knowledge sources from one or more dimensions (such as text quality, source reliability, degree of relevance to the input text, text duplication degree) as the retrieval enhancement data for the input text. Thus, the quality (text quality, accuracy) of the retrieval enhancement data is improved, the diversity of the retrieval enhancement data is increased, and among the retrieval enhancement data, the candidate knowledge text segments from different medical knowledge sources can play a role of mutual supplementation and mutual verification, improving the reliability of the retrieval enhancement data.

[0062] S204. According to the input text and the retrieval enhancement data, generate a response text corresponding to the input text through a medical Q&A model.

[0063] In this embodiment, the retrieval enhancement data can be used as prompt information for the input text and input into the medical Q&A model together with the input text, and a response text corresponding to the input text is generated through the medical Q&A model. Thus, through the retrieval enhancement data, more information related to the input text is provided for the medical Q&A model, improving the accuracy and reliability of the response text generated by the medical Q&A model.

[0064] In the embodiments of the present application, candidate knowledge text segments related to the input text are found from multiple medical knowledge sources, and retrieval enhancement data is selected from these candidate knowledge text segments, improving the diversity, reliability and accuracy of the retrieval enhancement data. Through this retrieval enhancement data, more information related to the input text is provided for the medical Q&A model, improving the accuracy and reliability of the response text generated by the medical Q&A model for the input text.

[0065] In some embodiments, the multiple medical knowledge sources may include offline knowledge sources and / or online knowledge sources. Among them, the following situations may be included: the multiple medical knowledge sources include multiple offline knowledge sources, or the multiple medical knowledge sources include multiple online knowledge sources, or the multiple medical knowledge sources include at least one offline knowledge source and at least one online knowledge source.

[0066] Next, based on the multiple medical knowledge sources including offline knowledge sources and / or online knowledge sources, exemplary embodiments of the medical Q&A method are provided.

[0067] Please refer to Figure 3 , in yet another exemplary embodiment, a medical Q&A method is provided. The medical Q&A method includes the following steps:

[0068] S301, obtain the input text to be answered.

[0069] Among them, S301 can refer to the description of the foregoing embodiments and will not be elaborated here.

[0070] S302, in the medical knowledge base corresponding to the offline knowledge source, search for medical knowledge related to the input text to obtain the candidate knowledge text segments corresponding to the offline knowledge source.

[0071] Among them, the offline knowledge source refers to: a way or resource that can obtain medical knowledge locally without a network connection, or a way or resource that can obtain medical knowledge through a local area network (or private network).

[0072] Among them, the number of offline knowledge sources can be one or more. If the number of offline knowledge sources is multiple, different offline knowledge sources can correspond to different medical knowledge bases. Thus, the knowledge data of multiple offline knowledge sources are stored independently, so that independent data processing and searching can be performed for different offline knowledge sources, and candidate knowledge text segments from different offline knowledge sources can be found for the input text, improving the diversity and reliability of the retrieved enhanced data.

[0073] In one example, the offline knowledge source may include at least one of the following: medical textbooks, medical guidelines (medical guidelines can be clinical trial guidelines), medical product manuals, medical literature (such as research papers, popular science articles, etc.).

[0074] In this embodiment, the medical knowledge base of the offline knowledge source may contain multiple knowledge text segments. Using the input text as the search keyword, search for relevant knowledge of the input text from the multiple knowledge text segments contained in the medical knowledge base to obtain one or more knowledge text segments, and the one or more knowledge text segments are the candidate knowledge text segments corresponding to the offline knowledge source.

[0075] In a possible implementation manner, S302 includes S3021 to S3023: S3021, extract the text features of the input text; S3022, determine the similarity between the input text and multiple knowledge text segments according to the text features of the input text and the text features respectively corresponding to the multiple knowledge text segments in the medical knowledge base, where the medical knowledge base includes multiple knowledge text segments and the text features respectively corresponding to the multiple knowledge text segments; S3023, select the candidate knowledge text segments corresponding to the offline knowledge source from the multiple knowledge text segments according to the similarity between the input text and the multiple knowledge text segments.

[0076] In this implementation manner, feature extraction is performed on the input text to obtain the text features of the input text. The text features of the input text can be feature-matched with the text features corresponding to multiple knowledge text segments in the medical knowledge base to obtain the similarity between the input text and the multiple knowledge text segments. This similarity reflects the degree of relevance between the input text and the multiple knowledge text segments. The higher the similarity, the higher the degree of relevance. Subsequently, using the similarity between the input text and the multiple knowledge text segments as a reference parameter for selecting candidate knowledge text segments, candidate knowledge text segments corresponding to the offline knowledge source are selected from the multiple knowledge text segments, ensuring that candidate knowledge text segments with a relatively high degree of relevance to the input text can be selected from the multiple knowledge text segments, thereby improving the accuracy of the candidate knowledge text segments.

[0077] In one example, S3021 includes: performing feature extraction on the input text through the first large language model to obtain the output features of the last hidden layer of the first large language model, and determining the output features of the last hidden layer as the text features of the input text.

[0078] Among them, the output features of the last hidden layer contain the feature information of all tokens in the token sequence of the input text. Using the output features of the last hidden layer as the text features of the input text improves the accuracy of the text features of the input text.

[0079] Furthermore, the feature extraction of the first large language model includes multiple iterative processes, and the output features of the last hidden layer in the last iteration can be determined as the text features of the input text.

[0080] Optionally, the multiple iterative processes of the first large language model for feature extraction of the input text include: in the i-th iteration, input the input token into the first large language model. If i equals 1, the input token is the first token in the token sequence obtained by tokenizing the input text. If i is greater than 1, the input token is obtained by concatenating the input tokens of the previous i - 1 iterations and the output token in the i-th iteration. In the first large language model, perform feature extraction on the input data through multiple hidden layers to obtain the output features of the last hidden layer of the first large language model. If the i-th iteration is the last iteration (where the total number of iterations is the total number of tokens after tokenizing the input text), then the output features of the last hidden layer can be determined as the text features of the input text. If the i-th iteration is not the last iteration, perform decoding processing on the output features of the last hidden layer to obtain the i-th output token of the first large language model, concatenate the input tokens of the previous i iterations and the i-th output token to obtain the input token in the (i + 1)-th iteration, and continue the (i + 1)-th feature extraction until the output features of the last hidden layer in the last iteration are obtained. Thus, by performing iterative feature extraction multiple times and taking the output features of the last hidden layer in the last iteration as the text features of the input text, the accuracy of text feature extraction is improved.

[0081] In one example, S3022 includes: calculating the cosine similarity between the text features of the input text and the text features corresponding to multiple knowledge text segments in the medical knowledge base. For the multiple knowledge text segments in the medical knowledge base, the similarity between the input text and a knowledge text segment is the cosine similarity between the text features of the input text and the text features of the knowledge text segment. The calculation complexity of the cosine similarity is low. Considering the large data volume of the knowledge text segments in the medical knowledge base, using the cosine similarity with a lower calculation complexity as the similarity between the input text and the knowledge text segment can improve the calculation efficiency of the similarity between the input text and the knowledge text segment, without the need for additional model training, and provides the search efficiency of the knowledge text segments.

[0082] Optionally, the calculation formula for the cosine similarity between the text features of the input text and the text features corresponding to multiple knowledge text segments in the medical knowledge base is expressed as:

[0083]

[0084] where, f q represents the text features of the input text, f text represents the text features of the knowledge text segment in the medical knowledge base, represents the i-th element value in f q , represents the i-th element value in f Text , I represents the vector length of the text features, cos(fq , f text ) represents f q 's cosine similarity with f text .

[0085] Among them, f text ∈KB j , where KB j represents the medical knowledge base corresponding to the jth offline knowledge source.

[0086] In one example, in the medical knowledge base, multiple knowledge text segments are clustered into multiple clusters. S3023 includes: according to the similarity between the input text and multiple knowledge text segments, select multiple first knowledge text segments from multiple knowledge text segments, and the similarity between the input text and multiple first knowledge text segments meets the set conditions; according to the clusters where multiple first knowledge text segments are located, select candidate knowledge text segments from multiple first knowledge text segments. Thus, through two screenings, the relevance between the candidate knowledge text segments and the input text and the diversity of the candidate knowledge are taken into account.

[0087] Among them, the set condition can be to select the top K knowledge text segments arranged in descending order of similarity, where K is the number of first knowledge text segments, and K > 1.

[0088] In this example, multiple knowledge text segments can be sorted in descending order of similarity between the input text and multiple knowledge text segments; from the sorted multiple knowledge text segments, select the first K knowledge text segments as multiple first knowledge text segments to ensure a high degree of relevance between multiple first knowledge text segments and the input text. According to the clusters where multiple first knowledge text segments are located, select knowledge text segments from different clusters as candidate knowledge text segments from multiple first knowledge text segments, improving the diversity of candidate knowledge text segments. Thus, candidate knowledge text segments with a high degree of relevance and diversity to the input text are obtained.

[0089] Optionally, the set condition can also be to select knowledge text segments with a similarity greater than the similarity threshold, and based on this set condition, select the first knowledge text segments from multiple knowledge text segments.

[0090] Optionally, according to the clusters where multiple first knowledge text segments are located, candidate knowledge text segments are selected from the multiple first knowledge text segments, including: if the number of knowledge text segments belonging to different clusters among the multiple first knowledge text segments is greater than or equal to N, then among the multiple first knowledge text segments, N knowledge text segments belonging to different clusters are selected as candidate knowledge text segments in the order of decreasing similarity between the input text and the multiple first knowledge text segments, where N is greater than 1; if the number of knowledge text segments belonging to different clusters among the multiple first knowledge text segments is less than N, then candidate knowledge text segments are selected from the multiple first knowledge text segments in the order of decreasing similarity between the input text and the multiple first knowledge text segments, and the number of candidate knowledge text segments is N. Thus, while ensuring a high degree of relevance between the candidate knowledge text segments and the input text, the diversity of the candidate knowledge text segments is improved.

[0091] As an example, K is 10 and N is 3. For the medical knowledge base corresponding to the j-th offline knowledge source, the multiple knowledge text segments in the medical knowledge base are sorted in the order of decreasing similarity between the input text and the multiple knowledge text segments; among the sorted multiple knowledge text segments, the first 10 knowledge text segments are selected; if there are 3 knowledge text segments belonging to different clusters among the first 10 knowledge text segments, then 3 knowledge text segments belonging to different clusters are selected from the first 10 knowledge text segments to obtain the candidate knowledge text segment E corresponding to the j-th offline knowledge source j ={e1, e2, e3}. In this way, by repeating the above process for multiple offline knowledge sources, candidate knowledge text segments corresponding to multiple offline knowledge sources can be obtained, and the set E composed of candidate knowledge text segments corresponding to multiple offline knowledge sources P can be expressed as: E P ={E 1 , E 2 , ……, E j , ……}, E 1 represents the candidate knowledge text segment corresponding to the first offline knowledge source, and E 1 represents the candidate knowledge text segment corresponding to the second offline knowledge source.

[0092] S303. In the access address of the online knowledge source, medical knowledge related to the input text is searched to obtain the candidate knowledge text segment corresponding to the online knowledge source.

[0093] Among them, the online knowledge source refers to a way or resource that can obtain medical knowledge only through a network connection (a network connection in a wide area network).

[0094] In one example, the access addresses of the online knowledge sources include: the website address of a search website and / or the interface address disclosed by an online large language model (which can be a large language model providing question-and-answer services, and is a different large language model from the medical question-and-answer model in the embodiments of the present application). Thus, relevant content of the input text can be searched on the search website, and / or relevant content of the input text can be collected and sorted through the online large language model, providing rich and selectable online knowledge for the input text.

[0095] Among them, the number of online knowledge sources can be one or more. If the number of online knowledge sources is multiple, then for different online knowledge sources, S303 can be executed separately to obtain candidate knowledge text segments corresponding to each of the multiple online knowledge sources.

[0096] In this embodiment, the access address of the online knowledge source can be accessed through a network connection, and the input text is sent to the access address to search for medical knowledge related to the input text through the services provided by the access address (such as search services, dialogue services, question-and-answer services, etc.), obtaining candidate knowledge text segments corresponding to the online knowledge source.

[0097] In a possible implementation manner, S303 includes S3031 and S3032: S3031, in the access address, search for medical knowledge related to the input text to obtain a search result, where the search result includes: multiple third knowledge text segments and the degree of relevance between the input text and the multiple third knowledge text segments; S3032, according to the degree of relevance between the input text and the multiple third knowledge text segments, and the similarity between the multiple third knowledge text segments, select candidate knowledge text segments corresponding to the online knowledge source from the multiple third knowledge text segments. Thus, starting from the degree of relevance between the input text and the knowledge text segments, select knowledge text segments with a relatively high degree of relevance to the input text, and starting from the similarity between the multiple third knowledge text segments, select diverse knowledge text segments from them to obtain candidate knowledge text segments with a relatively high degree of relevance to the input text and diversity.

[0098] In this implementation manner, knowledge text segments whose degree of relevance to the input text meets a set condition (such as the degree of relevance is greater than the relevance threshold) can be selected from the multiple third knowledge text segments according to the degree of relevance between the input text and the multiple third knowledge text segments; candidate knowledge text segments corresponding to the online knowledge source are selected from the knowledge text segments whose degree of relevance to the input text meets the set condition according to the similarity between the knowledge text segments whose degree of relevance to the input text meets the set condition.

[0099] In one example, S3032 includes: selecting, as the first candidate knowledge text segment corresponding to the online knowledge source, the knowledge text segment with the highest degree of relevance to the input text among multiple third knowledge text segments according to the degree of relevance between the input text and the multiple third knowledge text segments; in the (j + 1)-th selection, determining the similarity between the j-th candidate knowledge text segment corresponding to the online knowledge source and the unselected knowledge text segments among the multiple third knowledge text segments, where j is greater than or equal to 1; selecting, as the (j + 1)-th candidate knowledge text segment corresponding to the online knowledge source, the knowledge text segment with the lowest similarity to the j-th candidate knowledge text segment among the unselected knowledge text segments, and repeating the selection multiple times until M candidate knowledge text segments corresponding to the online knowledge source are selected, where M is greater than 1.

[0100] In this example, for the online knowledge source, the first candidate knowledge text segment is the knowledge text segment with the highest degree of relevance to the input text among the multiple third knowledge text segments. When j equals 1, that is, in the second selection, determine the similarity between the unselected knowledge text segments among the multiple knowledge text segments and the first candidate knowledge text segment. At this time, the unselected knowledge text segments are the remaining knowledge text segments among the multiple knowledge text segments except the first candidate knowledge text segment; search among the unselected knowledge text segments for the knowledge text segment with the lowest similarity to the first candidate knowledge text segment, and select this knowledge text segment as the second candidate knowledge text segment. When j equals 2, that is, in the third selection, determine the similarity between the unselected knowledge text segments among the multiple knowledge text segments and the second candidate knowledge text segment. At this time, the unselected knowledge text segments are the remaining knowledge text segments among the multiple knowledge text segments except the first candidate knowledge text segment and the second candidate knowledge text segment; search among the unselected knowledge text segments for the knowledge text segment with the lowest similarity to the second candidate knowledge text segment, and select this knowledge text segment as the third candidate knowledge text segment. And so on, finally, multiple candidate knowledge text segments corresponding to the online knowledge source can be obtained. On the one hand, it ensures that the multiple candidate knowledge text segments have a high degree of relevance to the input text. On the other hand, starting from the second selection, the knowledge text segment with the lowest similarity is selected each time, improving the diversity of the candidate knowledge text segments.

[0101] For example: First, through a search engine, find 10 pieces of web page data (equivalent to the third knowledge text segments) on the Internet that are most relevant to the input text; then, select the most relevant web page data as the first candidate knowledge text segment corresponding to the online knowledge source, and determine the similarity with the remaining 9 pieces of web page data, and select from the remaining 9 pieces of web page data the one with the lowest similarity as the second candidate knowledge text segment corresponding to the online knowledge source Repeat the above operation to find among the remaining 8 web page data the web page data with the lowest similarity as the third candidate knowledge text segment corresponding to the online knowledge source In this way, the candidate knowledge text segments corresponding to the online knowledge source are obtained:

[0102] In one example, in the (j + 1)-th selection, determine the similarity between the j-th candidate knowledge text segment corresponding to the online knowledge source and the unselected knowledge text segments among multiple third knowledge text segments, including: segment the j-th candidate knowledge text segment to obtain the token sequence of the j-th candidate knowledge text segment; for any unselected knowledge text segment among multiple third knowledge text segments, segment the any unselected knowledge text segment to obtain the token sequence of the any unselected knowledge text segment; splice the token sequence of the j-th candidate knowledge text segment and the token sequence of the any unselected knowledge text segment to obtain the input token sequence; input the input token sequence into a re-ranking model based on a cross-encoder. In the re-ranking model based on a cross-encoder, feature extraction and correlation score calculation are performed on the input token sequence from the perspective of semantic matching degree, and finally a correlation score is output, and this correlation score is the similarity between the j-th candidate knowledge text segment and the any unselected knowledge text segment. Thus, by using the re-ranking model based on a cross-encoder, the accuracy of the similarity measurement between the j-th candidate knowledge text segment and the unselected knowledge text segments among multiple third knowledge text segments is improved.

[0103] Among them, the re-ranking model based on a cross-encoder includes a cross-encoder and a scoring layer. In the cross-encoder, feature extraction is performed on the input token sequence, and during the feature extraction process, the relationship between tokens at different positions in the input token sequence is concerned based on the self-attention mechanism, and the correlation between sentences is captured, and finally a feature vector is output; the feature vector is input into the scoring layer, and after the processing of the scoring layer, the correlation score output by the scoring layer is obtained.

[0104] Optionally, the re-ranking model based on a cross-encoder can adopt a bidirectional encoder representations from transformers (BERT) model of a transformer, or a large language model similar to BERT, to improve the accuracy of re-ranking and encoding the input token sequence. In the re-ranking model based on a cross-encoder, the scoring layer can adopt a classification head to improve the accuracy of scoring.

[0105] For example, Figure 4 is a structural example diagram of the re-ranking model based on a cross-encoder. AsFigure 4 As shown, after concatenating the token sequence of sentence A and the token sequence of sentence B, the result is input into a cross-encoder-based re-ranking model. The cross-encoder-based re-ranking model includes a backbone network similar to a large language model like BERT and a classification head. The backbone network of the large language model like BERT is used to extract features from the data input into the model, obtaining feature vectors. These feature vectors are input into the classification head, and finally, the correlation score between sentence A and sentence B is obtained.

[0106] Optionally, the cross-encoder-based re-ranking model uses the Zhipu General Embedding Re-ranking Large Model (bge-reranker-large), which is a large model for text re-ranking and can improve the accuracy of the similarity measurement between the j-th candidate knowledge text segment and the unselected knowledge text segments.

[0107] S304. Among the candidate knowledge text segments corresponding to multiple medical knowledge sources, select the retrieval enhancement data for the input text.

[0108] In this embodiment, select the retrieval enhancement data for the input text from the candidate knowledge text segments corresponding to the offline knowledge source and / or from the candidate knowledge text segments corresponding to the online knowledge source.

[0109] In a possible implementation, S304 includes: when multiple medical knowledge sources include offline knowledge sources and online knowledge sources, corresponding candidate knowledge text segments can be respectively selected from the candidate knowledge text segments corresponding to the offline knowledge source and the candidate knowledge text segments corresponding to the online knowledge source as the retrieval enhancement data. If there are multiple offline knowledge sources, corresponding candidate knowledge text segments are respectively selected from the candidate knowledge text segments corresponding to each offline knowledge source as the retrieval enhancement data. Thus, the diversity and reliability of the retrieval enhancement data are improved.

[0110] In another possible implementation, S304 includes: S3041. Bucket the candidate knowledge text segments corresponding to multiple medical knowledge sources respectively to obtain multiple buckets, each of which contains multiple candidate knowledge text segments; S3042. Sort the candidate knowledge text segments within the multiple buckets; S3043. Select the retrieval enhancement data from the multiple buckets that have been sorted within the bucket.

[0111] It should be noted that S304 including S3041 to S3043 is also applicable to Figure 2 the embodiment shown, that is Figure 2 "selecting the retrieval enhancement data for the input text among the candidate knowledge text segments corresponding to multiple medical knowledge sources respectively" can also be implemented with reference to S3041 to S3043.

[0112] In this implementation manner, according to the categories corresponding to multiple buckets, the candidate text segments belonging to the same category in the candidate knowledge text segments corresponding to multiple medical knowledge sources can be divided into the same bucket, and multiple buckets containing multiple candidate knowledge text segments are obtained. Then, according to the quality of the candidate knowledge text segments in the multiple buckets, the candidate knowledge text segments in the multiple buckets can be sorted within the bucket. According to the in-bucket sorting and the between-bucket order, retrieval enhancement data is selected from the multiple buckets sorted within the bucket. On the one hand, by selecting retrieval enhancement data from multiple buckets, the diversity and reliability of the retrieval enhancement data are improved; on the other hand, by performing in-bucket sorting, the data quality of the selected retrieval enhancement data is improved, and retrieval enhancement data with higher reliability and better quality can be selected.

[0113] In one example, among the multiple buckets, the candidate knowledge text segments in each bucket come from different medical knowledge sources. S3041 includes: for multiple medical knowledge sources, the candidate knowledge text segments with the same sorting position in different medical knowledge sources are divided into the same bucket to obtain multiple buckets.

[0114] In this example, for each medical knowledge source, among the candidate knowledge text segments corresponding to the medical knowledge source respectively, the candidate knowledge text segments can be sorted according to the degree of relevance (or similarity) to the input text. The candidate knowledge text segments with the same sorting position in different medical knowledge sources can be divided into the same bucket. The candidate knowledge text segment with the first sorting position in the candidate knowledge text segments corresponding to the first medical knowledge source, the candidate knowledge text segment with the first sorting position in the candidate knowledge text segments corresponding to the second medical knowledge source, the candidate knowledge text segment with the first sorting position in the candidate knowledge text segments corresponding to the third medical knowledge source,..., the candidate knowledge text segment with the first sorting position in the candidate knowledge text segments corresponding to the Lth medical knowledge source are divided into the first bucket, where L is the number of medical knowledge sources; the candidate knowledge text segment with the second sorting position in the candidate knowledge text segments corresponding to the first medical knowledge source, the candidate knowledge text segment with the second sorting position in the candidate knowledge text segments corresponding to the second medical knowledge source, the candidate knowledge text segment with the second sorting position in the candidate knowledge text segments corresponding to the third medical knowledge source,..., the candidate knowledge text segment with the second sorting position in the candidate knowledge text segments corresponding to the Lth medical knowledge source are divided into the second bucket. And so on, finally obtaining multiple buckets.

[0115] Thus, the order of the buckets can reflect the order of the relevance (or similarity) between the candidate knowledge texts and the input text, and each bucket collects a candidate knowledge text corresponding to each medical knowledge source, making the data in each bucket comprehensive and diverse. By selecting retrieval enhanced data from multiple buckets obtained based on the above bucketing method, the diversity and accuracy of the retrieval enhanced data can be improved, and retrieval enhanced data with a high degree of relevance to the input text can be selected.

[0116] In one example, S3042 includes: using a second large language model to perform in-bucket sorting on the candidate knowledge text segments in multiple buckets from evaluation dimensions, where the evaluation dimensions include at least one of the following: the relevance between the candidate knowledge text segment and the input text, the text quality of the candidate knowledge text segment, and the reliability of the candidate knowledge text segment. Thus, by using the large language model to perform in-bucket sorting on the candidate knowledge text segments from one or more dimensions, the accuracy of the in-bucket sorting is improved.

[0117] Among them, the relevance between the candidate knowledge text segment and the input text, the text quality of the candidate knowledge text segment, and the reliability of the candidate knowledge text segment all respectively reflect the quality of the candidate knowledge text segment.

[0118] In this example, the candidate knowledge text segments in multiple buckets and the sorting instructions can be input into the second large language model, instructing the second large language model to perform in-bucket sorting on the candidate knowledge text segments in multiple buckets according to the sorting instructions, and obtaining multiple buckets after in-bucket sorting.

[0119] Among them, the sorting requirements corresponding to the evaluation dimensions can be described in the sorting instructions.

[0120] Optionally, in the evaluation dimension of the relevance between the candidate knowledge text segment and the input text, first, the main intention of the input text can be identified through the second large language model, and according to the main intention of the input text, the key conclusions and / or key content required for answering the input text can be generated; then, through the second large language model, it is judged whether the candidate knowledge text segment contains the key conclusions and / or the key content, and according to the judgment of whether the candidate knowledge text segment contains the key conclusions and / or the key content, the candidate knowledge text segment is evaluated. Thus, the intention of the input text is recognized, the key conclusions and / or key content are summarized, and it is recognized whether the candidate knowledge text segment contains the key conclusions and / or key content of the input text, improving the recognition accuracy of the relevance between the candidate knowledge text segment and the input text, and further improving the accuracy of the in-bucket sorting.

[0121] Optionally, in terms of the evaluation dimension of the text quality of the candidate knowledge text segment, the second large language model can be used to identify whether there are text quality problems in the candidate knowledge text segment, and an identification result can be obtained. Based on this identification result, the candidate knowledge text can be evaluated. Among them, the text quality problems may include at least one of the following: grammar errors, typos, medical term errors, and redundant answer content. Thus, starting from one or more text quality problems, the accuracy of text quality evaluation can be improved.

[0122] Optionally, in terms of the evaluation dimension of the reliability of the candidate knowledge text segment, the second large language model can be used to rate multiple medical knowledge sources, and levels corresponding to the multiple medical knowledge sources can be obtained. The level corresponding to the medical knowledge source to which the candidate knowledge text segment belongs reflects the reliability of the candidate knowledge text segment. Thus, by rating the medical knowledge sources, the accuracy of evaluating the reliability of the candidate knowledge text segment can be improved.

[0123] Optionally, the input sorting instruction includes task definition, requirements for sorting the candidate knowledge text segment in terms of the relevance between the candidate knowledge text segment and the input text, requirements for sorting the candidate knowledge text segment in terms of the text quality of the candidate knowledge text segment, requirements for sorting the candidate knowledge text segment in terms of the reliability of the candidate knowledge text segment, and requirements for the output format.

[0124] For example, the task definition is: "Suppose you are a professional medical expert. Please review the input candidate knowledge text segment step by step according to the following requirements, sort the candidate knowledge text segment, and output it in the specified format without considering the input order."

[0125] For example, the requirement for sorting the candidate knowledge text segment in terms of the relevance between the candidate knowledge text segment and the input text is: "Please review the candidate knowledge from the perspective of the relevance to the user's question (i.e., the input text) according to the following thought process: 1. Subject intention recognition: Find the subject of the user's question and analyze the subject intention; 2. Key conclusion recognition: Output the key conclusions or key content necessary to answer the user's question; 3. Content judgment: Judge whether the key conclusions or content are given in the candidate knowledge text segment."

[0126] For example, the requirements for sorting candidate knowledge text segments based on the text quality of the candidate knowledge text segments are as follows: "Please determine whether there are the following text quality problems in the candidate knowledge text segments and output the following analysis process: 1. Grammar: Grammar errors in the statements (grammar errors may include at least one of the following: incomplete components, improper word order, improper collocation, redundant components, punctuation errors, special sentence pattern errors, words that make the statement incoherent); 2. Spelling mistakes: Non-medical noun errors that do not affect understanding in the statements (non-medical noun errors may include spelling mistakes, missing characters, extra characters, improper word usage, translation errors, colloquialisms, etc. in non-medical fields); 3. Medical name errors: Individual word errors, individual word omissions, or individual word redundancies in the medical professional terms in the statements (which may include disease names, drug names, test and examination names, surgical names, anatomical names), but the only correct statement can still be confirmed (for example: coronary heart disease → coronary heart disease, Lianhua Qingwen Granules → Lianhua Qingwen Granules, transcranial magnetic stimulation → transcranial magnetic stimulation, oral upper palate → oral upper palate); 4. Excessive redundancy: In the case of being able to fully and effectively answer the question, there is a large amount of non-essential information in the text segment (non-essential information such as table of contents, watermarks, invalid characters, etc.)."

[0127] For example, the requirements for sorting candidate knowledge text segments based on the reliability of the candidate knowledge text segments are as follows: "Guidelines (high), textbooks (high), instructions (high), literature (relatively high), web page data (low)". Among them, guidelines, textbooks, instructions, literature, and web page data are different sources of medical knowledge. Guidelines (high) means that the rating of the guidelines is at a high level. If the candidate knowledge text segment belongs to the candidate knowledge text segment corresponding to the guidelines, the reliability of the candidate knowledge text segment is high. The meanings of textbooks (high), instructions (high), literature (relatively high), and web page data (low) can be explained with reference to the meaning of guidelines (high) and will not be described one by one.

[0128] For example, the output format is: "User's question: 1. The recognition result of the main intention is: ……; 2. The recognition result of the key conclusion and / or content is: ……

Candidate knowledge text segment X

[0129] In one example, S3043 includes: among multiple buckets, according to the in-bucket sorting of multiple candidate knowledge text segments in the first bucket, select multiple candidate knowledge text segments from the first bucket as retrieval enhancement data; if the number of candidate knowledge text segments in the first bucket is less than the required number of retrieval enhancement data, then according to the in-bucket order of multiple candidate knowledge text segments in the second bucket, select multiple candidate knowledge text segments from the second bucket as retrieval enhancement data; if the sum of the number of candidate knowledge text segments in the first bucket and the number of candidate knowledge text segments in the second bucket is less than the required number of retrieval enhancement data, then continue to select retrieval enhancement data from the third bucket, and so on. Among them, the candidate knowledge text segments in the j-th bucket are the candidate knowledge text segments ranked j-th among the candidate knowledge text segments corresponding to multiple medical knowledge sources respectively. Through the above selection process, retrieval enhancement data with a relatively high degree of relevance to the input text and with diversity can be selected.

[0130] For example, Figure 5 is an example diagram of candidate knowledge text segments corresponding to multiple medical knowledge sources. As Figure 5 shown, for the input text "What are the causes and symptoms of allergic rhinitis?", multiple candidate knowledge text segments can be found from three medical knowledge sources: web data, guidelines, and textbooks. For example, the web data corresponds to three candidate knowledge text segments, which are "1) Allergic rhinitis is a multifactorial disease induced by the interaction of genes and the environment, that is, allergic rhinitis...; 2) Allergic rhinitis, also known as allergic rhinitis, is a common non-infectious chronic inflammation of the nasal mucosa...; 3) Allergic rhinitis refers to people with allergic constitution or allergic diathesis who come into contact with factors that can cause allergies..."; the guidelines correspond to three candidate knowledge text segments, which are "1) Allergic rhinitis is a disease involving neurotransmitters caused by allergen sensitization and excitation...; 2) Allergic rhinitis is mainly caused by the exposure of atopic individuals to allergens and is mainly mediated by immunoglobulin...; 3) Pediatric allergic rhinitis is mainly mediated by immunoglobulin E..."; the textbooks correspond to three candidate knowledge text segments, which are "1) Allergic rhinitis, abbreviated as allergic rhinitis, is a disease in which susceptible individuals come into contact with allergens...; 2) Allergic rhinitis is mainly caused by inhaled allergens (allergens), and the allergens exist throughout the year or seasonally...; 3) With the development of genetic research, more and more scholars believe that multiple phenotypes of allergic rhinitis are under strong genetic control...".

[0131] For example, Figure 6 is an example diagram for bucketing, in-bucket sorting, and selection of retrieval enhancement data for candidate knowledge text segments corresponding to multiple medical knowledge sources. First, after bucketing the candidate knowledge text segments corresponding to multiple medical knowledge sources in Figure 5 it is possible to obtain Figure 6The buckets 1, 2, and 3 shown. Among them, the first candidate knowledge text segment corresponding to the web page data, the first candidate knowledge text segment corresponding to the guide, and the first candidate knowledge text segment corresponding to the textbook are stored in bucket 1; the second candidate knowledge text segment corresponding to the web page data, the second candidate knowledge text segment corresponding to the guide, and the second candidate knowledge text segment corresponding to the textbook are stored in bucket 2; the third candidate knowledge text segment corresponding to the web page data, the third candidate knowledge text segment corresponding to the guide, and the third candidate knowledge text segment corresponding to the textbook are stored in bucket 3. Then, perform in-bucket sorting on buckets 1, 2, and 3. Through Figure 6 It can be seen that the order of the candidate knowledge text segments in the three buckets has changed; finally, in the order from bucket 1 to bucket 2 and then to bucket 3, and according to the in-bucket order of buckets 1, 2, and 3, retrieve enhanced data is selected. For example, Figure 6 First, the candidate knowledge text segments corresponding to A), B), and C) in bucket 1 are selected, and then the candidate knowledge text segments corresponding to D, E, and F in bucket 2 are selected.

[0132] S305. According to the input text and the retrieved enhanced data, use the medical Q&A model to generate a response text corresponding to the input text.

[0133] Among them, the implementation principle and technical effect of S305 can refer to the foregoing embodiments and will not be elaborated here.

[0134] In the embodiments of the present application, multiple medical knowledge sources include offline knowledge sources and / or online knowledge sources. By searching for corresponding candidate knowledge text segments from the medical knowledge base corresponding to the offline knowledge source, and searching for corresponding candidate knowledge text segments from the access addresses corresponding to the online knowledge source, and then selecting the retrieved enhanced data from the candidate knowledge text segments corresponding to multiple medical knowledge sources, the diversity and reliability of the retrieved enhanced data are effectively improved, and further the accuracy and reliability of the medical Q&A model for generating response texts are improved.

[0135] Please refer to Figure 7 , in another exemplary embodiment, a data processing process for a medical knowledge base is provided. The data processing process of the medical library may include:

[0136] S701. According to the medical knowledge source, store the knowledge data from the offline knowledge source as multiple knowledge text segments in the medical knowledge base corresponding to the offline knowledge source.

[0137] In this embodiment, there can be multiple offline knowledge sources, and different offline knowledge sources can correspond to different medical knowledge bases. For each offline knowledge source, the knowledge data from the offline knowledge source can be stored as multiple knowledge text segments in the medical knowledge base corresponding to the offline knowledge source. The knowledge data from the offline knowledge source can be knowledge content recorded in various document formats.

[0138] S702 generates corresponding titles for multiple knowledge text segments.

[0139] In this embodiment, for each knowledge text segment among multiple knowledge text segments, a title corresponding to the knowledge text segment can be generated by extracting information from the knowledge text segment.

[0140] Optionally, the form of the title corresponding to the knowledge text segment is expressed as: {description of the main content of the knowledge text segment}: {keywords corresponding to the main content description}, so that the title corresponding to the knowledge text segment can reflect the main content and keywords of the knowledge text segment, and the title description is more accurate.

[0141] In a possible implementation manner, a third large language model can be used to extract features from the knowledge text segment, and a title is generated for the knowledge text segment based on the extracted features. Thus, the accuracy of the title of the knowledge text segment is improved through the large language model.

[0142] Among them, in the embodiments of the present application, the first large language model, the second large language model, and the third large language model can adopt large language models with the same or different structures.

[0143] In this implementation manner, the title generation requirements, the knowledge text segment, and the original title corresponding to the knowledge text segment can be input into the third large language model. In the third large language model, features are extracted from the knowledge text segment and the original title corresponding to the knowledge text segment, and based on the extracted features, a title (new title) corresponding to the knowledge text segment is generated according to the title generation requirements.

[0144] For example, the title generation requirements are: "I am clustering content and need to give a title to the input content. The title needs to contain the main content mentioned in the input content and the corresponding description. Please process step by step according to the following requirements: 1. If the original title of the input is not empty, first output the keywords in the original title in the keyword column of the original title; if the input title is empty, output "none" in the keyword column of the original title. 2. Summarize the main content of the input and output it in the content summary column. 3. According to the keywords of the original title and the summary of the main content, give a new title to the input content. The form of the new title is: description of the main body content: keywords corresponding to the description of the main body content.

[0145] Several examples are provided below:

[0146] Example 1, the original title was "The Main Effects of Community-Acquired Pneumonia (CAP) on All Systems of the Body", and the knowledge text segment was "Inflammatory mediators produced by severe pneumonia and direct damage to cardiomyocytes by pathogens lead to non-specific necrosis of cardiomyocytes, or myocardial depression resulting in impaired cardiac pump function; inflammatory mediators cause dysregulation of vasomotor function and increased capillary permeability, thereby leading to redistribution of blood circulation." Through the large language model, the keywords extracted from the original title were "CPA, systemic system, circulatory system", and the main content description of the knowledge text segment was "Severe pneumonia causes inflammatory mediators and pathogens to damage the myocardium, affecting cardiac function and vasomotor function, and triggering circulatory problems." The new title generated for the knowledge text segment was "The Effects of Severe Pneumonia on the Circulatory System: Myocardial Damage and Circulatory Dysfunction."

[0147] Example 2, the original title was "Is it Useful to Take Pudilan Xiaoyan Tablets?", and the knowledge text segment was "Pudilan Xiaoyan Tablets have the effects of clearing heat and detoxifying, and anti-inflammatory and detumescence. They are mainly used for the treatment of common cold, pharyngitis, tonsillitis, etc. The main ingredients are..., and it should be used under the guidance of a doctor. If the symptoms do not relieve after three days, you should go to the hospital for treatment. If the patient has any discomfort symptoms or adverse reactions when taking Pudilan, they need to consult a doctor or pharmacist in time." Through the large language model, the keywords extracted from the original title were "Pudilan, Xiaoyan Tablets, useful", and the main content description of the knowledge text segment was "Pudilan Xiaoyan Tablets clear heat and detoxify and have anti-inflammatory and detumescence effects, are suitable for common cold, pharyngitis, tonsillitis, have... ingredients, should be used under the guidance of a doctor, and if ineffective after three days, medical treatment is required." The new title generated for the knowledge text segment was "The Efficacy and Usage Guidelines of Pudilan Xiaoyan Tablets: Clearing Heat and Detoxifying and Anti-Inflammation."

[0148] S703, extract the features of multiple knowledge text segments and the titles corresponding to multiple knowledge text segments respectively to obtain the text features corresponding to multiple knowledge text segments respectively.

[0149] In this embodiment, for each knowledge text segment, use the title corresponding to the knowledge text segment as the auxiliary information of the knowledge text segment, and participate in the feature extraction process of the knowledge text segment together with the knowledge text segment. In the feature extraction generation process, extract the features of the knowledge text segment and the title corresponding to the knowledge text segment to obtain the text features corresponding to the knowledge text segment. Since the title information corresponding to the knowledge text segment knows the main content and keywords of the knowledge text segment, using the title corresponding to the knowledge text segment for feature extraction can improve the accuracy of the text features corresponding to the knowledge text segment.

[0150] In a possible implementation, S703 includes: extracting features from the second knowledge text segment and the title of the second knowledge text segment through a first large language model to obtain the output features of the last hidden layer of the first large language model, where the second knowledge text segment is one of multiple knowledge text segments in a medical knowledge base; determining the text features of the second knowledge text segment as the output features.

[0151] In this embodiment, the second knowledge text segment and the title of the second knowledge text segment are concatenated, and the concatenated text is segmented to obtain a token sequence corresponding to the concatenated text; the token sequence is input into the first large language model, and features are extracted in the first large language model to obtain the output features of the last hidden layer of the first large language model. The output features of the last hidden layer contain the feature information of all tokens in the token sequence. Therefore, using the output features of the last hidden layer as the text features of the second knowledge text segment effectively improves the integrity and accuracy of the text features of the second knowledge text segment.

[0152] Optionally, the feature extraction of the first large language model includes multiple iteration processes. In the process of extracting features from the second knowledge text segment and the title of the second knowledge text segment through the first large language model, the output features of the last hidden layer in the last iteration can be determined as the text features of the second knowledge text segment, improving the integrity and accuracy of the text features of the second knowledge text segment.

[0153] Furthermore, the multiple iteration process of the first large language model for feature extraction of the second knowledge text segment and the title corresponding to the second knowledge text segment includes: in the i-th iteration, the input token is input into the first large language model. If i equals 1, the input token is the first token in the token sequence obtained by tokenizing the concatenated text (obtained by concatenating the second knowledge text segment and the title corresponding to the second knowledge text segment). If i is greater than 1, the input token is obtained by concatenating the input tokens of the previous i - 1 iterations and the output token in the i-th iteration; in the first large language model, feature extraction is performed on the input data through multiple hidden layers to obtain the output features of the last hidden layer of the first large language model; if the i-th iteration is the last iteration (where the total number of iterations is the total number of tokens after tokenizing the concatenated text), the output features of the last hidden layer can be determined as the text features of the second knowledge text segment; if the i-th iteration is not the last iteration, the output features of the last hidden layer are decoded to obtain the i-th output token of the first large language model, and the input tokens of the previous i iterations and the i-th output token are concatenated to obtain the input token in the (i + 1)-th iteration, and the (i + 1)-th feature extraction is continued until the output features of the last hidden layer in the last iteration are obtained. Thus, through multiple iterations of feature extraction and taking the output features of the last hidden layer in the last iteration as the text features of the second knowledge text segment, the accuracy of text feature extraction for the second knowledge text segment is improved.

[0154] Optionally, the first large language model includes multiple Transformer decoders, and the multiple Transformer decoders are multiple hidden layers in the first large language model. In the multiple iteration process of the first large language model for feature extraction of the second knowledge text segment and the title corresponding to the second knowledge text segment, the output features of the last Transformer decoder in the last iteration process can be determined as the text features of the second knowledge text segment. Thus, through multiple Transformer decoders, the accuracy of text feature extraction for the second knowledge text segment is improved.

[0155] In this optional method, in the i-th (i is greater than or equal to 1) iteration, the token sequence (if i equals 1, this token sequence is the token sequence corresponding to the concatenated text obtained by concatenating the second knowledge text segment and the title corresponding to the second knowledge text segment; if i is greater than 1, this token sequence is obtained by concatenating the output tokens of the first large language model in the (i - 1)-th iteration and the token sequence input to the first large language model in the (i - 1)-th iteration) is input into the first large language model; in the first large language model, the token sequence is encoded through a token embedding matrix and a position embedding matrix to obtain the input data for the first Transformer decoder; this input data is input into the first Transformer decoder for feature extraction to obtain the output features of the first Transformer decoder; the output features of the j-th (j is greater than or equal to 1) Transformer decoder are input into the (j + 1)-th Transformer decoder to obtain the output features of the (j + 1)-th Transformer decoder until the output features of the last Transformer decoder are obtained; based on the output features of the last Transformer decoder, the output tokens of the first large language model in the i-th iteration are obtained. If the i-th iteration is the last iteration, then the output features of the last Transformer decoder are determined to be the text features of the second knowledge text segment, otherwise the (i + 1)-th iteration is continued.

[0156] Optionally, the token sequence corresponding to the concatenated text is represented as:

[0157] Tokenize(Text) = U = (u1, u2, …, u k )

[0158] where Text represents the concatenated text, U represents the token sequence obtained after tokenizing the concatenated text, and u1, u2, u k represent the 1st token, the 2nd token, and the k-th token in U, respectively.

[0159] Optionally, in the i-th iteration, the input tokens of the i-th iteration are encoded through a token embedding matrix and a position embedding matrix to obtain the input data for the first Transformer decoder, which is represented as:

[0160]

[0161] where U i represents the input tokens of the i-th iteration, represents the token embedding vector corresponding to the i-th iteration (or corresponding to the input tokens of the i-th iteration), represents the token position vector corresponding to the i-th iteration (or corresponding to the input tokens of the i-th iteration), and h i represents the input data for the 1st Transformer decoder in the i-th iteration.

[0162] Optionally, the output features of the j-th transformer decoder are input into the (j + 1)-th transformer decoder to obtain the output features of the (j + 1)-th transformer decoder, which are expressed as:

[0163]

[0164] where p is greater than 1 and less than or equal to n, and n represents the total number of transformer decoders in the first large language model. represents the output features of the (p - 1)-th transformer decoder in the i-th iteration, represents the output features of the p-th transformer decoder in the i-th iteration.

[0165] For example, Figure 8 is an example diagram for feature extraction by the first large language model. As Figure 8 shown, the knowledge text segment and the title corresponding to the knowledge text segment are concatenated and tokenized to obtain the token sequence input into the first large language model in the first iteration. In the first iteration, the first token in the token sequence is used as the input token U1 of the first iteration, and U1 is input into the first large language model to obtain the output features of the last hidden layer in the first iteration Based on this output feature the first output token T1 of the first large language model is decoded. In the second iteration, the first output token T1 is concatenated with the previous input token U1 to obtain the input token U2 of the second iteration input into the first large language model. U2 is input into the first large language model to obtain the output features of the last hidden layer in the second iteration Based on this output feature the second output token T2 of the first large language model is decoded. This is done for multiple iterations. In the g-th iteration, the input tokens of the previous g - 1 times are concatenated with the output token of the (g - 1)-th time to obtain the input token U g of the g-th iteration. The token sequence U g in the g-th iteration is input into the first large language model to obtain the output features of the last hidden layer in the g-th iteration Based on the g-th output token T g of the first large language model is decoded. The g-th iteration is the last iteration, and can be determined as the text features of the knowledge text segment.

[0166] S704. Store the titles corresponding to multiple knowledge text segments and the text features corresponding to multiple knowledge text segments in the medical knowledge base.

[0167] In this embodiment, the titles corresponding to multiple knowledge text segments and the text features corresponding to multiple knowledge text segments are stored in the medical knowledge base, so that subsequent candidate knowledge text segments can be searched in the medical knowledge base according to the text features of the knowledge text segments and the text features of the input text. For specific reference, please refer to the description of the foregoing embodiment, and details are not described herein.

[0168] In the embodiment of the present application, a data processing process of the medical knowledge base, that is, a data acquisition process, is provided, which provides data reserve for medical question answering. In this process, by separately storing data from different medical knowledge sources, it provides convenience for searching corresponding data from each medical knowledge source during the medical question answering process. By generating titles for knowledge text segments and using the titles together with the knowledge text segments for feature extraction, the accuracy of feature extraction is improved, and more accurate text features are provided for medical question answering.

[0169] In some embodiments, after extracting the text features corresponding to multiple knowledge text segments and the titles corresponding to multiple knowledge text segments respectively, the data processing process of the medical knowledge base further includes: clustering multiple knowledge text segments according to the text features corresponding to multiple knowledge text segments respectively to obtain multiple clusters. At this time, the cluster identifiers corresponding to multiple knowledge text segments can be stored in the medical knowledge base, and the cluster identifiers corresponding to multiple knowledge text segments respectively indicate the clusters to which multiple knowledge text segments respectively belong. Thus, on the one hand, clustering multiple knowledge text segments based on text features improves the accuracy of clustering; on the other hand, when searching for candidate knowledge text segments in the medical knowledge base later, the candidate knowledge text segments can be selected according to the clusters to which the knowledge text segments belong. For specific reference, please refer to the description of the foregoing embodiment, and details are not described herein.

[0170] In this embodiment, according to the text features corresponding to multiple knowledge text segments respectively, the knowledge text segments with similar or close text features can be divided into the same cluster, and the knowledge text segments with relatively large text feature differences can be divided into different clusters to obtain multiple clusters.

[0171] Optionally, clustering multiple knowledge text segments according to the text features corresponding to multiple knowledge text segments respectively to obtain multiple clusters includes: in the i-th clustering process, determining the clusters to which multiple knowledge text segments respectively belong according to the text features corresponding to multiple knowledge text segments respectively and the centroid features corresponding to multiple clusters respectively, where i is greater than or equal to 1; adjusting the centroid features corresponding to multiple clusters respectively according to the text features of the knowledge text segments included in multiple clusters respectively to obtain adjusted centroid features; if the i-th clustering meets the clustering end condition, end the clustering of multiple knowledge text segments, otherwise perform the (i + 1)-th clustering according to the adjusted centroid features. Thus, by performing multiple clusterings and adjusting the centroid features of the clusters multiple times, the accuracy of clustering the knowledge text segments is improved.

[0172] In this optional method, during the first clustering process, the centroid features corresponding to multiple clusters can be randomly initialized. The Euclidean distances between the text features corresponding to multiple knowledge text segments and the centroid features corresponding to multiple clusters are calculated. According to the Euclidean distances between the text features corresponding to multiple knowledge text segments and the centroid features corresponding to multiple clusters, the multiple knowledge text segments are divided into the clusters corresponding to the centroid features with the closest distances. For each cluster among the multiple clusters, the mean value of the text features of the knowledge text segments included in the cluster is calculated, and the centroid feature corresponding to the cluster is updated to this mean value. Then, the second clustering is performed. In this way, the final multiple clusters are obtained after multiple clusterings.

[0173] As an example, Figure 9 FIG. is a process example diagram for obtaining retrieval-enhanced data from the data processing of a medical knowledge base to the medical question-answering process. As Figure 9 shown, during the data processing of the medical knowledge base, first, through a large language model, title generation is performed on the knowledge text segments included in multiple medical knowledge bases (different medical knowledge bases correspond to different medical knowledge sources); then, through the large language model, feature extraction is performed on the knowledge text segments and the titles corresponding to the knowledge text segments in the medical knowledge base, and the features of the last hidden layer in the large language model are taken as the text features of the knowledge text segments; finally, the corresponding text features are added to the knowledge text segments in the medical knowledge base, and based on the text features of the knowledge text segments, clustering is performed on the knowledge text segments in the medical knowledge base to obtain the final multiple medical knowledge bases. During the medical question-answering process, first, for the input text, based on multiple medical knowledge bases, candidate knowledge text segments corresponding to multiple offline knowledge sources can be found, and search results related to the input text can be searched through a search engine, and candidate knowledge text segments corresponding to online knowledge sources can be found in the search results; then, the candidate knowledge text segments corresponding to multiple medical knowledge sources can be bucketed to obtain multiple buckets, and the large language model is used to perform in-bucket sorting on the multiple buckets, and then retrieval-enhanced data is selected from the multiple buckets after in-bucket sorting.

[0174] Exemplary device

[0175] Correspondingly, an embodiment of the present application further provides a medical question-answering device.

[0176] Please refer to Figure 10 , in an exemplary embodiment, a medical question-answering device 1000 is provided. The medical question-answering device 1000 includes: an acquisition unit 1001, a search unit 1002, a selection unit 1003, and a reply generation unit 1004. Among them:

[0177] An acquisition unit 1001 for acquiring the input text to be answered; a search unit 1002 for searching for medical knowledge related to the input text from multiple medical knowledge sources to obtain candidate knowledge text segments corresponding to the multiple medical knowledge sources respectively; a selection unit 1003 for selecting retrieval enhancement data for the input text from the candidate knowledge text segments corresponding to the multiple medical knowledge sources respectively; and a response generation unit 1004 for generating a response text corresponding to the input text through a medical Q&A model according to the input text and the retrieval enhancement data.

[0178] In some embodiments, the multiple medical knowledge sources include an offline knowledge source and / or an online knowledge source, and the search unit 1002 is specifically configured to: search for medical knowledge related to the input text in the medical knowledge base corresponding to the offline knowledge source to obtain candidate knowledge text segments corresponding to the offline knowledge source; and / or search for medical knowledge related to the input text in the access address of the online knowledge source to obtain candidate knowledge text segments corresponding to the online knowledge source.

[0179] In some embodiments, the search unit 1002 is specifically configured to: extract the text features of the input text; determine the similarity between the input text and multiple knowledge text segments in the medical knowledge base according to the text features of the input text and the text features corresponding to the multiple knowledge text segments respectively, where the medical knowledge base includes multiple knowledge text segments and the text features corresponding to the multiple knowledge text segments respectively; and select candidate knowledge text segments corresponding to the offline knowledge source from the multiple knowledge text segments according to the similarity between the input text and the multiple knowledge text segments.

[0180] In some embodiments, in the medical knowledge base, the multiple knowledge text segments are clustered into multiple clusters, and the search unit 1002 is specifically configured to: select multiple first knowledge text segments from the multiple knowledge text segments according to the similarity between the input text and the multiple knowledge text segments, where the similarity between the input text and the multiple first knowledge text segments meets a set condition; and select candidate knowledge text segments from the multiple first knowledge text segments according to the clusters where the multiple first knowledge text segments are located.

[0181] In some embodiments, the search unit 1002 is specifically configured to: if the number of knowledge text segments belonging to different clusters among the multiple first knowledge text segments is greater than or equal to N, then select N knowledge text segments belonging to different clusters as candidate knowledge text segments from the multiple first knowledge text segments in the order of the similarity between the input text and the multiple first knowledge text segments from high to low, where N is greater than 1; if the number of knowledge text segments belonging to different clusters among the multiple first knowledge text segments is less than N, then select candidate knowledge text segments from the multiple first knowledge text segments in the order of the similarity between the input text and the multiple first knowledge text segments from high to low, and the number of candidate knowledge text segments is N.

[0182] In some embodiments, the data processing process of the medical knowledge base includes: storing the knowledge data from the offline knowledge source as multiple knowledge text segments in the medical knowledge base corresponding to the offline knowledge source according to the medical knowledge source; generating corresponding titles for the multiple knowledge text segments; extracting features from the multiple knowledge text segments and the titles respectively corresponding to the multiple knowledge text segments to obtain text features respectively corresponding to the multiple knowledge text segments; and storing the titles respectively corresponding to the multiple knowledge text segments and the text features respectively corresponding to the multiple knowledge text segments in the medical knowledge base.

[0183] In some embodiments, extracting features from the multiple knowledge text segments and the titles respectively corresponding to the multiple knowledge text segments to obtain text features respectively corresponding to the multiple knowledge text segments includes: extracting features from the second knowledge text segment and the title of the second knowledge text segment through the first large language model to obtain the output features of the last hidden layer of the first large language model, where the second knowledge text segment is one of the multiple knowledge text segments; and determining the text feature of the second knowledge text segment as the output features.

[0184] In some embodiments, after extracting features from the multiple knowledge text segments and the titles respectively corresponding to the multiple knowledge text segments to obtain text features respectively corresponding to the multiple knowledge text segments, the data processing process of the medical knowledge base further includes: clustering the multiple knowledge text segments according to the text features respectively corresponding to the multiple knowledge text segments to obtain multiple clusters.

[0185] In some embodiments, clustering the multiple knowledge text segments according to the text features respectively corresponding to the multiple knowledge text segments to obtain multiple clusters includes: in the i-th clustering process, determining the clusters to which the multiple knowledge text segments respectively belong according to the text features respectively corresponding to the multiple knowledge text segments and the centroid features respectively corresponding to the multiple clusters, where i is greater than or equal to 1; adjusting the centroid features respectively corresponding to the multiple clusters according to the text features of the knowledge text segments respectively included in the multiple clusters to obtain adjusted centroid features; and if the i-th clustering meets the clustering end condition, ending the clustering of the multiple knowledge text segments, otherwise performing the (i + 1)-th clustering according to the adjusted centroid features.

[0186] In some embodiments, the searching unit 1003 is specifically configured to: search for medical knowledge related to the input text in the access address to obtain a search result, where the search result includes: multiple third knowledge text segments and the degree of relevance between the input text and the multiple third knowledge text segments; and select a candidate knowledge text segment corresponding to the online knowledge source from the multiple third knowledge text segments according to the degree of relevance between the input text and the multiple third knowledge text segments and the similarity between the multiple third knowledge text segments.

[0187] In some embodiments, the search unit 1003 is specifically configured to: according to the relevance between the input text and multiple third knowledge text segments, select the knowledge text segment with the highest relevance to the input text among the multiple third knowledge text segments as the first candidate knowledge text segment corresponding to the online knowledge source; in the (j + 1)-th selection, determine the similarity between the j-th candidate knowledge text segment corresponding to the online knowledge source and the unselected knowledge text segments among the multiple third knowledge text segments, where j is greater than or equal to 1; select the knowledge text segment with the lowest similarity to the j-th candidate knowledge text segment among the unselected knowledge text segments as the (j + 1)-th candidate knowledge text segment corresponding to the online knowledge source, and repeat the selection multiple times until M candidate knowledge text segments corresponding to the online knowledge source are selected, where M is greater than 1.

[0188] In some embodiments, the selection unit 1003 is specifically configured to: perform bucketing on the candidate knowledge text segments corresponding to multiple medical knowledge sources to obtain multiple buckets, where each of the multiple buckets contains multiple candidate knowledge text segments; perform in-bucket sorting on the candidate knowledge text segments in the multiple buckets; and select retrieval enhancement data from the multiple buckets after in-bucket sorting.

[0189] In some embodiments, among the multiple buckets, the candidate knowledge text segments in each bucket come from different medical knowledge sources. The search unit 1003 is specifically configured to: for multiple medical knowledge sources, divide the candidate knowledge text segments with the same sorting position in different medical knowledge sources into the same bucket to obtain multiple buckets.

[0190] In some embodiments, the search unit 1003 is specifically configured to: perform in-bucket sorting on the candidate knowledge text segments in the multiple buckets from the evaluation dimension through a second large language model, where the evaluation dimension includes at least one of the following: the relevance between the candidate knowledge text segment and the input text, the text quality of the candidate knowledge text segment, and the reliability of the candidate knowledge text segment.

[0191] The medical question-answering device 1000 provided in this embodiment belongs to the same inventive concept as the medical question-answering method provided in the foregoing embodiments of the present application, and can execute the medical question-answering method provided in any of the foregoing embodiments of the present application, and has corresponding functional modules and beneficial effects for executing the medical question-answering method. For the technical details not described in detail in this embodiment, reference may be made to the specific processing content of the medical question-answering method provided in the foregoing embodiments of the present application, which will not be elaborated here.

[0192] In the above device, the functions implemented by each unit can be realized by the same or different processors respectively, which is not limited in the embodiments of the present application.

[0193] It should be understood that the units in the above device can be implemented in the form of a processor invoking software. For example, the device includes a processor, the processor is connected to a memory, instructions are stored in the memory, and the processor invokes the instructions stored in the memory to implement any of the above methods or the functions of each unit of the device. The processor can be a general-purpose processor, such as a CPU or a microprocessor, etc., and the memory can be a memory inside the device or a memory outside the device. Alternatively, the units in the device can be implemented in the form of a hardware circuit. By designing the hardware circuit, the functions of some or all of the units can be implemented. The hardware circuit can be understood as one or more processors. For example, in one implementation, the hardware circuit is an ASIC, and the functions of some or all of the above units are implemented by designing the logical relationship of the components in the circuit. Again, for example, in another implementation, the hardware circuit can be implemented by a PLD. Taking FPGA as an example, it can include a large number of logic gate circuits, and the connection relationship between the logic gate circuits is configured through a configuration file, so as to implement the functions of some or all of the above units. All the units of the above device can be all implemented in the form of a processor invoking software, or all implemented in the form of a hardware circuit, or part implemented in the form of a processor invoking software, and the remaining part implemented in the form of a hardware circuit.

[0194] In the embodiments of the present application, the processor is a circuit with the ability to process signals. In one implementation, the processor can be a circuit with the ability to read and execute instructions, such as a CPU, a microprocessor, a GPU, or a DSP, etc. In another implementation, the processor can implement certain functions through the logical relationship of a hardware circuit, and the logical relationship of the hardware circuit is fixed or can be reconstructed. For example, the processor is a hardware circuit implemented by an ASIC or a PLD, such as an FPGA. In a reconfigurable hardware circuit, the process of the processor loading a configuration document to implement the configuration of the hardware circuit can be understood as the process of the processor loading instructions to implement the functions of some or all of the above units. In addition, it can also be a hardware circuit designed for artificial intelligence, which can be understood as a kind of ASIC, such as an NPU, a TPU, a DPU, etc.

[0195] It can be seen that each unit in the above device can be one or more processors (or processing circuits) configured to implement the above method, such as: CPU, GPU, NPU, TPU, DPU, microprocessor, DSP, ASIC, FPGA, or a combination of at least two of these processor forms.

[0196] In addition, each unit in the above device can be integrated in whole or in part, or can be implemented independently. In one implementation, these units are integrated together and implemented in the form of an SOC. The SOC can include at least one processor for implementing any of the above methods or the functions of each unit of the device. The types of the at least one processor can be different, for example, including CPU and FPGA, CPU and artificial intelligence processor, CPU and GPU, etc.

[0197] Exemplary electronic device

[0198] Another embodiment of this application also proposes an electronic device. Refer to Figure 11 As shown, the electronic device may include: a memory 1100 and a processor 1110; wherein, the memory 1100 is connected to the processor 1110 for storing programs; the processor 1110 is configured to implement the medical Q&A method disclosed in any of the above embodiments by running the programs stored in the memory 1100.

[0199] Specifically, the above electronic device may further include: a bus, a communication interface 1120, an input device 1130, and an output device 1140.

[0200] The processor 1110, the memory 1100, the communication interface 1120, the input device 1130, and the output device 1140 are interconnected through the bus. Among them:

[0201] The bus may include a path for transmitting information between various components of the computer system.

[0202] The processor 1110 can be a general-purpose processor, such as a general-purpose central processing unit (CPU), a microprocessor, etc., or an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the solution of this application. It can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0203] The processor 1110 may include a main processor, and may also include a baseband chip, a modem, etc.

[0204] The program for implementing the technical solution of this application is stored in the memory 1100, and the operating system and other key services may also be stored. Specifically, the program may include program code, and the program code includes computer operation instructions. More specifically, the memory 800 may include a read-only memory (ROM), other types of static storage devices that can store static information and instructions, a random access memory (RAM), other types of dynamic storage devices that can store information and instructions, a disk memory, a flash memory, etc.

[0205] The input device 1130 may include devices for receiving data and information input by a user, such as a keyboard, a mouse, a camera, a scanner, a light pen, a voice input device, a touch screen, a pedometer, or a gravity sensor, etc.

[0206] The output device 1140 may include devices for allowing information to be output to a user, such as a display screen, a printer, a speaker, etc.

[0207] The communication interface 1120 may include any device of a transceiver type for communicating with other devices or communication networks, such as an Ethernet, a radio access network (RAN), a wireless local area network (WLAN), etc.

[0208] The processor 1110 executes the program stored in the memory 1100 and calls other devices, and can be used to implement each step of any one of the medical Q&A methods provided in the above embodiments of this application.

[0209] An embodiment of this application also provides a chip, which includes a processor and a data interface. The processor reads and runs the program stored on the memory through the data interface to execute any one of the medical Q&A methods provided in the above embodiments. For the specific processing process and its beneficial effects, reference may be made to the description of the embodiments of the above medical Q&A method.

[0210] Exemplary computer program product and storage medium

[0211] In addition to the above methods and devices, an embodiment of this application may also be a computer program product, which includes computer program instructions. When the computer program instructions are run by a processor, the processor is caused to execute the steps in the medical Q&A method according to various embodiments of this application described in any of the above embodiments of this specification.

[0212] The computer program product can be written in any combination of one or more programming languages for executing the program code of the operations of the embodiments of the present application. The programming languages include object-oriented programming languages such as Java, C++, etc., and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, executed as an independent software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0213] In addition, an embodiment of the present application can also be a storage medium on which a computer program is stored, and the computer program is executed by a processor to perform the steps in the medical Q&A method according to various embodiments of the present application described in any of the above embodiments of this specification.

[0214] For the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the present application.

[0215] It should be noted that the embodiments in this specification are all described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The same or similar parts among the embodiments can be referred to each other. For the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0216] The steps in the methods of the embodiments of the present application can be adjusted, combined, and deleted according to actual needs, and the technical features recorded in each embodiment can be replaced or combined.

[0217] The modules and sub-modules in the devices and terminals in the embodiments of the present application can be combined, divided, and deleted according to actual needs.

[0218] In several embodiments provided by the present application, it should be understood that the disclosed terminals, devices and methods can be implemented in other ways. For example, the terminal embodiments described above are merely illustrative. For example, the division of modules or sub-modules is only a logical function division. In actual implementation, there may be other division methods. For example, multiple sub-modules or modules can be combined or integrated into another module, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection to each other can be through some interfaces, and the indirect coupling or communication connection of devices or modules can be in electrical, mechanical or other forms.

[0219] The modules or sub-modules described as separate components may or may not be physically separated. The components as modules or sub-modules may or may not be physical modules or sub-modules, that is, they can be located in one place, or can be distributed to multiple network modules or sub-modules. Some or all of the modules or sub-modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0220] In addition, each functional module or sub-module in various embodiments of the present application can be integrated in a processing module, or each module or sub-module can exist physically alone, or two or more modules or sub-modules can be integrated in one module. The above-mentioned integrated modules or sub-modules can be implemented in the form of hardware or in the form of software functional modules or sub-modules.

[0221] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in this article can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.

[0222] The steps of the method or algorithm described in combination with the embodiments disclosed in this article can be directly implemented by hardware, software units executed by a processor, or a combination of the two. The software units can be placed in a random access memory (RAM), memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium well-known in the technical field.

[0223] Finally, it should also be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the said element.

[0224] The foregoing description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A medical Q&A method, characterized in that, Including: Obtain the input text to be answered; Search for medical knowledge related to the input text from multiple medical knowledge sources, and obtain candidate knowledge text segments corresponding to the multiple medical knowledge sources respectively; Select the retrieval enhancement data of the input text from the candidate knowledge text segments corresponding to the multiple medical knowledge sources respectively; Generate a response text corresponding to the input text through a medical question-answering model according to the input text and the retrieval enhancement data.

2. The medical Q&A method according to claim 1, characterized in that The multiple medical knowledge sources include offline knowledge sources and / or online knowledge sources. The step of searching for medical knowledge related to the input text from multiple medical knowledge sources and obtaining candidate knowledge text segments corresponding to the multiple medical knowledge sources respectively includes: Search for medical knowledge related to the input text in the medical knowledge base corresponding to the offline knowledge source, and obtain the candidate knowledge text segment corresponding to the offline knowledge source; And / or, search for medical knowledge related to the input text in the access address of the online knowledge source, and obtain the candidate knowledge text segment corresponding to the online knowledge source.

3. The medical Q&A method according to claim 2, wherein The step of searching for medical knowledge related to the input text in the medical knowledge base corresponding to the offline knowledge source and obtaining the candidate knowledge text segment corresponding to the offline knowledge source includes: Extract the text features of the input text; Determine the similarity between the input text and multiple knowledge text segments according to the text features of the input text and the text features corresponding to the multiple knowledge text segments in the medical knowledge base. The medical knowledge base includes the multiple knowledge text segments and the text features corresponding to the multiple knowledge text segments respectively; Select the candidate knowledge text segment corresponding to the offline knowledge source from the multiple knowledge text segments according to the feature similarity between the input text and the multiple knowledge text segments.

4. The medical Q&A method according to claim 3, characterized in that In the medical knowledge base, the multiple knowledge text segments are clustered into multiple clusters. The step of selecting the candidate knowledge text segment corresponding to the offline knowledge source from the multiple knowledge text segments according to the similarity between the input text and the multiple knowledge text segments includes: Select multiple first knowledge text segments from the multiple knowledge text segments according to the similarity between the input text and the multiple knowledge text segments, and the similarity between the input text and the multiple first knowledge text segments meets the set conditions; Select the candidate knowledge text segment from the multiple first knowledge text segments according to the clusters where the multiple first knowledge text segments are located.

5. The medical Q&A method according to claim 4, characterized in that, The step of selecting the candidate knowledge text segment from the multiple first knowledge text segments according to the clusters where the multiple first knowledge text segments are located includes: If the number of knowledge text segments belonging to different clusters among the multiple first knowledge text segments is greater than or equal to N, then select N knowledge text segments belonging to different clusters as the candidate knowledge text segments from the multiple first knowledge text segments in the order of the similarity between the input text and the multiple first knowledge text segments from high to low, where N is greater than 1; If the number of knowledge text segments belonging to different clusters among the multiple first knowledge text segments is less than N, then according to the similarity between the input text and the multiple first knowledge text segments in descending order, select the candidate knowledge text segments from the multiple first knowledge text segments, and the number of the candidate knowledge text segments is N.

6. The medical Q&A method according to any one of claims 3 to 5, characterized in that, The data processing process of the medical knowledge base includes: According to the medical knowledge source, store the knowledge data from the offline knowledge source as multiple knowledge text segments in the medical knowledge base corresponding to the offline knowledge source; Generate corresponding titles for the multiple knowledge text segments; Extract features from the multiple knowledge text segments and the titles respectively corresponding to the multiple knowledge text segments to obtain the text features respectively corresponding to the multiple knowledge text segments; Store the titles respectively corresponding to the multiple knowledge text segments and the text features respectively corresponding to the multiple knowledge text segments into the medical knowledge base.

7. The medical Q&A method according to claim 6, wherein The extracting features from the multiple knowledge text segments and the titles respectively corresponding to the multiple knowledge text segments to obtain the text features respectively corresponding to the multiple knowledge text segments includes: Through a first large language model, extract features from a second knowledge text segment and the title of the second knowledge text segment to obtain the output features of the last hidden layer of the first large language model, where the second knowledge text segment is one of the multiple knowledge text segments; Determine the text feature of the second knowledge text segment as the output feature.

8. The medical Q&A method according to claim 6, characterized in that After the extracting features from the multiple knowledge text segments and the titles respectively corresponding to the multiple knowledge text segments to obtain the text features respectively corresponding to the multiple knowledge text segments, the data processing process of the medical knowledge base further includes: Cluster the multiple knowledge text segments according to the text features respectively corresponding to the multiple knowledge text segments to obtain multiple clusters.

9. The medical Q&A method according to claim 8, wherein, The clustering the multiple knowledge text segments according to the text features respectively corresponding to the multiple knowledge text segments to obtain multiple clusters includes: In the i-th clustering process, determine the clusters to which the multiple knowledge text segments respectively belong according to the text features respectively corresponding to the multiple knowledge text segments and the centroid features respectively corresponding to the multiple clusters, where i is greater than or equal to 1; Adjust the centroid features respectively corresponding to the multiple clusters according to the text features of the knowledge text segments respectively included in the multiple clusters to obtain the adjusted centroid features; If the i-th clustering meets the clustering end condition, end the clustering of the multiple knowledge text segments, otherwise perform the (i + 1)-th clustering according to the adjusted centroid features.

10. The medical Q&A method according to any one of claims 2 to 5, characterized in that, The finding the candidate knowledge text segments related to the input text in the access address of the online knowledge source includes: In the access address, find the medical knowledge related to the input text to obtain a search result, where the search result includes: multiple third knowledge text segments and the degree of relevance between the input text and the multiple third knowledge text segments; Select a candidate knowledge text segment corresponding to the online knowledge source from the multiple third knowledge text segments according to the relevance degree between the input text and the multiple third knowledge text segments, and the similarity degree between the multiple third knowledge text segments.

11. The medical Q&A method according to claim 10, wherein The step of selecting a candidate knowledge text segment corresponding to the online knowledge source from the multiple third knowledge text segments according to the relevance degree between the input text and the multiple third knowledge text segments, and the similarity degree between the multiple third knowledge text segments, includes: According to the relevance degree between the input text and the multiple third knowledge text segments, select the knowledge text segment with the highest relevance degree to the input text among the multiple third knowledge text segments as the first candidate knowledge text segment corresponding to the online knowledge source; In the (j + 1)-th selection, determine the similarity degree between the j-th candidate knowledge text segment corresponding to the online knowledge source and the unselected knowledge text segments among the multiple third knowledge text segments, where j is greater than or equal to 1; Select the knowledge text segment with the lowest similarity degree to the j-th candidate knowledge text segment among the unselected knowledge text segments as the (j + 1)-th candidate knowledge text segment corresponding to the online knowledge source, and repeat the selection multiple times until M candidate knowledge text segments corresponding to the online knowledge source are selected, where M is greater than 1.

12. The medical Q&A method according to any one of claims 1 to 5, characterized in that The step of selecting retrieval enhancement data for the input text from the candidate knowledge text segments corresponding to the multiple medical knowledge sources respectively, includes: Perform bucketing on the candidate knowledge text segments corresponding to the multiple medical knowledge sources respectively to obtain multiple buckets, and each of the multiple buckets contains multiple candidate knowledge text segments; Perform in-bucket sorting on the candidate knowledge text segments in the multiple buckets; Select the retrieval enhancement data from the multiple buckets after in-bucket sorting.

13. The medical Q&A method according to claim 12, wherein In the multiple buckets, the candidate knowledge text segments in each bucket come from different medical knowledge sources. The step of performing bucketing on the candidate knowledge text segments corresponding to the multiple medical knowledge sources respectively to obtain multiple buckets, includes: For the multiple medical knowledge sources, divide the candidate knowledge text segments with the same sorting position in different medical knowledge sources into the same bucket to obtain the multiple buckets.

14. The medical Q&A method according to claim 12, characterized in that, The step of performing in-bucket sorting on the candidate knowledge text segments in the multiple buckets, includes: Perform in-bucket sorting on the candidate knowledge text segments in the multiple buckets from the evaluation dimension through a second large language model, and the evaluation dimension includes at least one of the following: the relevance degree between the candidate knowledge text segment and the input text, the text quality of the candidate knowledge text segment, and the reliability of the candidate knowledge text segment.

15. A medical Q&A device, characterized in that, Includes: An acquisition unit, configured to acquire an input text to be answered; A search unit, configured to search for medical knowledge related to the input text from multiple medical knowledge sources to obtain candidate knowledge text segments corresponding to the multiple medical knowledge sources respectively; A selection unit, configured to select retrieval enhancement data for the input text from the candidate knowledge text segments corresponding to the multiple medical knowledge sources respectively; A reply generation unit, configured to generate a reply text corresponding to the input text through a medical question and answer model according to the input text and the retrieval enhancement data.

16. An electronic device, characterized in that, Comprising a memory and a processor; The memory is connected to the processor and is used for storing programs; The processor is used for implementing the medical Q&A method according to any one of claims 1 to 14 by running the programs in the memory.

17. A computer program product, characterized in that, Comprising a computer program which, when executed by a processor, implements the medical Q&A method according to any one of claims 1 to 14.

Citation Information

Cited By

  • Consultation result generation method and device and electronic equipment

    CN120670582A