An intelligent medical question and answer system and method based on hybrid retrieval and lightweight reordering

This intelligent medical question-answering system, which combines hybrid retrieval with lightweight reordering, solves the problems of low signal-to-noise ratio and long text processing in Chinese medical information retrieval, improves the relevance and accuracy of retrieval, reduces the model illusion rate, and achieves efficient medical question-answering support.

CN121009174BActive Publication Date: 2026-05-12BEIJING CANCER HOSPITAL PEKING UNIV CANCER HOSPITAL
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING CANCER HOSPITAL PEKING UNIV CANCER HOSPITAL
Filing Date
2025-08-13
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

Existing technologies in the Chinese medical field suffer from several drawbacks, including difficulties in processing Chinese medical texts, low signal-to-noise ratio in information retrieval recall, lack of visual modality information processing capabilities, high computational costs, and a tendency to induce erroneous hallucinations. These limitations restrict the application of question-answering systems in real clinical scenarios.

Method used

An intelligent medical question-answering system employs hybrid retrieval and lightweight re-ranking. It utilizes complementary recall through BM25 and vector retrieval, combined with a reciprocal ranking fusion algorithm, and employs a lightweight re-ranking model for refined scoring and ranking. The system also trains the model by generating high-quality labeled data through a large language model, and optimizes attention calculation by combining query-aware intelligent compression technology and the FlashAttention algorithm. Finally, it integrates medical knowledge graphs and visual information.

Benefits of technology

It improves the relevance and accuracy of search results, reduces the model illusion rate, increases the efficiency of long text processing, reduces reliance on high-end computing hardware, and has higher cost-effectiveness and deployability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121009174B_ABST
    Figure CN121009174B_ABST
Patent Text Reader

Abstract

The application provides an intelligent medical question and answer system and method based on hybrid retrieval and lightweight reordering, applied to the technical field of medical data processing. The application extracts five types of core entities through a preset Chinese medical NER model, forms a structured knowledge base by modeling and correlating the relations extracted, analyzes user Chinese queries, extracts medical entities, identifies four types of appeals, and converts them into semantic vectors. PubMedBERT is used to encode medical documents to generate vector storage, perform BM25 and vector retrieval in parallel when receiving queries, and generate candidate documents through RRF algorithm fusion. A scoring dataset is generated based on a prompt template, a lightweight model is trained to sort and output an evidence set. The query semantics are combined to generate a simplified context through retrieval-sorting-compression, and FlashAttention is integrated to optimize the calculation. An optimized U-Net is used to segment images to generate a structured report, and multi-modal information is integrated to generate a precise answer considering images and medical knowledge through LLM reasoning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of medical data processing technology, and in particular to an intelligent medical question-answering system and method based on hybrid retrieval and lightweight reordering. Background Technology

[0002] In recent years, artificial intelligence technologies, especially large language models (LLMs), have been increasingly applied in the healthcare field. Frameworks such as Retrieval-Augmented Generation (RAG), by combining external knowledge bases with the generative capabilities of LLMs, have provided new solutions for scenarios such as clinical decision support and medical question answering. However, existing technologies still face many challenges when applied to the highly specialized and rigorous field of Chinese medical knowledge. First, natural language processing (NLP) of Chinese medical texts inherently presents difficulties, such as word segmentation ambiguity, frequent emergence of new terms and jargon, and significant differences between colloquial expressions and professional terminology. Second, the rapid iteration and massive growth of medical knowledge places extremely high demands on the construction, maintenance, and real-time retrieval of knowledge bases.

[0003] More importantly, the effectiveness of the standard RAG framework is highly dependent on the quality of the retrieval phase. If the retrieved document fragments have a low signal-to-noise ratio, meaning they contain irrelevant, outdated, or even erroneous information, this "toxic" context will severely mislead the LLM (Local Level Model), causing it to produce seemingly reasonable but actually erroneous "illusion" content. In the high-risk field of medicine, such errors can have serious consequences. Furthermore, processing extremely long texts containing complex disease descriptions and multiple examination reports is a common technical bottleneck currently faced by LLMs. Clinical diagnosis and treatment not only rely on textual information but also heavily depend on the interpretation of medical images (such as CT and MRI). Existing question-answering systems generally lack the ability to process and understand visual modal information, resulting in high computational costs and information forgetting ("lost in the middle"), limiting their in-depth application in real-world clinical scenarios. Therefore, how to optimize the retrieval and information processing flow within the RAG framework for Chinese medical scenarios, improve the relevance and accuracy of retrieved content, suppress model illusions, and efficiently process long text information is a pressing technical challenge in this field.

[0004] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0005] The purpose of this application is to provide an intelligent medical question-answering system and method based on hybrid retrieval and lightweight re-ranking, which at least to some extent overcomes the problems existing in the prior art. This application does not employ a single retrieval method, but rather designs a sophisticated pipeline. It first performs complementary recall through BM25 and vector retrieval, then uses the Reverse Rank Fusion (RRF) algorithm to balance keyword precision and semantic breadth, and finally uses a dedicated lightweight re-ranking model to finely score and rank candidate evidence. This architecture maximizes the contextual signal-to-noise ratio of the input LLM, which is a key guarantee for suppressing model illusions. Another major innovation of this application lies in the training method of the re-ranking model. It cleverly utilizes the powerful understanding capabilities of large language models (such as GPT-4) to generate massive amounts of high-quality (question, document, relevance score) labeled data through Prompt Engineering, and then uses this data to train a dedicated re-ranking model with small parameters and fast inference speed. This method balances labeling quality and training efficiency, achieving low-cost, high-performance, and accurate re-ranking.

[0006] To address the challenges of long text processing, this application proposes first utilizing query-aware intelligent compression technology to accurately extract the most relevant core information fragments from massive amounts of original text, significantly compressing the context. Then, on the compressed, streamlined context, efficient hardware-aware attention algorithms such as FlashAttention are applied. This fundamentally avoids the enormous overhead of LLM in processing redundant information, enabling efficient analysis of complex cases. Through offline construction of a medical knowledge graph and online dual analysis of "entity + intent," this application can accurately understand the true query intent of Chinese users, transforming colloquial and vague questions into structured retrieval signals that can be precisely executed by the machine, laying a solid foundation for all subsequent processing steps.

[0007] Other features and advantages of this application will become apparent from the following detailed description, or may be learned in part by practice of the invention.

[0008] According to one aspect of this application, an intelligent medical question-answering method based on hybrid retrieval and lightweight re-ranking is provided, comprising: acquiring multi-source authoritative Chinese medical data, query text input by Chinese medical users, Chinese medical knowledge base documents, and Chinese clinical scene medical images uploaded by users; extracting five types of core Chinese medical entities based on a preset Chinese medical NER model, modeling entity association through relation extraction, constructing a Chinese medical knowledge graph containing standard names and Chinese alias attributes, forming a structured knowledge base hub; extracting medical entities from user Chinese queries, identifying four core needs for disease consultation, converting Chinese queries into semantic vectors using a fine-tuned Chinese medical Sentence-BERT model, achieving cross-expression semantic equivalence mapping in the Chinese medical field; generating vectors by encoding Chinese medical documents using PubMedBERT and storing them. When receiving Chinese queries, the system performs BM25 keyword retrieval and vector semantic retrieval in parallel. An initial candidate document list is generated by fusing these queries using the RRF algorithm, balancing the accuracy of Chinese keywords with semantic relevance. A Chinese medical question-and-answer relevance scoring dataset is generated based on structured prompt templates. A lightweight model is trained to score and rank the candidate documents, outputting a Chinese medical evidence set to improve evidence accuracy. Combining the semantics of the user's Chinese queries, a concise context is generated through a retrieval-ranking-compression pipeline. FlashAttention technology is integrated to optimize attention calculation and reduce memory usage for processing long Chinese texts. An optimized U-Net model is used to segment medical image lesions and generate a structured Chinese visual report. The report, user's Chinese questions, and retrieval knowledge are integrated to form a multimodal context. LLM inference is then used to generate answer information that considers both image features and Chinese medical knowledge.

[0009] Another aspect of this application discloses an intelligent medical question-answering device based on hybrid retrieval and lightweight reordering, characterized by comprising: an acquisition module for acquiring multi-source authoritative Chinese medical data, query text input by Chinese medical users, Chinese medical knowledge base documents, and Chinese clinical scene medical images uploaded by users; a processing model for extracting five types of core Chinese medical entities based on a preset Chinese medical NER model, modeling entity association through relation extraction, constructing a Chinese medical knowledge graph containing standard names and Chinese alias attributes, forming a structured knowledge base hub; extracting medical entities from user Chinese queries, identifying four core needs for disease consultation, converting Chinese queries into semantic vectors using a fine-tuned Chinese medical Sentence-BERT model, achieving cross-expression semantic equivalence mapping in the Chinese medical field; and encoding Chinese medical documents using PubMedBERT. The system generates and stores vectors, and performs BM25 keyword retrieval and vector semantic retrieval in parallel when receiving Chinese queries. These are then fused using the RRF algorithm to generate a preliminary candidate document list, balancing the accuracy of Chinese keywords with semantic relevance. A Chinese medical question-and-answer relevance scoring dataset is generated based on structured prompt templates. A lightweight model is trained to score and rank candidate documents, outputting a Chinese medical evidence set to improve evidence accuracy. A concise context is generated through a retrieval-ranking-compression pipeline, combined with the semantics of the user's Chinese query. FlashAttention technology is integrated to optimize attention calculation and reduce memory usage for processing long Chinese texts. An optimized U-Net model is used to segment medical image lesions and generate a structured Chinese visual report. The report, user's Chinese question, and retrieval knowledge are integrated to form a multimodal context, which is then used for LLM inference to generate answer information that considers both image features and Chinese medical knowledge.

[0010] According to another aspect of this application, an electronic device is characterized by comprising: a first processor; and a memory for storing executable instructions of the first processor; wherein the first processor is configured to execute the above-described intelligent medical question-answering method based on hybrid retrieval and lightweight reordering by executing the executable instructions.

[0011] According to another aspect of this application, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a second processor, implements the above-described intelligent medical question-answering method based on hybrid retrieval and lightweight reordering.

[0012] This application presents an intelligent medical question-answering system and method based on hybrid retrieval and lightweight reordering. The core "retrieval-fusion-reordering" architecture ensures that the evidence received by the LLM (Limited Language Management) is highly relevant and reliable. In the internal CBLUE medical text understanding benchmark test, the system achieved a macro-average F1 score of 92.4% on the critical tasks, a significant improvement over the baseline RAG system. More importantly, the illusion rate of the generated content is strictly controlled below 1.5%, greatly ensuring the security of the medical question answering.

[0013] The use of a lightweight re-ranking model avoids calling large and expensive LLMs for ranking during online inference, resulting in faster response times. The two-stage long context processing framework reduces the average time doctors spend integrating and analyzing complex medical records and multiple reports by approximately 60%. This framework reduces reliance on high-end computing hardware while ensuring information integrity, offering higher cost-effectiveness and deployability.

[0014] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0015] Figure 1 The flowchart illustrates an intelligent medical question-answering method based on hybrid retrieval and lightweight reordering provided in an embodiment of this application.

[0016] Figure 2 The diagram shows a schematic of the structure of an intelligent medical question-answering device based on hybrid retrieval and lightweight reordering, according to an embodiment of this application. Detailed Implementation

[0017] The preferred embodiments of the present invention will be described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.

[0018] The following is combined Figure 1 This application describes an intelligent medical question-answering method based on hybrid retrieval and lightweight reordering, according to exemplary embodiments thereof. It should be noted that the following application scenarios are shown only to facilitate understanding of the spirit and principles of this application, and the embodiments of this application are not limited in any way. Rather, the embodiments of this application are applicable to any suitable scenario.

[0019] In one embodiment, this application also proposes an intelligent medical question-answering system and method based on hybrid retrieval and lightweight reordering. Figure 1 A schematic diagram of a process flow for an intelligent medical question-answering method based on hybrid retrieval and lightweight reordering according to an embodiment of this application is shown.

[0020] S101, Obtain multi-source authoritative Chinese medical data, query texts input by Chinese medical users, Chinese medical knowledge base documents, and Chinese clinical scenario medical images uploaded by users.

[0021] In one implementation, integrate Chinese medical data from multiple channels such as medical textbooks (e.g., the chapter on the diagnostic criteria for type 2 diabetes in "Internal Medicine (9th Edition)"), clinical practice guidelines (e.g., the content on blood glucose control targets in "Chinese Guidelines for the Prevention and Treatment of Type 2 Diabetes (2023 Edition)"), drug instructions (e.g., the indications and dosage instructions of "Metformin Hydrochloride Tablets"), etc. These data need to be screened to ensure their authority and accuracy, providing a basis for subsequent knowledge graph construction and retrieval. In addition to the medical textbooks, clinical practice guidelines, and drug instructions mentioned above, it also covers authoritative medical journal literature (e.g., research papers on the clinical application of new hypoglycemic drugs in "Chinese Journal of Internal Medicine"), clinical pathway documents (e.g., the "Clinical Pathway for Type 2 Diabetes" issued by the National Health Commission), medical continuing education materials (e.g., training courseware on the progress of diabetes diagnosis and treatment organized by medical societies), etc. After integrating these data, strict preprocessing is required: First, eliminate duplicate content (e.g., duplicate basic diagnostic criteria in different guidelines), correct data errors (e.g., dosage annotation errors caused by possible typesetting omissions in drug instructions), and unify the format (e.g., standardize the disease staging expressions from different sources to the internationally common staging standard). Through screening and preprocessing, ensure that the data conforms to the professional norms in the Chinese medical field, providing high-quality original materials for subsequent extraction of five types of core entities such as diseases and symptoms using a preset Chinese medical NER model, and for constructing a medical knowledge graph containing standard names and Chinese alias attributes.

[0022] The Chinese query texts input by users not only include direct medical condition consultations and medication inquiries, but also cover concept queries (e.g., "What is insulin resistance?"), treatment plan consultations (e.g., "What are the postoperative adjuvant chemotherapy regimens for gastric cancer?"), etc. After receiving the query texts, the system will first perform basic cleaning: Remove meaningless modal particles (e.g., "um", "ah"), correct typos (e.g., correct "shuanggua" to "shuanggua" in "Can a patient with high blood sugar take metformin?"), and perform word segmentation (e.g., split "What fruits can a patient with diabetic nephropathy eat?" into "diabetic nephropathy", "patient", "can eat", "which", "fruits"). These preprocessed query texts will serve as the basis for subsequent extraction of medical entities (e.g., extract "diabetic nephropathy" and "fruits" from "What fruits can a patient with diabetic nephropathy eat?"), identification of core demands (in this case, diet consultation, which is a derivative type of medical condition consultation), and then be converted into semantic vectors through a fine-tuned Chinese medical Sentence-BERT model to achieve cross-expression semantic equivalent mapping.

[0023] During the structured processing of Chinese medical knowledge base documents, the content dimensions need to be refined: for disease-related documents, it is necessary to include etiology (e.g., "The main causes of coronary atherosclerotic heart disease include hyperlipidemia and hypertension"), epidemiological data (e.g., "The prevalence of coronary heart disease in Chinese adults is approximately 10%), and key points for differential diagnosis (e.g., the differentiating symptoms from pulmonary embolism); for examination-related documents, it is necessary to clearly define the examination indications (e.g., "Indications for electrocardiogram examination include chest pain and palpitations") and the standards for interpreting results (e.g., "ST segment depression ≥0.1mV suggests myocardial ischemia"). These structured documents will be encoded into semantic vectors using the PubMedBERT model and stored in a vector database, becoming the core resource for subsequent BM25 keyword retrieval and vector semantic retrieval, providing support for quickly recalling document fragments relevant to user queries.

[0024] In addition to lung CT scans and brain MRIs, user-uploaded medical images include ultrasound images (such as abdominal ultrasound), pathological slide images, and X-ray films. The accompanying Chinese descriptions must include key information such as the purpose of the examination (e.g., "Chest CT scan performed due to chest tightness"), basic patient information (e.g., "Male, 65 years old, 10-year history of hypertension"), and preliminary examination conclusions (e.g., "Ultrasound suggests possible hepatic hemangioma"). After being input into the system, this image data undergoes standardization: adjusting the size to a uniform resolution (e.g., standardizing CT images from different devices to 512×512 pixels), enhancing the contrast of lesion areas (e.g., highlighting abnormal signal areas in MRI using algorithms). This lays the foundation for subsequent segmentation of lesion areas using an optimized U-Net model (e.g., segmenting nodules from lung CT scans), extracting quantitative features such as location and size, and generating structured Chinese visual reports such as "A nodule approximately 8mm in diameter with clear borders is seen in the upper lobe of the left lung."

[0025] S102 extracts five core Chinese medical entities based on a pre-defined Chinese medical NER model, models entity association through relation extraction, and constructs a Chinese medical knowledge graph containing standard names and Chinese aliases, forming a structured knowledge base hub.

[0026] In one implementation, multi-source authoritative Chinese medical data is integrated and preprocessed to generate preprocessed text data. When integrating multi-source authoritative Chinese medical data, in addition to medical textbooks, treatment guidelines, and drug instructions, it also includes authoritative medical journal articles (such as research papers on the clinical application of novel anti-tumor drugs in the *Chinese Medical Journal*), clinical pathway documents (such as the "Clinical Pathway for Community-Acquired Pneumonia" issued by the National Health Commission), and continuing medical education materials (such as training materials on "Advances in the Diagnosis and Treatment of Diabetic Complications" organized by the Medical Association). This data needs to undergo multi-dimensional preprocessing:

[0027] Standardized formatting: This involves not only adjusting fonts and paragraph formats, but also converting documents in different formats such as PDF, Word, and TXT into a unified text format. It also requires extracting structured data from tables (such as tables showing normal blood pressure ranges for different age groups) and using OCR technology to recognize text in images (such as hand-drawn anatomical illustrations in textbooks) as editable text, ensuring data format consistency.

[0028] Redundancy removal: In addition to deleting duplicate basic medical knowledge (such as "normal human body temperature range"), it is also necessary to remove the same research data repeatedly cited in multiple articles (such as the same clinical trial results of a certain type of drug), advertising and promotional information (such as irrelevant brand promotion content in drug instructions), and redundant paragraphs unrelated to medical professional knowledge (such as editor's notes in textbooks).

[0029] Error correction: In addition to correcting possible dosage labeling errors in drug instructions (such as mistakenly writing "300mg three times a day" as "300mg five times a day"), it is also necessary to correct outdated content in treatment guidelines due to version updates (such as treatment regimens that have been phased out in the old version of the guidelines), typos in medical terminology (such as correcting "myocardial infarction" to "myocardial infarction"), and errors in formulas or data in literature due to typesetting errors (such as incorrect symbols in drug concentration calculation formulas).

[0030] Through the above preprocessing, the resulting standardized text data not only retains the authority of the data from each source, but also eliminates format differences, redundant information and erroneous content, providing high-quality raw materials for subsequent extraction of five core entities such as diseases and symptoms using a pre-set Chinese medical NER model, as well as for constructing a Chinese medical knowledge graph.

[0031] An entity extraction framework is constructed based on a pre-defined Chinese medical NER model to generate an entity recognition model. This pre-defined model extracts five core categories of Chinese medical entities from pre-processed text: disease entities, symptom entities, drug entities, examination entities, and treatment plan entities. The entity extraction framework, built using a finely tuned PCL-MedBERT-NER model, is a specialized tool optimized for the characteristics of Chinese medical text. Its core lies in improving the recognition accuracy of professional terms, aliases, and complex expressions by pre-training with medical domain knowledge and fine-tuning the Chinese medical corpus. The process of extracting the five core entities from the pre-processed text requires precise boundary localization and type determination based on contextual semantics.

[0032] Disease entity extraction: It not only identifies explicit disease names (e.g., "type 2 diabetes"), but also captures subcategories such as complications (e.g., "diabetic nephropathy") and staging / type (e.g., "stage IV gastric cancer"). For example, from "a patient with hypertensive heart disease presents with chest tightness," it accurately extracts the disease entity "hypertensive heart disease," rather than simply identifying "hypertension" or "heart disease." Symptom entity extraction: It can distinguish between typical symptoms (e.g., "excessive thirst and urination"), accompanying symptoms (e.g., "fatigue"), and descriptions of signs (e.g., "hepatosplenomegaly"). For example, from "a patient has fever with cough and yellow sputum for 3 days," it extracts the symptom entities "fever," "cough," and "yellow sputum," and determines their relevance through contextual analysis.

[0033] Drug entity extraction: This includes generic names (e.g., "Metformin Hydrochloride Tablets"), brand names (e.g., "Glucophage"), and dosage forms / specifications (e.g., "Insulin Injection (300U / 3ml)"). For example, from "Recommended to take Bayer Aspirin (Aspirin Enteric-coated Tablets 100mg / tablet)," the drug entity "Aspirin Enteric-coated Tablets" and the brand name "Bayer Aspirin" are extracted simultaneously, along with the specification information. Examination entity extraction: This includes imaging examinations (e.g., "Electrocardiogram," "Lung CT"), laboratory examinations (e.g., "Blood glucose test," "Complete blood count"), and invasive examinations (e.g., "Coronary angiography"). For example, from "Postoperative monitoring of coagulation function and chest X-ray examination are required," the examination entities "Coagulation function (test)" and "Chest X-ray examination" are extracted. Treatment plan entity extraction: This covers drug therapy (e.g., "Treatment with Metformin Hydrochloride Tablets"), surgical treatment (e.g., "Laparoscopic cholecystectomy"), rehabilitation interventions (e.g., "Dietary guidance for diabetes"), etc. For example, from the phrase "chemotherapy combined with targeted therapy after diagnosis, supplemented by nutritional support," the treatment plan entities "chemotherapy combined with targeted therapy" and "nutritional support" are extracted. This framework provides a precise entity foundation for subsequent relation extraction and knowledge graph construction through accurate identification of entity boundaries (such as distinguishing between "diabetes" and "diabetic retinopathy") and fine-grained classification of types.

[0034] Preprocessed text data is input into an entity recognition model, combined with a relation extraction model, to generate entity association data. The relation extraction process clarifies the semantic relationships between entities by modeling the medical logical connections between them. After obtaining various entities from the preprocessed text input into the entity recognition model, the relation extraction model establishes the connections between entities. For example, the text identifies a "typical symptom" relationship between "type 2 diabetes" and "polyuria and polydipsia," and a "treatment" relationship between "metformin hydrochloride tablets" and "type 2 diabetes," thus clarifying the medical logical connections between the entities.

[0035] When constructing the initial graph using the five extracted core entities as nodes and the medical logical relationships between entities as edges, a refined design combining entity attributes and relationship types is necessary to ensure the structured and semantic integrity of the graph. This includes the structured presentation of node information: each entity node should not only contain its core definition but also integrate basic attributes. For example, the "Type 2 Diabetes" node should include core information such as its definition ("a metabolic disease characterized by insulin resistance and insufficient insulin secretion"), epidemiological data ("the prevalence among adults in my country is approximately 11.9%), and pathogenesis ("related to genetics, obesity, and lifestyle"). The "Metformin Hydrochloride Tablets" node should include basic attributes such as drug ingredients ("Metformin Hydrochloride"), route of administration ("oral"), and common dosage forms ("tablets, extended-release tablets"), providing detailed evidence for subsequent knowledge association.

[0036] Edge association types and semantic annotation: Edges between entities must clearly indicate the specific association type, and the association must conform to medical logic. In addition to "typical symptoms" and "indications," this includes "complications" (e.g., "type 2 diabetes" and "diabetic nephropathy" are connected by this edge), "contraindications" (e.g., "metformin hydrochloride tablets" and "renal insufficiency" are connected by this edge), "examination indications" (e.g., "type 2 diabetes" and "glycated hemoglobin testing" are connected by this edge), and "treatment plans" (e.g., "type 2 diabetes" and "insulin injection therapy" are connected by this edge). For example, the "electrocardiogram" node and the "myocardial infarction" node are connected by the "key examination" edge, accurately reflecting the core role of this examination in disease diagnosis.

[0037] Hierarchical integration of multi-dimensional relationships: For complex entity relationships, a hierarchical relationship structure needs to be constructed. For example, the "hypertension" node and the "stroke" node are associated with "risk factors." Simultaneously, "hypertension" is associated with "atherosclerosis" through "causing," and "atherosclerosis" is associated with "stroke" through "inducing," forming a chain of relationships: "hypertension → atherosclerosis → stroke," clearly presenting the causal chain between diseases. This initial graph, through the comprehensiveness of node attributes and the accuracy of edge relationships, lays the foundation for subsequent attribute expansion and optimization.

[0038] When expanding and optimizing the attributes of the basic knowledge base structure, it is necessary to focus on the professional characteristics of Chinese medical scenarios and improve the accuracy and practicality of the knowledge base from two aspects: attribute expansion and association verification. Specifically, the following is an example: Multi-dimensional expansion of node attributes: In addition to standard names, definitions, and Chinese aliases, key attributes adapted to clinical scenarios should be added. For example, the node "coronary atherosclerotic heart disease" should add attributes such as "typical symptoms" (e.g., "chest pain, chest tightness"), "high-risk groups" (e.g., "middle-aged and elderly men, patients with hypertension"), and "diagnostic gold standard" (e.g., "coronary angiography"); the node "penicillin" should add information such as "pharmacological effects" (e.g., "inhibition of bacterial cell wall synthesis"), "adverse reactions" (e.g., "anaphylactic shock"), and "dosage form and specifications" (e.g., "800,000 units of penicillin sodium for injection"). The expansion of Chinese aliases needs to cover commonly used abbreviations and colloquial names in clinical practice. For example, the aliases for "acute myocardial infarction" include "heart attack" and "acute myocardial infarction", and the aliases for "hepatitis B" include "hepatitis B". This ensures that the system can accurately locate the entity through alias matching when users use colloquial expressions.

[0039] Precise verification and correction of associations: Through cross-validation using medical logic rules and authoritative data, erroneous associations are eliminated and missing associations are added. For example, the erroneous treatment association between "penicillin" and "viral cold" is deleted (because penicillin is ineffective against viruses), while the association between "penicillin" and "streptococcal pharyngitis" (treatment of sensitive bacterial infections) is added; the erroneous "indication" association between "nifedipine" and "diabetes" is corrected, replaced by the association between "nifedipine" and "hypertension" (first-line treatment drug), and the association between "nifedipine" and "hypotension" (contraindications) is added. For complex associations, the strength or conditions of the association need to be indicated. For example, the association between "aspirin" and "coronary heart disease" (secondary prevention drug) needs to be supplemented with the condition of "daily dose 75-150mg" to improve the rigor of the knowledge.

[0040] The expanded and optimized structured knowledge base hub can support a multi-dimensional understanding of entities through rich attributes, and ensure the consistency of knowledge logic through precise relationships. This provides reliable support for semantic disambiguation in subsequent user queries (such as distinguishing the different connotations of "coronary heart disease" and "pulmonary heart disease"), accurate knowledge matching during retrieval, and factual basis when LLM generates answers.

[0041] S103 extracts medical entities from user Chinese queries, identifies four core needs for medical consultation, and uses a fine-tuned Chinese medical Sentence-BERT model to convert Chinese queries into semantic vectors, achieving cross-expression semantic equivalence mapping in the Chinese medical field.

[0042] In one implementation, in the node attribute extension of the Chinese medical knowledge graph, in addition to the standard name, definition, and Chinese aliases, multi-dimensional key attributes need to be supplemented in combination with clinical practice requirements to enhance the practicality and scenario adaptability of knowledge, as follows: Attribute extension of disease nodes: Taking "stroke" as an example, in addition to the core attributes, attributes such as "risk factors" (such as "hypertension, atrial fibrillation, smoking"), "first aid measures" (such as "call 120 immediately and keep the airway unobstructed"), and "prognosis" (such as "thrombolytic therapy within 3 hours of onset can significantly improve the prognosis") need to be supplemented. These information are directly related to clinical decisions. For example, when a user queries "what to do after a stroke", the system can quickly return standardized treatment suggestions based on the "first aid measures" attribute, avoiding misguidance caused by lack of information.

[0043] Attribute extension of drug nodes: For "insulin injection", attributes such as "administration route" (such as "subcutaneous injection"), "suitable population" (such as "type 1 diabetes patients, type 2 diabetes patients with poor oral medication control"), "precautions" (such as "monitor blood glucose after injection and avoid hypoglycemia"), and "drug interactions" (such as "combined use with glucocorticoids may reduce efficacy") need to be supplemented. For example, when a user asks "can insulin be used with prednisone", the system can clearly inform the risk through the "drug interactions" attribute to ensure medication safety.

[0044] Attribute extension of examination nodes: Taking "blood routine" as an example, attributes such as "examination purpose" (such as "judging the type of infection and the degree of anemia"), "reference range" (such as "white blood cell count 4-10×10 9 / L"), "interpretation of abnormal results" (such as "an increase in the proportion of neutrophils indicates bacterial infection"), and "preparation before examination" (such as "no fasting required") need to be supplemented. When a user queries "what does it mean if the white blood cells in the blood routine are high", the system can provide a professional explanation in combination with the "interpretation of abnormal results" attribute to reduce the user's misunderstanding of the report. Fine-tuning extension of Chinese aliases: It needs to cover clinical colloquialisms, regional common names, and abbreviated forms. For example, the aliases of "chronic obstructive pulmonary disease" include "COPD" (Chinese adaptation of English abbreviation) and "chronic obstructive pulmonary disease"; the aliases of "lumbar disc herniation" include "lumbar disc herniation" and "lumbar disc prolapse" (association of easily confused terms). For polysemous words, they need to be clearly distinguished. For example, "hyperthyroidism" only corresponds to "hyperthyroidism", avoiding confusion with "hypothyroidism" (hypothyroidism), ensuring that when a user enters "how to treat hyperthyroidism", the system can accurately match the correct entity.

[0045] Through the aforementioned attribute expansion, knowledge graph nodes not only contain basic definitions but also integrate key information required throughout the entire clinical diagnosis and treatment process. This satisfies the in-depth query needs of professional medical staff and provides easy-to-understand and practical guidance for ordinary users. At the same time, the comprehensive coverage of aliases solves the retrieval and matching difficulties caused by the diversity of Chinese medical expressions, providing solid knowledge support for subsequent semantic disambiguation and accurate question answering.

[0046] A medical entity extraction framework based on the NER model is constructed, generating an entity recognition tool. This tool focuses on extracting medical entities from standardized query text, accurately capturing the core medical elements in the query. Using this tool, core medical entities can be extracted from standardized query text. For example, from "high blood sugar, dizziness, take metformin," the tool extracts the disease-related entity "high blood sugar," the symptom entity "dizziness," and the drug entity "metformin," precisely locating the core medical elements in the query.

[0047] Standardized query text is input into an intent classifier to generate core request tags. The classification process identifies four core requests based on text semantics: medical condition consultation, medication consultation, concept query, and treatment plan inquiry, thus clarifying the user's specific query purpose. For example, for the query "high blood sugar, dizziness, take metformin," the intent classifier determines the core request to be "medication consultation" (inquiring whether metformin is suitable for this condition), thus clarifying the user's query purpose.

[0048] This semantic vector conversion tool, built upon a fine-tuned Chinese medical Sentence-BERT model, transforms user query semantic information into a computable high-dimensional dense vector. This provides a precise basis for semantic matching in subsequent retrieval stages. The specific implementation and application scenarios are as follows: Flexible input format adaptation: The tool supports two input modes. First, the complete query text, such as "Can I take metformin if I have high blood sugar and dizziness?", directly preserving the semantic integrity of the user's original expression. Second, "entity + intent" sentence reconstruction, which extracts core medical entities (such as "high blood sugar," "dizziness," and "metformin") from the query and combines them with the identified core needs (such as "medication consultation") into a structured sentence (such as "[high blood sugar, dizziness, metformin] + medication consultation"). This reconstruction method focuses on key information, reducing the interference of redundant expressions on the semantic vector, and is particularly suitable for long sentence queries or scenarios with ambiguous expressions.

[0049] After being fine-tuned with a large-scale Chinese medical corpus (such as clinical practice guidelines and doctor-patient Q&A data), the Chinese medical Sentence-BERT model has the ability to deeply understand professional terms, aliases, and clinical expressions. For example, for "metformin" and "Glucophage" (trade name), "high blood sugar" and "hyperglycemia" (Chinese adaptation of English terms), the model can capture their semantic associations and ensure that the converted vectors are close in distance in the space. The generated high-dimensional dense vectors (usually 768-dimensional or 1024-dimensional) map the text semantics to the geometric space, and the cosine similarity between vectors can quantify the degree of semantic association. For example, the cosine similarity between the vectors of "Is it safe to take metformin for high blood sugar?" and "What is the safety of metformin for patients with hyperglycemia?" is close to 1, while the cosine similarity with the vector of "What medicine should I take for a cold?" approaches 0. This quantization feature provides a mathematical basis for semantic matching in the subsequent retrieval stage.

[0050] The generated semantic vectors will serve as navigation signals to drive the approximate nearest neighbor search (ANN) in the vector database, quickly recalling documents semantically related to the query. For example, when the user queries "[High blood sugar, Metformin] + Medication consultation", the vectors generated by the tool can accurately match the vectors of relevant documents such as "Metformin indications" and "Medication contraindications for hyperglycemia" in the knowledge base, ensuring the semantic relevance of the retrieval results and providing a key dense retrieval basis for hybrid retrieval (BM25 + vector retrieval).

[0051] Cross-expression semantic equivalent mapping is achieved through vector space calculation to generate semantic association results. Among them, by calculating the cosine similarity of different query vectors, it is ensured that semantically equivalent Chinese medical queries are understood consistently, improving the system's ability to handle diverse expressions. Calculate the cosine similarity of different query vectors. For example, the cosine similarity between the vectors of "Can I take metformin for high blood sugar?" and "Can metformin treat hyperglycemia?" approaches 1, ensuring that semantically equivalent queries are understood consistently and improving the system's ability to handle diverse expressions.

[0052] S104, generate vectors by encoding Chinese medical documents through PubMedBERT and store them. When receiving a Chinese query, perform BM25 keyword retrieval and vector semantic retrieval in parallel, and generate a preliminary candidate document list through the RRF algorithm, taking into account the accuracy of Chinese keywords and semantic relevance.

[0053] In one implementation, a basic architecture for text encoding and storage is constructed based on the PubMedBERT model, generating an initial encoding and storage framework. This initial framework includes a text feature extraction layer, a vector transformation layer, and a storage layer. The feature extraction layer extracts Chinese medical entity and relation features; the vector transformation layer converts entities and relations into vector representations; and the storage layer stores the vectors in a structured manner. For example, given the text "Type 2 diabetes patients can use metformin hydrochloride tablets for treatment and need to have regular blood glucose tests," the feature extraction layer extracts the disease entity "type 2 diabetes," the drug entity "metformin hydrochloride tablets," the examination entity "blood glucose test," and relation features such as "treatment" and "need to be performed regularly." The vector transformation layer converts these entities and relations into vectors; and the storage layer stores the vectors in a structured manner in a vector database such as FAISS.

[0054] Preprocessed text data is input into an initial encoding and storage framework. Entity recognition and relation extraction algorithms are used to extract and model entities and their relationships, generating intermediate knowledge data. During extraction, entity boundary loss and relation classification loss functions are employed to improve the accuracy of extracting five core categories of Chinese medical entities and their relationships. Simultaneously, PubMedBERT is used to encode the document, generating semantic vectors that are stored in a vector database. Taking the preprocessed text "Patients with hypertension may experience dizziness; nifedipine tablets can be taken; an electrocardiogram (ECG) is recommended" as input, the entity recognition algorithm extracts entities such as "hypertension," "dizziness," "nifedipine tablets," and "ECG," while the relation extraction algorithm establishes associations such as "hypertension - may experience - dizziness" and "hypertension - can take - nifedipine tablets." During extraction, the entity boundary loss function is used to optimize the boundary recognition accuracy of entities such as "hypertension," and the relation classification loss function improves the classification accuracy of relations such as "may experience." Meanwhile, PubMedBERT encodes the document to generate semantic vectors, which are stored in the vector database.

[0055] The intermediate knowledge data is expanded and integrated to generate a Chinese medical knowledge graph. During the expansion process, attributes such as standard names and Chinese aliases are added to entities, and entity relationships are validated and corrected to ensure the completeness and accuracy of the knowledge graph. Simultaneously, a vector retrieval index is built to improve the efficiency of subsequent semantic retrieval. For example, the entity "hypertension" is given the standard name "primary hypertension," the Chinese alias "hypertension disease," and the definition "a clinical syndrome characterized primarily by elevated systemic arterial blood pressure." The incorrect relationship "nifedipine tablets have a therapeutic association with diabetes" is corrected to "nifedipine tablets have a therapeutic association with hypertension." Indexes are also built for the vector database, such as indexing document vectors related to "hypertension," to improve the matching speed during subsequent semantic retrieval.

[0056] A Chinese medical knowledge graph is stored in a dedicated database to generate a structured knowledge base hub. During storage, a graph database format is used to store entity and relational structures, while a vector database stores document semantic vectors. The two databases collaborate and establish an associated index to support subsequent mixed retrieval. When receiving queries from Chinese medical users, BM25 sparse retrieval and approximate nearest neighbor semantic retrieval from the vector database are performed in parallel. A reciprocal ranking fusion algorithm is used to generate a preliminary candidate document list. The graph database stores entity and relational structures such as "Type 2 Diabetes - Treatment - Metformin Hydrochloride Tablets," while the vector database stores the semantic vectors of the corresponding documents. The two databases establish an associated index through entity IDs. When receiving a user query "Can I take metformin if I have high blood sugar?", BM25 retrieval (matching keywords "high blood sugar" and "metformin") and approximate nearest neighbor retrieval from the vector database are performed in parallel (recalling semantically relevant documents). The RRF algorithm is used to calculate a fusion score and generate a preliminary candidate document list, such as prioritizing documents like "Application Instructions for Metformin in Type 2 Diabetes Treatment Guidelines."

[0057] S105 generates a Chinese medical question-and-answer relevance scoring dataset based on structured prompt templates, trains a lightweight model to score and rank candidate documents, and outputs a Chinese medical evidence set to improve the accuracy of evidence.

[0058] In one implementation, a Chinese medical question-and-answer relevance score dataset is generated based on a structured prompt template. The structured prompt template guides a powerful general-purpose LLM (such as GPT-4) to act as a "medical relevance assessment expert." For example, the prompt template might be: "Please evaluate the document fragment's support for answering the user's question, its relevance, and the reliability of the information. Output a relevance score in the range of 0-1, and explain the reasoning. User question: 'Can I take metformin if I have high blood sugar and dizziness?' Document fragment: 'Metformin is suitable for patients with type 2 diabetes, especially obese patients, as it can lower blood sugar levels.'" The general-purpose LLM outputs a score (e.g., 0.85) and a reasoning ("The document fragment mentions that metformin is suitable for lowering blood sugar, which is relevant to the user's question about high blood sugar, indicating high support"). This process is performed on over 100,000 medical question-and-answer pairs (e.g., "What medicine should I take for high blood pressure?" and excerpts from various antihypertensive drug instructions) to generate a dataset of (question, document fragment, relevance score) triples.

[0059] A lightweight model is trained to score and rank candidate documents. Using the dataset generated above, a lightweight model based on a 6-layer Transformer architecture (such as TinyBERT) is trained. This model takes "user question + [SEP] + candidate document fragment" as input, for example, the input "Can I take metformin if I have high blood sugar and dizziness? [SEP] Metformin is suitable for patients with type 2 diabetes, especially obese patients, as it can lower blood sugar levels." The top layer of the model outputs a 0-1 relevance prediction score through a regression layer. The training objective is to minimize the mean squared error between the predicted score and the target score in the dataset, and ListNet ranking loss is introduced to optimize document ranking performance.

[0060] During online inference, the Top-N (e.g., N=20) candidate document fragments obtained from hybrid retrieval are input into a pre-trained lightweight model. For example, for the user question "Can I take metformin if I have high blood sugar and dizziness?", 20 relevant document fragments are input, and the model outputs their relevance scores (e.g., 0.85, 0.72, 0.3, etc.). The document fragments are then reordered in descending order based on their scores, and the top K (e.g., K=5) fragments with the highest scores are selected to form a high-quality evidence set, such as document fragments containing core content like "metformin indications" and "precautions for medication use in cases of high blood sugar".

[0061] S106 combines the semantics of user Chinese queries and generates concise context through a retrieval-sorting-compression pipeline. It also integrates FlashAttention technology to optimize attention calculation and reduce memory usage for processing long Chinese texts.

[0062] In one implementation, semantic association analysis and preprocessing are performed on the user's Chinese query text and the retrieved long Chinese text data to generate associated preprocessed data. This associated preprocessed data includes semantic alignment of the text, filtering of redundant information, and sorting of search results by relevance. For example, regarding the user query "Can I take metformin if I have high blood sugar and dizziness?", combined with the retrieved long text data (such as the section on metformin in the "Guidelines for the Diagnosis and Treatment of Type 2 Diabetes" and the full text of the drug's instructions), semantic alignment is performed (associating "high blood sugar" in the query with "hyperglycemia" and "elevated blood sugar levels" in the document), redundant information is filtered (removing manufacturer information, packaging specifications, etc., from the document that are irrelevant to "suitability for use"), and the search results are sorted according to the relevance score of the mixed search stage (e.g., placing segments related to "metformin indications" before segments related to "causes of diabetes"), thus forming associated preprocessed data.

[0063] A streamlined context generation framework is constructed based on a retrieval-ranking-compression pipeline, generating an initial processing framework. This initial processing framework includes a retrieval module, a ranking module, and a compression module. The retrieval module matches relevant text, the ranking module sorts the text by relevance, and the compression module extracts core information. For example, the retrieval module retrieves long texts related to "medication for high blood sugar" from the knowledge base using vector matching; the ranking module calls a lightweight re-ranking model to re-rank the retrieved texts based on "semantic relevance to the query" and "information necessity"; and the compression module extracts core information (such as "suitable population for metformin" and "contraindications") from the ranked text using an extractive summarization algorithm (e.g., BERT-based key sentence extraction), forming the initial processing framework.

[0064] The preprocessed data is input into the initial processing framework. User query semantic guidance and a lightweight re-ranking model are used to prioritize text fragments, generating intermediate simplified text. The evaluation process employs a relevance scoring mechanism and information density assessment metrics to retain high-value content. After inputting preprocessed data (such as sorted excerpts from "metformin instruction manual" and "diabetes treatment guidelines"), the lightweight re-ranking model prioritizes text fragments based on user query semantics ("feasibility of medication for dizziness due to high blood sugar"). A relevance scoring mechanism is used (e.g., the fragment "the effect of metformin in lowering blood sugar" scores 0.9, and the fragment "the development history of metformin" scores 0.2). Combined with information density assessment metrics (e.g., the number of key knowledge points per unit of word), high-value content is retained (e.g., "metformin is suitable for type 2 diabetes patients with elevated blood sugar; dizziness may be a symptom of hypoglycemia, requiring blood sugar monitoring before medication"), while low-relevance or repetitive information is removed, generating intermediate simplified text.

[0065] The FlashAttention technique is integrated into the simplified text to optimize attention computation and generate a target simplified context. During the optimization process, memory access optimization and kernel fusion are used to reduce memory usage and improve processing efficiency when processing long Chinese texts. When processing simplified text (such as long texts containing 5 high-value segments), the FlashAttention technique is integrated to optimize the attention computation of the Transformer model: memory access optimization (avoiding repeated loading of text vectors) and kernel fusion (merging multiple matrix operations) reduce memory usage when processing long texts such as "Precautions for Diabetes Medication + Assessment of Hypoglycemia Symptoms + Contraindications of Metformin" (e.g., reducing the required memory from 8GB to 4GB), while also improving processing speed (e.g., reducing the compression time of 1000 characters from 2 seconds to 0.5 seconds). Finally, a target simplified context is generated (e.g., "Metformin can lower blood sugar and is suitable for patients with type 2 diabetes; dizziness may be a symptom of hypoglycemia; it is recommended to monitor blood sugar before medication; use with caution in patients with renal insufficiency").

[0066] S107 utilizes an optimized U-Net model to segment medical image lesions and generate a structured Chinese visual report. It integrates the report, user Chinese questions, and retrieval knowledge to form a multimodal context, and generates answer information that takes into account both image features and Chinese medical knowledge through LLM inference.

[0067] In one implementation, medical image data and associated text information are preprocessed to generate preprocessed image data and a structured text template. The preprocessing includes enhancing lesion areas and standardizing the dimensions of the images, as well as unifying the format and standardizing the fields of the visual report template. For user-uploaded lung CT images and associated text (e.g., "Patient coughed for a week, CT showed lung shadows"), the images are preprocessed—potential nodule areas are highlighted using a contrast enhancement algorithm, and images from different devices are uniformly adjusted to a standardized size of 512×512 pixels; the visual report template is formatted, setting fixed fields such as "image location, lesion location, size, and morphology" (e.g., "Image found: [location] has [size] [morphology] lesion") to ensure consistent report structure.

[0068] An optimized medical image segmentation model structure is constructed based on the U-Net framework to generate an initial segmentation model. This initial model includes an encoder, a decoder, and skip connections. The encoder extracts lesion features from the image, the decoder locates the lesion region, and the skip connections fuse features from different levels. The optimized medical image segmentation model based on the U-Net framework achieves accurate extraction and localization of lesion regions through the collaborative design of the encoder, decoder, and skip connections. The functions and mechanisms of each component are as follows: The encoder is used for hierarchical feature extraction. It consists of multiple convolutional and pooling layers, achieving hierarchical feature extraction by progressively reducing the feature map size (e.g., from 512×512→256×256→128×128). Taking lung CT images as an example, shallow convolutional layers (such as layers 1-2) extract low-level detailed features, including the edge texture of lesions (such as the spiky edges of nodules) and local density differences (such as the density contrast between ground-glass opacities and normal lung tissue); deep convolutional layers (such as layers 3-4) focus on high-level semantic features, such as the overall shape of the lesion (round, irregular) and its spatial relationship with surrounding tissues (such as proximity to the pleura). For example, when segmenting liver cancer MRI images, the encoder can progressively capture key features such as the clarity of the tumor boundary and the homogeneity of its internal signal, providing a basis for subsequent localization.

[0069] The decoder is used for precise localization and feature reconstruction. It progressively enlarges the feature map size through deconvolution operations (such as transposed convolution), mapping the abstract features extracted by the encoder back to the original image space to achieve precise coordinate localization of the lesion. Taking glioma segmentation in brain MRI as an example, the decoder first receives the 16×16 high-level feature map output by the encoder, and then successively reconstructs it to 32×32 and 64×64 through deconvolution, ultimately matching the original image size (256×256). During this process, the decoder combines the spatial location information of the feature map to determine the specific pixel range of the lesion in the image (e.g., the coordinate range of a glioma located in the left frontal lobe), while refining the boundary contours to avoid confusion with normal brain tissue.

[0070] Skip connections are used for multi-scale feature fusion. By connecting features across layers, skip connections directly pass feature maps from the encoder to the decoder, achieving complementary fusion of low-level details and high-level semantics. For example, in lung nodule segmentation, the shallow edge texture features (low-level) of the encoder are fused with the nodule contour features (high-level) of the corresponding layer in the decoder through skip connections. This preserves the subtle burrs at the nodule edges (key diagnostic features) while ensuring the accuracy of the overall contour. In fracture X-ray image segmentation, skip connections can combine bone texture (low-level) with the fracture line orientation (high-level), improving the accuracy of identifying small fissures. This fusion mechanism effectively solves the problem of incomplete feature information at a single level, significantly improving the completeness and accuracy of segmentation. Through the synergistic effect of these three components, the initial segmentation model can analyze features layer by layer from complex medical images, accurately locate lesions, and fuse multi-scale information to optimize the segmentation results, laying the foundation for subsequent generation of structured visual reports.

[0071] Preprocessed image data is input into the initial segmentation model. The model parameters are iteratively trained using backpropagation and loss functions to generate a trained segmentation model. The training process employs Dice loss and cross-entropy loss functions to improve the model's segmentation accuracy of lesion regions. Preprocessed CT images labeled "left lung nodule" are input, and the model parameters are iteratively optimized using backpropagation. During training, Dice loss function (to reduce the deviation between the segmented region and the actual lesion, such as accurate segmentation of "nodule edges") and cross-entropy loss function (to improve the classification accuracy between "nodules" and "normal tissue") are used. After multiple rounds of training, the model can accurately identify solid lung nodules larger than 10mm in diameter, generating the trained segmentation model.

[0072] The trained segmentation model was applied to medical images to generate structured Chinese visual reports. BM25 sparse retrieval and vector database approximate nearest neighbor semantic retrieval were used, and a preliminary candidate document list was generated using a reciprocal ranking fusion algorithm. After inputting the patient's lung CT images into the trained and optimized U-Net model, the system achieved lesion feature extraction and structured report generation through multi-step processing. The specific process is as follows: For accurate lesion segmentation, the model first performs a full-domain scan of the input lung CT images. Utilizing multi-level features extracted by the encoder (such as density differences between nodules and normal lung tissue, and edge textures), combined with the spatial localization capability of the decoder, the solid nodule region in the left upper lobe of the lung is accurately segmented. During this process, the model's boundary recognition capability, optimized by the DICE loss function, clearly distinguishes the boundaries between the nodules and surrounding blood vessels and pleura, ensuring the integrity of the segmented region (e.g., avoiding missing small protrusions of the nodules).

[0073] Multi-dimensional feature extraction: For the segmented nodule region, the model automatically extracts key quantitative features and qualitative descriptions: Location features: Positioning is achieved through image coordinates, accurate to the lung lobe region (e.g., "apical segment of the left upper lobe"), rather than just a general label of "left upper lobe"; Size features: The longest diameter (12mm) and shortest diameter (10mm) of the nodule are measured, and the aspect ratio (1.2) is calculated to provide data support for the differentiation between benign and malignant nodules; Morphological features: The overall shape of the nodule (circular) is determined through an edge detection algorithm, and the presence of lobulation is identified (no lobulation in this case); Edge features: The smoothness of the edge is analyzed (smooth), and details such as spiculation and pleural traction are recorded (no such features in this case).

[0074] The system integrates extracted features into a standardized Chinese report based on a pre-set visual report template (containing fixed fields such as "image location, lesion characteristics, and measurement data"). For example: "Imaging findings: A solid nodule is visible in the apical segment of the left upper lobe, with a longest diameter of 12mm, a shortest diameter of 10mm, an aspect ratio of 1.2, a round shape, smooth edges, and no lobulation, spiculation, or pleural traction." The report format is consistent with the "Standard Description of Lung Nodules" in the knowledge base, facilitating semantic alignment with user questions (such as "Does this nodule require surgery?") and retrieved medical knowledge (such as "<15mm smooth solid nodule has a benign probability >80%)." This process, through the model's automated and standardized extraction of image features, transforms pixel-level visual information into machine-understandable structured text, providing accurate image evidence for multimodal context integration and LLM inference.

[0075] The system integrates structured Chinese visual reports, user questions in Chinese, and retrieved medical knowledge to generate multimodal contextual data. During the integration process, semantic alignment and redundancy removal are performed on the information. For example, regarding the user question "What could the shadow on this CT scan be?", the system integrates the visual report (the nodule description above) and retrieved medical knowledge (such as "solid lung nodules are commonly seen in benign adenomas or early-stage lung cancer"), performs semantic alignment (associating "shadow" with "nodule"), and removes redundancy (eliminating equipment parameters irrelevant to the "nubule's nature") to form a multimodal context (e.g., "The user asked about the nature of the shadow; the image shows a 12mm round nodule; the knowledge base mentions that benign adenomas often have smooth edges").

[0076] After inputting multimodal context into the LLM, the model generates accurate answers that take into account both image features and medical knowledge through deep semantic parsing and knowledge fusion. The specific process is as follows: Attention allocation of multimodal context: The multimodal context received by the LLM contains three core pieces of information—structured visual report ("12mm round solid nodule in the upper lobe of the left lung with smooth edges"), user question ("What could the shadow on this CT scan be? Is further examination necessary?"), and retrieved medical knowledge (such as "The probability of benignity of smooth solid nodules <15mm is about 85%, commonly adenoma; spiculated or lobulated edges suggest malignancy" and "Tumor markers CEA and CYFRA21-1 can help differentiate between benign and malignant lung nodules"). The model dynamically allocates weights through an attention mechanism, focusing on key features in the image ("12mm", "smooth edges") and the user's core needs ("nature judgment", "further examination suggestion"), while also associating with matching diagnostic and treatment rules in the knowledge base to ensure that the reasoning is anchored to factual evidence.

[0077] LLM constructs an inference chain based on attention-focused information: First, it compares the imaging features "12mm, round, smooth edges" with the "typical features of benign adenomas" in the knowledge base, initially determining a tendency towards benignity; second, it incorporates the statistical data that "nodules <15mm still have a 15% risk of malignancy," introducing a risk warning; finally, based on the "Guidelines for the Diagnosis and Treatment of Lung Nodules," which recommends further examination for solid nodules >10mm in diameter, it derives a recommendation for tumor marker testing. During the inference process, the model automatically verifies logical consistency (e.g., avoiding contradictory conclusions such as "high probability of benign but immediate surgery recommended") and uses retrieved guidelines as evidence to suppress the generation of "illusions."

[0078] A beamsearch decoding strategy was employed, prioritizing outputs that conformed to standard Chinese medical terminology (e.g., using phrases like "maybe" to indicate uncertainty and avoid absolute judgments). The final answer, based on integrated reasoning, optimized for fluency and clinical applicability: "Based on imaging characteristics, a 12mm round solid nodule (smooth edges) in the left upper lobe is consistent with typical benign adenoma presentation, with a benign probability of approximately 85%. However, because the nodule diameter exceeds 10mm, there is still a certain risk of malignancy (approximately 15%). Further testing of tumor markers (such as CEA and CYFRA21-1) is recommended to aid in differentiation. Regular follow-up CT scans (every 3 months later) are advised to monitor nodule changes and avoid missing early-stage lung cancer." The answer incorporates both interpretation of imaging characteristics and integration of risk assessment and treatment recommendations.

[0079] In one implementation, such as Figure 2 As shown, this application also provides an intelligent medical question-answering device based on hybrid retrieval and lightweight reordering, comprising:

[0080] The acquisition module 201 is used to acquire multi-source authoritative Chinese medical data, query text input by Chinese medical users, Chinese medical knowledge base documents, and Chinese clinical scene medical images uploaded by users.

[0081] Processing module 202 is used to extract five core Chinese medical entities based on a preset Chinese medical NER model, model entity association through relation extraction, construct a Chinese medical knowledge graph containing standard names and Chinese aliases, forming a structured knowledge base hub; extract medical entities from user Chinese queries, identify four core needs for disease consultation, and convert Chinese queries into semantic vectors using a fine-tuned Chinese medical Sentence-BERT model to achieve cross-expression semantic equivalence mapping in the Chinese medical field; generate vectors by encoding Chinese medical documents with PubMedBERT and store them; when receiving Chinese queries, perform BM25 keyword retrieval and vector semantic retrieval in parallel, and fuse them using the RRF algorithm to generate preliminary candidate data. The document list balances the accuracy of Chinese keywords with semantic relevance; a Chinese medical question-and-answer relevance scoring dataset is generated based on structured prompt templates, and a lightweight model is trained to score and rank candidate documents, outputting a Chinese medical evidence set to improve evidence accuracy; combined with the semantics of user Chinese queries, a concise context is generated through a retrieval-ranking-compression pipeline, and FlashAttention technology is integrated to optimize attention calculation and reduce memory usage for processing long Chinese texts; an optimized U-Net model is used to segment medical image lesions and generate structured Chinese visual reports, integrating the reports, user Chinese questions, and retrieval knowledge to form a multimodal context, and LLM inference is used to generate answer information that takes into account both image features and Chinese medical knowledge.

[0082] The computer-readable storage medium provided in the above embodiments of this application and the intelligent medical question-answering method based on hybrid retrieval and lightweight reordering provided in the embodiments of this application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the applications stored therein.

[0083] The various embodiments in this application are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments for evaluating the intelligent medical question-answering method, electronic device, electronic device, and readable storage medium based on hybrid retrieval and lightweight reordering are basically similar to the embodiments of the intelligent medical question-answering method based on hybrid retrieval and lightweight reordering described above, and are therefore described simply. Relevant parts can be referred to in the descriptions of the embodiments of the intelligent medical question-answering method based on hybrid retrieval and lightweight reordering described above.

Claims

1. An intelligent medical question-answering method based on hybrid retrieval and lightweight re-ranking, characterized in that, include: Acquire authoritative Chinese medical data from multiple sources, query texts entered by Chinese medical users, Chinese medical knowledge base documents, and Chinese clinical scene medical images uploaded by users; Based on a pre-defined Chinese medical NER model, five core Chinese medical entities are extracted. Entity associations are modeled through relation extraction to construct a Chinese medical knowledge graph containing standard names and Chinese aliases, forming the central structure of the knowledge base. Extracting medical entities from user Chinese queries, identifying four core needs for medical consultation, and using a fine-tuned Chinese medical Sentence-BERT model to convert Chinese queries into semantic vectors, achieving cross-expression semantic equivalence mapping in the Chinese medical field; The system encodes Chinese medical documents using PubMedBERT, generates vectors, and stores them. When receiving Chinese queries, it performs BM25 keyword retrieval and vector semantic retrieval in parallel. The RRF algorithm is used to fuse the vectors to generate a preliminary candidate document list, taking into account both the accuracy of Chinese keywords and semantic relevance. This includes building a basic architecture for text encoding and storage based on the PubMedBERT model, generating an initial encoding and storage framework. The initial encoding framework includes a text feature extraction layer, a vector transformation layer, and a storage layer. The feature extraction layer is used to extract Chinese medical entity and relation features. The preprocessed text data is input into the initial encoding storage framework. Entity recognition and relation extraction algorithms are used to extract and model entities and their relationships, generating intermediate knowledge data. The intermediate knowledge data is then expanded and integrated to generate a Chinese medical knowledge graph. The Chinese medical knowledge graph is stored in a dedicated database to generate a structured knowledge base hub. When receiving queries from Chinese medical users, BM25 sparse retrieval and vector database approximate nearest neighbor semantic retrieval are performed in parallel. An inverse sorting fusion algorithm is used to generate a preliminary candidate document list. A Chinese medical question-and-answer relevance scoring dataset is generated based on structured prompt templates. A lightweight model is trained to score and rank candidate documents, outputting a set of evidence in the Chinese medical field to improve the accuracy of evidence. By combining the semantics of user Chinese queries, a concise context is generated through a retrieval-sorting-compression pipeline. FlashAttention technology is integrated to optimize attention calculation and reduce memory usage for processing long Chinese texts. We use an optimized U-Net model to segment medical image lesions and generate structured Chinese visual reports. We integrate the reports, user Chinese questions, and search knowledge to form a multimodal context. Through LLM inference, we generate answer information that takes into account both image features and Chinese medical knowledge.

2. The method as described in claim 1, characterized in that, Based on a pre-defined Chinese medical NER model, five core Chinese medical entities are extracted. Entity relationships are modeled through relation extraction to construct a Chinese medical knowledge graph containing standard names and Chinese aliases, forming a structured knowledge base hub, including: Integrate authoritative Chinese medical data from multiple sources and preprocess it to generate preprocessed text data; An entity extraction framework is constructed based on a pre-defined Chinese medical NER model to generate an entity recognition model. The pre-defined Chinese medical NER model extracts five core Chinese medical entities from the pre-processed text, including disease entities, symptom entities, drug entities, examination entities, and treatment plan entities. Preprocessed text data is input into the entity recognition model and combined with the relation extraction model to generate entity association data. The relation extraction process clarifies the semantic relationships between entities by modeling the medical logical relationships between entities. Using entities as nodes and relationships between entities as edges, an initial Chinese medical knowledge graph is constructed to generate a basic graph structure. Nodes contain the core information of entities, and edges label the specific relationship types between entities. The basic knowledge graph structure is expanded and optimized to generate a structured knowledge base hub. This includes expanding the standard name, definition, and Chinese alias attributes of the nodes, correcting erroneous associations in the graph, improving the completeness and accuracy of the knowledge graph, and providing support for subsequent semantic disambiguation and answer generation.

3. The method as described in claim 1, characterized in that, This method extracts medical entities from user Chinese queries, identifies four core needs related to medical conditions, and uses a fine-tuned Chinese medical Sentence-BERT model to convert Chinese queries into semantic vectors. This achieves cross-expression semantic equivalence mapping in the Chinese medical domain, including: The Chinese query text input by the user is preprocessed to generate standardized query text. The preprocessing includes word segmentation, removal of stop words and cleaning of special symbols to ensure the standardization of the query text and lay the foundation for subsequent entity extraction and intent recognition. A medical entity extraction framework is built based on the NER model, and an entity recognition tool is generated. This tool focuses on extracting medical entities from standardized query text and accurately capturing the core medical elements in the query. The standardized query text is input into the intent classifier to generate core demand labels. The classification process identifies four core demands based on the semantics of the text, including medical consultation, medication consultation, concept query, and treatment plan inquiry, thus clarifying the specific purpose of the user's query. A semantic vector transformation framework is built based on the fine-tuned Chinese medical Sentence-BERT model, and a vector transformation tool is generated. This tool takes a complete query or a "entity + intent" reconstructed statement as input and converts it into a high-dimensional dense semantic vector to achieve a mathematical representation of semantics. Cross-expression semantic equivalence mapping is achieved through vector space computation, generating semantic association results. Specifically, by calculating the cosine similarity of different query vectors, it is ensured that semantically equivalent Chinese medical queries are understood consistently, thereby improving the system's ability to handle diverse expressions.

4. The method as described in claim 1, characterized in that, Combining the semantics of user Chinese queries, a concise context is generated through a retrieval-sorting-compression pipeline. FlashAttention technology is integrated to optimize attention calculations and reduce memory usage for processing long Chinese texts, including: Semantic association analysis and preprocessing are performed on the user's Chinese query text and the retrieved long Chinese text data to generate associated preprocessed data. The associated preprocessed data includes semantic alignment of the text, filtering of redundant information, and sorting of search results according to relevance. A simplified context generation framework is built based on the retrieval-sorting-compression pipeline to generate an initial processing framework. The initial processing framework includes a retrieval module, a sorting module, and a compression module. The retrieval module is used to match relevant text, the sorting module is used to sort by relevance, and the compression module is used to extract core information. The associated preprocessed data is input into the initial processing framework, and the text fragments are prioritized using user query semantic guidance and a lightweight re-ranking model to generate intermediate simplified text. During the evaluation process, a relevance scoring mechanism and information density evaluation index are used to retain high-value content. The FlashAttention technology is integrated into the simplified text in the middle to optimize attention calculation and generate a simplified target context. In the optimization process, memory usage is reduced and processing efficiency is improved when processing long Chinese texts by optimizing memory access and fusion of computing kernels.

5. The method as described in claim 4, characterized in that, The optimized U-Net model is used to segment medical image lesions and generate structured Chinese visual reports. These reports, user Chinese questions, and retrieved knowledge are integrated to form a multimodal context. LLM inference is then used to generate response information that considers both image features and Chinese medical knowledge, including: Medical image data and associated text information are preprocessed to generate preprocessed image data and structured text templates. The preprocessing includes enhancing the lesion area of ​​the image, standardizing the size adjustment, and unifying the format and standardizing the fields of the visual report template. An optimized medical image segmentation model structure is constructed based on the U-Net framework to generate an initial segmentation model. The initial segmentation model includes an encoder, a decoder, and skip connections. The encoder is used to extract image lesion features, the decoder is used to locate lesion regions, and the skip connections are used to fuse features from different levels. Preprocessed image data is input into the initial segmentation model, and the model parameters are iteratively trained using the backpropagation algorithm and loss function to generate the trained segmentation model. The training process uses the Dice loss function and the cross-entropy loss function to improve the model's segmentation accuracy of lesion areas. The trained segmentation model is applied to medical images to generate structured Chinese visual reports; The system integrates structured Chinese visual reports, user Chinese questions, and retrieved medical knowledge to generate multimodal contextual data. During the integration process, semantic alignment and redundancy removal are performed on the information. Multimodal context data is input into the LLM, and response information is generated using attention mechanisms and generative decoding strategies.

6. An intelligent medical question-answering device based on hybrid retrieval and lightweight reordering, for implementing the method of claim 1.

7. An electronic device, characterized in that, include: First processor; and memory for storing executable instructions of the first processor; The first processor is configured to execute the intelligent medical question-answering method based on hybrid retrieval and lightweight reordering as described in any one of claims 1 to 5 by executing the executable instructions.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the second processor, it implements the intelligent medical question-answering method based on hybrid retrieval and lightweight reordering as described in any one of claims 1 to 5.