Product intelligent recommendation method, system and equipment based on Dify platform and medium

By generating a product knowledge base and a question-and-answer knowledge base on the Dify platform, combined with semantic parsing and AI big models, the traditional recommendation system's problems of understanding complex requirements and cold start are solved, efficient and accurate product recommendations are achieved, and the user experience is improved.

CN120670546AActive Publication Date: 2025-09-19SHANDONG INSPUR ULTRA HD INTELLIGENT TECH CO LTD

Patent Information

Application Number
CN202510684705.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-26
Publication Date
2025-09-19
Estimated Expiration
2045-05-26

AI Technical Summary

Technical Problem

Traditional recommendation systems have difficulty understanding the complex needs expressed by users in natural language. The cold start problem leads to poor new product recommendation results. The knowledge-enhanced recommendation system is expensive to build and difficult to migrate across domains. The separation of knowledge retrieval and product recommendation leads to deviations between recommendation results and users' real needs.

Method used

Based on the Dify platform, by generating product knowledge base and question-and-answer knowledge base, combined with semantic parsing services, AI big models and multiple algorithms, we can achieve in-depth understanding of user problems and product recommendations.

Benefits of technology

It improves the accuracy and relevance of product recommendations, enhances user experience, reduces data maintenance costs, and ensures the accuracy and reliability of recommendation results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120670546A_ABST
    Figure CN120670546A_ABST
Patent Text Reader

Abstract

The invention provides an intelligent product recommendation method, system and device based on a Dify platform and a medium, and belongs to the technical field of artificial intelligence information recommendation, and the method comprises the steps: uploading structured product data and a question and answer text based on Dify, generating a product knowledge base according to the structured product data, and generating a question and answer knowledge base according to the question and answer text; receiving a question input by a user, and calling a Dify semantic analysis service to extract a structured query object; according to the extracted structured query object, performing retrieval matching on the question and answer knowledge base to obtain an optimal answer, and calling the AI large model to generate the optimal answer when retrieval matching fails; extracting a keyword from the optimal answer, and screening an optimal product from a product knowledge base by using the keyword; and returning the screened optimal product and the matched answer text to the user. Through combination of the product knowledge base, the question and answer knowledge base, the Dify semantic analysis service and the AI model, the product recommendation efficiency and accuracy are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of artificial intelligence information recommendation technology, and specifically relates to a product intelligent recommendation method, system, device and medium based on the Dify platform. Background Art

[0002] In today's digital landscape, users often struggle to quickly and accurately find products that meet their needs when faced with a vast amount of product information. Traditional recommendation systems primarily rely on collaborative filtering or content matching, but these approaches have the following limitations: First, they cannot understand the complex needs expressed in natural language; second, the cold start problem leads to poor new product recommendations. While pre-trained models like BERT improve semantic understanding capabilities, relying solely on large models presents challenges such as unpredictable results and a lack of specialized knowledge.

[0003] Existing solutions are polarized: rule-based systems are controllable but lack flexibility, requiring manual maintenance of a large number of dialogue rules; pure end-to-end model solutions carry the risk of illusions and struggle to guarantee the accuracy of product information. Knowledge-enhanced recommendation systems attempt to incorporate knowledge graphs, but these systems are expensive to build and difficult to migrate across domains. The emergence of AI development platforms such as Dify offers new solutions to these problems. First, the AI ​​development platform's visual knowledge base management reduces data maintenance costs; second, modular process design supports flexible combinations of retrieval and generation capabilities; and finally, a unified model interface enables optimal multi-model invocation. However, these implementations often separate knowledge retrieval from product recommendations, failing to fully leverage the synergy between the knowledge base and large models, resulting in recommendations that deviate from actual user needs. Summary of the Invention

[0004] In a first aspect, an embodiment of the present application provides a product intelligent recommendation method based on the Dify platform, comprising the following steps: S1. Upload structured product data and question-and-answer text based on Dify, generate a product knowledge base based on the structured product data, and generate a question-and-answer knowledge base based on the question-and-answer text; S2. Receive the user's input question and call Dify's semantic parsing service to extract the structured query object; S3. Search the Q&A knowledge base for the best answer based on the extracted structured query object, and call the AI ​​model to generate the best answer if the search fails. S4. Extract keywords from the best answers and use the keywords to filter the best products from the product knowledge base; S5. Return the best filtered product and the matching answer text to the user.

[0005] Furthermore, the specific steps of step S1 are as follows: S11. The Dify-based REST API accepts structured product data uploaded by users and saves it to the MongoDB document database as a product knowledge base; the structured product data includes product ID, name, specifications, user evaluation tags, and product attributes; S12. Based on the Dify REST API, the user-uploaded Q&A text and standard answers are accepted. The Sentence-BERT model is used to generate FAISS vectors of a specified dimension from the Q&A text. The Q&A text, standard answers, and FAISS vectors are used as the Q&A knowledge base. S13. Establish an Elasticsearch federated index for the product knowledge base, associating product structured data with vectorized representations. The fields of the Elasticsearch federated index include product keywords, category tags, and vector fields.

[0006] Furthermore, the specific steps of step S2 are as follows: S21. Issues with receiving user input in text form via the WebSocket interface; S22. Call Dify's semantic parsing service to extract a structured query object from the text-based question; the structured query object includes product recommendation intent and query entities; the query entities include product types and product features.

[0007] Furthermore, the specific steps of step S3 are as follows: S31. Use the BM25 algorithm of Elasticsearch to retrieve the question and answer text in the Q&A knowledge base using the query entity value as the query term, and receive the top-N candidate answers returned from the Q&A knowledge base. S32. Determine whether the highest score is higher than the score threshold; If so, the candidate answer is taken as the best answer and the process goes to step S4; If not, proceed to step S33; S33. Generate a query vector based on the textual question input by the user through the Contriever model in ONNX format; S34. Execute an approximate nearest neighbor search algorithm on the FAISS vector of the question-answering knowledge base according to the query vector to determine whether there is a FAISS vector with a similarity greater than a first similarity threshold; If so, the answer corresponding to the text vector whose similarity is greater than the similarity threshold is taken as the best answer, and the process goes to step S4; If not, proceed to step S35; S35. Generate prompt words based on the text-based questions input by the user, use the prompt words to call the AI ​​big model for analysis, and generate the best answer.

[0008] Furthermore, the specific steps of step S35 are as follows: S351. Pre-encapsulate the AI ​​large model service through Dify's RESTful interface; S352 pre-built structured prompt word template; the prompt word template includes product recommendation tasks, user input parameters, query restrictions; S353. Fill the user input text question into the user input parameter of the prompt word template to generate a prompt word, and generate a query request based on the prompt word and the AI ​​model name; S354. Send the query request to the Dify model gateway, call the AI ​​big model to perform question and answer analysis, and receive the answer returned by the AI ​​big model; S355. Extract the product name from the answer returned by the AI ​​model and determine whether the extracted product name is in the product knowledge base; If yes, go to step S4; If not, return to step S354.

[0009] Furthermore, the specific steps of step S4 are as follows: S41. Use the TF-IDF algorithm to extract keywords from the best answers as filtering criteria; S42. Filter products that meet all the filter conditions from the product knowledge base using a Boolean query in Elasticsearch as the first category of products. S43. Calculate the cosine similarity between the product attribute text and the best answer text for the remaining products in the product knowledge base, and extract products with a similarity greater than the second threshold as the second category of products; S44. The first and second category products are considered the best products; The specific steps of step S5 are as follows: S51. Pre-construct a recommendation result object, the recommendation result object includes the answer text parameter and the product entity; the product entity includes the product entity ID, matching score and recommendation reason; S52. Calculate the matching score between the selected best products and the answer text, obtain sales data for each best product, and use the AI ​​model to analyze the reasons for the recommendation; S53. Add the product entity ID, matching score, and recommendation reason of the best product to the recommendation result object to generate a recommendation result object entity; S54. Arrange the recommended result object entities of each best product in descending order according to the matching score from high to low, and check the matching score difference of adjacent best products. If the matching score difference is less than the score threshold, sort the adjacent best products in descending order according to sales data.

[0010] Furthermore, the specific steps of step S41 are as follows: S411. Segment the best answer text and generate a candidate word set after removing stop words; S412. Calculate the TF-IDF weight of each word in the candidate word set, and select words with TF-IDF weight greater than the weight threshold as keywords; S413. The filtered keywords are expanded through a pre-built synonym dictionary, and the keywords and the expanded synonyms are used as filtering conditions; In step S52, the semantic matching score between the product attribute and the best answer is calculated using the Elasticsearch score calculation script; The specific steps for calling the AI ​​big model to analyze the reasons for recommendations are as follows: Pre-build an input prompt word template, which includes a product ID, matching conditions, and usage scenarios; Fill the product ID and keywords of the best product into the input prompt word template, determine the usage scenario based on the text-form question entered by the user, and obtain the input prompt word; Generate a recommended query request by combining the input prompt word and the AI ​​model name; Send the recommendation query request to the Dify model gateway, call the AI ​​big model to perform question and answer analysis, and receive the recommendation reason returned by the AI ​​big model.

[0011] In a second aspect, the embodiments of the present application further provide a product intelligent recommendation system based on the Dify platform, comprising: The knowledge base construction module is used to upload structured product data and question-and-answer text based on Dify, generate a product knowledge base based on the structured product data, and generate a question-and-answer knowledge base based on the question-and-answer text; The question input module is used to receive questions input by users and call Dify's semantic parsing service to extract structured query objects; The answer retrieval module is used to search and match the best answer to the question-and-answer knowledge base based on the extracted structured query object, and to call the AI ​​big model to generate the best answer when the retrieval fails; Product retrieval module, which extracts keywords from the best answers and uses the keywords to filter the best products from the product knowledge base; The product recommendation result return module is used to return the best filtered products and matching answer text to the user.

[0012] In a third aspect, an embodiment of the present application further provides an electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the steps of the product intelligent recommendation method based on the Dify platform as described in the first aspect are implemented.

[0013] In a fourth aspect, an embodiment of the present application further provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the product intelligent recommendation method based on the Dify platform as described in the first aspect are implemented.

[0014] It can be seen from the above technical solutions that this application has the following advantages: The product intelligent recommendation method, system, device and medium based on the Dify platform provided in this application generate a knowledge base through structured product data and question and answer text to achieve efficient storage and indexing, improve data management efficiency and reduce costs; based on Dify's semantic parsing service and semantic analysis model, accurately understand user questions and improve question parsing accuracy; combine Elasticsearch's BM25 algorithm, approximate nearest neighbor search algorithm and AI large model to achieve flexible retrieval and generate the best answer, improving the quality and reliability of the answer; extract keywords through TF-IDF and cosine similarity algorithms to filter products, analyze the relationship between products and answers from multiple dimensions, ensure accurate recommendations and improve user satisfaction; by constructing detailed recommendation result objects, comprehensively matching scores, sales data and recommendation reasons to rank products, provide users with personalized recommendation results and improve user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solution of the present application, the following is a brief introduction to the drawings required for the description. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0016] Figure 1 Schematic diagram of the process of the intelligent product recommendation method based on the Dify platform of the present invention.

[0017] Figure 2 Schematic diagram of the product intelligent recommendation system based on the Dify platform of the present invention. DETAILED DESCRIPTION

[0018] The various embodiments of the present disclosure will be described in more detail below in the specific steps of the product intelligent recommendation method based on the Dify platform. The present disclosure can have various embodiments, and adjustments and changes can be made therein. However, it should be understood that there is no intention to limit the various embodiments of the present disclosure to the specific embodiments disclosed herein, but rather that the present disclosure should be understood to cover all adjustments, equivalents and / or alternatives that fall within the spirit and scope of the various embodiments of the present disclosure.

[0019] For example, in the current wave of digitalization, users face a vast amount of product information and struggle to quickly and accurately identify products that meet their needs. Traditional recommendation systems often rely on collaborative filtering or content matching, but these systems suffer from significant drawbacks: first, they struggle to grasp the complex needs expressed in natural language; second, the cold start problem makes new product recommendations ineffective. While pre-trained models like BERT enhance semantic understanding, relying solely on large models can lead to uncontrolled generation and a lack of specialized knowledge.

[0020] Current solutions present a polarized landscape: rule-based systems are controllable but lack flexibility, requiring manual maintenance of numerous dialogue rules; pure end-to-end model solutions carry the risk of hallucinations and struggle to ensure the accuracy of product information. Knowledge-enhanced recommendation systems attempt to incorporate knowledge graphs, but they are expensive to build and difficult to migrate across domains. The emergence of AI development platforms such as Dify offers new solutions to these problems: their visual knowledge base management reduces data maintenance costs; modular process design supports flexible combinations of retrieval and generation capabilities; and unified model interfaces enable optimal multi-model invocation. However, these implementations often separate knowledge retrieval from product recommendations, failing to fully leverage the synergy between the knowledge base and large models, resulting in recommendations that deviate from actual user needs.

[0021] To address the above issues, this embodiment provides a product intelligent recommendation method based on the Dify platform. By combining the AI ​​big model with the question-and-answer knowledge base and the product knowledge base, it can deeply understand user questions. It can not only accurately answer user questions, but also accurately recommend related products based on the answer content, thereby improving the accuracy and relevance of product recommendations and enhancing the user experience.

[0022] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0023] See also Figure 1 FIG. 1 is a flowchart of a method for intelligent product recommendation based on the Dify platform in a specific embodiment, the method comprising the following steps: S1. Upload structured product data and question-and-answer text based on Dify, generate a product knowledge base based on the structured product data, and generate a question-and-answer knowledge base based on the question-and-answer text; It should be noted that by integrating structured product data and question-answer text to generate a knowledge base, a data foundation is provided for product recommendations; S2. Receive the user's input question and call Dify's semantic parsing service to extract the structured query object; It should be noted that by receiving user questions and calling the semantic parsing service to extract structured query objects, we can deeply understand user needs and accurately grasp the recommendation direction, providing a basis for subsequent retrieval and recommendation, and improving the accuracy of product recommendations; S3. Search the Q&A knowledge base for the best answer based on the extracted structured query object, and call the AI ​​model to generate the best answer if the search fails. It should be noted that the best answer is matched by searching the question-answer knowledge base, and when it fails, the AI ​​big model is called to generate the answer to ensure accurate answers. The AI ​​big model enhances the ability to deal with complex questions and ensures the quality and reliability of the answers. S4. Extract keywords from the best answers and use the keywords to filter the best products from the product knowledge base; It should be noted that by extracting keywords from the best answers to filter the product knowledge base, accurate screening of the best products can be achieved; S5. Return the best product selected and the matching answer text to the user; It should be noted that specific recommendation results are provided to users by returning the best products and matching answer texts.

[0024] This embodiment achieves full-link automated processing from user questions to product recommendations through the processing flow of knowledge base construction, question parsing, answer retrieval, product screening, and result return, reducing manual intervention; by combining knowledge base retrieval with large model generation, it not only ensures rapid response to high-frequency questions, but also meets low-frequency needs, thereby expanding the scope of product recommendations.

[0025] Furthermore, as a refinement and extension of the specific implementation of the above embodiment, in order to fully illustrate the specific implementation process of this embodiment, another product intelligent recommendation method based on the Dify platform is provided, which includes the following steps: S1. Upload structured product data and question-and-answer text based on Dify, generate a product knowledge base based on the structured product data, and generate a question-and-answer knowledge base based on the question-and-answer text. The specific steps of step S1 are as follows: S11. The Dify-based REST API accepts structured product data uploaded by users and saves it to the MongoDB document database as a product knowledge base; the structured product data includes product ID, name, specifications, user evaluation tags, and product attributes; S12. Based on the Dify REST API, the user-uploaded Q&A text and standard answers are accepted. The Sentence-BERT model is used to generate FAISS vectors of a specified dimension from the Q&A text. The Q&A text, standard answers, and FAISS vectors are used as the Q&A knowledge base. For example, the Sentence-BERT model is used to generate a 768-dimensional FAISS vector from the question-answer text; S13. Create an Elasticsearch federated index for the product knowledge base, associating product structured data with vectorized representations. The fields in the Elasticsearch federated index include product keywords, category tags, and vector fields. Specifically, Elasticsearch is a Lucene-based search server that supports full-text search and distributed indexing. When building a joint index, product keywords, category tags, and vector fields can be combined for indexing for fast retrieval. It should be noted that MongoDB is used to store the product knowledge base, FAISS vectors are used to store the question-and-answer knowledge base, and Elasticsearch is used to establish a joint index. This improves the efficiency of knowledge base construction and retrieval speed, and enhances the reliability and ease of data management. S2. Receive the user's input question and call Dify's semantic parsing service to extract the structured query object. The specific steps of step S2 are as follows: S21. Issues with receiving user input in text form via the WebSocket interface; S22. Call Dify's semantic parsing service to extract a structured query object from the textual question; the structured query object includes product recommendation intent and query entities; the query entity includes product type and product features; For example, product recommendation, product, product type: soy sauce, product characteristics: enhance flavor; It should be noted that questions are received through WebSocket, and the semantic parsing service is called to extract structured query objects. User questions are received in real time, and key information is accurately extracted to provide a data basis for subsequent retrieval and recommendation. S3. Search and match the best answer to the question-and-answer knowledge base based on the extracted structured query object, and call the AI ​​model to generate the best answer if the search fails. The specific steps of step S3 are as follows: S31. Use the BM25 algorithm of Elasticsearch to retrieve the question and answer text in the Q&A knowledge base using the query entity value as the query term, and receive the top-N candidate answers returned from the Q&A knowledge base. It should be noted that BM25 is a ranking function for information retrieval, which is used to measure the relevance between documents and queries. The specific formula is as follows:

[0026] Where k1 and b are adjustment parameters, |d| is the length of document d, and avgdl is the average length of all documents; Exemplarily, receiving the top-N candidate answers returned from the question-answering knowledge base; S32. Determine whether the highest score is higher than the score threshold; If so, the candidate answer is taken as the best answer and the process goes to step S4; If not, proceed to step S33; Exemplarily, the score threshold may be set to 0.65; S33. Generate a query vector based on the textual question input by the user through the Contriever model in ONNX format; S34. Execute an approximate nearest neighbor search algorithm on the FAISS vectors of the question-answering knowledge base according to the query vector to determine whether there is a FAISS vector with a similarity greater than a first similarity threshold; illustratively, the first similarity threshold is 0.78; If so, the answer corresponding to the text vector whose similarity is greater than the similarity threshold is taken as the best answer, and the process goes to step S4; If not, proceed to step S35; Specifically, the Approximate Nearest Neighbor (ANN) algorithm is used to quickly find the nearest neighbor points in high-dimensional space. FAISS, short for Facebook AI Similarity Search, is an efficient ANN library that improves search speed while maintaining a certain level of accuracy by building index structures (such as inverted index and cluster index). S35. Generate prompt words based on the text form of the question entered by the user, use the prompt words to call the AI ​​large model for analysis, and generate the best answer; the specific steps of step S35 are as follows: S351. Pre-encapsulate the AI ​​large model service through Dify's RESTful interface; S352 pre-built structured prompt word template; the prompt word template includes product recommendation tasks, user input parameters, query restrictions; S353. Fill the user input text question into the user input parameter of the prompt word template to generate a prompt word, and generate a query request based on the prompt word and the AI ​​model name; For example, the prompt word may be: Generate professional questions and answers based on the following knowledge: Known product features: {context_products} User question: {query} Requirements: Limited to 200 words, including 3 product selling points; S354. Send the query request to the Dify model gateway, call the AI ​​big model to perform question and answer analysis, and receive the answer returned by the AI ​​big model; S355. Extract the product name from the answer returned by the AI ​​model and determine whether the extracted product name is in the product knowledge base; If yes, go to step S4; If not, return to step S354; It should be noted that by encapsulating the AI ​​large model service, building a prompt word template, calling the model to analyze and generate answers based on the prompt words, the accuracy and relevance of the generated answers are improved, and the recommendation ability to handle complex problems is enhanced; It should be noted that the BM25 algorithm and the approximate nearest neighbor search algorithm are used to call the AI ​​large model to generate answers, optimize the search process, improve the efficiency and accuracy of answer retrieval, and ensure that the results meet user needs; S4. Extract keywords from the best answers and use the keywords to filter the best products from the product knowledge base. The specific steps of step S4 are as follows: S41. Use the TF-IDF algorithm to extract keywords from the best answers as screening criteria. The specific steps of step S41 are as follows: S411. Segment the best answer text and generate a candidate word set after removing stop words; S412. Calculate the TF-IDF weight of each word in the candidate word set, and select words with TF-IDF weight greater than the weight threshold as keywords; S413. The filtered keywords are expanded through a pre-built synonym dictionary, and the keywords and the expanded synonyms are used as filtering conditions; It should be noted that TF-IDF in the TF-IDF algorithm is the abbreviation of term frequency-inverse document frequency. It is a text mining and information retrieval algorithm used to measure the importance of a word in a document; its formula is:

[0027] Among them, TF(t,d) represents the word frequency of word t in document d, and is calculated as follows:

[0028] IDF(t) represents the inverse document frequency of word t, which is calculated as: ; Exemplarily, words with an F-IDF weight greater than 0.2 are selected as keywords; S42. Filter products that meet all the filter conditions from the product knowledge base using a Boolean query in Elasticsearch as the first category of products. S43. Calculate the cosine similarity between the product attribute text and the best answer text for the remaining products in the product knowledge base, and extract products with a similarity greater than the second threshold as the second category of products; Specifically, cosine similarity is used to calculate the similarity between two vectors and is often used for text similarity calculation. Its formula is:

[0029] in, A⋅B is the dot product of vector A and vector B, ∥A∥ and ∥B∥ are the moduli of vector A and vector B respectively; The second similarity threshold may be 0.7; S44. The first and second category products are considered the best products; It should be noted that the TF-IDF algorithm is used to extract keywords to screen products, and the best products are selected through Boolean query and cosine similarity calculation to achieve precise matching at the semantic level, rather than simple keyword matching; S5. The best product selected and the matching answer text are returned to the user; the specific steps of step S5 are as follows: S51. Pre-construct a recommendation result object, the recommendation result object includes the answer text parameter and the product entity; the product entity includes the product entity ID, matching score and recommendation reason; S52. Calculate the matching score between the selected best products and the answer text, obtain sales data for each best product, and use the AI ​​model to analyze the reasons for the recommendation; In step S52, the semantic matching score between the product attribute and the best answer is calculated using the Elasticsearch score calculation script; The specific steps for calling the AI ​​big model to analyze the reasons for recommendations are as follows: Pre-build an input prompt word template, which includes a product ID, matching conditions, and usage scenarios; Fill the product ID and keywords of the best product into the input prompt word template, determine the usage scenario based on the text-form question entered by the user, and obtain the input prompt word; Generate a recommended query request by combining the input prompt word and the AI ​​model name; Send the recommendation query request to the Dify model gateway, call the AI ​​big model to perform question-and-answer analysis, and receive the recommendation reason returned by the AI ​​big model; S53. Add the product entity ID, matching score, and recommendation reason of the best product to the recommendation result object to generate a recommendation result object entity; S54. Sort the recommended result objects of each best product in descending order according to the matching score from high to low, and check the matching score difference of adjacent best products. If the matching score difference is less than the score threshold, sort the adjacent best products in descending order according to sales data; It should be noted that by constructing the recommendation result object, the comprehensive matching score and sales ranking are combined to enrich the recommendation results and improve user satisfaction.

[0030] For example, if a user enters the question "What soy sauce recommendations are suitable for home cooking?" on the Dify platform, the following steps are performed in sequence: Upload structured product data (such as soy sauce brand, specifications, brewing process, etc.) and question-and-answer text (such as "What are the culinary uses of soy sauce?" and its answers) to generate a product knowledge base and a question-and-answer knowledge base; Receive user questions and call Dify's semantic parsing service to extract structured query objects, such as "home cooking," "enhance flavor," and "soy sauce." First, the BM25 algorithm is used to search for matching answers in the question-answering knowledge base. If no matching answers are found, the AI ​​model is used to generate the answer, such as "Soy sauce suitable for home cooking should be rich in amino acids to enhance the flavor of dishes." Extract keywords (such as "amino acid" and "enhance flavor") from the answers, and use the TF-IDF algorithm and cosine similarity calculation to filter out the best products in the product knowledge base, such as "XXX soy sauce"; The filtered products and matching answer texts are returned to the user, such as "We recommend you use XXX soy sauce, which is brewed using traditional techniques, rich in amino acids, and can enhance the flavor of home cooking."

[0031] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0032] like Figure 2 As shown, the following is an embodiment of the product intelligent recommendation system based on the Dify platform provided by the embodiment of the present disclosure. This system and the product intelligent recommendation method based on the Dify platform in the above-mentioned embodiments belong to the same inventive concept. For details not fully described in the embodiment of the product intelligent recommendation system based on the Dify platform, please refer to the embodiment of the product intelligent recommendation method based on the Dify platform.

[0033] The system includes: The knowledge base construction module is used to upload structured product data and question-and-answer text based on Dify, generate a product knowledge base based on the structured product data, and generate a question-and-answer knowledge base based on the question-and-answer text; The question input module is used to receive questions input by users and call Dify's semantic parsing service to extract structured query objects; The answer retrieval module is used to search and match the best answer to the question-and-answer knowledge base based on the extracted structured query object, and to call the AI ​​big model to generate the best answer when the retrieval fails; Product retrieval module, which extracts keywords from the best answers and uses the keywords to filter the best products from the product knowledge base; The product recommendation result return module is used to return the best filtered products and matching answer text to the user.

[0034] This embodiment realizes the automation and intelligence of product recommendation through the interactive collaboration of the knowledge base construction module, question input module, answer retrieval module, product retrieval module and product recommendation result return module.

[0035] The product intelligent recommendation method based on the Dify platform provided in the embodiment of the present application can be applied to electronic devices. Those skilled in the art will understand that the electronic device structure involved in the embodiment of the present invention does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange components differently. In the embodiment of the present invention, the electronic device includes but is not limited to a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the embodiments of the present application described and / or required herein.

[0036] The electronic device may include a processor, an external memory interface, an internal memory, a universal serial bus (USB) interface, a charging management module, a power management module, a battery, a wireless communication module, an audio module, a speaker, a microphone, a sensor module, a button, a camera, a display, and a SIM card interface, etc.

[0037] It is understood that the structures illustrated in the embodiments of the present application do not constitute specific limitations on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer components than shown, or combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0038] A processor may include one or more processing units, such as a central processing unit (CPU), an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). Different processing units may be independent devices or integrated into one or more processors.

[0039] The processor can be the nerve center and command center of the electronic device. The controller can generate operation control signals based on the instruction opcode and timing signal to complete the control of instruction fetching and execution.

[0040] The processor may also include a memory for storing instructions and data. In some embodiments, the memory in the processor is a cache memory. This memory can store instructions or data that the processor has just used or is reusing. If the processor needs to use the instruction or data again, it can directly call it from the memory. This avoids repeated accesses, reduces processor latency, and thus improves system efficiency.

[0041] The above-mentioned electronic device implements the product intelligent recommendation method based on the Dify platform of the present application, which is based on uploading structured product data and question and answer text to Dify, generating a product knowledge base based on the structured product data, and generating a question and answer knowledge base based on the question and answer text; receiving questions input by users, calling Dify's semantic parsing service to extract structured query objects; performing retrieval and matching the best answer to the question and answer knowledge base based on the extracted structured query object, and calling the AI ​​large model to generate the best answer when the retrieval and matching fail; extracting keywords from the best answer, and using the keywords to screen the best products from the product knowledge base; returning the screened best products and the matching answer text to the user. The technical solution achieves the goal of generating a knowledge base through structured product data and question and answer text, improving storage and indexing efficiency, and reducing data management costs; accurately understanding user questions through Dify's semantic parsing service and algorithms and models, flexibly retrieving and generating the best answers, and improving the quality of answers; screening products through keyword extraction and multi-dimensional analysis to ensure recommendation accuracy and improve user satisfaction; constructing detailed recommendation result objects, providing personalized recommendation results, and optimizing the user experience.

[0042] The storage medium provided in this application stores a program product that can implement the product intelligent recommendation method based on the Dify platform.

[0043] The product intelligent recommendation method based on the Dify platform includes: uploading structured product data and question-and-answer text based on Dify, generating a product knowledge base based on the structured product data, and generating a question-and-answer knowledge base based on the question-and-answer text; receiving questions input by users, calling Dify's semantic parsing service to extract structured query objects; performing retrieval and matching the best answer in the question-and-answer knowledge base based on the extracted structured query objects, and calling the AI ​​big model to generate the best answer when the retrieval and matching fail; extracting keywords from the best answer, and using the keywords to filter the best products from the product knowledge base; returning the filtered best products and matching answer text to the user.

[0044] In some possible implementations, the product intelligent recommendation method based on the Dify platform disclosed herein can be implemented in the form of a program product, which includes program code. When the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps of various exemplary implementations of the present disclosure described in the above "Exemplary Method" section of this specification.

[0045] The storage medium of the present disclosure can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but not limited to, a system, device or component of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.

[0046] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not limited to the embodiments shown herein but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A product intelligent recommendation method based on the Dify platform, characterized in that: The steps include: S1. Upload structured product data and question-and-answer text based on Dify, generate a product knowledge base based on the structured product data, and generate a question-and-answer knowledge base based on the question-and-answer text; S2. Receive the user's input question and call Dify's semantic parsing service to extract the structured query object; S3. Search the Q&A knowledge base for the best answer based on the extracted structured query object, and call the AI ​​model to generate the best answer if the search fails. S4. Extract keywords from the best answers and use the keywords to filter the best products from the product knowledge base; S5. Return the best filtered product and the matching answer text to the user.

2. The product intelligent recommendation method based on the Dify platform according to claim 1 is characterized in that: The specific steps of step S1 are as follows: S11. The Dify-based REST API accepts structured product data uploaded by users and saves it to the MongoDB document database as a product knowledge base; the structured product data includes product ID, name, specifications, user evaluation tags, and product attributes; S12. Based on the Dify REST API, the user-uploaded Q&A text and standard answers are accepted. The Sentence-BERT model is used to generate FAISS vectors of a specified dimension from the Q&A text. The Q&A text, standard answers, and FAISS vectors are used as the Q&A knowledge base. S13. Establish an Elasticsearch federated index for the product knowledge base, associating product structured data with vectorized representations. The fields of the Elasticsearch federated index include product keywords, category tags, and vector fields.

3. The product intelligent recommendation method based on the Dify platform according to claim 2 is characterized in that: The specific steps of step S2 are as follows: S21. Issues with receiving user input in text form via the WebSocket interface; S22. Call Dify's semantic parsing service to extract a structured query object from the text-based question; the structured query object includes product recommendation intent and query entities; the query entities include product types and product features.

4. The product intelligent recommendation method based on the Dify platform according to claim 3 is characterized in that: The specific steps of step S3 are as follows: S31. Use the BM25 algorithm of Elasticsearch to retrieve the question and answer text in the Q&A knowledge base using the query entity value as the query term, and receive the top-N candidate answers returned from the Q&A knowledge base. S32. Determine whether the highest score is higher than the score threshold; If so, the candidate answer is taken as the best answer and the process goes to step S4; If not, proceed to step S33; S33. Generate a query vector based on the textual question input by the user through the Contriever model in ONNX format; S34. Execute an approximate nearest neighbor search algorithm on the FAISS vector of the question-answering knowledge base according to the query vector to determine whether there is a FAISS vector with a similarity greater than a first similarity threshold; If so, the answer corresponding to the text vector whose similarity is greater than the similarity threshold is taken as the best answer, and the process goes to step S4; If not, proceed to step S35; S35. Generate prompt words based on the text-based questions input by the user, use the prompt words to call the AI ​​big model for analysis, and generate the best answer.

5. The product intelligent recommendation method based on the Dify platform according to claim 4 is characterized in that: The specific steps of step S35 are as follows: S351. Pre-encapsulate the AI ​​large model service through Dify's RESTful interface; S352 pre-built structured prompt word template; the prompt word template includes product recommendation tasks, user input parameters, query restrictions; S353. Fill the user input text question into the user input parameter of the prompt word template to generate a prompt word, and generate a query request based on the prompt word and the AI ​​model name; S354. Send the query request to the Dify model gateway, call the AI ​​big model to perform question and answer analysis, and receive the answer returned by the AI ​​big model; S355. Extract the product name from the answer returned by the AI ​​model and determine whether the extracted product name is in the product knowledge base; If yes, go to step S4; If not, return to step S354.

6. The product intelligent recommendation method based on the Dify platform according to claim 4 is characterized in that: The specific steps of step S4 are as follows: S41. Use the TF-IDF algorithm to extract keywords from the best answers as filtering criteria; S42. Filter products that meet all the filter conditions from the product knowledge base using a Boolean query in Elasticsearch as the first category of products. S43. Calculate the cosine similarity between the product attribute text and the best answer text for the remaining products in the product knowledge base, and extract products with a similarity greater than the second threshold as the second category of products; S44. The first and second category products are considered the best products; The specific steps of step S5 are as follows: S51. Pre-construct a recommendation result object, the recommendation result object includes the answer text parameter and the product entity; the product entity includes the product entity ID, matching score and recommendation reason; S52. Calculate the matching score between the selected best products and the answer text, obtain sales data for each best product, and use the AI ​​model to analyze the reasons for the recommendation; S53. Add the product entity ID, matching score, and recommendation reason of the best product to the recommendation result object to generate a recommendation result object entity; S54. Arrange the recommended result object entities of each best product in descending order according to the matching score from high to low, and check the matching score difference of adjacent best products. If the matching score difference is less than the score threshold, sort the adjacent best products in descending order according to sales data.

7. The product intelligent recommendation method based on the Dify platform according to claim 6, characterized in that: The specific steps of step S41 are as follows: S411. Segment the best answer text and generate a candidate word set after removing stop words; S412. Calculate the TF-IDF weight of each word in the candidate word set, and select words with TF-IDF weight greater than the weight threshold as keywords; S413. The filtered keywords are expanded through a pre-built synonym dictionary, and the keywords and the expanded synonyms are used as filtering conditions; In step S52, the semantic matching score between the product attribute and the best answer is calculated using the Elasticsearch score calculation script; The specific steps for calling the AI ​​big model to analyze the reasons for recommendations are as follows: Pre-build an input prompt word template, which includes a product ID, matching conditions, and usage scenarios; Fill the product ID and keywords of the best product into the input prompt word template, determine the usage scenario based on the text-form question entered by the user, and obtain the input prompt word; Generate a recommended query request by combining the input prompt word and the AI ​​model name; Send the recommendation query request to the Dify model gateway, call the AI ​​big model to perform question and answer analysis, and receive the recommendation reason returned by the AI ​​big model.

8. A product intelligent recommendation system based on the Dify platform, characterized in that: include: The knowledge base construction module is used to upload structured product data and question-and-answer text based on Dify, generate a product knowledge base based on the structured product data, and generate a question-and-answer knowledge base based on the question-and-answer text; The question input module is used to receive questions input by users and call Dify's semantic parsing service to extract structured query objects; The answer retrieval module is used to search and match the best answer to the question-and-answer knowledge base based on the extracted structured query object, and to call the AI ​​big model to generate the best answer when the retrieval fails; Product retrieval module, which extracts keywords from the best answers and uses the keywords to filter the best products from the product knowledge base; The product recommendation result return module is used to return the best filtered products and matching answer text to the user.

9. An electronic device, characterized in that: The invention comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the product intelligent recommendation method based on the Dify platform as claimed in any one of claims 1 to 7 are implemented.

10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the product intelligent recommendation method based on the Dify platform as claimed in any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Intelligent question answering method and system based on four-layer feature vector matching model

    CN115964466A

  • Method for improving response speed of large-scale language model based on similarity retrieval

    CN116910221A

  • Conversation method and device, storage medium, terminal and computer program product

    CN118132731A

  • Large language model commodity recommendation method based on slice tag retrieval and electronic equipment

    CN118365409A

  • Intelligent retail recommendation system based on big language model and shopping basket analysis

    CN119166900A

Cited By

  • Intelligent real estate management system development method based on large model

    CN121903802A

  • A large model-based intelligent real estate management system development method

    CN121903802B