An intelligent medicine recommendation method and device based on semantic vector search

By using an intelligent drug recommendation method based on semantic vector search, we have solved the problems of insufficient semantic understanding, low recommendation accuracy, lack of security, and static model in existing technologies, and achieved personalized, safe, and efficient drug recommendation.

CN122266624APending Publication Date: 2026-06-23SHALLBRIGHT HEALTHTECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610144370.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-02-02
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

Existing drug recommendation systems suffer from limited semantic understanding capabilities, insufficient recommendation accuracy and personalization, lack of medical safety guarantees, lack of dynamic optimization capabilities in their models, and poor adaptability of their retrieval strategies, making it difficult to meet users' needs for personalized, safe, and efficient drug recommendations.

Method used

We employ an intelligent drug recommendation method based on semantic vector search. By transforming drug information and user queries into high-dimensional semantic vectors through a pre-trained language model, and combining fine-tuning of pharmaceutical-specific corpora with knowledge graph optimization, we construct a multi-dimensional comprehensive scoring algorithm. We also integrate a user feedback learning mechanism to achieve a hybrid strategy of vector retrieval and keyword indexing.

Benefits of technology

It achieves a deep understanding of complex semantic relationships, accurately captures user needs, provides personalized recommendations that conform to medical adaptation logic, builds a full-link security verification system, dynamically optimizes the recommendation model, and balances the efficiency of fuzzy semantics with precise information retrieval.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122266624A_ABST
    Figure CN122266624A_ABST
Patent Text Reader

Abstract

The application discloses an intelligent medicine recommendation method and device based on semantic vector search, and belongs to the technical field of intelligent medicine recommendation. The method converts medicine information and user natural language queries into high-dimensional semantic vectors through a pre-training language model optimized in the medical field; a comprehensive query representation is constructed by fusing medical exclusive features and personalized preferences; a hybrid strategy combining vector retrieval and keyword indexing is adopted to obtain a preliminary recommendation set; a multidimensional comprehensive scoring algorithm containing medical safety verification is used for secondary screening and sorting; a user feedback reinforcement learning mechanism is introduced to realize dynamic optimization of the model; and the device corresponds to a medicine information processing module, a user query processing module, a vector database and a matching and recommendation engine module. The application improves complex semantic understanding capability, realizes personalized and accurate recommendation, guarantees medicine safety, considers both search efficiency and scene adaptability, and is suitable for internet medical and medical e-commerce scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent drug recommendation technology, and in particular to an intelligent drug recommendation method and apparatus based on semantic vector search. Background Technology

[0002] With the rapid development of internet healthcare and pharmaceutical e-commerce, drug recommendation systems have become an important bridge connecting users' medication needs with drug resources. Related technical solutions are constantly emerging, but there are still many technical pain points that need to be addressed.

[0003] Specifically, the existing technology has the following significant drawbacks:

[0004] First, the semantic understanding capability is limited. Traditional keyword matching schemes can only achieve a superficial correspondence between symptom keywords and drug indications, and cannot identify the semantic association logic in the medical field, such as the intrinsic relationship between drug ingredients and efficacy, and the conflicting relationship between contraindications and medical history. They are completely inadequate for complex query scenarios such as synonyms and multiple symptom combinations. Even general vector retrieval schemes, due to the lack of fine-tuning of pharmaceutical-specific corpora and knowledge graph optimization, are unable to accurately capture the professional semantic associations in medical scenarios, resulting in a large deviation between the recommended results and the actual needs of users.

[0005] Secondly, the accuracy and personalization of recommendations are insufficient. Existing technologies either make broad recommendations based on a single symptom or simply add basic features such as age and gender. They have not formed a multi-dimensional fusion mechanism that integrates semantic features, medical-specific features, and personalized preferences. Such recommendation methods cannot fully consider key information such as users' allergy history, past medical history, medication dosage form preferences, and price range needs. As a result, the recommendation results lack specificity and are difficult to meet the medication selection needs of different users, leading to low user suitability and satisfaction.

[0006] Third, there is a lack of medical safety assurance. The core goal of existing general recommendation systems is to improve matching accuracy and user click-through rates, often neglecting the safety constraints required in the pharmaceutical field. Although traditional drug recommendation schemes have simple contraindication prompts, they have not built a systematic safety verification system. They have not integrated multiple safety dimensions such as allergy conflicts and drug interaction risks, nor have they connected to authoritative medical knowledge bases for real-time verification. As a result, they cannot form a full-chain risk prevention and control system, and there are high risks to medication safety.

[0007] Fourth, the model lacks dynamic optimization capabilities. The recommendation logic of existing technologies is mostly statically designed. Neither keyword matching rules nor vector retrieval models have established an effective user feedback learning mechanism. The recommendation model cannot dynamically adjust according to the user's actual usage feedback, changes in medication habits, and updates in medical knowledge, resulting in difficulty in continuously improving recommendation accuracy and a poor long-term user experience.

[0008] Fifth, the retrieval strategy has poor adaptability. When dealing with complex semantic queries, the existing keyword indexing scheme not only has a significantly reduced retrieval efficiency as the drug database expands, but also cannot guarantee accuracy. While the single vector retrieval scheme can improve the semantic matching effect, it is not direct enough when users query for specific drug names, dosage forms and other precise information. It is difficult to meet the dual needs of fuzzy semantic queries and precise information queries, and the scenario coverage is limited.

[0009] Therefore, this invention proposes an intelligent drug recommendation method and apparatus based on semantic vector search. Summary of the Invention

[0010] One objective of this invention is to propose an intelligent drug recommendation method and device based on semantic vector search. This invention can deeply understand the complex semantic relationships in medical scenarios and accurately capture the ambiguous natural language needs of users, such as combinations of multiple symptoms and mixtures of symptoms and medical history. By integrating semantic features, medical-specific features, and personalized preferences, it achieves accurate recommendations that conform to medical adaptation logic and fit individual user needs. It constructs a full-link medical safety verification system to avoid medication risks such as conflicts of allergens and drug interactions from the algorithmic level. It uses a user feedback reinforcement learning mechanism to dynamically iterate and optimize the recommendation model as user needs change and medical knowledge is updated. Through a hybrid strategy combining vector retrieval and keyword indexing, it balances the accuracy of complex semantic queries with the efficiency of precise information queries, ultimately meeting users' core needs for personalized, safe, and efficient drug recommendations.

[0011] An intelligent drug recommendation method based on semantic vector search according to an embodiment of the present invention includes the following steps:

[0012] S1. Drug Information Vectorization: Using a pre-trained language model, the drug's name, generic name, main efficacy, ingredients, indications, contraindications, adverse reactions, and user reviews are transformed into high-dimensional semantic vectors. The pre-trained language model is one of the Sentence-Transformers model, BERT model, and RoBERTa model.

[0013] S2. User query vectorization: The natural language query input by the user, which includes symptom description, expected efficacy and medication preference, is transformed into a corresponding high-dimensional semantic vector through the pre-trained language model described in step S1.

[0014] S3. Multi-dimensional feature construction: Extract the user's medical-specific features and personalized preference features, and integrate the user's medical-specific features, personalized preference features and user query vector obtained in step b to form a comprehensive query representation;

[0015] S4. Vector retrieval and matching: Store the high-dimensional semantic vector of the drug obtained in step S1 in the vector database. After receiving the comprehensive query representation in step S3, retrieve a preset number of drug vectors that meet the preset conditions of similarity with the user's query vector through the efficient index structure and similarity measurement method of the vector database, and form a preliminary recommended drug set.

[0016] S5. Multi-dimensional Fusion Recommendation: Based on a multi-dimensional comprehensive scoring algorithm, the drugs in the initial recommended drug set are further filtered and sorted to generate a personalized drug recommendation list. The core formula of the multi-dimensional comprehensive scoring algorithm is:

[0017]

[0018] in, Let be the overall recommendation score for the i-th drug. A higher score indicates a higher recommendation priority. , , , The preset weighting coefficients satisfy the following conditions: These correspond to the importance percentages of semantic similarity, medical safety, user suitability, and efficacy matching, respectively. For user query vectors With the vector of the i-th drug semantic similarity, Let i be the medical safety score for the i-th drug. The score represents the compatibility score between the i-th drug and the user. The efficacy matching score for the i-th drug.

[0019] Preferably, the drug information in step S1 also includes drug dosage form, specifications, brand, and clinical application scenario information. The sources of the drug information include the full text of the drug instruction manual, drug details page on e-commerce platforms, medical database filing information, and drug clinical application reports. The pre-trained language model is a model fine-tuned with a corpus specific to the pharmaceutical field. The fine-tuning process adopts an incremental training method. The corpus includes a drug terminology dictionary, literature on the association between symptoms and drugs, drug interaction research reports, and clinical treatment guidelines. The fine-tuning goal is to improve the model's accuracy in recognizing semantic associations in the pharmaceutical field, specifically including the correspondence between symptoms and indications, the association between drug ingredients and efficacy, and the identification of conflicts between contraindications and medical history.

[0020] Preferably, in step S2, the user's natural language query includes single symptom query, multiple symptom combination query, symptom and medical history combination query, and efficacy-oriented query. Before user query vectorization, a query preprocessing step is also included.

[0021] The system performs word segmentation, redundant information removal, and core information extraction on user input text. The core information includes symptom keywords, medical history keywords, efficacy demand keywords, and medication preference keywords.

[0022] During the generation of the user query vector, the model's attention mechanism assigns higher weights to core information, making the vector more accurately represent the user's core needs.

[0023] Preferably, the medical-specific features in step S3 include age group, gender, allergy history, past medical history, and a list of currently used medications; the personalized preference features include medication dosage form preference, efficacy priority preference, brand preference, and price range preference; the user features are obtained through user-initiated submission, authorized synchronization of data from a third-party health management platform, and compliant acquisition of electronic medical record summary information. The acquisition of electronic medical record information must be processed with privacy encryption, extracting only medication-related feature data, and complying with medical data privacy protection regulations. During feature integration, each feature is standardized, and non-numerical features are converted into vector form and then concatenated with the user query vector to form a unified dimensional comprehensive query representation.

[0024] Preferably, in step S4, the vector database is one of ChromaDB, Milvus, Pinecone, or Faiss, and the efficient index structure is the HNSW index structure. This structure achieves fast retrieval by constructing a multi-layer navigation graph. Each layer of the navigation graph consists of a subset of drug vectors. During retrieval, the search starts from the top-level navigation graph and gradually locates the most similar set of vectors. The similarity measurement method includes cosine similarity or Euclidean distance, where cosine similarity is used to calculate the similarity of vector directions, and Euclidean distance is used to calculate the proximity of vector spatial positions. The preset condition is that the semantic similarity is greater than or equal to a preset threshold. The preset number is 5-20, which can be adjusted according to the user terminal display requirements. The retrieval process adopts a hybrid retrieval strategy.

[0025] When a user query is detected to contain keywords for a precise drug name, generic drug name, or specific dosage form, the BM25 keyword index is used for precise matching to directly locate the target drug.

[0026] When a user queries a fuzzy query such as symptom description or efficacy requirement, semantic similarity retrieval using a vector database is employed; when mixed retrieval yields results simultaneously, the union of the two is taken, and the exact matching results are retained first.

[0027] Preferably, the medical safety score in step S5 The calculation method is as follows:

[0028]

[0029] in, Let be the conflict coefficient between the i-th drug and the user's allergy history. If the drug contains an allergen or belongs to the category of drugs the user is allergic to, then the coefficient is 1; otherwise, it is 0. Let be the contraindication coefficient between the i-th drug and the user's past medical history. If the drug's contraindications explicitly include the user's past medical history or may aggravate the user's underlying condition, then the coefficient is 1; otherwise, the coefficient is 0. Let be the interaction risk coefficient between the i-th drug and the user's current medication. If there is a contraindication interaction between the drug and the user's current medication, the value is 1; if there is a cautionary interaction, the value is 0.5; otherwise, the value is 0. , , Let be the weight coefficients of the safety sub-dimension, and satisfy . ,in The weighting should be no less than 40%, prioritizing the avoidance of allergy risks;

[0030] User fit score The calculation method is as follows:

[0031]

[0032] in, The coefficient for matching the drug to the user's age group is 1 for a complete match, 0.8 for a partial match, and 0 for an incomplete match. The coefficient represents the compatibility of the drug with the user's medical history. A value of 1 is assigned if there is no adverse impact on the medical history and the drug meets the treatment needs; 0.6 is assigned if there is no adverse impact but no direct compatibility; and 0 is assigned if there is potential risk. The coefficient for matching drug preferences with user-specific preferences is set as follows: 1 for complete alignment with all preferences, 0.8 for alignment with core preferences, 0.5 for partial alignment, and 0 for no alignment at all. The coefficient for matching drug prices to user price range preferences is set to 1 if the price range is within the user's price range, 0.6 if the price range is outside the range but not exceeding 20%, and 0 if the price range is more than 20%.

[0033] The efficacy matching score The calculation is based on the degree of alignment between the drug's therapeutic effects and the user's symptoms and desired effects, using a semantic similarity weighting method:

[0034]

[0035] in, This is the semantic vector corresponding to the user's k-th desired effect or symptom. Let be the semantic vector corresponding to the main therapeutic effects of the i-th drug. Let the semantic similarity between the user's k-th request and the efficacy of the drug be denoted as . The weight of the user's k-th request is determined by the strength of the request's description in the user's query or the user's preset priority of functionality. The total number of user requests;

[0036] During the secondary screening and sorting process, first remove... High-risk drugs, and then the remaining drugs are classified as follows: The scores are sorted in descending order to generate the final recommendation list.

[0037] Preferably, the pre-trained language model in steps S1 and S2 can also be optimized using a medical domain knowledge graph. This medical domain knowledge graph contains the full-link relationships between diseases, symptoms, drugs, ingredients, contraindications, adverse reactions, and clinical application scenarios. The model optimization process is as follows:

[0038] The structured association information in the knowledge graph is transformed into triple constraints and incorporated into the loss function of the model training, so that the semantic vectors generated by the model are more in line with the association logic in the medical field.

[0039] Preferably, it also includes the following steps:

[0040] S6. User feedback learning. The specific steps of user feedback learning are as follows:

[0041] S61. Receive feedback signals from users regarding the recommendation list. The feedback signals include five types: useful, irrelevant, risk warning, unsatisfactory price, and unsuitable dosage form. Users can choose a single feedback type or provide supplementary text descriptions.

[0042] S62. Constructing a reward function for reinforcement learning based on feedback signals:

[0043]

[0044] in, Let t be the instant reward value for the t-th recommendation. A useful feedback coefficient is assigned to the user, with 1 for useful and 0 otherwise. The feedback coefficient is assigned to indicate whether a user is unrelated; a value of 1 is assigned to the coefficient, and a value of 0 is assigned to the coefficient otherwise. The feedback coefficient for marking a risk warning to the user is set to 1, and 0 otherwise. A feedback coefficient is assigned to indicate user dissatisfaction with the price: 1 for dissatisfaction and 0 otherwise. The feedback coefficient for marking users as having an unsuitable dosage form is set to 1, and 0 otherwise. , , , , For the feedback weighting coefficients, satisfying Risk feedback weight No less than 30%;

[0045] S63, Utilizing reward values Dynamically update the weight coefficients in the multi-dimensional comprehensive scoring algorithm , , , The update cycle is to perform a batch update every 10-20 user feedbacks received, ensuring that the recommendation model is continuously optimized with user feedback and adapted to users' long-term needs.

[0046] A smart drug recommendation device based on semantic vector search includes a drug information processing module, a user query processing module, a vector database, and a matching and recommendation engine;

[0047] The drug information processing module is used to collect drug information in all dimensions and transform the drug information into high-dimensional semantic vectors through a pre-trained language model.

[0048] The user query processing module is used to receive user natural language queries and convert them into high-dimensional semantic vectors, while extracting the user's medical-specific features and personalized preference features to construct a comprehensive query representation;

[0049] The vector database is used to store the high-dimensional semantic vectors of the drug and provides efficient retrieval services based on efficient index structure and similarity measurement method;

[0050] The matching and recommendation engine is used to receive the comprehensive query representation, retrieve a preliminary recommended drug set through the vector database, perform secondary screening and sorting on the preliminary recommended drug set based on a multi-dimensional comprehensive scoring algorithm, and generate and output a personalized drug recommendation list.

[0051] Preferably, the drug information processing module further includes an information preprocessing unit and a model optimization unit;

[0052] The information preprocessing unit performs deduplication, format standardization, and validity verification on the collected drug information across all dimensions. Format standardization includes unifying drug ingredient names, standardizing indication terminology, and classifying adverse reactions. Validity verification includes removing information on expired drugs, recalled drugs, and false advertising. The verification is based on authoritative data published by the National Medical Products Administration.

[0053] The model optimization unit fine-tunes the pre-trained language model based on a medical field-specific corpus, and optimizes the semantic representation capabilities of the model by combining a medical field knowledge graph. The fine-tuning corpus and knowledge graph data are updated regularly, with the update cycle synchronized with the medical knowledge base.

[0054] The matching and recommendation engine also integrates an interpretable output module, a medical knowledge base interface, and a user feedback learning unit.

[0055] The interpretable output module generates a structured recommendation rationale for each recommended drug, including five parts: symptom and indication matching basis, core ingredient efficacy description, user characteristic adaptation analysis, medical safety verification results, and usage precautions summary, presented in a natural and easy-to-understand language.

[0056] The medical knowledge base interface connects to an authoritative medical knowledge base that is updated in real time, including the National Medical Products Administration's adverse drug reaction database, clinical drug use guideline database, drug interaction database, and drug price monitoring database, for dynamic updates of drug information, medical safety verification, and price suitability assessment.

[0057] The user feedback learning unit receives user feedback signals and dynamically optimizes the weight coefficients of the multi-dimensional comprehensive scoring algorithm through reinforcement learning algorithms. It also supports converting user text feedback into a basis for feature weight adjustment.

[0058] The beneficial effects of this invention are:

[0059] 1. In this invention, a pre-trained language model is used to perform high-dimensional semantic vector modeling of drug information and user queries. Combined with fine-tuning of pharmaceutical-specific corpora and optimization of knowledge graphs, the model can deeply understand the semantic relationships in medical scenarios. Unlike traditional keyword matching, which can only identify literal overlap, this solution can accurately capture the correspondence between symptoms and indications, the correlation logic between drug ingredients and efficacy, and the conflict between contraindications and medical history. It can easily handle complex queries such as synonym expressions, multiple symptom combinations, and mixed symptoms and medical history, and completely solve the pain points of traditional solutions that have shallow semantic understanding and cannot respond to the needs of ambiguous natural language.

[0060] 2. This invention relies on a comprehensive query representation built upon semantic vectors, medical-specific features, and personalized preferences. Combined with a multi-dimensional comprehensive scoring algorithm, it systematically integrates semantic similarity, medical safety, user suitability, and efficacy matching. This algorithm does not simply superimpose features but uses a logical quantitative model to comprehensively consider users' medical attributes such as age, medical history, and allergy history, as well as preferences such as dosage form, brand, and price. This ensures that the recommendation results not only conform to medical suitability logic but also align with users' personalized choices, forming accurate recommendations. This differs from traditional solutions that rely solely on a single symptom or basic feature for broad recommendations, significantly improving the suitability and satisfaction of users' medication choices.

[0061] 3. This invention prioritizes medical safety as the core of recommendations. Through a specially designed medical safety score calculation logic, it integrates multiple safety verification dimensions such as allergy component conflicts, medical history contraindications, and drug interaction risks. It also highlights the importance of allergy risk avoidance through weight allocation. At the same time, it connects to an authoritative database through a medical knowledge base interface to achieve real-time verification and dynamic updates of drug safety information. This forms a full-link risk control system that includes vector retrieval screening, safety score filtering, and authoritative knowledge base verification. This design breaks through the limitations of general recommendation systems that emphasize matching degree but neglect safety constraints, ensuring the medical safety of drug recommendations from the algorithmic level and reducing medication risks.

[0062] 4. This invention introduces a user feedback learning mechanism, which uses a reinforcement learning reward function to transform user feedback signals such as usefulness, risk warnings, and price dissatisfaction into the basis for model optimization. The weight coefficients of the multi-dimensional comprehensive scoring algorithm are updated in batches on a regular basis. This closed-loop optimization logic allows the recommendation model to continuously learn user preferences and actual usage needs, dynamically adapt to changes in user medication habits and updates in medical knowledge, and achieve a gradual improvement in recommendation accuracy with usage time, resulting in a better long-term user experience.

[0063] 5. This invention employs a hybrid retrieval strategy combining vector retrieval and keyword indexing. It leverages an efficient index structure to achieve rapid response in semantic similarity retrieval, while using keyword indexing to accurately pinpoint specific query needs such as drug names and dosage forms. This solution not only addresses the issues of low efficiency and poor accuracy of traditional keyword indexing in complex semantic queries, but also compensates for the shortcomings of single vector retrieval in providing insufficient direct response in precise query scenarios. It achieves dual adaptation between fuzzy semantic queries and precise information queries, balancing retrieval efficiency and scenario coverage. Attached Figure Description

[0064] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:

[0065] Figure 1 This is a flowchart illustrating the steps of an intelligent drug recommendation method based on semantic vector search proposed in this invention.

[0066] Figure 2 This is a system architecture diagram of an intelligent drug recommendation device based on semantic vector search proposed in this invention. Detailed Implementation

[0067] To make the technical means and objectives and effects of the present invention easier to understand, the embodiments of the present invention will be described in detail below with reference to specific illustrations.

[0068] Example 1

[0069] like Figure 1 As shown, this invention discloses an intelligent drug recommendation method based on semantic vector search, comprising the following steps:

[0070] S1. Drug Information Vectorization: Using a pre-trained language model, the drug's name, generic name, main efficacy, ingredients, indications, contraindications, adverse reactions, and user reviews are transformed into high-dimensional semantic vectors. The pre-trained language model is one of the Sentence-Transformers model, BERT model, and RoBERTa model.

[0071] Specifically, we collect comprehensive information about drugs, including drug name, generic name, main efficacy, ingredients, indications, contraindications, adverse reactions, user reviews, dosage form, specifications, brand, and clinical application scenarios. The sources of this drug information are the full text of the drug instructions, drug details pages on e-commerce platforms, medical database filing information, and drug clinical application reports.

[0072] The pre-trained language model selected is the all-MiniLM-L6-v2 version of the Sentence-Transformers model. To improve the model's accuracy in recognizing semantic relationships in the pharmaceutical field, incremental training is required to fine-tune the model. The pharmaceutical-specific corpus used for fine-tuning includes a drug terminology dictionary, literature on symptom-drug associations, drug interaction research reports, and clinical guidelines. The fine-tuning focuses on strengthening the model's ability to identify the correspondence between symptoms and indications, such as the association between "cough, sore throat" and "respiratory infection indication"; the association between drug ingredients and efficacy, such as the association between "acetaminophen" and "antipyretic and analgesic effects"; and the conflict between contraindications and medical history, such as the conflict between "history of hypertension" and "contraindications for pseudoephedrine-containing drugs". During fine-tuning, the aforementioned corpus was divided into training, validation, and test sets in an 8:1:1 ratio. The Adam optimizer was used with a learning rate of 2e-5 and 10 training epochs. After each training epoch, the training parameters were adjusted based on the semantic similarity matching accuracy on the validation set until the semantic association recognition accuracy on the test set reached over 90%. After fine-tuning, the collected full-dimensional information on the drugs was input into the optimized Sentence-Transformers model. The model outputs a high-dimensional semantic vector with 384 dimensions. For example, the semantic vector of a cold medicine can be represented as [0.023, 0.156, ..., 0.089]. This vector comprehensively represents the semantic features of all key information such as the name, ingredients, efficacy, and contraindications of the drug.

[0073] S2. User query vectorization: The natural language query input by the user, which includes symptom description, expected efficacy and medication preference, is transformed into a corresponding high-dimensional semantic vector through the pre-trained language model described in step S1.

[0074] Specifically, users can input natural language queries through the terminal, which can include single symptom queries, queries for multiple symptom combinations, queries for symptom and medical history combinations, and efficacy-oriented queries.

[0075] Before vectorization, the user input text needs to be preprocessed:

[0076] First, the input text is segmented using the jieba word segmentation tool. For example, if a user inputs "a diabetic patient has been coughing recently and wants to find an oral medication with fewer side effects", the segmented text will be "diabetes", "patient", "recently", "always", "cough", "want to find", "side effects", "small", "of", and "oral medication".

[0077] Then, redundant information such as "recently", "always", "want to find", and "of" were removed; finally, the core information was extracted, which included the medical history keyword "diabetes", the symptom keyword "cough", the efficacy requirement keyword "few side effects" and the medication preference keyword "oral medication".

[0078] Next, the Sentence-Transformers model, fine-tuned from the pharmaceutical corpus in step one, is invoked to vectorize the preprocessed query text. During vector generation, the model assigns higher weights to core information through an attention mechanism. For example, the weight coefficients for "diabetes," "cough," "few side effects," and "oral medication" are set to 0.3, 0.3, 0.2, and 0.2, respectively, while other non-core information is assigned weights below 0.05. Finally, a 384-dimensional user query vector with the same dimension as the drug semantic vector is generated, such as [0.045, 0.123, ..., 0.067]. This vector accurately focuses on the user's core medication needs.

[0079] S3. Multi-dimensional feature construction: Extract the user's medical-specific features and personalized preference features, and integrate the user's medical-specific features, personalized preference features and user query vector obtained in step b to form a comprehensive query representation;

[0080] Specifically, medical-specific characteristics include age group, gender, allergy history, past medical history, and a list of currently used medications;

[0081] Personalized preference characteristics include preference for dosage form, preference for efficacy priority, brand preference, and price range preference.

[0082] The methods for obtaining user characteristics are as follows:

[0083] Users actively fill in basic information such as age, gender, allergy history, and medication preferences through the terminal;

[0084] Authorize the synchronization of blood glucose monitoring data, medication records, etc. stored on third-party health management platforms;

[0085] For electronic medical record summary information, it is obtained through an encrypted transmission channel that complies with medical data privacy protection regulations. Only characteristic data such as medical history and treatment records related to medication are extracted, and the data is de-identified to remove personal identification information such as name and ID number.

[0086] During feature integration, each feature is standardized:

[0087] Convert the age group "elderly" into a numerical vector [0,0,0,1], the gender "male" into [1,0], the allergy history "penicillin allergy" into [1,0,0,...], and the past medical history "type 2 diabetes" into [0,1,0,...].

[0088] In the personalized preference features, the dosage form preference "oral" is transformed into [1,0,0], and the price range preference "below 50 yuan" is transformed into [1,0,0].

[0089] These standardized non-numerical feature vectors are concatenated with the 384-dimensional user query vector generated in step two to form a unified query representation. For example, the concatenated vector has a dimension of 384+4+2+100+200+3+3=696. This unified query representation fully integrates the user's query semantics, medical-specific features, and personalized preferences.

[0090] S4. Vector retrieval and matching: Store the high-dimensional semantic vector of the drug obtained in step S1 in the vector database. After receiving the comprehensive query representation in step S3, retrieve a preset number of drug vectors that meet the preset conditions of similarity with the user's query vector through the efficient index structure and similarity measurement method of the vector database, and form a preliminary recommended drug set.

[0091] Specifically, ChromaDB was chosen as the vector database, and all the high-dimensional semantic vectors of drugs generated in step one were stored in this database. The database adopts the HNSW index structure, which achieves fast retrieval by constructing a multi-layer navigation graph. The top-level navigation graph contains a 10% subset of drug vectors, the middle-level navigation graph contains a 30% subset of drug vectors, and the bottom-level navigation graph contains all drug vectors. Vector nodes in each navigation graph are connected through similarity association.

[0092] The similarity metric chosen is cosine similarity, used to calculate the directional similarity between the user query vector and the drug vector. The preset criteria are a semantic similarity greater than or equal to 0.7, and the preset number of similarities is 15.

[0093] The search process employs a hybrid search strategy:

[0094] First, the keyword type in the user's query text is detected. If the user's query is "buy ibuprofen sustained-release capsules", which contains the exact generic name of the drug "ibuprofen sustained-release capsules", then the BM25 keyword index is used for precise matching first, directly locating the vector and related information of the drug in the database.

[0095] If a user's query is "oral medication for cough in diabetic patients with few side effects", which is a fuzzy query combining symptoms, medical history, and preferences, then the semantic similarity retrieval of the ChromaDB vector database is used. The retrieval starts from the top-level navigation graph and gradually locates the lower-level navigation graph through the similarity association between vector nodes. Finally, 15 drug vectors with a semantic similarity greater than or equal to 0.7 with the query vector part in the user's comprehensive query representation are selected to form a preliminary set of recommended drugs.

[0096] If a user query contains both precise keywords such as "oral medication" and vague descriptions such as "relieve joint pain," a mixed search will be performed simultaneously. The union of precise matching results and semantic similarity search results will be taken. If duplicate drugs exist, precise matching results will be retained first to ensure the comprehensiveness and accuracy of the initial recommended drug set.

[0097] S5. Multi-dimensional Fusion Recommendation: Based on a multi-dimensional comprehensive scoring algorithm, the drugs in the initial recommended drug set are further filtered and sorted to generate a personalized drug recommendation list. The core formula of the multi-dimensional comprehensive scoring algorithm is:

[0098]

[0099] in, Let be the overall recommendation score for the i-th drug. A higher score indicates a higher recommendation priority. , , , The preset weighting coefficients are set to a value of [value]. =0.3、 =0.4、 =0.15、 =0.15, which satisfies the condition. These correspond to the importance percentages of semantic similarity, medical safety, user suitability, and efficacy matching, respectively.

[0100] For user query vectors With the vector of the i-th drug The semantic similarity, for example, the cosine similarity between a certain drug and the user query vector is calculated to be 0.82, that is... .

[0101] The medical safety score for the i-th drug is calculated using the following formula:

[0102]

[0103] in, Let be the conflict coefficient between the i-th drug and the user's allergy history. If the drug does not contain penicillin or β-lactam antibiotics, then... ;

[0104] Let be the contraindication coefficient between the i-th drug and the user's past medical history. If diabetes is not among the contraindications of this drug, and it will not worsen abnormal blood sugar levels, then... ;

[0105] Let be the interaction risk coefficient between the i-th drug and the user's current medication. If the drug does not interact with the user's currently used metformin extended-release tablets, then... ;

[0106] , , The weight coefficient for the security sub-dimension has a value of [value]. , , ,satisfy ,in The weighting should be no less than 40%, prioritizing the avoidance of allergy risks;

[0107] therefore .

[0108] The formula for calculating the suitability score between the i-th drug and the user is as follows:

[0109]

[0110] in, The coefficient for matching the drug to the user's age group is set as follows: 1 for a complete match, 0.8 for a partial match, and 0 for an incomplete match. For example, if the drug is clearly labeled as suitable for the elderly, ; The coefficient for drug suitability to the user's medical history is calculated as follows: 1 for no adverse effect on medical history and suitability for treatment needs; 0.6 for no adverse effect but no direct suitability; and 0 for potential risks, such as no adverse effect on diabetic patients and relief of cough symptoms. ;

[0111] The coefficient for matching a drug to a user's personalized preferences is calculated as follows: 1 for complete matching of all preferences, 0.8 for matching core preferences, 0.5 for partial matching, and 0 for no matching at all. For example, if a drug matches a user's preference for oral dosage form and preference for well-known domestic brands, then... ;

[0112] The coefficient for matching drug prices to user price range preferences is set to 1 if the price falls within the user's price range, 0.6 if the price exceeds 20% of the range, and 0 if the price exceeds 20% of the range. For example, if the drug price is 35 yuan, it falls within the user's price range below 50 yuan. ;

[0113] therefore .

[0114] The efficacy matching score for the i-th drug is calculated using the following formula:

[0115]

[0116] in, This is the semantic vector corresponding to the user's k-th desired effect or symptom. Let be the semantic vector corresponding to the main therapeutic effects of the i-th drug. Let the semantic similarity between the user's k-th request and the efficacy of the drug be denoted as . The weight of the user's k-th request is determined by the intensity of the request's description in the user's query or the user's preset efficacy priority, where n is the total number of user requests.

[0117] For example, the total number of user requests At the time, it was for "relieving cough". "Mild side effects" "Suitable for diabetic patients" The corresponding weight , , Semantic vectors corresponding to the main therapeutic effects of drugs and semantic similarity ,and semantic similarity ,and semantic similarity ,therefore:

[0118]

[0119] Substituting the above values ​​into the core formula, the overall recommendation score for the drug is calculated:

[0120]

[0121] During the secondary screening and sorting process, the above calculations were performed on each of the 15 drugs in the initial recommended drug set, first eliminating those that were not included. High-risk drugs, such as a drug containing penicillin, , The exclusion criteria are not met.

[0122] A certain drug has a contraindicated interaction with metformin. , Furthermore, the exclusion criteria are not met, therefore, no high-risk drugs need to be excluded in this embodiment.

[0123] Then sort the remaining 15 medicines according to their scores. Sort the drugs in descending order and select the top 10 to generate the final personalized drug recommendation list.

[0124] S6, User Feedback Learning;

[0125] The specific steps are as follows:

[0126] S61. Receive feedback signals from users regarding the recommendation list. The feedback signals include five types: useful, irrelevant, risk warning, unsatisfactory price, and unsuitable dosage form. Users can choose a single feedback type or provide supplementary text descriptions.

[0127] Specifically, users can provide feedback on the recommended drugs through the terminal. The feedback signals include five types: "useful", "irrelevant", "risk warning", "unsatisfactory price", and "unsuitable dosage form". Users can choose a single feedback type or add text descriptions. For example, a user may mark a recommended drug as "unsatisfactory price" and add text descriptions such as "hope the price is below 30 yuan".

[0128] After receiving the feedback signal, the system enters the feedback processing flow: first, the feedback signal is classified and identified, and the feedback type is determined to be "dissatisfied with the price". ,the remaining , , , .

[0129] S62. Constructing a reward function for reinforcement learning based on feedback signals:

[0130]

[0131] in, Let t be the instant reward value for the t-th recommendation. , , , , The feedback weighting coefficient has a value of , , , , , ,satisfy Risk feedback weight The immediate reward value for this recommendation is no less than 30%.

[0132] A useful feedback coefficient is assigned to the user, with 1 for useful and 0 otherwise.

[0133] The feedback coefficient is set to 1 if the user is marked as irrelevant, and 0 otherwise.

[0134] The feedback coefficient for marking risk warnings to users is set to 1 if the warning is marked as risk warning, and 0 otherwise.

[0135] The feedback coefficient for marking users as dissatisfied with the price is set to 1, and 0 otherwise.

[0136] The feedback coefficient for marking users as having an inappropriate dosage form is set to 1 if the dosage form is marked as inappropriate, and 0 otherwise.

[0137] S63, Utilizing reward values Dynamically update the weight coefficients in the multi-dimensional comprehensive scoring algorithm , , , The update cycle is to perform a batch update after receiving 10-20 user feedbacks to ensure that the recommendation model is continuously optimized with user feedback and adapts to users' long-term needs.

[0138] Specifically, the system receives a cumulative total of user feedback, and when the number of feedback items reaches 15, a batch update is executed:

[0139] Utilize accumulated reward values The weight coefficients in the multi-dimensional comprehensive scoring algorithm are dynamically updated using the gradient descent algorithm. , , , Due to repeated user feedback regarding "dissatisfaction with the price," improvements are needed. The proportion, after adjustment, is taken as the weight. , , , still satisfied This allows for greater emphasis on the alignment between drug prices and user preferences during subsequent recommendation processes.

[0140] Meanwhile, the system incorporates the user's additional text description, "hoping the price is below 30 yuan," into the weighting of price range preferences for further optimization. middle The calculation threshold is used to determine the price of drugs below 3 yuan. Higher values ​​ensure that the recommendation model continues to adapt to users' long-term needs.

[0141] In addition, in steps S61 and S62, the pre-trained language model can be optimized through a medical domain knowledge graph, which contains the full-link relationship between diseases, symptoms, drugs, ingredients, contraindications, adverse reactions, and clinical application scenarios. For example, triple constraints include <cough, corresponding drug, acute bronchitis syrup>, <penicillin, allergy contraindication, penicillin allergy population>, <metformin, interaction contraindication, iodine-containing contrast agent>, etc.

[0142] During model optimization, these triplet constraints are transformed into regularization terms of the loss function and incorporated into the incremental training process of the Sentence-Transformers model. The loss function is:

[0143]

[0144] in, The original semantic matching loss of the model, For triplet constraint loss, , which is the weighting coefficient used to balance the basic loss and the constraint loss.

[0145] Through this optimization, the semantic vectors generated by the model are more in line with the correlation logic in the medical field. The accuracy of semantic association recognition between "cough" and "acute bronchitis syrup" and the accuracy of conflict recognition between "penicillin" and "penicillin allergy population" have both been improved by more than 25%, further improving the accuracy of drug information vectorization and user query vectorization.

[0146] Example 2

[0147] like Figure 2 As shown, this embodiment, based on the intelligent drug recommendation method based on semantic vector search in Embodiment 1, also discloses an intelligent drug recommendation device based on semantic vector search;

[0148] The device includes a drug information processing module, a user query processing module, a vector database, and a matching and recommendation engine. Each module achieves bidirectional data interaction through a data bus. The hardware of the device can be deployed on a cloud server, supporting multiple user terminals to access and use it through a network interface.

[0149] The core function of the drug information processing module is to collect comprehensive drug information and transform it into high-dimensional semantic vectors. This module includes an information preprocessing unit and a model optimization unit. The information preprocessing unit first collects drug data from sources such as the full text of drug instructions, drug details pages on e-commerce platforms, medical database filing information, and drug clinical application reports. Data collection is conducted daily to ensure timeliness. Subsequently, the collected comprehensive drug information undergoes deduplication. Duplicate entries are eliminated by comparing keywords combining the drug's generic name and specifications; for example, only one duplicate entry for "ibuprofen sustained-release capsules (0.3g / capsule)" is retained. During format standardization, drug ingredient names are standardized to the standard names in the *Pharmacopoeia of the People's Republic of China*, indication terms are standardized to the standard terms published by the National Medical Products Administration, and adverse reactions are categorized into "digestive system," "nervous system," and "skin and appendages." During validity verification, based on authoritative data published by the National Medical Products Administration, expired drug information, recalled drug information, and false advertising information are eliminated to ensure the legality and accuracy of drug information. The model optimization unit offers a choice of Sentence-Transformers, BERT, and RoBERTa models. This embodiment selects the Sentence-Transformers model, which is fine-tuned based on a corpus specific to the medical field. The fine-tuning corpus includes a drug terminology dictionary, literature on symptom-drug associations, drug interaction research reports, and clinical treatment guidelines. The fine-tuning process uses incremental training, updating the corpus quarterly, synchronized with the update cycle of the medical knowledge base. Simultaneously, the structured association information in the medical knowledge graph is transformed into triple constraints and incorporated into the loss function of model training, making the semantic vectors generated by the model more consistent with the association logic of the medical field. For example, through the constraint of the triple <hypertension, contraindicated drugs, pseudoephedrine-containing drugs>, the model can more accurately identify the contraindication attribute of pseudoephedrine-containing drugs when processing queries from hypertension users.

[0150] The drug information processing module inputs the pre-processed full-dimensional drug information into the optimized pre-trained language model to generate a 384-dimensional high-dimensional semantic vector, which is then transmitted to the vector database for storage via a data interface.

[0151] The user query processing module receives natural language queries from users and constructs a comprehensive query representation. This module receives the query text and user ID sent by the user terminal via a network interface. First, it performs preprocessing operations on the query text, including word segmentation, redundant information removal, and extraction of core information. Core information includes symptom keywords, medical history keywords, efficacy requirement keywords, and medication preference keywords. After preprocessing, it calls the optimized pre-trained language model from the drug information processing module to transform the query text into a 384-dimensional high-dimensional semantic vector. Simultaneously, it extracts medical-specific features and personalized preference features from the user feature database based on the user ID. Medical-specific features include age group, gender, etc. Allergy history, past medical history, and a list of currently used medications are collected. Personalized preference features include medication dosage form preference, efficacy priority preference, brand preference, and price range preference. User feature data is obtained through three methods: user-initiated submission, authorized synchronization of data from third-party health management platforms, and compliant acquisition of electronic medical record summary information. The electronic medical record information is encrypted to comply with medical data privacy protection regulations. The user query processing module standardizes the extracted user features, converting non-numerical features into vector form, which is then concatenated with the user query vector to form a unified comprehensive query representation, which is transmitted to the matching and recommendation engine via the data bus.

[0152] The vector database uses ChromaDB to store high-dimensional semantic vectors of drugs transmitted by the drug information processing module. This database employs an efficient HNSW index structure, constructing a multi-layered navigation graph for fast retrieval. Each layer of the navigation graph consists of a subset of drug vectors, and the index construction frequency matches the drug information update frequency. The vector database supports two similarity measurement methods: cosine similarity and Euclidean distance. This embodiment is configured with cosine similarity measurement and integrates a BM25 keyword index module, supporting the execution of hybrid retrieval strategies. The vector database receives retrieval requests and query vector portions from the matching and recommendation engines, performs semantic similarity retrieval through the HNSW index structure, or performs precise matching through the BM25 keyword index, retrieving 15 drug vectors that meet a preset threshold of semantic similarity greater than or equal to 0.7, forming a preliminary recommended drug set. The drug ID, vector similarity score, and basic drug information are then fed back to the matching and recommendation engine.

[0153] The matching and recommendation engine is the core processing unit of the device. It receives the comprehensive query representation sent by the user query processing module and the preliminary recommended drug set fed back by the vector database, and performs secondary screening and sorting based on a multi-dimensional comprehensive scoring algorithm.

[0154] This engine integrates an interpretable output module, a medical knowledge base interface, and a user feedback learning unit. The medical knowledge base interface connects to authoritative medical knowledge bases that are updated in real time, including the National Medical Products Administration's adverse drug reaction database, clinical practice guidelines database, drug interaction database, and drug price monitoring database. Through this interface, the engine obtains the latest drug safety information, clinical drug use guidelines, drug interaction data, and real-time price data for medical safety verification and price suitability assessment. The matching and recommendation engine first calls a multi-dimensional comprehensive scoring algorithm, combining user characteristics from the comprehensive query representation and the latest data obtained from the medical knowledge base interface, to calculate a comprehensive recommendation score for each drug in the initial recommended drug set. The calculation process is the same as in Example 1, first eliminating... High-risk drugs, then according to The scores are sorted in descending order to generate a final personalized drug recommendation list. Subsequently, the interpretability output module generates a structured recommendation reason for each drug in the recommendation list, including the symptom and indication matching basis, the efficacy description of the core ingredients, the user characteristic adaptation analysis, the medical safety verification results, and a summary of usage precautions, presented in easy-to-understand natural language. Finally, the recommendation list and recommendation reasons are transmitted to the user terminal through the API gateway for the user to view.

[0155] The user feedback learning unit receives feedback signals sent from user terminals. These signals include five types: "useful," "irrelevant," "risk warning," "unsatisfactory price," and "inappropriate dosage form," along with possible textual descriptions. The unit parses the feedback signals, extracts key information from the feedback type and textual descriptions, and constructs a reinforcement learning reward function to calculate immediate reward values. The reward function and calculation method are the same as in Example 1; when the cumulative number of user feedback received reaches 15, the unit uses the accumulated reward value. The weight coefficients in the multi-dimensional comprehensive scoring algorithm are dynamically updated using the gradient descent algorithm. , , , At the same time, key information in the text description is transformed into the basis for feature weight adjustment. For example, if a user feedback states "we hope for fewer side effects," then the weight will be automatically increased. The percentage of users reporting "dissatisfaction with the price" increased. The proportion of price-adapted components ensures continuous optimization of the recommendation model.

[0156] The model optimization unit of the drug information processing module updates the fine-tuning corpus and knowledge graph data quarterly, keeping in line with the update cycle of the medical knowledge base, further ensuring the accuracy and security of the device's recommendation results.

[0157] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for intelligent drug recommendation based on semantic vector search, characterized in that, Includes the following steps: S1. Drug Information Vectorization: Using a pre-trained language model, the drug's name, generic name, main efficacy, ingredients, indications, contraindications, adverse reactions, and user reviews are transformed into high-dimensional semantic vectors. The pre-trained language model is one of the Sentence-Transformers model, BERT model, and RoBERTa model. S2. User query vectorization: The natural language query input by the user, which includes symptom description, expected efficacy and medication preference, is transformed into a corresponding high-dimensional semantic vector through the pre-trained language model described in step S1. S3. Multi-dimensional feature construction: Extract the user's medical-specific features and personalized preference features, and integrate the user's medical-specific features, personalized preference features and user query vector obtained in step b to form a comprehensive query representation; S4. Vector retrieval and matching: Store the high-dimensional semantic vector of the drug obtained in step S1 in the vector database. After receiving the comprehensive query representation in step S3, retrieve a preset number of drug vectors that meet the preset conditions of similarity with the user's query vector through the efficient index structure and similarity measurement method of the vector database, and form a preliminary recommended drug set. S5. Multi-dimensional Fusion Recommendation: Based on a multi-dimensional comprehensive scoring algorithm, the drugs in the initial recommended drug set are further filtered and sorted to generate a personalized drug recommendation list. The core formula of the multi-dimensional comprehensive scoring algorithm is: , in, Let be the overall recommendation score for the i-th drug. A higher score indicates a higher recommendation priority. , , , The preset weighting coefficients satisfy the following conditions: These correspond to the importance percentages of semantic similarity, medical safety, user suitability, and efficacy matching, respectively. For user query vectors With the vector of the i-th drug semantic similarity, Let i be the medical safety score for the i-th drug. The score represents the compatibility score between the i-th drug and the user. The efficacy matching score for the i-th drug.

2. The intelligent drug recommendation method based on semantic vector search according to claim 1, characterized in that, The drug information in step S1 also includes drug dosage form, specifications, brand, and clinical application scenario information. The sources of the drug information include the full text of the drug instructions, drug details pages on e-commerce platforms, medical database filing information, and drug clinical application reports. The pre-trained language model is a model fine-tuned with a corpus specific to the pharmaceutical field. The fine-tuning process adopts an incremental training method. The corpus includes a drug terminology dictionary, literature on the association between symptoms and drugs, drug interaction research reports, and clinical diagnosis and treatment guidelines. The fine-tuning goal is to improve the model's accuracy in recognizing semantic associations in the pharmaceutical field, specifically including the correspondence between symptoms and indications, the association between drug ingredients and efficacy, and the identification of conflicts between contraindications and medical history.

3. The intelligent drug recommendation method based on semantic vector search according to claim 1, characterized in that, In step S2, the user's natural language query includes single symptom query, multiple symptom combination query, symptom and medical history combination query, and efficacy-oriented query. Before the user query is vectorized, a query preprocessing step is also included. The system performs word segmentation, redundant information removal, and core information extraction on user input text. The core information includes symptom keywords, medical history keywords, efficacy demand keywords, and medication preference keywords. During the generation of the user query vector, the model's attention mechanism assigns higher weights to core information, making the vector more accurately represent the user's core needs.

4. The intelligent drug recommendation method based on semantic vector search according to claim 1, characterized in that, The medical-specific features in step S3 include age group, gender, allergy history, past medical history, and a list of currently used medications. The personalized preference features include medication dosage form preference, efficacy priority preference, brand preference, and price range preference. The user features are obtained through user-initiated submission, authorized synchronization of data from a third-party health management platform, and compliant acquisition of electronic medical record summary information. The acquisition of electronic medical record information must be processed with privacy encryption, extracting only medication-related feature data, and complying with medical data privacy protection regulations. During feature integration, each feature is standardized, and non-numerical features are converted into vector form and then concatenated with the user query vector to form a comprehensive query representation with unified dimensions.

5. The intelligent drug recommendation method based on semantic vector search according to claim 1, characterized in that, In step S4, the vector database is one of ChromaDB, Milvus, Pinecone, or Faiss. The efficient index structure is the HNSW index structure, which achieves fast retrieval by constructing a multi-layered navigation graph. Each layer of the navigation graph consists of a subset of drug vectors. During retrieval, the search starts from the top-level navigation graph and gradually locates the most similar set of vectors. The similarity measurement method includes cosine similarity or Euclidean distance. Cosine similarity is used to calculate the similarity of vector directions, and Euclidean distance is used to calculate the proximity of vector spatial positions. The preset condition is that the semantic similarity is greater than or equal to a preset threshold. The preset number is 5-20, which can be adjusted according to the user terminal display requirements. The retrieval process adopts a hybrid retrieval strategy. When a user query is detected to contain keywords for a precise drug name, generic drug name, or specific dosage form, the BM25 keyword index is used for precise matching to directly locate the target drug. When a user queries a fuzzy query such as symptom description or efficacy requirement, semantic similarity retrieval using a vector database is employed; when mixed retrieval yields results simultaneously, the union of the two is taken, and the exact matching results are retained first.

6. The intelligent drug recommendation method based on semantic vector search according to claim 1, characterized in that, Medical safety score in step S5 The calculation method is as follows: , in, Let be the conflict coefficient between the i-th drug and the user's allergy history. If the drug contains an allergen or belongs to the category of drugs the user is allergic to, then the coefficient is 1; otherwise, it is 0. Let be the contraindication coefficient between the i-th drug and the user's past medical history. If the drug's contraindications explicitly include the user's past medical history or may aggravate the user's underlying condition, then the coefficient is 1; otherwise, the coefficient is 0. Let be the interaction risk coefficient between the i-th drug and the user's current medication. If there is a contraindication interaction between the drug and the user's current medication, the value is 1; if there is a cautionary interaction, the value is 0.5; otherwise, the value is 0. , , Let be the weight coefficients of the safety sub-dimension, and satisfy . ,in The weighting should be no less than 40%, prioritizing the avoidance of allergy risks; User fit score The calculation method is as follows: , in, The coefficient for matching the drug to the user's age group is 1 for a complete match, 0.8 for a partial match, and 0 for an incomplete match. The coefficient represents the compatibility of the drug with the user's medical history. A value of 1 is assigned if there is no adverse impact on the medical history and the drug meets the treatment needs; 0.6 is assigned if there is no adverse impact but no direct compatibility; and 0 is assigned if there is potential risk. The coefficient for matching drug preferences with user-specific preferences is set as follows: 1 for complete alignment with all preferences, 0.8 for alignment with core preferences, 0.5 for partial alignment, and 0 for no alignment at all. The coefficient for matching drug prices to user price range preferences is set to 1 if the price range is within the user's price range, 0.6 if the price range is outside the range but not exceeding 20%, and 0 if the price range is more than 20%. The efficacy matching score The calculation is based on the degree of alignment between the drug's therapeutic effects and the user's symptoms and desired effects, using a semantic similarity weighting method: , in, This is the semantic vector corresponding to the user's k-th desired effect or symptom. Let be the semantic vector corresponding to the main therapeutic effects of the i-th drug. Let the semantic similarity between the user's k-th request and the efficacy of the drug be denoted as . The weight of the user's k-th request is determined by the strength of the request's description in the user's query or the user's preset priority of functionality. The total number of user requests; During the secondary screening and sorting process, first remove... High-risk drugs, and then the remaining drugs are classified as follows: The scores are sorted in descending order to generate the final recommendation list.

7. The intelligent drug recommendation method based on semantic vector search according to claim 1, characterized in that, The pre-trained language model in steps S1 and S2 can also be optimized using a medical domain knowledge graph. This medical domain knowledge graph contains the full-link relationships between diseases, symptoms, drugs, ingredients, contraindications, adverse reactions, and clinical application scenarios. The model optimization process is as follows: The structured association information in the knowledge graph is transformed into triple constraints and incorporated into the loss function of the model training, so that the semantic vectors generated by the model are more in line with the association logic in the medical field.

8. The intelligent drug recommendation method based on semantic vector search according to claim 1, characterized in that, It also includes the following steps: S6. User feedback learning. The specific steps of user feedback learning are as follows: S61. Receive feedback signals from users regarding the recommendation list. The feedback signals include five types: useful, irrelevant, risk warning, unsatisfactory price, and unsuitable dosage form. Users can choose a single feedback type or provide supplementary text descriptions. S62. Constructing a reward function for reinforcement learning based on feedback signals: , in, Let t be the instant reward value for the t-th recommendation. A useful feedback coefficient is assigned to the user, with 1 for useful and 0 otherwise. The feedback coefficient is assigned to indicate whether a user is unrelated; a value of 1 is assigned to the coefficient, and a value of 0 is assigned to the coefficient otherwise. The feedback coefficient for marking a risk warning to the user is set to 1, and 0 otherwise. A feedback coefficient is assigned to indicate user dissatisfaction with the price: 1 for dissatisfaction and 0 otherwise. The feedback coefficient for marking users as having an unsuitable dosage form is set to 1, and 0 otherwise. , , , , For the feedback weighting coefficients, satisfying Risk feedback weight No less than 30%; S63, Utilizing reward values Dynamically update the weight coefficients in the multi-dimensional comprehensive scoring algorithm , , , The update cycle is to perform a batch update every 10-20 user feedbacks received, ensuring that the recommendation model is continuously optimized with user feedback and adapted to users' long-term needs.

9. A smart drug recommendation device based on semantic vector search, comprising a smart drug recommendation method based on semantic vector search according to any one of claims 1-8, characterized in that, It includes a drug information processing module, a user query processing module, a vector database, and a matching and recommendation engine; The drug information processing module is used to collect drug information in all dimensions and transform the drug information into high-dimensional semantic vectors through a pre-trained language model. The user query processing module is used to receive user natural language queries and convert them into high-dimensional semantic vectors, while extracting the user's medical-specific features and personalized preference features to construct a comprehensive query representation; The vector database is used to store the high-dimensional semantic vectors of the drug and provides efficient retrieval services based on efficient index structure and similarity measurement method; The matching and recommendation engine is used to receive the comprehensive query representation, retrieve a preliminary recommended drug set through the vector database, perform secondary screening and sorting on the preliminary recommended drug set based on a multi-dimensional comprehensive scoring algorithm, and generate and output a personalized drug recommendation list.

10. The intelligent drug recommendation device based on semantic vector search according to claim 9, characterized in that, The drug information processing module also includes an information preprocessing unit and a model optimization unit; The information preprocessing unit performs deduplication, format standardization, and validity verification on the collected drug information across all dimensions. Format standardization includes unifying drug ingredient names, standardizing indication terminology, and classifying adverse reactions. Validity verification includes removing information on expired drugs, recalled drugs, and false advertising. The verification is based on authoritative data published by the National Medical Products Administration. The model optimization unit fine-tunes the pre-trained language model based on a medical field-specific corpus, and optimizes the semantic representation capabilities of the model by combining a medical field knowledge graph. The fine-tuning corpus and knowledge graph data are updated regularly, with the update cycle synchronized with the medical knowledge base. The matching and recommendation engine also integrates an interpretable output module, a medical knowledge base interface, and a user feedback learning unit. The interpretable output module generates a structured recommendation rationale for each recommended drug, including five parts: symptom and indication matching basis, core ingredient efficacy description, user characteristic adaptation analysis, medical safety verification results, and usage precautions summary, presented in a natural and easy-to-understand language. The medical knowledge base interface connects to an authoritative medical knowledge base that is updated in real time, including the National Medical Products Administration's adverse drug reaction database, clinical drug use guideline database, drug interaction database, and drug price monitoring database, for dynamic updates of drug information, medical safety verification, and price suitability assessment. The user feedback learning unit receives user feedback signals and dynamically optimizes the weight coefficients of the multi-dimensional comprehensive scoring algorithm through reinforcement learning algorithms. It also supports converting user text feedback into a basis for feature weight adjustment.