Medical structured data query method, related device and storage medium

In medical structured data query, using a large language model combined with query sample information to generate query expressions, the problem of insufficient accuracy of query results in the prior art is solved, and efficient and accurate medical structured data query is achieved.

CN119576976APending Publication Date: 2025-03-07BEIJING JIAHE HAISEN HEALTH TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411806441.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-09
Publication Date
2025-03-07

AI Technical Summary

Technical Problem

The prior art cannot effectively ensure the accuracy of medical structured data query results, especially in complex and deep-level field queries.

Method used

By obtaining the current query statement, extracting key entities, and finding the most similar query sample information from the repository, combining the large language model to generate query expressions, and finally using query expressions for data query.

Benefits of technology

It realizes the generation of accurate structured query expressions on a large language model trained with a small amount of corpus, which improves the accuracy and efficiency of medical structured data query.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119576976A_ABST
    Figure CN119576976A_ABST
Patent Text Reader

Abstract

The invention discloses a medical structured data query method, a related device and a storage medium. The method comprises the following steps: acquiring a current query statement; extracting a key entity of the current query statement; based on the current query statement and the key entity thereof, searching query sample information with the highest similarity with the current query statement from a storage library; wherein the query sample information in the storage library is obtained by analyzing query sample statements and corresponding structured query expressions in advance; combining the current query statement with the searched query sample information, and constructing prompt information of the current query statement; the prompt information of the current query statement is input into the large language model which is finely adjusted in advance, and a query expression of the current query statement is obtained; wherein the large language model is finely adjusted by using a mixed corpus set formed by combining a field completion path data set and a query corpus set in advance; and performing data query by utilizing the query expression of the current query statement to obtain a current query result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data query technology, and in particular to a query method for medical structured data and related devices and storage media. Background Art

[0002] Medical structured data is usually more complex, involving many fields and multiple levels, and is generally stored in a certain database. When it is necessary to accurately query certain data, querying directly from the database requires not only proficiency in database query methods, but also understanding the specific field content of medical structured data. Therefore, data query is more complicated and costly.

[0003] The current convenient query methods for structured data are: one is to query keywords from the input query statement, then combine it with multiple template rules to splice out SQL query statements, and use the query statements to query data. Another way is to use a large amount of relevant data to train a large language model so that the large language model can fully learn the knowledge in the relevant field, so that the input query statement can be directly input into the large language model for processing, and the corresponding SQL query statement can be obtained, and the query statement can be used to query data.

[0004] However, the first method relies on custom templates and rules, so it is not only unable to query flexibly, but also the accuracy of the query results depends on the accuracy of the templates and rules. Medical structured data is relatively complex and has many levels. It is difficult for templates and rules to accurately adapt to fields with deeper levels, and thus the accuracy of the query results cannot be effectively guaranteed. For the second method, since medical structured data is relatively complex and has many levels, it is necessary to collect and annotate a large amount of fine-tuning data, that is, to collect input query statements and annotate the corresponding SQL query statements, and fine-tune the large language model so that the large language model can directly process the query statements, and then an accurate SQL query statement can be obtained. The collection and annotation of medical structured data is time-consuming and labor-intensive, and it is difficult to collect a large amount of fine-tuning data, which makes it impossible for the large language model to accurately process complex and deep-level fields, and thus the accuracy of the query results cannot be guaranteed. Summary of the invention

[0005] Based on the above-mentioned deficiencies of the prior art, the present application provides a query method and related devices and storage media for medical structured data to solve the problem that the prior art cannot effectively guarantee the accuracy of the query results.

[0006] In order to achieve the above objectives, this application provides the following technical solutions:

[0007] The first aspect of the present application provides a method for querying medical structured data, comprising:

[0008] Get the current query statement;

[0009] Extracting key entities of the current query statement;

[0010] Based on the current query statement and its key entities, query sample information with the highest similarity to the current query statement is searched from each query sample information in the repository; wherein the query sample information is obtained in advance by analyzing the acquired query sample statement and its corresponding structured query expression, and stored in the repository; the query sample information at least includes the query sample statement and the key entities, query type, query field path and corresponding structured query of the query sample statement;

[0011] Combining the current query statement with the found query sample information to construct prompt information of the current query statement;

[0012] Inputting the prompt information of the current query statement into a pre-fine-tuned large language model to obtain a query expression of the current query statement; wherein the large language model is pre-fine-tuned using a mixed corpus composed of a field completion path dataset and a query corpus; the field completion path dataset is constructed using the path completion prompt information and an incomplete field path; the incomplete field is obtained by truncating the field in the complete field path; the query corpus is obtained by combining various types of information in each of the query sample information with its corresponding query prompt information;

[0013] The query expression of the current query statement is used to perform data query to obtain the current query result.

[0014] Optionally, in the above-mentioned query method for medical structured data, after extracting the key entities in the current query statement, the method further includes:

[0015] The key entities are standardized based on the constructed medical entity knowledge graph.

[0016] Optionally, in the above-mentioned query method for medical structured data, searching for query sample information with the highest similarity to the current query statement from various query sample information in the repository based on the current query statement and its key entities includes:

[0017] Vectorizing the current query statement using a vector model;

[0018] By matching the key entities of the current query statement with the key entities in each of the query sample information in the repository, and performing similarity matching between the vectorized current query statement and the semantic vectors of the query sample statements in the query sample information, the query sample information having the highest similarity to the current query statement is queried.

[0019] Optionally, in the above-mentioned query method for medical structured data, after inputting the prompt information of the current query statement into a pre-fine-tuned large language model to obtain a query expression of the current query statement, the method further includes:

[0020] The query expression of the current query statement is subjected to grammatical correction using a query expression grammar detection and correction device.

[0021] Optionally, in the above-mentioned query method for medical structured data, after the query expression of the current query statement is used to query data and the current query result is obtained, the method further includes:

[0022] The current query result is input into the large language model for polishing to obtain language description information or table display results of the current query result.

[0023] Optionally, in the above-mentioned query method for medical structured data, before obtaining the current query statement, the method further includes:

[0024] Get the medical structured field table;

[0025] Randomly removing fields from each of the complete field paths in the medical structured field table to obtain a plurality of incomplete fields;

[0026] The field completion path data set is constructed by using the path completion prompt information and each of the incomplete field paths.

[0027] Optionally, in the above-mentioned query method for medical structured data, before obtaining the current query statement, the method further includes:

[0028] Acquire multiple fine-tuning corpora, wherein each of the fine-tuning corpora includes a query sample sentence and its corresponding structured query expression;

[0029] For each of the fine-tuned corpora, entity extraction is performed on the query sample sentences in the fine-tuned corpora to obtain key entities of the query sample sentences;

[0030] Standardizing key entities of the query sample sentences using a knowledge graph;

[0031] Based on the standardized key entities of the sample query statements, determining the query type of the sample query statements; wherein the query type is a single-field query or a multi-field query;

[0032] Using a vector model to transform the query sample sentence into a vector to obtain a semantic vector of the query sample sentence;

[0033] Extracting the query field path of the query sample statement from the structured query expression in the fine-tuning corpus;

[0034] The query sample statement, the key entity of the query sample statement, the query type, the semantic vector, the query field path and the corresponding structured query expression are stored in the repository as query sample information;

[0035] The query corpus is obtained by combining various types of information in each of the query sample information with corresponding query prompt information.

[0036] A second aspect of the present application provides a medical structured data query device, comprising:

[0037] A statement acquisition unit, used to acquire the current query statement;

[0038] A first extraction unit, used to extract key entities of the current query statement;

[0039] A sample matching unit, configured to search for the query sample information with the highest similarity to the current query statement from each query sample information in the repository based on the current query statement and its key entities; wherein the query sample information is obtained in advance by analyzing the acquired query sample statement and its corresponding structured query expression, and stored in the repository; the query sample information at least includes the query sample statement and the key entities, query type, query field path and corresponding structured query of the query sample statement;

[0040] An information construction unit, used to combine the current query statement with the found query sample information to construct prompt information of the current query statement;

[0041] An expression generation unit is used to input the prompt information of the current query statement into a pre-fine-tuned large language model to obtain a query expression of the current query statement; wherein the large language model is pre-fine-tuned using a mixed corpus composed of a field completion path data set and a query corpus; the field completion path data set is constructed using the path completion prompt information and an incomplete field path; the incomplete field is obtained by truncating the field in the complete field path; the query corpus is obtained by combining various types of information in each of the query sample information with its corresponding query prompt information;

[0042] The data query unit is used to perform data query using the query expression of the current query statement to obtain the current query result.

[0043] Optionally, the above-mentioned medical structured data query device further includes:

[0044] The first standardization unit is used to standardize the key entities in the current query statement based on the constructed medical entity knowledge graph after the first extraction unit extracts the key entities in the current query statement.

[0045] Optionally, in the above-mentioned query device for medical structured data, the sample matching unit includes:

[0046] A first vectorization unit, configured to vectorize the current query statement using a vector model;

[0047] A similar sample matching unit is used to match the key entities of the current query statement with the key entities in each of the query sample information in the repository, and to perform similarity matching between the vectorized current query statement and the semantic vectors of the query sample statements in the query sample information, so as to query the query sample information with the highest similarity to the current query statement.

[0048] Optionally, the above-mentioned medical structured data query device further includes:

[0049] The grammar correction unit is used to perform grammar correction on the query expression of the current query statement using a query expression grammar detection and correction device.

[0050] Optionally, the above-mentioned medical structured data query device further includes:

[0051] The result processing unit is used to input the current query result into the large language model for polishing processing to obtain language description information or table display results of the current query result.

[0052] Optionally, the above-mentioned medical structured data query device further includes:

[0053] A field table acquisition unit, used for acquiring a medical structured field table;

[0054] A field removal unit, used for randomly removing fields from each of the complete field paths in the medical structured field table to obtain a plurality of incomplete fields;

[0055] The path set construction unit is used to construct the field completion path data set by using the path completion prompt information and each of the incomplete field paths.

[0056] Optionally, the above-mentioned medical structured data query device further includes:

[0057] A corpus acquisition unit, used to acquire a plurality of fine-tuning corpora; wherein each of the fine-tuning corpora includes a query sample sentence and its corresponding structured query expression;

[0058] A second extraction unit is used to perform entity extraction on the query sample sentences in the fine-tuning corpus for each of the fine-tuning corpus, so as to obtain key entities of the query sample sentences;

[0059] A second standardization unit, used to standardize key entities of the query sample sentence using a knowledge graph;

[0060] A type determination unit, configured to determine the query type of the query sample statement based on the standardized key entity of the query sample statement; wherein the query type is a single-field query or a multi-field query;

[0061] A second vectorization unit, configured to perform vector conversion on the query sample sentence by using a vector model to obtain a semantic vector of the query sample sentence;

[0062] A path extraction unit, configured to extract a query field path of the query sample statement from the structured query expression in the fine-tuning corpus;

[0063] An information storage unit, used to store the sample query statement, key entities of the sample query statement, query type, semantic vector, query field path and the corresponding structured query expression as sample query information in the repository;

[0064] The corpus construction unit is used to combine various types of information in each of the query sample information with its corresponding query prompt information to obtain the query corpus set.

[0065] A third aspect of the present application provides an electronic device, including:

[0066] Memory and processor;

[0067] Wherein, the memory is used to store programs;

[0068] The processor is used to execute the program, and when the program is executed, it is specifically used to implement the query method for medical structured data as described in any one of the above.

[0069] A fourth aspect of the present application provides a computer storage medium for storing a computer program, wherein when the computer program is executed by a processor, the computer program is used to implement a method for querying medical structured data as described in any one of the above.

[0070] The present application provides a method for querying medical structured data, which obtains query sample information by analyzing the obtained query sample statements and their corresponding structured query expressions in advance, and stores them in a repository. Among them, the query sample information includes the query sample statements involved in the process of generating structured queries and the key entities, query types, query field paths and corresponding structured queries of the query sample statements. In addition, a mixed corpus composed of a field completion path data set and a small amount of query corpus is used in advance to fine-tune the large language model, so as to make up for the limited data volume of the query corpus by combining the field completion path data set, and also enable the large language model to learn the knowledge of obtaining a complete medical field path. Among them, the field completion path data set is constructed using path completion prompt information and incomplete field paths. The incomplete field is obtained by truncating the field in the complete field path. The query corpus is obtained by combining various types of information in each query sample information with its corresponding query prompt information. When querying data, the current query statement is obtained, and then the key entities of the current query statement are extracted. Based on the current query statement and its key entities, the query sample information with the highest similarity to the current query statement is found from each query sample information in the repository, and then the current query statement is combined with the found query sample information to construct the prompt information of the current query statement, so as to input the prompt information of the current query statement into the pre-fine-tuned large language model to obtain the query expression of the current query statement, so that the large language model can refer to similar query sample information to generate the query expression of the current query statement, ensuring that the large language model can obtain accurate results. Finally, the query expression of the current query statement is used to query the data and obtain the current query result, thereby realizing a query method for medical structured data that can obtain accurate structured query expressions by training a large language model with a small amount of corpus, thereby effectively ensuring the accuracy of the query structure. BRIEF DESCRIPTION OF THE DRAWINGS

[0071] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0072] Figure 1 A flowchart of a method for querying medical structured data provided in an embodiment of the present application;

[0073] Figure 2 A flowchart of a method for finding query sample information with the highest similarity to a current query statement provided in an embodiment of the present application;

[0074] Figure 3 A flowchart of a method for constructing a field completion path dataset provided in an embodiment of the present application;

[0075] Figure 4 A flowchart of a method for constructing a repository and a query corpus provided in an embodiment of the present application;

[0076] Figure 5 A schematic diagram of the architecture of a medical structured data query device is provided for an embodiment of the present application;

[0077] Figure 6 A schematic diagram of the architecture of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0078] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0079] In this application, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.

[0080] The present application embodiment provides a method for querying medical structured data, such as Figure 1 As shown, the following steps are included:

[0081] S101. Obtain the current query statement.

[0082] The current query statement refers to the query statement currently input by the user.

[0083] Specifically, the user may enter a current query statement in the search bar according to the query requirement, for example, please help me search for inpatients with a current medical history of gigantism.

[0084] S102: Extract key entities of the current query statement.

[0085] The key entity refers to the key medical entity in the current query statement.

[0086] It should be noted that in the embodiment of the present application, similar examples need to be found and provided to the large language model for reference in order to obtain an accurate query expression. The key entity in the query statement is the key to the query statement and the main information of the searched data, so the key entity of the current query statement needs to be extracted in order to query the most similar examples.

[0087] Optionally, considering that the same entity may have different names, which will affect the matching of similar examples, in another embodiment of the present application, after executing step S102, the following may be further performed:

[0088] Key entities are standardized based on the constructed medical entity knowledge graph.

[0089] For example, the obtained medical entity is: disease: gigantism. After entity standardization through the knowledge graph, it is converted into: acromegaly.

[0090] S103: Based on the current query statement and its key entities, query sample information with the highest similarity to the current query statement is searched from various query sample information in the repository.

[0091] The query sample information is obtained in advance by analyzing the acquired query sample statements and their corresponding structured query expressions, and is stored in the repository.

[0092] It should be noted that it is impossible to provide a large amount of fine-tuning corpus to fine-tune the large language model, so the knowledge that the large language model can learn is limited. Therefore, in order to enable it to process complex and deep-level query statements while learning limited knowledge. Therefore, in the embodiment of the present application, information of multiple query samples is stored in the repository in advance, so that the information of the corresponding query samples can be matched and provided to the large language model together, so that the large language model can refer to the query samples to process the current query statement and generate its corresponding structured query expression.

[0093] Since the main function of the query sample is to allow the large model to refer to its query statement and generate the corresponding structured query expression, the query sample needs to be obtained through the query sample statement and its corresponding structured query expression. However, it is not convenient for the large language model to determine the information that needs to be referenced by simply providing the query sample statement and its corresponding structured query expression directly. Therefore, in the embodiment of the present application, the query sample statement and its corresponding structured query expression will be analyzed in advance to extract the information involved in constructing the query statement into a structured query expression, and store it in the repository as query sample information.

[0094] The query sample information at least includes the query sample statement and the key entity, query type, query field path and corresponding structured query of the query sample statement. Of course, other information can also be included according to the needs. The big model can check the query sample information and analyze the key entity, query type and query field path of the query statement similar to the query sample statement in the query sample information. And, based on the analysis of the above information, determine what kind of structural information should be generated for the similar query statement.

[0095] In order to find the most similar query sample information, in the embodiment of the present application, similarity matching is performed between the query statement itself and the key entities in the query statement, so as to find out the query sample information that is most similar in structure and semantics.

[0096] For example, the current query statement is: Please help me search for inpatients with gigantism in their current medical history. The matched query sample information includes: the query statement is: search for inpatient data whose current medical history is acromegaly; its corresponding query category is "single field"; its query key entity is: "acromegaly"; the query field path is "hospitalization admission record_current medical history_time node_disease diagnosis_diagnosis name"; the corresponding structured expression is: {"expressions":[[{"field":"hospitalization admission record_current medical history_time node_disease diagnosis_diagnosis name","exp":"include","values":["acromegaly"],"flag":"1","unit":"","isPrecision":true}]],"page":0,"size":10}.

[0097] Optionally, in another embodiment of the present application, a specific implementation of step S103 is as follows: Figure 2 As shown, the following steps are included:

[0098] S201. Vectorize the current query statement using a vector model.

[0099] It should be noted that, in order to facilitate the calculation of the semantic similarity between the current query statement and the query sample statement, it is necessary to vectorize the current query statement using a vector model to obtain the vectorization of the current query statement.

[0100] S202, by matching the key entities of the current query statement with the key entities in each query sample information in the repository, and performing similarity matching between the vectorized current query statement and the semantic vectors of the query sample statements in the query sample information, query sample information with the highest similarity to the current query statement is found.

[0101] Optionally, the matching degree of the key entity and the similarity of the semantic vector can be calculated, and then the query sample information with the largest sum of the two is used as the query sample information with the highest similarity to the current query statement. Of course, other strategies can also be used to determine the query sample information with the highest similarity to the current query statement, for example, the matching degree of the key entity meets a certain threshold, and the query sample information with the largest similarity of the semantic vector is used as the query sample information with the highest similarity to the current query statement.

[0102] S104: Combine the current query statement with the found query sample information to construct prompt information of the current query statement.

[0103] Specifically, query sample information found by the large language model is constructed to construct a prompt of a structured query expression corresponding to the current query statement. For example, taking the above example, the prompt of the current query statement constructed can be: Please refer to the reasoning process of the query example to convert the query statement "Please help me query the inpatients whose current medical history has gigantism" into a query expression. The query example is: Query statement: Query the data of inpatients whose current medical history is acromegaly; the query classification is: single field; the query key entity word: acromegaly; the query field path is: hospitalization admission record_current medical history_time node_disease diagnosis_diagnosis name; the query expression is: {"expressions":[[{"field":"hospitalization admission record_current medical history_time node_disease diagnosis_diagnosis name","exp":"contains","values":["acromegaly"],"flag":"1","unit":"","isPrecision":true}]],"page":0,"size":10}.

[0104] S105: Input the prompt information of the current query statement into the pre-fine-tuned large language model to obtain the query expression of the current query statement.

[0105] Specifically, the prompt information of the current query statement is input into the pre-fine-tuned large language model, and the large language model generates and outputs the query expression of the current query statement according to the prompt information of the current query statement.

[0106] Among them, the large language model is pre-fine-tuned using a mixed corpus composed of a field completion path dataset and a query corpus.

[0107] It should be noted that since it is not convenient to collect a large amount of fine-tuning corpus, a large number of query statements and corresponding structured query expressions, and train the large language surface model, a small amount of query corpus will be obtained in the embodiment of the present application. Among them, the query corpus is obtained by combining the query sample statements in each query sample information and the key entities, query types, query field paths and corresponding structured queries of the query sample statements with their corresponding query prompt information. Then it is mixed with the field completion path data set to fine-tune the large language model.

[0108] Among them, the field completion path dataset is constructed using the path completion prompt information and the incomplete field path. Among them, the incomplete field is obtained by truncating the fields in the complete field path, that is, removing one or more fields in the complete field path, so that the incomplete field can be obtained. The complete field path refers to the complete path of the medical field, which reflects the hierarchical relationship of the medical data and can be used to query data. For example, the complete field path can be: hospitalization record_chief complaint_disease_disease name. Therefore, by constructing the medical field path completion task, the large language model can learn complex multi-level medical field paths without the need for real annotated corpus, so that the query statement can be converted into the corresponding structured query expression.

[0109] Before implementing real-time data query, that is, before executing step S101, not only the repository needs to be built first, but also the field completion path dataset and the query corpus are required. The construction of the query corpus requires the query sample information in the repository, so the repository and the query corpus can be built together.

[0110] Optionally, in another embodiment of the present application, a method for constructing a field completion path dataset is provided, such as Figure 3 As shown, the following steps are included:

[0111] S301. Obtain a medical structured field table.

[0112] Optionally, a known medical structured field table may be directly obtained, wherein the medical structured field table contains various complete medical field paths, for example, hospital admission record_current medical history_time node_symptom_symptom name.

[0113] S302: Randomly remove fields from each complete field path in the medical structured field table to obtain multiple incomplete fields.

[0114] Specifically, randomly removing fields from the complete field path may include: randomly hollowing out some medical entity fields, for example, hospitalization record_chief complaint_{}_disease name; tail field truncation, such as: hospitalization record_chief complaint_disease_{}; tail secondary truncation, such as: hospitalization record_chief complaint_{}_{}; head field truncation, such as: {}_chief complaint_disease_disease name; head secondary truncation, such as: {}_{}_disease_disease name, etc.

[0115] S303: construct a field completion path data set using the path completion prompt information and each incomplete field path.

[0116] Specifically, each incomplete field path is combined with the path completion prompt information to obtain a field completion path dataset, which is convenient for the subsequent construction of a mixed corpus as training data to fine-tune the large language model so that it can learn to analyze the complete field path. Optionally, the path completion prompt information can be: You are now a medical expert, please complete the "{}" in the following medical field path.

[0117] Optionally, in another embodiment of the present application, a method for constructing a repository and a query corpus is provided, such as Figure 4 As shown, the following steps are included:

[0118] S401. Obtain multiple fine-tuning corpora.

[0119] Each fine-tuning corpus includes a query sample sentence and its corresponding structured query expression.

[0120] Since fine-tuning corpus is difficult to obtain in large quantities, only a small amount of fine-tuning corpus can be obtained. However, training a large language model with a small amount of fine-tuning corpus will make the output accuracy of the large language model not high. Therefore, in an embodiment of the present application, the fine-tuning corpus and the completion path set are mixed, and similar query samples are matched to ensure that the large language model can output accurate results.

[0121] S402: For each fine-tuning corpus, perform entity extraction on the query sample sentences in the fine-tuning corpus to obtain key entities of the query sample sentences.

[0122] S403. Use the knowledge graph to standardize key entities of the query sample sentences.

[0123] Similarly, in order to unify the names of entities and facilitate subsequent matching, the key entities of the query sample statements also need to be standardized.

[0124] S404: Determine the query type of the query sample statement based on the standardized key entity of the query sample statement.

[0125] The query type is a single-field query or a multi-field query. Therefore, judging the query type of the sample query statement is to judge whether the sample query statement queries multiple fields or a single field. Since the key entity reflects the content to be queried by the sample query statement, based on the key entity of the sample query statement, it can be judged whether the sample query statement queries multiple fields or a single field.

[0126] S405: Use the vector model to transform the query sample sentence into a vector to obtain a semantic vector of the query sample sentence.

[0127] In order to facilitate the subsequent calculation of the similarity with the semantic vector of the current query statement, in an embodiment of the present application, when processing the query sample statement, it is vectorized, so that there is no need to vectorize it every time a match is made, thereby improving processing efficiency.

[0128] S406: Extract the query field path of the query sample statement from the structured query expression in the fine-tuning corpus.

[0129] It should be noted that the structured query expression includes the query field path, so the query field path of the query sample statement can be directly extracted from the structured query expression.

[0130] S407: Store the query sample statement, key entities of the query sample statement, query type, semantic vector, query field path, and corresponding structured query expression as query sample information in a repository.

[0131] S408: Combine various types of information in each query sample information with its corresponding query prompt information to obtain a query corpus.

[0132] It should be noted that in order to enable the large language model to accurately learn how to obtain various types of information of the query statement, that is, how to obtain the key entities of the query statement, the query type, the query field path and the structured query expression. Therefore, in an embodiment of the present application, a single query statement is split into multiple question-answer pairs, which are combined with corresponding query prompt information. For example, the corresponding query prompt set for each type of information can be: You are now a database administrator, and according to the following query statement, determine whether it is a single field or multiple fields of the query category. You are now a database administrator, and according to the following query statement, extract the keywords of the query. You are now a database administrator, and according to the following query statement, output the complete field path of the query. You are now a database administrator, and according to the following query statement, output the structured query expression.

[0133] Optionally, considering that the structured query expression output by the large language model is accurate as a whole, but there may be some grammatical problems, in order to further improve the accuracy of the data obtained by using the structured query expression to perform data query, in another embodiment of the present application, after executing step S105, the following may be further executed:

[0134] The query expression syntax detection and correction is used to perform syntax correction on the query expression of the current query statement.

[0135] Specifically, the expression grammar detection and correction device analyzes the various grammatical parts in the query expression of the current query statement, such as subject, predicate, object, attributive, etc., and then analyzes whether the combination of various grammatical parts conforms to the grammatical rules according to the set grammatical rules. If not, adjustments are made according to the grammatical rules until the various grammatical parts are combined into an expression that conforms to the grammatical rules.

[0136] S106: Use the query expression of the current query statement to perform data query to obtain the current query result.

[0137] Specifically, the query expression of the current query statement is used to query corresponding data from a database storing structured medical data, thereby obtaining the current query result.

[0138] Optionally, in order to better display and understand the current query result, in another embodiment of the present application, after executing step S106, the following may be further performed:

[0139] The current query result is input into the large language model for polishing to obtain the language description information or table display result of the current query result.

[0140] Among them, polishing processing can be processing to obtain clearer, easier to understand or assist in understanding information, or to display it in a more understandable way.

[0141] The embodiment of the present application provides a query method for medical structured data, which obtains query sample information by analyzing the obtained query sample statements and their corresponding structured query expressions in advance, and stores them in a repository. Among them, the query sample information includes the query sample statements involved in the process of generating structured queries and the key entities, query types, query field paths and corresponding structured queries of the query sample statements. In addition, a mixed corpus composed of a field completion path data set and a small amount of query corpus is used in advance to fine-tune the large language model, so as to make up for the limited data volume of the query corpus by combining the field completion path data set, and also enable the large language model to learn the knowledge of obtaining a complete medical field path. Among them, the field completion path data set is constructed using path completion prompt information and incomplete field paths. The incomplete field is obtained by truncating the field in the complete field path. The query corpus is obtained by combining various types of information in each query sample information with its corresponding query prompt information. When querying data, the current query statement is obtained, and then the key entities of the current query statement are extracted. Based on the current query statement and its key entities, the query sample information with the highest similarity to the current query statement is found from each query sample information in the repository, and then the current query statement is combined with the found query sample information to construct the prompt information of the current query statement, so as to input the prompt information of the current query statement into the pre-fine-tuned large language model to obtain the query expression of the current query statement, so that the large language model can refer to similar query sample information to generate the query expression of the current query statement, ensuring that the large language model can obtain accurate results. Finally, the query expression of the current query statement is used to query the data and obtain the current query result, thereby realizing a query method for medical structured data that can obtain accurate structured query expressions by training a large language model with a small amount of corpus, thereby effectively ensuring the accuracy of the query structure.

[0142] Another embodiment of the present application provides a query device for medical structured data, such as Figure 5 As shown, including:

[0143] The statement acquisition unit 501 is used to acquire the current query statement.

[0144] The first extraction unit 502 is used to extract key entities of the current query statement.

[0145] The sample matching unit 503 is used to find out the query sample information with the highest similarity to the current query statement from each query sample information in the storage repository based on the current query statement and its key entities.

[0146] The query sample information is obtained by analyzing the obtained query sample statements and their corresponding structured query expressions in advance and stored in the repository. The query sample information at least includes the query sample statement and the key entities, query type, query field path and corresponding structured query of the query sample statement.

[0147] The information construction unit 504 is used to combine the current query statement with the found query sample information to construct the prompt information of the current query statement.

[0148] The expression generation unit 505 is used to input the prompt information of the current query statement into the pre-fine-tuned large language model to obtain the query expression of the current query statement.

[0149] The large language model is fine-tuned in advance using a mixed corpus consisting of a field completion path dataset and a query corpus. The field completion path dataset is constructed using path completion prompt information and incomplete field paths. Incomplete fields are obtained by truncating fields in the complete field path. The query corpus is obtained by combining various types of information in each query sample information with its corresponding query prompt information.

[0150] The data query unit 506 is used to perform data query using the query expression of the current query statement to obtain the current query result.

[0151] Optionally, in the medical structured data query device provided in another embodiment of the present application, the device further includes:

[0152] The first standardization unit is used to standardize the key entities based on the constructed medical entity knowledge graph after the first extraction unit extracts the key entities in the current query statement.

[0153] Optionally, in the medical structured data query device provided in another embodiment of the present application, the sample matching unit includes:

[0154] The first vectorization unit is used to vectorize the current query statement by using a vector model.

[0155] The similar sample matching unit is used to match the key entities of the current query statement with the key entities in each query sample information in the repository, and to perform similarity matching between the vectorized current query statement and the semantic vectors of the query sample statements in the query sample information, so as to query the query sample information with the highest similarity to the current query statement.

[0156] Optionally, in the medical structured data query device provided in another embodiment of the present application, the device further includes:

[0157] The grammar correction unit is used to perform grammar correction on the query expression of the current query statement by using the query expression grammar detection and correction device.

[0158] Optionally, in the medical structured data query device provided in another embodiment of the present application, the device further includes:

[0159] The result processing unit is used to input the current query result into the large language model for polishing processing to obtain the language description information or table display result of the current query result.

[0160] Optionally, in the medical structured data query device provided in another embodiment of the present application, the device further includes:

[0161] The field table acquisition unit is used to acquire the medical structured field table.

[0162] The field removal unit is used to randomly remove fields from each complete field path in the medical structured field table to obtain multiple incomplete fields.

[0163] The path set construction unit is used to construct a field completion path dataset using the path completion prompt information and each incomplete field path.

[0164] Optionally, in the medical structured data query device provided in another embodiment of the present application, the device further includes:

[0165] The corpus acquisition unit is used to acquire a plurality of fine-tuning corpora, wherein each fine-tuning corpus includes a query sample sentence and its corresponding structured query expression.

[0166] The second extraction unit is used to perform entity extraction on the query sample sentences in the fine-tuning corpus for each fine-tuning corpus, so as to obtain key entities of the query sample sentences.

[0167] The second standardization unit is used to standardize the key entities of the query sample sentences using the knowledge graph.

[0168] The type judgment unit is used to judge the query type of the query sample sentence based on the key entity of the standardized query sample sentence, wherein the query type is a single-field query or a multi-field query.

[0169] The second vectorization unit is used to convert the query sample sentence into a vector using a vector model to obtain a semantic vector of the query sample sentence.

[0170] The path extraction unit is used to extract the query field path of the query sample statement from the structured query expression in the fine-tuning corpus.

[0171] The information storage unit is used to store the query sample statement, the key entity of the query sample statement, the query type, the semantic vector, the query field path and the corresponding structured query expression as the query sample information in the repository.

[0172] The corpus construction unit is used to combine various types of information in each query sample information with its corresponding query prompt information to obtain a query corpus set.

[0173] It should be noted that the specific working process of each unit provided in the above embodiments of the present application can refer to the implementation process of the corresponding steps in the above method embodiments, and will not be repeated here.

[0174] Another embodiment of the present application provides an electronic device, such as Figure 6 As shown, including:

[0175] Memory 601 and processor 602 .

[0176] The memory 601 is used to store programs.

[0177] The processor 602 is used to execute the program stored in the memory 601. When the program is executed, it is specifically used to implement any of the above-mentioned query methods for medical structured data.

[0178] Another embodiment of the present application provides a computer storage medium for storing a computer program. When the computer program is executed by a processor, it is used to implement a method for querying medical structured data as provided in any of the above embodiments.

[0179] Computer storage media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0180] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0181] The above 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 may 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 will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for querying medical structured data, characterized in that: include: Get the current query statement; Extracting key entities of the current query statement; Based on the current query statement and its key entities, query sample information with the highest similarity to the current query statement is searched from each query sample information in the repository; wherein the query sample information is obtained in advance by analyzing the acquired query sample statement and its corresponding structured query expression, and stored in the repository; the query sample information at least includes the query sample statement and the key entities, query type, query field path and corresponding structured query of the query sample statement; Combining the current query statement with the found query sample information to construct prompt information of the current query statement; Inputting the prompt information of the current query statement into a pre-fine-tuned large language model to obtain a query expression of the current query statement; wherein the large language model is pre-fine-tuned using a mixed corpus composed of a field completion path dataset and a query corpus; the field completion path dataset is constructed using the path completion prompt information and an incomplete field path; the incomplete field is obtained by truncating the field in the complete field path; the query corpus is obtained by combining various types of information in each of the query sample information with its corresponding query prompt information; The query expression of the current query statement is used to perform data query to obtain the current query result.

2. The method according to claim 1, characterized in that After extracting the key entities in the current query statement, the method further includes: The key entities are standardized based on the constructed medical entity knowledge graph.

3. The method according to claim 1, characterized in that The step of searching, based on the current query statement and its key entities, for query sample information having the highest similarity to the current query statement from each query sample information in the repository includes: Vectorizing the current query statement using a vector model; By matching the key entities of the current query statement with the key entities in each of the query sample information in the repository, and performing similarity matching between the vectorized current query statement and the semantic vectors of the query sample statements in the query sample information, the query sample information having the highest similarity to the current query statement is queried.

4. The method according to claim 1, characterized in that After inputting the prompt information of the current query statement into the pre-fine-tuned large language model to obtain the query expression of the current query statement, the method further includes: The query expression of the current query statement is subjected to grammatical correction using a query expression grammar detection and correction device.

5. The method according to claim 1, characterized in that After performing data query using the query expression of the current query statement to obtain the current query result, the method further includes: The current query result is input into the large language model for polishing to obtain language description information or table display results of the current query result.

6. The method according to claim 1, characterized in that Before obtaining the current query statement, the method further includes: Get the medical structured field table; Randomly removing fields from each of the complete field paths in the medical structured field table to obtain a plurality of incomplete fields; The field completion path data set is constructed by using the path completion prompt information and each of the incomplete field paths.

7. The method according to claim 1, characterized in that Before obtaining the current query statement, the method further includes: Acquire multiple fine-tuning corpora, wherein each of the fine-tuning corpora includes a query sample sentence and its corresponding structured query expression; For each of the fine-tuned corpora, entity extraction is performed on the query sample sentences in the fine-tuned corpora to obtain key entities of the query sample sentences; Standardizing key entities of the query sample sentences using a knowledge graph; Based on the standardized key entities of the sample query statements, determining the query type of the sample query statements; wherein the query type is a single-field query or a multi-field query; Using a vector model to transform the query sample sentence into a vector to obtain a semantic vector of the query sample sentence; Extracting the query field path of the query sample statement from the structured query expression in the fine-tuning corpus; The query sample statement, the key entity of the query sample statement, the query type, the semantic vector, the query field path and the corresponding structured query expression are stored in the repository as query sample information; The query corpus is obtained by combining various types of information in each of the query sample information with corresponding query prompt information.

8. A query device for medical structured data, characterized in that: include: A statement acquisition unit, used to acquire the current query statement; A first extraction unit, used to extract key entities of the current query statement; A sample matching unit, configured to search for the query sample information with the highest similarity to the current query statement from each query sample information in the repository based on the current query statement and its key entities; wherein the query sample information is obtained in advance by analyzing the acquired query sample statement and its corresponding structured query expression, and stored in the repository; the query sample information at least includes the query sample statement and the key entities, query type, query field path and corresponding structured query of the query sample statement; An information construction unit, used to combine the current query statement with the found query sample information to construct prompt information of the current query statement; An expression generation unit is used to input the prompt information of the current query statement into a pre-fine-tuned large language model to obtain a query expression of the current query statement; wherein the large language model is pre-fine-tuned using a mixed corpus composed of a field completion path data set and a query corpus; the field completion path data set is constructed using the path completion prompt information and an incomplete field path; the incomplete field is obtained by truncating the field in the complete field path; the query corpus is obtained by combining various types of information in each of the query sample information with its corresponding query prompt information; The data query unit is used to perform data query using the query expression of the current query statement to obtain the current query result.

9. An electronic device, characterized in that: include: Memory and processor; Wherein, the memory is used to store programs; The processor is used to execute the program, and when the program is executed, it is specifically used to implement the query method for medical structured data as described in any one of claims 1 to 7.

10. A computer storage medium, characterized in that: Used to store a computer program, which, when executed by a processor, is used to implement the medical structured data query method as described in any one of claims 1 to 7.

Citation Information

Cited By

  • Patent retrieval type intelligent construction method and device and storage medium

    CN120929487A