A medicine recommendation method and system based on a large language model and user psychological inference, and a storage medium
By using a large language model and multi-turn dialogue interaction, structured query conditions are generated. Combined with user history behavior and environmental parameters, psychological need tags are output, which solves the problem that drug search platforms cannot accurately capture implicit psychological needs and realizes dynamic adaptation and high-precision matching of drug recommendations.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGZHOU SUDAOYI INFORMATION TECHNOLOGY CO LTD
- Filing Date
- 2026-04-20
- Publication Date
- 2026-06-26
AI Technical Summary
Existing drug search platforms struggle to accurately capture users' implicit psychological needs, and recommendation results cannot dynamically adapt to users' real-time psychological states. Traditional recommendation models are trained based on static profiles or offline logs, resulting in lagging weight adjustments and an inability to adjust ranking strategies in real time.
The system employs a large language model to identify the completeness of drug pre-order attributes, generates structured query conditions through multi-turn dialogue interaction, combines user historical behavior and environmental parameters, outputs user psychological need tags using a step-by-step reasoning approach, constructs an independent reasoning agent to filter the candidate drug set, generates top recommendations and provides recommendation reasons.
It achieves deep semantic transformation of unstructured dialogue content, quantitatively represents implicit psychological needs, improves the accuracy of drug search and the matching precision of recommendation results, dynamically adapts to changes in user psychology, and improves the relevance and accuracy of recommendations.
Smart Images

Figure CN122286002A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent information retrieval, and in particular to a method, system, and storage medium for recommending medicines based on a large language model and user psychological inference. Background Technology
[0002] Currently, B2B buyers traditionally use keyword-based search with filters to search for pharmaceutical products. However, the fixed format of keywords can only express a limited range of product intentions and cannot accommodate the complex psychological needs of users or the supplementary information obtained through multiple rounds of interaction. Although voice search exists, existing search platforms can only determine search keywords from user voice and struggle to effectively convert unstructured real-time dialogue content into calculable behavioral feature vectors, resulting in the inaccurate capture of users' implicit psychological needs.
[0003] Secondly, traditional recommendation models are trained based on static profiles or offline logs, resulting in lagging weight adjustments. They cannot adjust ranking strategies in real time based on changes in the user's psychological state during the conversation (such as a sudden shift from prioritizing low price to prioritizing timeliness), making it difficult to dynamically adapt recommendation results to the user's immediate psychological state. Therefore, how to utilize large language models to achieve deep semantic transformation in real-time dialogue and dynamically adapt to changes in user psychology is a pressing issue that needs to be addressed. Summary of the Invention
[0004] This invention provides a drug recommendation method, system, and storage medium based on a large language model and user psychological inference to solve the problems existing in related technologies. The technical solution is as follows: In a first aspect, embodiments of the present invention provide a drug recommendation method based on a large language model and user psychological inference, including: Obtain the purchasing requirements input by the user in the dialogue interaction, and use a large language model to identify the completeness of multiple pre-defined attributes of the medicine in the current dialogue; If all predefined attributes are complete, corresponding query conditions are generated based on the complete values of each predefined attribute, and a set of candidate drugs is obtained by searching the drug database based on the query conditions. Based on the user's historical behavior data, dialogue history, and at least one environmental parameter, the psychological need inference model outputs at least one user psychological need label using a step-by-step inference approach. The user's psychological needs tags, the product characteristics of each candidate drug in the candidate drug set, the merchant characteristics of each candidate drug, and the user characteristics obtained based on the user profile are all input into the big language model. The big language model then constructs an independent reasoning agent for each user's psychological needs, filters the candidate drug set, determines the top recommended drug, and generates the corresponding recommendation reason.
[0005] In one implementation, identifying the completeness of multiple predetermined attributes of a drug in the current dialogue using a large language model includes: Based on procurement needs, similar drug entries are retrieved from the drug standard catalog vector library through a search-enhanced generation method. Using a large language model, the completeness of multiple predefined attributes of drugs in the current dialogue is identified based on similar drug entries; among these, multiple predefined attributes include variety attributes, specification attributes, and brand attributes used to uniquely identify the target drug. If information is missing in any of the predefined attributes, the corresponding completion operation is performed; the completion operation includes generating corresponding follow-up questions or providing corresponding filter options for the user to complete.
[0006] In one implementation, environmental parameters include user type, customer group characteristics, regional attributes, purchase volume, inventory level, seasonal epidemic data, and user qualifications; the step-by-step inference method includes, in turn: Key behavioral signals are extracted from historical behavioral data, dialogue history records, and environmental parameters; these signals originate from explicit intent flows, implicit behavioral flows, and environmental constraint flows. Based on key behavioral signals, at least one potential psychological hypothesis is proposed. Each potential psychological hypothesis is verified in combination with user profiles. Based on the verification results, user psychological need labels and confidence levels are output. Among them, user profiles include basic user profiles, medium- and long-term behavioral profiles, and short-term behavioral profiles.
[0007] In one implementation, the explicit intent flow includes the current search term, user input in the conversation history, and click stream sequence; the implicit behavior flow includes dwell time, number of comparisons, percentage of promotional items, search time period, and historical return reasons; and the environmental constraint flow includes at least one of the environmental parameters.
[0008] In one implementation, a dynamic weight adaptation step is also included: Based on users' purchasing or ignoring behavior of top-recommended drugs, a reinforcement learning feedback loop is used to positively reward or negatively punish the psychological feature weights corresponding to the user's psychological need tags, and to adjust the retrieval enhancement examples in the prompt templates used by the step-by-step inference method in reverse.
[0009] In one implementation, the psychological need reasoning module uses a multi-granularity psychological graph to output user psychological need labels; the multi-granularity psychological graph includes a hierarchical graph of atomic psychology and composite psychology, wherein atomic psychology includes greed for cheapness, speed, stability, and conformity, and composite psychology is represented by a linear combination of atomic psychology; the user psychological need label is a coefficient vector of composite psychology.
[0010] In one implementation, the user's psychological need tags, the product characteristics of each candidate drug in the candidate drug set, the merchant characteristics of each candidate drug, and the user characteristics obtained based on the user profile are jointly input into the large language model, including: For each user's psychological need in the user's psychological need tags, construct an independent reasoning agent; A dynamic prompt template is constructed for each inference agent. The dynamic prompt template transforms the corresponding user psychological needs into binding instructions. The product characteristics, merchant characteristics, and user characteristics of each candidate drug in the candidate drug set are compressed into structured data and input into the large language model.
[0011] In one implementation, screening the candidate drug set includes: The large language model performs Pareto dominance screening on the inference agent corresponding to each user's psychological needs, generating a top drug sequence sorted after Pareto screening. The first drug in the top drug sequence is identified as the top recommended drug, and a large language model generates a recommendation reason containing comparative arguments for the top recommended drug.
[0012] Secondly, embodiments of the present invention provide a drug recommendation system based on a large language model and user psychological inference, which executes the drug recommendation method based on a large language model and user psychological inference as described above, including: The multi-turn dialogue management module is used to obtain the procurement requirements input by the user in the dialogue interaction, enhance the completeness of the generation of multiple predetermined attributes in the user's procurement requirements through retrieval, and generate query conditions when all predetermined attributes are complete. The search and recall module is used to retrieve a set of candidate drugs from the drug database based on query conditions. The psychological needs inference module is used to output at least one user psychological needs label by the psychological needs inference model using a step-by-step reasoning approach, based on the user's historical behavior data, dialogue history, and at least one environmental parameter. The filtering and recommendation module receives user psychological need tags, product features of candidate drugs, merchant features of candidate drugs, and user features obtained from user profiles. It constructs an independent reasoning agent for each user's psychological needs, filters the set of candidate drugs, and outputs the top recommended drugs and the reasons for the recommendation.
[0013] Thirdly, embodiments of the present invention provide a computer-readable storage medium that stores a computer program, wherein when the computer program is run on a computer, the methods in any of the above-described embodiments are executed.
[0014] The advantages or beneficial effects of the above technical solutions include at least the following: This invention inputs procurement needs through multi-turn dialogue interaction and utilizes a large language model to identify the completeness of multiple predetermined attributes of medicines in the dialogue. Based on the complete values of each predetermined attribute, query conditions are generated, which can transform unstructured real-time dialogue content into structured query conditions containing the complete values of each predetermined attribute. On this basis, key behavioral signals are further extracted from the user's historical behavior data, dialogue history, and environmental parameters. A step-by-step reasoning method is used to output user psychological need tags from a psychological need reasoning model, realizing the deep semantic transformation of unstructured dialogue content and the quantitative representation of implicit psychological needs.
[0015] Secondly, by inputting user psychological needs tags, product features of candidate drugs, merchant features, and user features into a large language model, an independent reasoning agent is constructed for each user's psychological needs and a filtering process is performed to generate top recommended drugs that meet the user's current psychological preferences. This significantly improves the matching accuracy between recommendation results and user psychology, and enhances the accuracy of drug search.
[0016] The above overview is for illustrative purposes only and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments, and features described above, further aspects, embodiments, and features of the invention will become readily apparent from the accompanying drawings and the following detailed description. Attached Figure Description
[0017] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the various drawings denote the same or similar parts or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings depict only some embodiments disclosed in the invention and should not be construed as limiting the scope of the invention.
[0018] Figure 1 This is a flowchart of the drug recommendation method based on a large language model and user psychological inference according to the present invention; Figure 2 This is a diagram illustrating the overall architecture of the drug recommendation system based on a large language model and user psychological inference, as described in this invention. Figure 3 This is a structural block diagram of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0019] In the following description, only certain exemplary embodiments are briefly described. As those skilled in the art will recognize, the described embodiments can be modified in various ways without departing from the spirit or scope of the invention. Therefore, the drawings and description are considered to be exemplary in nature and not restrictive.
[0020] Example 1 like Figure 1As shown, this embodiment provides a drug recommendation method based on a large language model and user psychological inference, including: Step S1: Obtain the purchasing requirements input by the user in the dialogue interaction, and use the large language model to identify the completeness of multiple pre-defined attributes of the medicine in the current dialogue.
[0021] In this embodiment, the drug search engine pre-builds a drug database, supporting precise retrieval of fields such as drug name, manufacturer, specifications, brand, and seller. It also supports structured filtering by fields such as specifications, manufacturer, seller, minimum order quantity, free shipping, traditional Chinese medicine, traceability code, and expiration date. This engine can be implemented using the ElasticSearch distributed search engine or a self-built inverted index engine.
[0022] Users input their purchasing needs in natural language through the front-end dialogue interface, such as "I need cold medicine granules". After obtaining this text, a pre-defined attribute recognition process based on a large language model is initiated, with the following specific steps: Step S11: Based on procurement needs, retrieve similar drug entries from the drug standard catalog vector library through a search-enhanced generation method.
[0023] This embodiment uses the user's original query text entered through dialogue as keywords. It performs vector similarity retrieval in a pre-built standard drug catalog vector library, recalling several standard similar drug entries that are semantically closest to the query as retrieval enhancement examples. For example, when a user enters a specific drug name, retrieval enhancement may recall standard entries such as "drug name (brand, product specifications)". These examples are injected into the subsequent large language model prompt template to guide the model in understanding the format and value specifications of predetermined drug attributes.
[0024] Step S12: Using a large language model, identify the completeness of multiple predefined attributes of drugs in the current dialogue based on similar drug entries; wherein, multiple predefined attributes include variety attribute, specification attribute and brand attribute used to uniquely identify the target drug.
[0025] In this embodiment, the predetermined attributes of the drug include at least three dimensions: variety, specification, and brand. The names and allowed value types of these attributes (e.g., specification as a string) are predefined through configuration files or a database dictionary. The prompt template explicitly informs the large language model that it needs to extract the specific values of these three attributes from the user's dialogue.
[0026] The large language model first determines whether the user has explicitly or implicitly provided the values for each predefined attribute in the purchase requirements entered in the dialog box, that is, whether the "brand + variety + specification" triple of the product requirement is complete. For example, if the user enters "Cold Relief Granules", the model identifies the variety as "Cold Relief Granules", but the specifications and brand are empty. Therefore, the completeness status is determined to be "incomplete", and the missing fields are "specification" and "brand".
[0027] Step S13: If information is missing in any predetermined attribute, perform the corresponding completion operation; the completion operation includes generating the corresponding follow-up question or providing the corresponding filter options for the user to complete.
[0028] When the completeness determination result is "incomplete", the corresponding completion operation is performed based on the missing field. Specifically, the large language model generates a natural language question based on the missing field, such as "Please supplement the specifications and brand you need".
[0029] Alternatively, a drug search engine can be invoked, using the currently identified complete attributes (such as variety) as conditions, to aggregate the enumerated values of all existing fields such as specifications, manufacturers, and brands under that variety in the database, generating a UI chip. When a user clicks on a chip, the system automatically fills the value of that field into the dialog context, achieving slot completion in a non-textual way.
[0030] The procurement requirements and information completion operations can be achieved through multi-turn dialogues. During each round of dialogue, the input text, attribute values, and completeness status are recorded and stored in the conversation context. When the user inputs supplementary information in a new round, the system combines the historical context to resolve the referential errors, updates the values of the corresponding attributes, and re-executes the completeness judgment of the predetermined attributes. Steps S12 to S13 are repeated until all predetermined attributes are assigned valid values. At this point, the system considers the product intent of the procurement requirement to be complete and proceeds to the subsequent query condition generation and retrieval stage.
[0031] In another embodiment, in addition to guiding users to complete the standard triple "brand + variety + specification" (i.e., the pre-defined attribute combination), users are also allowed to actively supplement other purchasing needs in the input box in natural language, such as "free shipping", "preferably SF Express", "needs a shelf life of more than six months", etc. These needs do not belong to the structured fields limited by the standard triple, and are therefore collectively referred to as "extra-triple demand intentions".
[0032] Furthermore, in each round of interaction, after the system completes the attribute recognition of the user input (including standard triplet values and external requirements), it stores all the results extracted in that round (field names and corresponding values) into the SessionContext. The SessionContext retains all confirmed information from previous rounds. When the user explicitly changes or corrects a previously provided value in a round (for example, the user first says "10g x 9 bags," then says "No, it should be 6g x 9 bags"), the large language model combines the dialogue history context to perform semantic understanding and determine whether the current input constitutes a correction to the historical value. Based on the correction intent output by the large language model, the corresponding field value in the SessionContext is updated to the new value, thus providing technical support for users to dynamically adjust their needs.
[0033] As a unified context storage center, Session Context provides well-structured and real-time updated input data for subsequent query condition generation, psychological need inference, and sorting and filtering, reducing the error rate of dialogue semantic parsing.
[0034] Step S2: If all predetermined attributes are complete, generate corresponding query conditions based on the complete values of each predetermined attribute, and retrieve the candidate drug set from the drug database based on the query conditions.
[0035] After confirming through multiple rounds of dialogue that all predefined attributes have been fully retrieved, the system enters the query condition generation phase. The core task of this phase is to transform the unstructured natural language intent accumulated during the dialogue into a structured query DSL that the drug search engine can directly execute.
[0036] This embodiment pre-defines a mapping dictionary from "natural language description" to "search engine fields." This dictionary is stored in key-value pairs and covers common intent expressions in pharmaceutical B2B procurement scenarios. (For example, if a user's natural language expression is "free shipping required," the mapping field and target value would be "isFreeShipping: 1").
[0037] The mapping dictionary supports dynamic expansion, and administrators can add new mapping rules through configuration files. When generating query conditions, the system traverses all structured information stored in the current session context (including standard triple values and user-added triple requirements), searching for the corresponding search engine field for each piece of information. If a match is found, an equality matching condition is directly generated; if no match is found, the original text is passed to a large language model for intelligent operator inference, achieving further semantic parsing.
[0038] For numerical or range-based conditions (such as minimum order quantity, price, delivery time, shelf life, etc.), users' natural language often includes comparison operators (greater than, less than, not equal to, between, etc.). This embodiment utilizes a large language model to intelligently infer these conditions and generate precise comparison query clauses. The specific process is as follows: The complete dialogue text input by the user (e.g., "limited to 10 boxes or more") is combined with the currently confirmed reservation attributes to construct a prompt, which is then input into the large language model. The large language model outputs structured JSON, explicitly specifying the fields, operators, and comparison values. For example: Enter: "Limited to 10 boxes or more" Output: {"field": "limitNum", "op": "gte", "value": 10} Subsequently, the multiple query clauses output by the large language model are logically ANDed with the equivalent conditions obtained from slot mapping to form a complete Boolean query expression. Simultaneously, the generated DSL undergoes validity checks (e.g., field existence, operator support, and value type matching) to avoid invalid queries.
[0039] The combined query expression is encapsulated as a DSL (Specific Query Language) and submitted to the drug search engine. The drug search engine performs an inverted index or vector index retrieval based on the DSL, returning the top N (e.g., 500) drug records with the highest matching degree. Each record contains the drug's product characteristics (such as price, sales volume, expiration date, minimum purchase threshold, gross profit margin, etc.) and the characteristics of its associated merchants (such as after-sales service rating, fulfillment rate, delivery time, free shipping threshold, sales control policies, whether an account has been opened, etc.). If the number of search results is zero, the system directly returns a "no matching drug found" message to the user and ends the current process; if the number of results is greater than zero, the candidate drug set is passed to the subsequent psychological demand-driven re-ranking module.
[0040] Step S3: Based on the user's historical behavior data, dialogue history, and at least one environmental parameter, the psychological need inference model outputs at least one user psychological need label using a step-by-step inference method.
[0041] This embodiment collects and fuses three types of heterogeneous data streams in real time to construct a "user psychological context window" for psychological reasoning. The three types of heterogeneous data streams include explicit intent stream, implicit behavior stream, and environmental constraint stream.
[0042] The explicit intent stream includes the current search term, multi-turn conversation history (i.e., the user's historical input and system-supplemented field values stored in the SessionContext), and clickstream sequence (the user's click behavior on search results or filters on the front-end interface). This data directly reflects the intent actively expressed by the user in the current session.
[0043] The hidden behavioral flow consists of indirect signals extracted from user behavior logs, including hesitation indicators, price sensitivity indicators, and time-sensitivity indicators. Hesitation indicators include dwell time (how long a user spends on a product details page or list page) and comparison counts (the number of times the same product is viewed from different manufacturers / specifications). Price sensitivity indicators include the percentage of promotional items in a user's historical orders and the price range distribution of products viewed / added to cart but not purchased. Time-sensitivity indicators include the time period when a user initiates a search (e.g., nighttime or holidays may indicate urgent need) and the proportion of historical return reasons related to logistics delays.
[0044] The three types of data streams mentioned above are concatenated in a time-aligned manner to form a structured or semi-structured input tensor for use by subsequent inference models.
[0045] This embodiment provides a dedicated Psych-LLM Prompt template to guide the large language model or a dedicated psychological need reasoning model to perform step-by-step reasoning in the following four steps: Step S31: The psychological needs reasoning model receives all data from the "user's psychological context window," including historical behavior data, dialogue history, and environmental parameters. These environmental parameters include user type, customer group characteristics, regional attributes, purchase volume, inventory level, seasonal epidemic data, and user qualifications. It automatically identifies key behavioral signals highly relevant to the purchasing decision from explicit intent flow, implicit behavior flow, and environmental constraint flow. These key behavioral signals include, but are not limited to: users repeatedly comparing multiple candidate drugs, hesitation behavior where the dwell time exceeds a preset threshold, the difference between the shopping cart amount and the free shipping threshold, and regional epidemic warning signals.
[0046] Step S32: The psychological needs reasoning model generates one or more potential psychological hypotheses based on observed key behavioral signals. Each hypothesis corresponds to a possible purchasing motivation (hypothesis A: price hesitation; hypothesis B: brand trust hesitation; hypothesis C: waiting to combine orders for free shipping).
[0047] Step S33: The psychological needs reasoning model calls the user profile service to obtain user profiles, and uses the user profiles to verify each potential psychological hypothesis.
[0048] The user profile includes a basic user profile, a medium-to-long-term behavioral profile, and a short-term behavioral profile. The basic user profile includes user type, region, and qualifications; the medium-to-long-term behavioral profile includes frequently purchased merchants, brand preferences (e.g., 80% of historical orders are from the Sanjiu brand), and price sensitivity (the ratio of historical average transaction price to average search price); the short-term behavioral profile includes the order history of items added to cart / browsed in the past 24 hours and available coupons.
[0049] For example, the underlying psychological hypothesis H1 is that the user is concerned about price (comparing the unit price difference between two manufacturers). The verification method for this hypothesis H1 is to query the historical price sensitivity index. If the proportion of promotional products in the user's history exceeds 60%, then H1 is supported.
[0050] Step S33: Output user psychological need labels and confidence scores based on the verification results. The psychological need inference model outputs multi-dimensional psychological need labels in JSON format based on the verification results. Each label includes a type code, a confidence score (0.0~1.0), and an evidence summary.
[0051] Furthermore, the psychological need inference model can also incorporate reinforcement learning feedback loops (RLHF). After the psychological need inference model outputs psychological need labels, when a user ultimately purchases a recommended product guided by a "high-confidence" psychological need label (e.g., a user purchases a product recommended by the FREE_SHIPPING label), the system positively rewards the weight of that psychological feature (by updating the corresponding coefficients in the weight matrix). Conversely, if the user completely ignores the recommendations (does not purchase any recommended products or clicks on other products), the model backpropagates through a loss function (such as cross-entropy loss) to fine-tune the Few-Shot example in the psychological inference prompt template. This example serves as a reference sample for the psychological need inference model during distributed inference. Through fine-tuning, the model generates more realistic psychological need labels in similar scenarios. This adaptive process runs continuously online, with the weight update cycle set to once every N sessions or real-time streaming updates.
[0052] Furthermore, the psychological needs reasoning model uses a multi-granularity psychological map to output user psychological needs tags; the multi-granularity psychological map includes a hierarchical map of atomic psychology and composite psychology.
[0053] Among them, the atomic psychology is an indivisible basic psychological winter, including greed for cheapness (pursuing low prices), speed (prioritizing timely delivery), stability (preferring merchants with good service, fast after-sales response, and frequent purchases), and conformity (tending to products with high overall sales volume).
[0054] Composite psychology is represented by a linear combination of atomic psychology. For example, "prioritizing cost-effectiveness" can be represented as greed for cheapness × 0.7 + seeking stability × 0.3.
[0055] The psychological need labels output by the psychological need reasoning model are the coefficient vectors of composite psychological needs (the dimension equals the number of atomic psychological needs). This graph is stored in a configuration file, allowing business personnel to dynamically adjust the combination coefficients.
[0056] In addition, to reduce the time required for psychological inference, this embodiment also includes a real-time streaming computing architecture, which uses Flink + Vector DB for real-time streaming computing. For each action a user takes (such as clicking, adding to cart, or dialogue input), the Flink task immediately updates the user's embedding in the vector database. The embedding is generated by the encoder from the user's most recent action sequence.
[0057] In each round of reasoning, the psychological needs reasoning model no longer scans the original logs, but instead reads the user's latest vector snapshot directly from the vector database as part of the psychological context window.
[0058] This architecture reduces the latency of feature extraction from seconds to milliseconds, ensuring that the total time for psychological inference does not exceed 200 milliseconds, thus meeting the requirements for real-time interaction.
[0059] This embodiment, through the aforementioned multi-source heterogeneous feature fusion, step-by-step reasoning of thought chains, dynamic weight adaptation, multi-granularity mental mapping, and real-time streaming architecture, can transform users' historical behavior, real-time dialogue, and environmental constraints into quantified psychological need tags. This solves the problems of difficulty in converting unstructured interaction logs and lagging weight adjustment in existing technologies. The confidence scores and evidence summaries of the psychological need tags provide interpretable and dynamically updated input features for subsequent re-ranking.
[0060] In another embodiment, to further improve the accuracy of the psychological needs reasoning model in recognizing users' purchasing psychology, two types of optimization mechanisms can be introduced: First, a user type business knowledge base is constructed, summarizing the historical purchasing habits of different user groups into structured knowledge and injecting it as context into the prompt template of the psychological needs reasoning model. For example, the typical purchasing habits of users of independent pharmacies, clinics, or chain stores are summarized as "price-sensitive, moderate minimum purchase quantity, compliance requirements for scanning traceability codes upon delivery, and preference for good merchant service," while the habits of users of chain headquarters are summarized as "long shelf life requirements, preference for platform or merchant discounts, mandatory traceability code scanning upon delivery, and tendency to repurchase from historically cooperating merchants."
[0061] While receiving user behavior data, the psychological needs reasoning model retrieves the corresponding habit descriptions from the knowledge base based on the current user's type tags, and uses them together with explicit intention streams, implicit behavior streams, and environmental constraint streams as the basis for reasoning, thereby making the psychological needs tags output by the model more adaptable to the group.
[0062] Second, to address the specific psychological need of "buying together items from the same merchant," a two-level inference mechanism based on quantitative calculation and intent confirmation using a large language model is introduced. Specifically: First, the potential energy value E of combining orders is calculated quantitatively. group Its definition is: E group = w1·Δ money + w2·Δ qty + w3·History habit + w4·Time decay ; Where, Δ money Δ represents the percentage difference between the total amount of items from the same merchant in the current shopping cart and the merchant's next discount tier (such as free shipping threshold or minimum spend threshold). qty This indicates the percentage difference between the current add-to-cart quantity and the minimum purchase amount. (History) habit This indicates the frequency with which a user actively adds items to reach the minimum order amount in their historical orders (i.e., the proportion of orders where this user adds items to reach the minimum order amount). Time decay This represents the normalized decay factor indicating the remaining time of available coupons or promotions (the shorter the remaining time, the higher the weight). The weight coefficients w1 to w4 can be pre-calibrated through offline experiments or online learning.
[0063] When E group When the threshold is exceeded, the system determines that the user has a potential need to add items to their cart and triggers a large language model to perform deep intent confirmation and scenario simulation. Specifically, the system constructs scenario simulation prompts, which include the current list of products from the merchant in the user's shopping cart and the total amount, the amount shortfall before the next discount tier, and the user's historical behavioral characteristics (including the percentage of orders placed with the same merchant in the user's historical orders, whether the user frequently purchases from this merchant, the average number and amount of products purchased with the same merchant in historical orders, and the specific varieties and price ranges of products that the user has placed with the same merchant in their historical orders).
[0064] The large language model outputs a structured result based on this prompt, including a binary judgment of whether there is a need to add items to a cart, the most likely type of item to add (such as a medicine category or specific product name), and a suggested price range. For example, if a user's shopping cart contains 480 yuan worth of goods from a certain merchant, 20 yuan short of the 500 yuan free shipping threshold, and the user has a high frequency of adding items from the same merchant in their historical orders, the large language model might output "There is a strong need to add items to a cart; it is predicted that commonly used medicines with a price range of 20 to 30 yuan, such as band-aids or vitamin C tablets, will be acceptable." This inference result will be stored in the conversation context as a specific instance of the user's mental need label (of type "FREE_SHIPPING_BUNDLE") for use by the subsequent multi-agent reordering module.
[0065] By combining the above-mentioned quantitative calculation of the potential for adding items to a shopping cart with intent confirmation based on a large language model, the system can proactively identify and quantify the user's implicit need to add items to a shopping cart without relying on the user's explicit expression. As a result, during the re-sorting stage, the system can prioritize recommending products that meet the needs for adding items to a shopping cart and that are in line with the user's historical preferences.
[0066] Step S4: Input the user's psychological needs tags, the product characteristics of each candidate drug in the candidate drug set, the merchant characteristics of each candidate drug, and the user characteristics obtained based on the user profile into the big language model; the big language model constructs an independent reasoning agent for each user's psychological needs, filters the candidate drug set, determines the top recommended drug, and generates the corresponding recommendation reason.
[0067] This embodiment uses the candidate drug set obtained in step S2, along with the corresponding product and merchant features in the candidate drug set, to construct a three-dimensional data feature system together with the user profile, as shown in Table 1: Table 1. Three-dimensional data feature table
[0068] Subsequently, the user's psychological needs tags, the product characteristics of each candidate drug in the candidate drug set, the merchant characteristics of each candidate drug, and the user characteristics obtained based on the user profile are all input into the big language model. The big language model performs intelligent re-ranking based on psychological needs to obtain the optimal recommendation result. At the same time, it provides other recommendation reasons for the product result in addition to matching psychological needs, and finally presents them to the user.
[0069] Among them, for the K salient psychological needs identified {P1, P2, ..., P...} k The system constructs K independent inference agents, each receiving a complete set of candidate drugs C={c1,c2,…,c...}. N}, and each agent includes components including dynamic prompt templates, which are used to express psychological needs P k This is transformed into executable binding instructions. The template uses natural language descriptions, including the optimization goals, logical rules, and priority requirements under this psychological need. For example, for the psychological need of "combining orders to get free shipping," the template will define how the final amount payable for the goods is calculated (goods price plus shipping fee; if the sum of the total amount of existing goods from the same merchant in the shopping cart and the current goods price is not lower than the merchant's free shipping threshold, then the shipping fee is zero), and explicitly require that low-priced goods be recommended first.
[0070] Furthermore, to avoid large language models processing excessively long contexts, the system compresses the key features of each drug in the candidate drug set C into a compact, structured format. This embodiment uses a JSON list (Markdown tables can also be used). Each entry contains fields such as drug ID, product name, price, delivery time (hours), expiration date (months), free shipping gap (the difference from the current merchant's free shipping threshold), and add-on gap (the difference from the current coupon usage threshold). This significantly reduces the number of input tokens while retaining the dimensions required for Pareto dominance judgment, as shown in Table 2. Table 2 Entry Fields
[0071] Each inference agent then executes the following inference flow: The large language model first reads the compressed candidate drug set and corresponding list and dynamic prompt template, outputs global observation results, and identifies the psychological need P. k Extreme points in each dimension (such as lowest price, fastest delivery time, best add-on items) and outliers (such as products with too short an expiration date or too long delivery time). Based on this, the large language model performs an extended Pareto dominance judgment on candidate drugs: if product A meets the psychological demand P k If product A outperforms product B in terms of performance in other secondary dimensions (such as price, shelf life, delivery time, and merchant after-sales service rating), then product A is considered to dominate product B. If product A outperforms product B in terms of psychological needs P, then product A is considered to dominate product B. k If a product performs slightly better in one aspect but performs extremely poorly in any important secondary dimension (e.g., the merchant's after-sales service rating is below the threshold or the remaining validity period is less than three months), then product A is considered unacceptable and its weight is reduced. This judgment rule simulates the decision-making logic of users in actual purchasing, who will not sacrifice other key factors for the satisfaction of minor psychological needs.
[0072] After the above dominance judgment, the large language model generates a head product sequence in an autoregressive manner. The first product in the sequence is the drug with the highest comprehensive score in the Pareto optimal solution set that has not been downgraded. Subsequent products output suboptimal solutions in turn. In this embodiment, only one or two recommended drugs are output at the head to control computational overhead.
[0073] For the final top-recommended drugs, the large language model further generates recommendation reasons containing comparative arguments. These reasons require the model to cite at least one other candidate drug as a comparison, quantifying the differences between the two in terms of psychological needs and secondary dimensions. For example, "Choose product A instead of product B because although B is 0.5 yuan cheaper, A immediately meets the free shipping threshold, actually saving 10 yuan in shipping costs, and A's shelf life is 6 months longer than B's." When multiple significant psychological needs exist, the system runs all inference agents in parallel, ultimately selecting the recommendation result from the agent with the highest confidence score based on the psychological need confidence score and presenting it to the user. Through the above multi-agent parallel inference and extended Pareto dominance screening, this scheme achieves efficient decoupled ranking under multiple conflict constraints, while generating interpretable comparative recommendation reasons in an autoregressive manner.
[0074] In another embodiment, within the multi-agent intelligent reordering framework, when the user's psychological need label output by the psychological need inference model contains the type "free shopping bundle" (FREE_SHIPPING_BUNDLE) and the confidence level exceeds a threshold, the system further initiates a dedicated recommendation link optimization for the bundle scenario to improve the accuracy and user acceptance of bundle recommendations. Specifically: First, the system performs candidate pool filtering, limiting the candidate drug set to the inventory of drugs from the same merchant as the products already in the user's shopping cart. In other words, it only searches for available products from the same merchant as the shopping cart, avoiding the inability to combine free shipping or discounts due to the recommendation of cross-merchant bundled items.
[0075] Secondly, precise matching is performed within the filtered candidate pool. Screening criteria include: the product price strictly falls within the gap range for adding items to a bundle (e.g., a gap of 20 to 30 yuan); the product category belongs to a "highly compatible category" predicted by the large language model (e.g., commonly used medicines, medical devices or consumables with low decision-making barriers); and the product itself has a high gross profit margin and low decision-making costs for users (e.g., low unit price, long shelf life, no prescription required). The system then sorts products that meet the above criteria in descending order of their bundle-adding potential value.
[0076] For the selected add-on items, the system dynamically inserts a "Add-on Item Powerhouse" card at the top of the search results page, and the large language model generates incentive-based recommendation copy for this card. The copy generation rules require the model to highlight the actual benefits that users can perceive, such as "Buy another box of medical cotton swabs (...)" (22.00), this order saves 15 yuan on shipping and meets the minimum order quantity, which is equivalent to getting cotton swabs for free. When the gap in the order is large (e.g., more than 50 yuan) and a single product cannot completely cover the gap, the system calls the combinatorial optimization algorithm. The large language model plans the best product combination package to meet the gap, rather than recommending a single product. The model generates an explanation such as "These two items are just enough for your needs next week" based on the complementarity of candidate products, price aggregation, and the user's historical purchasing cycle, and presents the combination package as a whole recommendation unit.
[0077] Furthermore, the system implements a negative feedback suppression mechanism: if the same user repeatedly closes or ignores the system-pushed add-on recommendation cards, the large language model will automatically lower the weight of the user's corresponding "add-on" psychological feature in subsequent inferences, while reducing or even stopping the proactive push of add-on recommendations to avoid interfering with the user. This suppression signal is also fed back to the dynamic weight adaptive mechanism, which updates the reward value of the psychological feature weights through reinforcement learning, enabling the model to gradually converge to an inference strategy that better reflects actual preferences for similar users. Through the multi-level optimization of candidate pool filtering, precise matching, interactive guidance, combinatorial optimization, and negative feedback suppression, this solution significantly improves the acceptance rate and conversion efficiency of add-on recommendations while maintaining recommendation relevance, and reduces the negative impact of invalid pushes on user experience.
[0078] Example 2 This embodiment provides a drug recommendation system based on a large language model and user psychological inference. Its overall architecture is divided into a data layer, a knowledge enhancement layer, a model service layer, a business logic layer, and an application interaction layer from bottom to top.
[0079] like Figure 2 As shown, the data layer comprises a user profile database, a product knowledge base, a merchant service database, and an industry knowledge graph. The user profile database stores static attributes (pharmacies type, region, size) and dynamic behavioral sequences (historical purchase frequency, price sensitivity curve, frequently purchased brand preferences, real-time shopping cart status, and available coupon pool). The product knowledge base includes a standard drug catalog (generic name, brand name, specifications, manufacturer), real-time inventory, price gradients, expiration date distribution, and gross profit margin tags. The merchant service database stores fulfillment rates, delivery time distribution, after-sales ratings, qualification certification status, sales control policies, and free shipping thresholds. The industry knowledge graph records drug substitution relationships, seasonal influenza medication guidelines, and GSP compliance rules.
[0080] The knowledge enhancement layer deploys a vector database to store drug knowledge graphs and industry rules in vector form and provides a retrieval interface. It recalls relevant context in real time before the large language model processes the data to suppress model illusions and ensure the accuracy of drug name, specification, and compliance judgments.
[0081] The model service layer includes three core models: the intent recognition model, which extracts predetermined attributes such as variety, specifications, and manufacturer from user dialogue based on the slot filling capability of the large language model; the psychological need inference model, which outputs probabilistic user psychological need tags based on user profiles and real-time context using a step-by-step reasoning approach; and the ranking and explanation generation model, which re-ranks the candidate drug set for specific psychological needs and generates natural language recommendation reasons.
[0082] The business logic layer includes a multi-turn dialogue state machine, a parameter mapping engine, and a 3D feature fusion module: The multi-turn dialogue state machine manages the dialogue context, determines the completeness of multiple predefined attributes in the user's purchasing needs, and generates follow-up questions or provides clickable filters when attributes are missing. It triggers search execution after all predefined attributes are complete; The parameter mapping engine converts the natural language slots output by the large language model into standard DSL query statements for the pharmaceutical search engine; The 3D feature fusion module constructs a 3D feature matrix of users, products, and merchants as the model input context.
[0083] The application interaction layer provides a streaming dialog interface, dynamic filter cards, and a results display area with tabs based on psychological needs. It is used to receive user input and present top recommended drugs and comparative recommendation reasons.
[0084] Based on the above architecture, the system specifically includes the following functional modules: The multi-turn dialogue management module is used to obtain the procurement requirements input by the user in the dialogue interaction, enhance the completeness of the generation of multiple predetermined attributes in the user's procurement requirements through retrieval, and generate query conditions when all predetermined attributes are complete. The search and recall module is used to retrieve a set of candidate drugs from the drug database based on query conditions. The psychological needs inference module is used to output at least one user psychological needs label by the psychological needs inference model using a step-by-step reasoning approach, based on the user's historical behavior data, dialogue history, and at least one environmental parameter. The filtering and recommendation module receives user psychological need tags, product features of candidate drugs, merchant features of candidate drugs, and user features obtained from user profiles. It constructs an independent inference agent for each user's psychological need, filters the candidate drug set, and outputs top recommended drugs and the reasons for the recommendation. These functional modules are deployed in the business logic layer (multi-turn dialogue state machine, parameter mapping engine), the model service layer (psychological need inference model, ranking and interpretation generation model), and the application interaction layer, respectively, together forming a complete drug recommendation system.
[0085] It should be noted that the functions of each module in the system of this embodiment can be found in the corresponding descriptions in the above methods, and will not be repeated here.
[0086] Example 3 This embodiment provides an electronic device. Figure 3 A structural block diagram of an electronic device according to an embodiment of the present invention is shown. Figure 3 As shown, the electronic device includes a memory 100 and a processor 200. The memory 100 stores a computer program that can run on the processor 200. When the processor 200 executes the computer program, it implements the drug recommendation method based on a large language model and user psychological inference in the above embodiments. The number of memories 100 and processors 200 can be one or more.
[0087] The electronic device also includes: The communication interface 300 is used to communicate with external devices and perform data exchange and transmission.
[0088] If the memory 100, processor 200, and communication interface 300 are implemented independently, they can be interconnected via a bus to communicate with each other. This bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. This bus can be divided into address bus, data bus, control bus, etc.
[0089] Optionally, in a specific implementation, if the memory 100, processor 200, and communication interface 300 are integrated on a single chip, then the memory 100, processor 200, and communication interface 300 can communicate with each other through an internal interface.
[0090] This invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method provided in this invention.
[0091] This invention also provides a chip, which includes a processor for calling and executing instructions stored in a memory, causing a communication device on which the chip is installed to perform the method provided in this invention.
[0092] This invention also provides a chip, including: an input interface, an output interface, a processor, and a memory. The input interface, output interface, processor, and memory are connected through an internal connection path. The processor is used to execute code in the memory. When the code is executed, the processor is used to execute the method provided in this invention.
[0093] It should be understood that the aforementioned processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. General-purpose processors can be microprocessors or any conventional processor. It is worth noting that the processor can be a processor supporting the Advanced Reduced Instruction Set Computing (RISC) machine (ARM) architecture.
[0094] Further, optionally, the aforementioned memory may include read-only memory and random access memory, and may also include non-volatile random access memory. The memory may be volatile or non-volatile, or may include both. Non-volatile memory may include read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may include random access memory (RAM), which serves as an external cache. Many forms of RAM are available by way of example, but not limitation. Examples include static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM).
[0095] In the above embodiments, implementation can be achieved, in whole or in part, by software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the present invention is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another.
[0096] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of those different embodiments or examples.
[0097] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0098] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various variations or substitutions within the technical scope disclosed in the present invention, and these should all be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A drug recommendation method based on a large language model and user psychological inference, characterized in that, include: Obtain the purchasing requirements input by the user in the dialogue interaction, and use a large language model to identify the completeness of multiple pre-defined attributes of the medicine in the current dialogue; If all predetermined attributes are complete, corresponding query conditions are generated based on the complete values of each predetermined attribute, and a set of candidate drugs is obtained by searching the drug database based on the query conditions. Based on the user's historical behavior data, dialogue history, and at least one environmental parameter, the psychological need inference model outputs at least one user psychological need label using a step-by-step inference approach. The user's psychological needs tags, the product characteristics of each candidate drug in the candidate drug set, the merchant characteristics of each candidate drug, and the user characteristics obtained based on the user profile are all input into the large language model. The large language model constructs an independent reasoning agent for each user's psychological needs, filters the candidate drug set, determines the top recommended drug, and generates the corresponding recommendation reason.
2. The drug recommendation method based on a large language model and user psychological inference as described in claim 1, characterized in that, The method of using a large language model to identify the completeness of multiple predetermined attributes of a drug in the current dialogue includes: Based on the procurement requirements, similar drug entries are retrieved from the drug standard catalog vector library through a search-enhanced generation method. Using a large language model, the completeness of multiple predetermined attributes of drugs in the current dialogue is identified based on the similar drug entries; wherein, the multiple predetermined attributes include variety attributes, specification attributes, and brand attributes used to uniquely identify the target drug; If information is missing in any of the predetermined attributes, a corresponding completion operation is performed; the completion operation includes generating corresponding follow-up questions or providing corresponding filter options for the user to complete.
3. The drug recommendation method based on a large language model and user psychological inference according to claim 1, characterized in that, The environmental parameters include user type, customer group characteristics, regional attributes, purchase volume, inventory level, seasonal epidemic data, and user qualifications; the step-by-step inference includes: Key behavioral signals are extracted from the historical behavioral data, the dialogue history, and the environmental parameters; the key behavioral signals originate from explicit intent flow, implicit behavior flow, and environmental constraint flow. Based on the key behavioral signals, at least one potential psychological hypothesis is proposed, and each potential psychological hypothesis is verified in combination with the user profile. Based on the verification results, the user's psychological need label and confidence level are output. The user profile includes the user's basic profile, medium- and long-term behavioral profile, and short-term behavioral profile.
4. The drug recommendation method based on a large language model and user psychological inference according to claim 3, characterized in that, The explicit intent stream includes the current search term, user input in the conversation history, and click stream sequence; the implicit behavior stream includes dwell time, number of comparisons, percentage of promotional products, search time period, and historical return reasons; the environmental constraint stream includes at least one of the environmental parameters.
5. The drug recommendation method based on a large language model and user psychological inference according to claim 1, characterized in that, It also includes a dynamic weight adaptation step: Based on the user's purchase or ignore behavior of the top recommended drugs, a reinforcement learning feedback loop is used to positively reward or negatively punish the psychological feature weights corresponding to the user's psychological need tags, and the retrieval enhancement examples in the prompt template used by the step-by-step reasoning method are adjusted in reverse.
6. The drug recommendation method based on a large language model and user psychological inference according to claim 1, characterized in that, The psychological need reasoning model uses a multi-granularity psychological graph to output the user's psychological need tags; the multi-granularity psychological graph includes a hierarchical graph of atomic psychology and composite psychology, wherein the atomic psychology includes greed for cheapness, speed, stability, and conformity, and the composite psychology is represented by a linear combination of the atomic psychology; the user's psychological need tags are coefficient vectors of composite psychology.
7. The drug recommendation method based on a large language model and user psychological inference according to claim 1, characterized in that, The user's psychological need tags, the product characteristics of each candidate drug in the candidate drug set, the merchant characteristics of each candidate drug, and the user characteristics obtained based on the user profile are jointly input into the large language model, including: For each user psychological need in the aforementioned user psychological need tags, an independent reasoning agent is constructed; A dynamic prompt template is constructed for each inference agent. The dynamic prompt template transforms the corresponding user psychological needs into binding instructions, and compresses the product characteristics, merchant characteristics, and user characteristics of each candidate drug in the candidate drug set into structured data and inputs them into the large language model.
8. The drug recommendation method based on a large language model and user psychological inference according to claim 1, characterized in that, The screening of the candidate drug set includes: The large language model performs Pareto dominance filtering on the inference agent corresponding to each user's psychological needs, generating a top drug sequence sorted after Pareto filtering. The first drug in the head drug sequence is identified as the head recommended drug, and the large language model generates a recommendation reason containing comparative arguments for the head recommended drug.
9. A drug recommendation system based on a large language model and user psychological inference, characterized in that, Performing the drug recommendation method based on a large language model and user psychological inference as described in any one of claims 1 to 8, comprising: The multi-turn dialogue management module is used to obtain the procurement requirements input by the user in the dialogue interaction, enhance the completeness of the generation of multiple predetermined attributes in the user's procurement requirements through retrieval, and generate query conditions when all predetermined attributes are complete. The search and recall module is used to retrieve a set of candidate drugs from the drug database based on the query conditions. The psychological needs inference module is used to output at least one user psychological needs label by the psychological needs inference model using a step-by-step reasoning approach, based on the user's historical behavior data, dialogue history, and at least one environmental parameter. The filtering and recommendation module is used to receive the user's psychological need tags, the product characteristics of the candidate drugs, the merchant characteristics of the candidate drugs, and the user characteristics obtained based on the user profile. It constructs an independent reasoning agent for each user's psychological need, filters the set of candidate drugs, and outputs the top recommended drugs and the reasons for the recommendation.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the drug recommendation method based on a large language model and user psychological inference as described in any one of claims 1 to 8.