A method for constructing a natural language retrieval model for electronic medical records based on generative AI

The method employs a generative AI model to convert natural language queries into logical expressions for electronic medical records, addressing the complexity of SQL-based systems by providing a user-friendly interface for error correction and reducing costs, thereby improving usability and efficiency in querying medical records.

CN119207824BActive Publication Date: 2025-03-25CHENGDU MEDICAL STAR TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411686435.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-25
Publication Date
2025-03-25
Estimated Expiration
2044-11-25

AI Technical Summary

Technical Problem

Current natural language querying systems for electronic medical records rely heavily on SQL, which requires users to have SQL knowledge, and are prone to errors due to the complexity of table structures and limited user-friendly interfaces.

Method used

A method using a generative AI model to convert natural language queries into logical query expressions, allowing users to describe their data needs in plain language, with automatic conversion to query conditions, and providing a user-friendly interface for error correction, while reducing training costs and project timelines.

Benefits of technology

Enhances user-friendliness and usability of querying systems by automatically generating query conditions, reducing the risk of SQL errors, and lowering project costs through automated data construction and validation processes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119207824B_ABST
    Figure CN119207824B_ABST
Patent Text Reader

Abstract

The method for constructing a natural language retrieval model for electronic medical records based on generative AI belongs to the field of electronic digital data processing technology, and includes the following steps: Step 01, obtaining / configuring relevant table information and field information in relevant tables; Step 02, automatically constructing a logical expression of query conditions; Step 03, converting the logical expression into a natural language description through a large language model; Step 04, using the logical expression of query conditions as output and the natural language description as input, and organizing them into training / fine-tuning data; Step 05, training / fine-tuning the model; Step 06, encapsulating the trained model as a service and providing it to the outside. The present invention can automatically construct training data, thereby reducing R&D costs; constraining logical expressions, reducing the risk of hallucinations of generative AI; avoiding the impact of directly executing erroneous SQL on the database; improving the convenience of user use; reducing the project R&D cycle, and promoting the application of AI large models.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of electronic digital data processing, and in particular to a method for constructing a natural language retrieval model for electronic medical records based on generative AI. Background Art

[0002] For medical electronic medical record retrieval scenarios, there are many medical record-related tables, and there are more than 50 standard electronic medical record data sets. When obtaining the medical records they need, business personnel often need to make more flexible queries. A common solution is general query, which allows you to freely select the logical expression combination of which table and which field in the search conditions to achieve flexible query conditions. However, there is a problem with this type of search. People who need to use this function are familiar with the table structure, but there are also business personnel who are not familiar with the table structure and do not know which tables the content they need to query is scattered in.

[0003] Training / fine-tuning the large language model of general generative AI to convert the natural language description of the query into the background query logic is a better solution. Users describe the content to be queried in natural language, that is, the query results are returned. This method is very user-friendly. Among the currently known large models, natural language is mainly converted into SQL statements, and then SQL is further used for database queries. This solution has the following problems: First, it is heavily dependent on SQL, and the target data of the query must be SQL-compatible data; second, the SQL generated by its generative AI is not necessarily correct. If there is a grammatical error or a logical error, it is difficult to correct the error; third, very few users are familiar with SQL, and it is not realistic to use user error correction methods. Summary of the invention

[0004] The present invention provides a method for constructing a natural language retrieval model for electronic medical records based on generative AI to address the deficiencies of the above-mentioned prior art. By training an AI model, the method enables business personnel to make natural language descriptions of the data they want, which can be automatically converted into logical expressions of query conditions of an external general query module. Business personnel no longer need to be familiar with the relevant table structure, which improves the ease of use and practicality of the external general query module. In this method, what is generated is the logical expression of the query condition required by the target query module. The logical expression has strong constraints, and it is relatively easy to judge whether the condition format generated by the model is correct. And it can be displayed through the query condition column of the external query module, which is convenient for users to further correct the retrieval conditions. In addition, the method adopts relevant automatic generation technology to reduce the labor cost of training / fine-tuning, reduce the project cycle, and thus reduce the overall cost of the project.

[0005] In order to achieve the purpose of the present invention, the following technologies are proposed:

[0006] A method for constructing a natural language retrieval model for electronic medical records based on generative AI, comprising the steps of:

[0007] Step 01, obtain / configure relevant table information and field information in relevant tables;

[0008] Step 02, automatically build the query condition logical expression;

[0009] Step 03, convert the logical expression into a natural language description through a large language model;

[0010] Step 04: Take the query condition logical expression as output and the natural language description as input to organize the training / fine-tuning data;

[0011] Step 05, train / fine-tune the model;

[0012] Step 06: Encapsulate the trained / fine-tuned model as a service and provide it to the outside world.

[0013] Furthermore, in step 01, when obtaining / configuring relevant table information:

[0014] Get / configure the patient basic information table and its fields;

[0015] Get / configure the patient visit information table and its fields;

[0016] Obtain / configure electronic medical records and the business tables and fields that need to be queried.

[0017] Furthermore, in step 02, the steps of automatically establishing the query condition logical expression are:

[0018] Step 20, configure the logical operation of each field and set the example value of each field operator;

[0019] Step 21, randomly setting the grouping level of the logical expression;

[0020] Step 22, iteratively and randomly setting the number of sub-expressions of the grouping expression, and the relationship between the sub-expression and the previous sub-expression;

[0021] Step 23, randomly set the atomic expression field, and obtain the logical symbols of the field and the value, and the example value corresponding to the logical symbol of the field.

[0022] Furthermore, in step 03, when the query condition logical expression is converted into a natural language description through the large language model, the relevant tables and field information in the tables mentioned in step 01 and the query condition logical expression automatically constructed in step 02 are used to organize them into calling parameters of the large language model and return the natural language description corresponding to the logical expression.

[0023] Furthermore, the calling parameters are a sample dialogue, user input and prompt words.

[0024] Furthermore, in step 04, the query condition logical expression is used as output, the natural language description is used as input, and the steps for organizing training / fine-tuning data are as follows:

[0025] The query condition logical expression automatically constructed in step 02 is used as output;

[0026] The natural language description obtained in step 03 is used as input;

[0027] And add the prompt word Prompt;

[0028] Combine multiple training data into a json training data set.

[0029] Furthermore, in step 06, the steps of encapsulating the trained model as a service are:

[0030] Step 60, receiving search conditions input by an external search system;

[0031] Step 61, organizing the calling parameters of the trained model;

[0032] Step 62, calling the logical expression generated by the model;

[0033] Step 63, parsing the segmentation logic expression and organizing the response data;

[0034] Step 64, verifying the logical expression;

[0035] Step 65, format conversion.

[0036] Further, the calling parameters in the calling parameters of the trained model are organized as prompt words and user input words.

[0037] Furthermore, when verifying the logical expression, the table, field and logical operator in the response are verified to be consistent with the configuration by the atomic expression;

[0038] If the atomic expression in the response is consistent with its table, field and logical operator configuration, it is converted into the name format required by the external retrieval system;

[0039] If the atomic expression in the response is inconsistent with its table, field, and logical operator configuration, the atomic expression is deleted or an error message is returned to the caller or the model is called again to regenerate.

[0040] The advantages of the above technical solution are:

[0041] The present invention can automatically construct training data, thereby reducing R&D costs; constrain logical expressions to reduce the risk of hallucinations in generative AI; avoid the impact of directly executing erroneous SQL on the database; improve user convenience; shorten project R&D cycles, and promote the application of large AI models. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to make the objectives, technical solutions and advantages of the present invention more clear, the present invention will be further described in detail below with reference to the accompanying drawings.

[0043] Figure 1 The overall flow chart of the method for constructing an electronic medical record natural language retrieval model based on generative AI is shown.

[0044] Figure 2 A schematic diagram showing the source of information in pre-configured related table information is shown.

[0045] Figure 3 A flowchart for automatically and randomly constructing a query condition logic expression is shown.

[0046] Figure 4 A flow chart for generating a natural language description of a logical expression of a query condition is shown.

[0047] Figure 5 A flowchart for organizing training / fine-tuning data is shown.

[0048] Figure 6 A flowchart showing service encapsulation and granting of verification and conversion capabilities. DETAILED DESCRIPTION

[0049] like Figure 1 As shown, a method for constructing an electronic medical record natural language retrieval model based on generative AI includes the following steps:

[0050] Step 01, obtain / configure relevant table information, wherein the relevant table information includes table information and field information of a patient basic information table, a patient consultation information table, and a relevant medical record information table.

[0051] Step 02: Automatically and randomly construct a query condition logical expression.

[0052] Step 03, call the general large language model to convert the query condition logical expression into a natural language description. The large language model is chatGLM, Qwen1.5, Qwen2, etc.

[0053] Step 04: Take the query condition logical expression as output and the natural language description as input, and organize them into training / fine-tuning data.

[0054] Step 05, train / fine tune the model.

[0055] Step 06: Encapsulate the trained / fine-tuned model as a service and provide it to the outside world, and give it verification and conversion capabilities.

[0056] like Figure 2 As shown, when the relevant table information is obtained / configured in step 01. Specifically, in electronic medical record queries, it is often necessary to filter out medical records that meet these medical record conditions. When screening, the screening conditions include the patient's basic information, medical (case) information, and related medical business (medical record) information. In step 01, it is necessary to obtain the above-mentioned tables and their field information required for retrieval. Among them, the basic information table is shown in Table 1, the medical information table is shown in Table 2, and the medical record tables are shown in Table 3. The table names and field names in Tables 1, 2, and 3 shown below are only examples. In specific applications, they can be adjusted according to different environments, and the number of fields also needs to be further determined according to actual retrieval needs.

[0057] Table 1 Basic information of patients

[0058] Field Name Field Chinese meaning Remark ID Patient ID name Patient Name sex gender birthday Date of Birth ABO ABO blood type RH RH blood type ...... Others such as phone number, contact person, home address, ID number, marriage, ethnicity, education, etc.

[0059] Table 2 Patients’ medical information

[0060] Field Name Field Chinese meaning Remark personID Patient ID Related basic information table hospital Hospital department Department begin Consultation start time end End time of consultation recordID Medical number recordType Type of visit Inpatient / Outpatient / Emergency diseaseCode Disease Code diseaseName Disease name doctor Attending Physician doctorID Attending physician code ... Others: such as wards, nurses, discharge status, disease status, etc.

[0061] Table 3 Medical records

[0062] Table name Chinese name of each table Fields bloodTransfusion Blood transfusion records Consultation number, blood transfusion type, nature of blood transfusion, application for RH blood type, application for ABO blood type, transfusion time... outpatientOrder Outpatient (emergency) doctor's orders Consultation number, frequency of drug use, type of doctor's order, content of doctor's order, type of drug, dosage form, time of doctor's order issuance... opration Surgical records Consultation number, surgical site category, surgical incision category, surgical level, surgical name, surgeon, name of interventional material, anesthesia method, surgical date... examinationReport Inspection Report Consultation number, examination items, examination site, examination method, examination department, report date, report results - objective findings, report results - subjective prompts, examination results... .... Test reports, hospitalization instructions, admission records, discharge summaries...

[0063] like Figure 3 As shown, when the query condition logic expression is automatically and randomly constructed in step 02, the following steps are performed:

[0064] Step 20: Configure the logical operators and sample values ​​of each field.

[0065] During configuration, when the field types are different, different logical operators can be set, as shown in the following examples.

[0066] For example: patient name, the general query is the complete name, no fuzzy query is required, and the operator is "equal to".

[0067] For example: Report results - subjective prompts, generally a fuzzy query contains a keyword, and the operator is "contains".

[0068] For example: surgery date, for the time field, the operator can be set to "less than", "equal to", "greater than", or "between".

[0069] During configuration, you can set different sample values ​​according to the field content and logical operators.

[0070] The example value can support enumeration, such as the example value of name "Zhang XX, Li XX, Wang XX" and other example lists. The example value can also support dictionary, such as the example value of ethnicity, which is extracted from the ethnic dictionary table. For another example, for the department field, different example values ​​are set for different operators. When the operator is "equal to", the example value is set to "Internal Medicine 1, Internal Medicine 2". When the operator is "contains", the example value is set to "Internal, External".

[0071] Step 21, automatically construct a logical expression, and randomly set the grouping level of the logical expression constructed this time according to the maximum grouping level of the target query logical expression.

[0072] Among them, examples of the maximum grouping level of the target query logic expression are as follows:

[0073] If a simple query is required, since no grouping is required, the grouping level is 1. For example, "patient name equals Zhang XX and consultation time is greater than 20xx-xx-xx", and since there is only one grouping level, the conditional logic expression has no brackets.

[0074] If you need to perform a slightly more complex query, assume that the grouping level is 2. For example, "(patient name equals Zhang XX and consultation time greater than 20xx-xx-xx) and (application ABO blood type equals O type or application ABO blood type equals B type)", from the above example, we can see that the conditional logic expression of level 2 is () and / or ().

[0075] If a more complex query is required, assume that the grouping level is 3. For example, "(patient name equals Zhang XX and (visit time less than 20xx-xx-xx or visit time greater than 20xx-xx-xx)) and (application ABO blood type equals O type or application ABO blood type equals B type)", from the above example, we can see that the logical expression of level 3 is (()and / or())or().

[0076] When executing step 21, the grouping level of the currently constructed logical expression can also be directly set according to the maximum grouping level. Assuming that the maximum level of the logical expression is 3, one of the grouping levels 1, 2, and 3 in the currently constructed logical expression can be randomly selected.

[0077] Step 22, iterate layer by layer, and randomly set the number of sub-expressions in each level group in the logical expression and the connection relationship symbols between the sub-expressions.

[0078] Based on the maximum number of sub-expressions set globally, the number of each local sub-expression is randomly set to be greater than 0 and less than or equal to the maximum number of sub-expressions, and the connection relationship symbol is randomly selected to be one of and or or.

[0079] For example, assuming that the number of sub-expressions at each level in the logical expression is at most 4, the random value obtained by the currently constructed logical expression grouping level is 2. Then, first randomly set the number of sub-expressions at the top level of the logical expression to one of 1 to 4, and the random value obtained by the logical expression grouping level is 2, then the structure of the top-level expression is: (sub-expression) and / or (sub-expression). Then, for each sub-expression, randomly select the connection relationship symbol and or or, and the result is: (sub-expression) and (sub-expression). Then, iterate and process the sub-expressions of the next level in turn, and the final result is: (atomic logical expression or atomic logical expression or atomic logical expression) and (atomic logical expression and atomic logical expression).

[0080] Step 23, randomly evaluate the atomic logical expression.

[0081] In this process, each atomic logical expression is evaluated, and its value is as follows: field, logic symbol, and example value. The field is any value randomly selected from the field in step 01, and the logic symbol is one of the logic operation symbols and or or configured for the field in step 02, and its example value is one of the example values ​​configured for the field in step 20.

[0082] For example, for one of the atomic expressions, a table is randomly selected, and the value obtained is "Medical Information Table", and then a field is randomly selected under the table, and the value obtained is "Medical Department". The logical operators set for the medical department are "equal" and "contains", and the randomly obtained logical operator is "equal"; for the "equal" operator of the medical department, the set example value is the medical department dictionary, which has values ​​such as "Internal Medicine 1", "Internal Medicine 2", "Pediatrics", and "Orthopedics", and the randomly selected value is "Orthopedics". Based on the above values, the logical expression is combined into: Medical Information Table, Medical Department, Equal, Orthopedics.

[0083] Then the two-level example expression in step 21 is: "(atomic logical expression or atomic logical expression or atomic logical expression) and (atomic logical expression and atomic logical expression)", and the value of each atomic expression can be obtained to obtain a result similar to the following:

[0084] "(Medical Information Form: Medical Department is equal to Orthopedics or Basic Information Form: Gender is equal to Male or Medical Information Form: Medical Time is greater than 20xx-xx-xx) and (Examination Report: Examination Items Include Lung and Blood Transfusion Record: ABO Blood Type Application is equal to Type A)".

[0085] In the actual electronic medical record retrieval business, the connection symbols and and or have a much higher probability of doing and query. Therefore, the random weights of and and or can be adjusted as needed. Similarly, the probability of querying the two tables involving basic information and medical information is also relatively high, and the random weights of the tables can also be adjusted.

[0086] like Figure 4 As shown, in step 03, when the query condition logical expression is converted into a natural language description through the large language model, the relevant table and field information in the table mentioned in step 01 and the query condition logical expression automatically and randomly constructed in step 02 are applied, organized into calling parameters of the large language model, and returned as a natural language description of the logical expression.

[0087] The above call parameters include prompt (prompt word), multiple rounds of sample dialogues, and user input (logical expression).

[0088] The following is an example of a prompt, for example: set the prompt as: "You are a medical expert with strong logical ability. Now you are required to convert some logical expressions of medical queries into natural language descriptions. Each sub-condition in these logical conditions is to locate a patient's visit. Multiple conditions are combined to further point to patients who meet these conditions. Please note that the description should be as concise and easy to understand as possible."

[0089] The following are examples of multi-round sample conversations, for example:

[0090] Q: Please describe the query conditions: "(Hospitalization order information: drug dosage form equals "syrup" and basic information: education level equals "junior high school graduate" and medical information: disease status equals "serious") and (medical information: attending physician code equals "xxxxxx")".

[0091] Answer: "The hospitalized patients are in serious condition, some are taking adhesive medications, have junior high school education, and their physician code is xxxxxx."

[0092] Q: Please describe the query conditions: "Outpatient (emergency) medical orders: medical order item equals "Nicorandil tablets"".

[0093] Answer: "There are patients in the outpatient clinic who are taking Nicorandil tablets."

[0094] Q: Please describe the query conditions: "(hospitalization medical order information: medical order category equals "long-term medical order") or (surgical record: surgical doctor equals "XXX")".

[0095] Answer: "Those who are hospitalized with long-term medical orders and have undergone surgery by doctor XXX."

[0096] Q: Please describe the search conditions: "(Surgical record: surgical site category equals "superficial surgery" or Surgical record: surgery name equals "testicular hydrocele aspiration" and Surgical record: surgical incision category equals "Class IV incision" and Examination report: examination category equals "neuro-electrophysiology") or (Hospitalization order information: order issuance date and time equals "20xx-xx-xx")".

[0097] Answer: "Those who have undergone surgery other than "testicular hydrocele aspiration" and the surgical incision was a "Class IV incision", and have undergone "neuroelectrophysiological" examination, or have undergone "superficial surgery", or have had a medical order issued on 20xx-xx-xx".

[0098] The user input consists of "Please describe the query conditions:" and the automatically constructed logical expression.

[0099] The following example is given to illustrate the user input, for example: Please describe the query condition: "(Medical Information Table: Medical Department is equal to Orthopedics or Basic Information Table: Gender is equal to Male or Medical Information Table: Medical Time is greater than 20xx-xx-xx) and (Examination Report: Examination Items Include Lung and Blood Transfusion Record: Application for ABO Blood Type is equal to Type A)".

[0100] like Figure 5 As shown, in step 04, when organizing the training / fine-tuning data, it is necessary to use the calling parameters of step 03 multiple times with a large language model (such as Wenxin Yiyan, Tongyi Qianwen, chatGLM, QWen1.5, Qwen2, etc.), and then organize and form a certain amount of batch training data. After testing, using tens of thousands of automatically generated training data has a good effect.

[0101] Each piece of training data is composed of the logical expression automatically constructed in step 02 as output, the natural language search condition converted in step 03 as input, and a specific prompt (prompt word) to form a complete piece of training data. The prompt needs to organize the statements according to the table field information, similar to the following prompt words: "You are a logical expression assistant, and you are familiar with the hospital diagnosis and treatment business. Now there is a diagnosis and treatment business query system that uses a set of custom logical expressions to obtain query results through this set of query expressions. Your task is to convert the query requirements described by the doctor in natural language into the custom logical expressions of the query system. Among them, the diagnosis and treatment business table information is as follows: 1. Table name: Basic information table, Fields: Patient ID, patient name, gender, date of birth, ABO blood type, RH blood type; 2. Table name: Medical information table, Fields: Medical hospital, medical department, medical start time, medical end time, medical number, medical type, disease code, disease name, attending physician; 3. Table name: Blood transfusion record, Fields, etc. The relationship between these tables is that a patient has one basic information, and there may be multiple medical information, which may be outpatient visits or inpatient visits; The medical information may include multiple blood transfusion records, multiple surgical records, and multiple examination reports; outpatient visits may include multiple outpatient medical orders, and inpatient visits may include multiple inpatient medical orders. Please convert the following description into a logical expression: "

[0102] In step 05, the training data organized in step 04 is used to train / fine-tune a large language model, and the model can be chatGLM, Qwen1.5, Qwen2, etc. The trained / fine-tuned model has the ability to convert the query condition description in natural language into the custom query logic expression.

[0103] like Figure 6 As shown, in step 06, the trained model is packaged as a service and provided to the outside.

[0104] By encapsulating the trained model into a service, we provide a service for converting natural language query conditions into query logic expressions for external general electronic medical record retrieval systems. The service processing method is as follows:

[0105] Step 060, receiving natural language query conditions.

[0106] For example: "Male, hospitalized before 2018, received type A blood transfusion."

[0107] Step 061, organize the calling parameters of the trained model, including prompt and user input, wherein the prompt is consistent with the prompt in step 04.

[0108] For example, the user input is the received natural language query condition, which in this example is: "Male, hospitalized before 2018, received type A blood transfusion".

[0109] Step 062, call the model to generate a logical expression, and use the prompt word and user input as call parameters to call the trained model.

[0110] For example, in this example, it returns "Basic information: Gender equals Male and Medical information: Medical category equals Hospitalization and Blood transfusion record: ABO blood type applied for equals Type A".

[0111] Step 063, parse and segment the logical expression, organize the response data, segment the logical expression returned by the trained model into group expressions according to the groups (brackets), and iteratively process the logical expressions in the groups, and finally decompose them into basic simple group expressions, and then segment the basic simple group expressions according to and / or to form atomic logical expressions.

[0112] For example, "(Visit Information Table: Visiting Department is equal to Orthopedics or Basic Information Table: Gender is equal to Male or Visit Information Table: Visiting Time is greater than 20xx-xx-xx) and (Examination Report: Examination Items Include Lung and Blood Transfusion Record: ABO Blood Type is equal to Type A)", the split group expressions are "Visit Information Table: Visiting Department is equal to Orthopedics or Basic Information Table: Gender is equal to Male or Visit Information Table: Visiting Time is greater than 20xx-xx-xx" and "Examination Report: Examination Items Include Lung and Blood Transfusion Record: ABO Blood Type is equal to Type A", and the group expressions are organized into the response json data format as follows:

[0113] [ { conditions: [],

[0114] operate: “”

[0115] },{ conditions:[],

[0116] operate: “and”

[0117] } ]

[0119] Among them, conditions represents the grouping expression (further filled in later), and operate represents the logical relationship with the previous grouping expression.

[0120] If there are still groups, further iterate to decompose the group expressions. In this example, the two group expressions are basic groups.

[0121] Continue to perform and / or segmentation on the basic grouping expressions. It can be seen that in this example, the first basic grouping expression "Medical Information Table: Medical Department Equals Orthopedics or Basic Information Table: Gender Equals Male or Medical Information Table: Medical Time Greater Than 20xx-xx-xx" is segmented into:

[0122] [{ table: "Medical Information Table",

[0123] field: "Consulting Department",

[0124] action: "equal to",

[0125] value: "Orthopedics",

[0126] value2: ""

[0127] operate: “”

[0128] },{ table: "Basic information table",

[0129] field: "Gender",

[0130] action: "equal to",

[0131] value: "male",

[0132] value2: ""

[0133] operate: “or”

[0134] },{ table: "Medical Information Table",

[0135] field: "Consultation time",

[0136] action: "greater than",

[0137] value: "2021-10-11",

[0138] value2: ""

[0139] operate: “”

[0140] }, ]

[0142] Among them, table is the table name (in Chinese), field is the field name (in Chinese), action is the logical relationship between the field and the value (in Chinese, such as greater than, less than, equal to, between, etc.), value is the value in general, value2 is used when action is between, such as time range, operate is the logical relationship with the previous expression (and, or).

[0143] Fill the basic grouping expression result into the grouping expression, such as the following response data:

[0144] [{ conditions: [{ table: “Medical Information Table”,

[0145] field: "Consulting Department",

[0146] action: "equal to",

[0147] value: "Orthopedics",

[0148] value2: ""

[0149] operate: “”

[0150] },{ table: "Basic information table",

[0151] field: "Gender",

[0152] action: "equal to",

[0153] value: "male",

[0154] value2: ""

[0155] operate: “or”

[0156] },{ table: "Medical Information Table",

[0157] field: "Consultation time",

[0158] action: "greater than",

[0159] value: "2021-10-11",

[0160] value2: ""

[0161] operate: “”

[0162] },

[0163] ],

[0164] operate: “”

[0165] },{ conditions: [{ table: “Inspection Report”,

[0166] field: "Inspection Items",

[0167] action: "include",

[0168] value: "lung",

[0169] value2: ""

[0170] operate: “”

[0171] },{ table: "Blood transfusion record",

[0172] field: "Apply for ABO blood type",

[0173] action: "equal to",

[0174] value: "Type A",

[0175] value2: ""

[0176] operate: “and”

[0177] }

[0178] ],

[0179] operate: “and”

[0180] } ]

[0182] Step 064, verify the logical expression, verify whether the table, field and logical operator of the atomic expression in the response are consistent with the configuration. After verification, if the table, field and logical operator configuration are consistent, then convert them into the name format required by the external retrieval system as needed. If the table, field and logical operator configuration are inconsistent, delete the atomic expression or return an error message to the caller or call the model again to regenerate the logical expression as needed.

[0183] Step 065, format conversion, converting the Chinese table name into its corresponding database table name, and the Chinese field name into the corresponding field name in the database, such as converting symbols such as greater than, less than, and equal to into general symbols such as >, <, and =.

[0184] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A method for constructing a natural language retrieval model for electronic medical records based on generative AI, characterized in that: Includes steps: Step 01, obtain pre-configured related table information and field information in the related table; Step 02, automatically build the query condition logical expression; In step 02, the steps to automatically create a query condition logical expression are: Step 20, configure the logical operation of each field and set the example value of each field operator; Step 21, randomly setting the grouping level of the logical expression; Step 22, iteratively and randomly setting the number of sub-expressions of the grouping expression, and the relationship between the sub-expression and the previous sub-expression; Step 23, randomly setting the atomic expression field, and obtaining the logical symbols of the field and the value, and the example value corresponding to the logical symbol of the field; Step 03, convert the logical expression into a natural language description through a large language model; Step 04: Use the query condition logical expression automatically constructed using rules as output, and the natural language description generated by generative AI conversion as input to organize training / fine-tuning data; In step 04, the query condition logical expression is used as output and the natural language description is used as input. The steps to organize the training / fine-tuning data are: The query condition logical expression automatically constructed in step 02 is used as output; The natural language description obtained in step 03 is used as input; And add the prompt word Prompt; Combine multiple training data into a json training data set; Step 05, train / fine-tune the model; Step 06: Package the trained / fine-tuned model as a service and provide it to the outside world; In step 06, the steps to encapsulate the trained model as a service are: Step 60, receiving search conditions input by an external search system; Step 61, organizing the calling parameters of the trained model; Step 62, calling the logical expression generated by the model; Step 63, parsing the segmentation logic expression and organizing the response data; Step 64, verifying the logical expression; Step 65, format conversion.

2. The method for constructing a natural language retrieval model for electronic medical records based on generative AI according to claim 1, characterized in that: In step 01, when obtaining / configuring related table information: Get the pre-configured patient basic information form and its fields; Get the pre-configured patient visit information form and its fields; Get pre-configured electronic medical records and the business tables and fields that need to be queried.

3. The method for constructing a natural language retrieval model for electronic medical records based on generative AI according to claim 1, characterized in that: In step 03, when the query condition logical expression is converted into a natural language description through the large language model, the relevant table and field information in the table mentioned in step 01 and the query condition logical expression automatically constructed in step 02 are used to organize them into calling parameters of the large language model and return the natural language description corresponding to the logical expression.

4. The method for constructing a natural language retrieval model for electronic medical records based on generative AI according to claim 3, characterized in that: The calling parameters are the sample dialogue, user input and prompt words.

5. The method for constructing a natural language retrieval model for electronic medical records based on generative AI according to claim 1, characterized in that: The calling parameters in the calling parameters of the trained model are the prompt words and the user input words.

6. The method for constructing a natural language retrieval model for electronic medical records based on generative AI according to claim 1, characterized in that: When validating a logical expression, the table, field, and logical operator in the response are verified to be consistent with the configuration by using the atomic expression. If the atomic expression in the response is consistent with its table, field and logical operator configuration, it is converted into the name format required by the external retrieval system; If the atomic expression in the response is inconsistent with its table, field, and logical operator configuration, the atomic expression is deleted or an error message is returned to the caller or the model is called again to regenerate the logical expression.

Citation Information

Patent Citations

  • Medical record retrieval system based on generative pre-training model

    CN117763129A

  • Method and system for constructing language transformation assistant based on generative model

    CN118332000A