A product intelligent recommendation method, system, device and medium based on a Dify platform
By generating product knowledge bases and question-and-answer knowledge bases on the Dify platform, and combining semantic parsing and AI large models, the traditional recommendation system's problems of understanding complex needs and cold start were solved, achieving efficient and accurate product recommendations and improving user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANDONG INSPUR ULTRA HD INTELLIGENT TECH CO LTD
- Filing Date
- 2025-05-26
- Publication Date
- 2026-08-04
AI Technical Summary
Traditional recommendation systems struggle to understand the complex needs expressed in users' natural language, suffer from the cold start problem, and have high construction costs and difficulties in cross-domain transfer, resulting in a discrepancy between recommendation results and users' actual needs.
Based on the Dify platform, product knowledge bases and question-and-answer knowledge bases are generated, and semantic parsing services, large AI models, and various algorithms are combined to achieve in-depth understanding of user questions and product recommendations.
It improves the accuracy and relevance of product recommendations, enhances user experience, reduces data maintenance costs, and ensures the reliability and personalization of recommendation results.
Smart Images

Figure CN120670546B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of artificial intelligence information recommendation technology, specifically relating to a product intelligent recommendation method, system, device and medium based on the Dify platform. Background Technology
[0002] In today's digital environment, users often struggle to quickly and accurately find products that meet their needs when faced with massive amounts of product information. Traditional recommendation systems primarily rely on collaborative filtering or content matching, but these methods have the following limitations: first, they cannot understand the complex needs expressed in users' natural language; second, the cold start problem leads to poor new product recommendations. Although pre-trained models such as BERT have improved semantic understanding capabilities, simply relying on large models results in uncontrollable generation outcomes and a lack of professional knowledge.
[0003] Existing solutions are polarized: rule-based systems, while controllable, lack flexibility and require manual maintenance of numerous dialogue rules; pure end-to-end model solutions are prone to illusions and struggle to guarantee the accuracy of product information. Knowledge-enhanced recommendation systems attempt to combine knowledge graphs, but their construction costs are high and cross-domain migration is difficult. The emergence of AI development platforms like Dify offers new solutions to these problems. First, the visual knowledge base management of AI development platforms 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 recommendation, failing to fully leverage the synergistic effect of the knowledge base and large models, resulting in deviations between recommendation results and users' actual needs. Summary of the Invention
[0004] In a first aspect, embodiments of this application provide a product intelligent recommendation method based on the Dify platform, comprising the following steps: S1. Based on Dify, upload structured product data and Q&A text, generate a product knowledge base based on the structured product data, and generate a Q&A knowledge base based on the Q&A text; S2. Receive the user's input question and call Dify's semantic parsing service to extract the structured query object; S3. Based on the extracted structured query object, perform a search on the question-and-answer knowledge base to find the best answer, and if the search fails to find the best answer, call the AI big model to generate the best answer; S4. Extract keywords from the best answer and use the keywords to filter the best products from the product knowledge base; S5. Return the selected best products and matching answer text to the user.
[0005] Furthermore, the specific steps of step S1 are as follows: S11. The Dify-based REST API interface accepts structured product data uploaded by users and saves it to a 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 Dify's REST API interface, it accepts user-uploaded question and answer text and standard answers, uses the Sentence-BERT model to generate FAISS vectors of a set dimension from the question and answer text, and uses the question and answer text, standard answers and FAISS vectors as a question and answer knowledge base; S13. Create an Elasticsearch composite index for the product knowledge base, linking the product's structured data with its vectorized representation; the Elasticsearch composite index fields include product keywords, category tags, and vector fields.
[0006] Furthermore, the specific steps of step S2 are as follows: S21. Problem of receiving raw text input from the user 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 entity; the query entity includes product type and product characteristics.
[0007] Furthermore, the specific steps of step S3 are as follows: S31. Use Elasticsearch's BM25 algorithm to retrieve question and answer text from the question and answer knowledge base using the value of the query entity as the query term, and receive the top-N candidate answers with the highest scores returned from the question and answer knowledge base; S32. Determine whether the highest score is higher than the score threshold; If so, select the candidate answer as the best answer and proceed to step S4; If not, proceed to step S33; S33. Generate a query vector from the user-input text-based question using the ONNX format Contriever model; S34. Based on the query vector, perform an approximate nearest neighbor search algorithm on the FAISS vectors in the question-answering knowledge base to determine whether there are FAISS vectors with a similarity greater than the first similarity threshold; If so, the answer corresponding to the text vector with a similarity greater than the similarity threshold is taken as the best answer, and proceed to step S4; If not, proceed to step S35; S35. Generate prompts based on the text-based question input by the user, use the prompts to call the AI model for analysis, and generate the best answer.
[0008] Furthermore, the specific steps of step S35 are as follows: S351. Pre-encapsulate the large AI model service using Dify's RESTful interface; S352. Pre-construct a structured prompt word template; the prompt word template includes product recommendation tasks, user input parameters, and query restrictions; S353. Fill the user-inputted text-based question into the user input parameters of the prompt word template, generate prompt words, and generate a query request based on the prompt words and the name of the AI large model; 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 names involved from the answers returned by the AI large model, and determine whether the extracted product names are in the product knowledge base; If so, proceed 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 answer as filtering criteria; S42. Use Elasticsearch's Boolean query to filter products from the product knowledge base that meet all the filtering criteria, and designate them 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 the products with a similarity greater than the second threshold as the second type of products; S44. The first and second categories of products are considered the best products; The specific steps of step S5 are as follows: S51. Pre-construct a recommendation result object, which includes answer text parameters and product entities; the product entity includes product entity ID, matching score, and recommendation reason; S52. Calculate the matching score between the selected best products and the answer text, obtain the sales data of each best product, and call the AI big 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 the recommendation result object entity; S54. Sort the recommended results of each best product in descending order of matching score, and check the matching score difference between 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. Perform word segmentation on the best answer text, remove stop words, and generate a candidate word set; S412. Calculate the TF-IDF weight of each word in the candidate word set, and select words with TF-IDF weights greater than the weight threshold as keywords; S413. Expand the selected keywords using a pre-built thesaurus, and use the keywords and the expanded synonyms as the filtering criteria; In step S52, the semantic matching score between the product attributes and the best answer is calculated using an Elasticsearch score calculation script; The specific steps for using a large AI model to analyze the reasons for recommendations are as follows: Pre-build an input prompt word template, which includes product ID, matching conditions, and usage scenarios; Fill the product ID and keywords of the best product into the input prompt template, determine the usage scenario based on the text format of the user input, and obtain the input prompt; The input prompts and the names of the large AI models will generate a recommended query request. Send the recommendation query request to the Dify model gateway, invoke the AI big model to perform question-and-answer analysis, and receive the recommendation reasons returned by the AI big model.
[0011] Secondly, embodiments of this application also provide a product intelligent recommendation system based on the Dify platform, including: The knowledge base building module is used to upload structured product data and question-and-answer text to 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 the question-and-answer knowledge base for the best answer based on the extracted structured query object, and to call the AI big model to generate the best answer when the retrieval fails. The product search module is used to extract keywords from the best answers and use those keywords to filter the best products from the product knowledge base. The product recommendation results return module is used to return the best filtered products and matching answer text to the user.
[0012] Thirdly, embodiments of this application also provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the product intelligent recommendation method based on the Dify platform as described in the first aspect.
[0013] Fourthly, embodiments of this application also provide a storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the product intelligent recommendation method based on the Dify platform as described in the first aspect.
[0014] As can be seen from the above technical solutions, this application has the following advantages: The product intelligent recommendation method, system, device, and medium provided in this application, based on the Dify platform, achieve efficient storage and indexing by generating a knowledge base from structured product data and question-and-answer text, thereby improving data management efficiency and reducing costs. Based on Dify's semantic parsing service and semantic analysis model, it accurately understands user questions and improves question parsing accuracy. Combining Elasticsearch's BM25 algorithm, near nearest neighbor search algorithm, and large AI model, it enables flexible retrieval and generation of optimal answers, improving answer quality and reliability. It extracts keywords to filter products using TF-IDF and cosine similarity algorithms, analyzing the association between products and answers from multiple dimensions to ensure accurate recommendations and improve user satisfaction. By constructing detailed recommendation result objects and comprehensively ranking products based on matching scores, sales data, and recommendation reasons, it provides users with personalized recommendation results, enhancing user experience. Attached Figure Description
[0015] To more clearly illustrate the technical solution of this application, the accompanying drawings used in the description will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 This is a flowchart illustrating the intelligent product recommendation method based on the Dify platform of the present invention.
[0017] Figure 2 This is a schematic diagram of the intelligent product recommendation system based on the Dify platform of the present invention. Detailed Implementation
[0018] The various embodiments of this disclosure will be described more fully in the following detailed description of the specific steps of the product intelligent recommendation method based on the Dify platform. This disclosure may have various embodiments, and adjustments and changes may be made therein. However, it should be understood that there is no intention to limit the various embodiments of this disclosure to the specific embodiments disclosed herein, but rather this disclosure should be understood to cover all adjustments, equivalents, and / or alternatives falling within the spirit and scope of the various embodiments of this disclosure.
[0019] For example, in today's digital age, users face a massive amount of product information and find it difficult to quickly and accurately locate products that meet their needs. Traditional recommendation systems often rely on collaborative filtering or content matching, but these have significant drawbacks: first, they struggle to grasp the complex needs expressed in users' natural language; second, the cold start problem leads to poor new product recommendations. Although pre-trained models like BERT enhance semantic understanding, relying solely on large models can easily result in uncontrolled generation of results and a lack of specialized knowledge.
[0020] Current solutions present a polarized situation: rule-based systems, while controllable, lack flexibility and require manual maintenance of numerous dialogue rules; pure end-to-end model solutions suffer from the risk of illusion and struggle to ensure the accuracy of product information. While knowledge-enhanced recommendation systems attempt to incorporate knowledge graphs, their construction costs are high and cross-domain transfer is difficult. The emergence of AI development platforms like Dify offers new solutions: their visual knowledge base management reduces data maintenance costs; modular process design supports flexible combinations of retrieval and generation capabilities; and a unified model interface allows for the optimal use of multiple models. However, these implementations often separate knowledge retrieval from product recommendation, failing to fully leverage the synergistic effect of knowledge bases and large models, resulting in recommendations that deviate from users' actual needs.
[0021] To address the aforementioned issues, this embodiment provides a product intelligent recommendation method based on the Dify platform. By combining a large AI model with a question-and-answer knowledge base and a product knowledge base, it can deeply understand user questions. This not only allows for accurate answers to user questions but also enables accurate product recommendations based on the answers, improving the accuracy and relevance of product recommendations and enhancing the user experience.
[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0023] Please see Figure 1 The diagram shows a flowchart of a product intelligent recommendation method based on the Dify platform in a specific embodiment. The method includes the following steps: S1. Based on Dify, upload structured product data and Q&A text, generate a product knowledge base based on the structured product data, and generate a Q&A knowledge base based on the Q&A text; It should be noted that by integrating structured product data with question-and-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 gain a deeper understanding of user needs, accurately grasp the direction of recommendations, provide a basis for subsequent retrieval and recommendations, and improve the accuracy of product recommendations. S3. Based on the extracted structured query object, perform a search on the question-and-answer knowledge base to find the best answer, and if the search fails to find the best answer, call the AI big model to generate the best answer; It should be noted that the best answer is matched by searching the question-and-answer knowledge base, and if that fails, the AI model is called to generate an answer to ensure that an accurate answer is obtained; the AI model enhances the ability to deal with complex problems, ensuring the quality and reliability of the answer. S4. Extract keywords from the best answer 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, the best products can be accurately selected. S5. Return the selected best products and matching answer texts to the user; It should be noted that specific recommendation results are provided to users by returning the best product and matching the response text.
[0024] This embodiment achieves fully automated processing from user inquiry to product recommendation through a process 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 ensures rapid response to high-frequency questions while also addressing low-frequency needs, thus expanding the scope of product recommendations.
[0025] Furthermore, as a refinement and extension of the specific implementation methods of the above embodiments, 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. Based on the structured product data and Q&A text uploaded to Dify, generate a product knowledge base based on the structured product data, and generate a Q&A knowledge base based on the Q&A text; the specific steps of step S1 are as follows: S11. The Dify-based REST API interface accepts structured product data uploaded by users and saves it to a 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 Dify's REST API interface, it accepts user-uploaded question and answer text and standard answers, uses the Sentence-BERT model to generate FAISS vectors of a set dimension from the question and answer text, and uses the question and answer text, standard answers and FAISS vectors as a question and answer knowledge base; For example, the Sentence-BERT model is used to generate a 768-dimensional FAISS vector from the question-and-answer text; S13. Create an Elasticsearch composite index for the product knowledge base, linking the structured product data with its vectorized representation; the fields of the Elasticsearch composite index include product keywords, category tags, and vector fields; Specifically, Elasticsearch is a search server based on Lucene that supports full-text search and distributed indexing. When building a composite index, product keywords, category tags, and vector fields can be combined for indexing to enable fast retrieval. It should be noted that MongoDB is used to store the product knowledge base, FAISS vector storage is used to store the question-and-answer knowledge base, and Elasticsearch is used to build a composite index to improve the efficiency of knowledge base construction and retrieval speed, and enhance 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. Problem of receiving raw text input from the user via the WebSocket interface; S22. Invoke 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 entity; the query entity includes product type and product characteristics; For example, product recommendation, product type: soy sauce, product characteristic: enhances umami; It should be noted that by receiving questions via WebSocket and calling the semantic parsing service to extract structured query objects, user questions are received in real time, key information is accurately extracted, and a data foundation is provided for subsequent retrieval and recommendation. S3. Based on the extracted structured query object, perform a search on the question-and-answer knowledge base to find the best answer, and if the search fails to find a match, call the AI large model to generate the best answer; the specific steps of step S3 are as follows: S31. Use Elasticsearch's BM25 algorithm to retrieve question and answer text from the question and answer knowledge base using the value of the query entity as the query term, and receive the top-N candidate answers with the highest scores returned from the question and answer knowledge base; It should be noted that BM25 is a ranking function for information retrieval, used to measure the relevance of a document to a query. 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; For example, receive the top-N candidate answers with the highest scores returned from the question-answering knowledge base; S32. Determine whether the highest score is higher than the score threshold; If so, select the candidate answer as the best answer and proceed to step S4; If not, proceed to step S33; For example, the scoring threshold can be set to 0.65; S33. Generate a query vector from the user-input text-based question using the ONNX format Contriever model; S34. Based on the query vector, perform an approximate nearest neighbor search algorithm on the FAISS vectors in the question-answering knowledge base to determine whether there are FAISS vectors with a similarity greater than a first similarity threshold; for example, the first similarity threshold is 0.78. If so, the answer corresponding to the text vector with a similarity greater than the similarity threshold is taken as the best answer, and proceed to step S4; If not, proceed to step S35; Specifically, the Approximate Nearest Neighbor (ANN) algorithm is used to quickly find the nearest neighbor in a 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 indexes and clustering indexes). S35. Generate prompts based on the user-input text question, use the prompts to call the AI model for analysis, and generate the best answer; the specific steps of step S35 are as follows: S351. Pre-encapsulate the large AI model service using Dify's RESTful interface; S352. Pre-construct a structured prompt word template; the prompt word template includes product recommendation tasks, user input parameters, and query restrictions; S353. Fill the user-inputted text-based question into the user input parameters of the prompt word template, generate prompt words, and generate a query request based on the prompt words and the name of the AI large model; For example, the prompt word could be: Professional Q&A is generated based on the following knowledge: Known product characteristics: {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 names involved from the answers returned by the AI large model, and determine whether the extracted product names are in the product knowledge base; If so, proceed to step S4; If not, return to step S354; It should be noted that by encapsulating large AI model services and constructing prompt word templates, the model is called to analyze and generate answers based on the prompt words, thereby improving the accuracy and relevance of the generated answers and enhancing the recommendation's ability to handle complex questions. It should be noted that by using the BM25 algorithm and the approximate nearest neighbor search algorithm, the AI large model is called to generate answers, optimize the retrieval process, improve the efficiency and accuracy of answer retrieval, and ensure that the results meet the user's needs. S4. Extract keywords from the best answer and use these keywords to filter the best product from the product knowledge base; the specific steps for step S4 are as follows: S41. Use the TF-IDF algorithm to extract keywords from the best answer as filtering criteria; the specific steps of S41 are as follows: S411. Perform word segmentation on the best answer text, remove stop words, and generate a candidate word set; S412. Calculate the TF-IDF weight of each word in the candidate word set, and select words with TF-IDF weights greater than the weight threshold as keywords; S413. Expand the selected keywords using a pre-built thesaurus, and use the keywords and the expanded synonyms as the filtering criteria; It should be noted that TF-IDF stands for Term Frequency-Inverse Document Frequency, a text mining and information retrieval algorithm used to measure the importance of a word in a document; its formula is:
[0027] Where TF(t,d) represents the term frequency of word t in document d, and is calculated as follows:
[0028] IDF(t) represents the inverse document frequency of word t, calculated as follows: ; For example, words with an F-IDF weight greater than 0.2 are selected as keywords; S42. Use Elasticsearch's Boolean query to filter products from the product knowledge base that meet all the filtering criteria, and designate them 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 the products with a similarity greater than the second threshold as the second type of products; Specifically, cosine similarity is used to calculate the similarity between two vectors, and is commonly used for text similarity calculation. Its formula is:
[0029] in, A⋅B It is the dot product of vectors A and B, and ∥A∥ and ∥B∥ are the magnitudes of vectors A and B, respectively. The second similarity threshold can be 0.7; S44. The first and second categories of products are considered the best products; It should be noted that the TF-IDF algorithm is used to extract keywords to filter products, and the best products are selected through Boolean queries and cosine similarity calculations to achieve accurate semantic matching, rather than simple keyword matching. S5. Return the selected best products and matching response texts to the user; the specific steps of step S5 are as follows: S51. Pre-construct a recommendation result object, which includes answer text parameters and product entities; the product entity includes product entity ID, matching score, and recommendation reason; S52. Calculate the matching score between the selected best products and the answer text, obtain the sales data of each best product, and call the AI big model to analyze the reasons for the recommendation; In step S52, the semantic matching score between the product attributes and the best answer is calculated using an Elasticsearch score calculation script; The specific steps for using a large AI model to analyze the reasons for recommendations are as follows: Pre-build an input prompt word template, which includes product ID, matching conditions, and usage scenarios; Fill the product ID and keywords of the best product into the input prompt template, determine the usage scenario based on the text format of the user input, and obtain the input prompt; The input prompts and the names of the large AI models will generate a recommended query request. 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 reasons 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 the recommendation result object entity; S54. Sort the recommended results of each best product in descending order of matching score, and check the matching score difference between 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 the recommendation result object is constructed by combining the matching score and sales ranking to enrich the recommendation results and improve user satisfaction.
[0030] Assuming a user enters the question "What are some good soy sauce recommendations for enhancing flavor in home cooking?" on the Dify platform, the following steps would be performed: Upload structured product data (such as the brand, specifications, and brewing process of soy sauce) and question-and-answer text (such as "What are the cooking 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", "flavor enhancement", and "soy sauce"; First, the BM25 algorithm is used to search for matching answers in the question-and-answer knowledge base; if no matching answer is found, the AI large model is called to generate an answer, such as "Soy sauce suitable for home cooking to enhance flavor should be rich in amino acids, which can enhance the umami flavor of dishes"; Extract keywords (such as "amino acids" and "flavor enhancer") from the answers, and use the TF-IDF algorithm and cosine similarity calculation to select the best product from the product knowledge base, such as "XXX soy sauce"; The selected products and matching response text are returned to the user, such as "We recommend XXX soy sauce, which is brewed using traditional methods, is rich in amino acids, and can enhance the flavor of home cooking."
[0031] It should be understood that the sequence number of each step in the above embodiments does not imply 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 are embodiments of the intelligent product recommendation system based on the Dify platform provided in this disclosure. This system and the intelligent product recommendation method based on the Dify platform in the above embodiments belong to the same inventive concept. For details not described in detail in the embodiments of the intelligent product recommendation system based on the Dify platform, please refer to the embodiments of the intelligent product recommendation method based on the Dify platform described above.
[0033] The system includes: The knowledge base building module is used to upload structured product data and question-and-answer text to 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 the question-and-answer knowledge base for the best answer based on the extracted structured query object, and to call the AI big model to generate the best answer when the retrieval fails. The product search module is used to extract keywords from the best answers and use those keywords to filter the best products from the product knowledge base. The product recommendation results return module is used to return the best filtered products and matching answer text to the user.
[0034] This embodiment achieves automated and intelligent 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 this application embodiment can be applied to electronic devices. Those skilled in the art will understand that the electronic device structure involved in the embodiments of this invention does not constitute a limitation on the electronic device. An electronic device may include more or fewer components than illustrated, or combine certain components, or have different component arrangements. In the embodiments of this invention, the electronic device includes, but is not limited to, laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, 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 this application described and / or claimed herein.
[0036] Electronic devices may include processors, external memory interfaces, internal memory, universal serial bus (USB) interfaces, charging management modules, power management modules, batteries, wireless communication modules, audio modules, speakers, microphones, sensor modules, buttons, cameras, displays, and SIM card interfaces, etc.
[0037] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device. In other embodiments of this application, the electronic device may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. 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, 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 serve as the nerve center and command center of an electronic device. The controller can generate operation control signals based on the instruction opcode and timing signals to control the fetching and execution of instructions.
[0040] The processor may also include 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 that are used repeatedly. If the processor needs to use the instruction or data again, it can retrieve it directly from this memory. This avoids repeated accesses, reduces processor latency, and thus improves system efficiency.
[0041] The aforementioned electronic device implements the product intelligent recommendation method based on the Dify platform proposed in this application. This method involves uploading structured product data and question-and-answer text to the Dify platform, 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. It receives user-input questions, calls Dify's semantic parsing service to extract structured query objects, performs a search on the question-and-answer knowledge base based on the extracted structured query objects to match the best answer, and calls an AI model to generate the best answer when the search fails. It extracts keywords from the best answer and uses these keywords to filter the best products from the product knowledge base. Finally, it returns the filtered best products and matching answer text to the user. This technical solution achieves the following benefits: generating a knowledge base from structured product data and question-and-answer text improves storage and indexing efficiency and reduces data management costs; accurately understanding user questions and flexibly retrieving and generating the best answers through Dify's semantic parsing service, algorithms, and models improves answer quality; filtering products through keyword extraction and multi-dimensional analysis ensures recommendation accuracy and improves user satisfaction; and constructing detailed recommendation result objects provides personalized recommendation results, thus optimizing the user experience.
[0042] The storage medium provided in this application stores a program product capable of implementing a product intelligent recommendation method based on the Dify platform.
[0043] The intelligent product recommendation method based on the Dify platform includes: uploading structured product data and question-and-answer text to Dify; generating a product knowledge base based on the structured product data and a question-and-answer knowledge base based on the question-and-answer text; receiving user-input questions and calling Dify's semantic parsing service to extract structured query objects; performing a search on the question-and-answer knowledge base based on the extracted structured query objects to match the best answer, and calling an AI big model to generate the best answer when the search fails; extracting keywords from the best answer and using the keywords to filter the best products from the product knowledge base; and 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 as a program product, which includes program code that, when the program product is run on a terminal device, causes the terminal device to perform the steps described in the "Exemplary Methods" section above according to various exemplary embodiments of this disclosure.
[0045] The storage medium disclosed herein may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof.
[0046] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those 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 invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded 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, Includes the following steps: S1. Based on the structured product data and Q&A text uploaded to Dify, generate a product knowledge base based on the structured product data, and generate a Q&A knowledge base based on the Q&A text; the specific steps of step S1 are as follows: S11. The Dify-based REST API interface accepts structured product data uploaded by users and saves it to a 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 Dify's REST API interface, it accepts user-uploaded question and answer text and standard answers, uses the Sentence-BERT model to generate FAISS vectors of a set dimension from the question and answer text, and uses the question and answer text, standard answers and FAISS vectors as a question and answer knowledge base; S13. Create an Elasticsearch composite index for the product knowledge base, linking the structured product data with its vectorized representation; the fields of the Elasticsearch composite index include product keywords, category tags, and vector fields; S2. Receive the user's input question and call Dify's semantic parsing service to extract the structured query object; S3. Based on the extracted structured query object, perform a search on the question-and-answer knowledge base to find the best answer, and if the search fails to find the best answer, call the AI big model to generate the best answer; The specific steps of step S3 are as follows: S31. Use Elasticsearch's BM25 algorithm to retrieve question and answer text from the question and answer knowledge base using the value of the query entity as the query term, and receive the top-N candidate answers with the highest scores returned from the question and answer knowledge base; S32. Determine whether the highest score is higher than the score threshold; If so, select the candidate answer as the best answer and proceed to step S4; If not, proceed to step S33; S33. Generate a query vector from the user-input text-based question using the ONNX format Contriever model; S34. Based on the query vector, perform an approximate nearest neighbor search algorithm on the FAISS vectors in the question-answering knowledge base to determine whether there are FAISS vectors with a similarity greater than the first similarity threshold; If so, the answer corresponding to the text vector with a similarity greater than the first similarity threshold is taken as the best answer, and proceed to step S4; If not, proceed to step S35; S35. Generate prompts based on the text-based question input by the user, use the prompts to call the AI model for analysis, and generate the best answer; The specific steps of step S35 are as follows: S351. Pre-encapsulate the large AI model service using Dify's RESTful interface; S352. Pre-construct a structured prompt word template; the prompt word template includes product recommendation tasks, user input parameters, and query restrictions; S353. Fill the user-inputted text-based question into the user input parameters of the prompt word template, generate prompt words, and generate a query request based on the prompt words and the name of the AI large model; 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 names involved from the answers returned by the AI large model, and determine whether the extracted product names are in the product knowledge base; If so, proceed to step S4; If not, return to step S354; S4. Extract keywords from the best answer and use the keywords to filter the best products from the product knowledge base; S5. Return the selected best products and matching answer text to the user.
2. The product intelligent recommendation method based on the Dify platform according to claim 1, characterized in that, The specific steps of step S2 are as follows: S21. Problem of receiving raw text input from the user 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 entity; the query entity includes product type and product characteristics.
3. The product intelligent recommendation method based on the Dify platform according to claim 2, characterized in that, The specific steps of step S4 are as follows: S41. Use the TF-IDF algorithm to extract keywords from the best answer as filtering criteria; S42. Use Elasticsearch's Boolean query to filter products from the product knowledge base that meet all the filtering criteria, and designate them 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 the products with a similarity greater than the second threshold as the second type of products; S44. The first and second categories of products are considered the best products; The specific steps of step S5 are as follows: S51. Pre-construct a recommendation result object, which includes answer text parameters and product entities; the product entity includes product entity ID, matching score, and recommendation reason; S52. Calculate the matching score between the selected best products and the answer text, obtain the sales data of each best product, and call the AI big 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 the recommendation result object entity; S54. Sort the recommended results of each best product in descending order of matching score, and check the matching score difference between 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.
4. The product intelligent recommendation method based on the Dify platform according to claim 3, characterized in that, The specific steps of step S41 are as follows: S411. Perform word segmentation on the best answer text, remove stop words, and generate a candidate word set; S412. Calculate the TF-IDF weight of each word in the candidate word set, and select words with TF-IDF weights greater than the weight threshold as keywords; S413. Expand the selected keywords using a pre-built thesaurus, and use the keywords and the expanded synonyms as the filtering criteria; In step S52, the semantic matching score between the product attributes and the best answer is calculated using an Elasticsearch score calculation script; The specific steps for using a large AI model to analyze the reasons for recommendations are as follows: Pre-build an input prompt word template, which includes product ID, matching conditions, and usage scenarios; Fill the product ID and keywords of the best product into the input prompt template, determine the usage scenario based on the text format of the user input, and obtain the input prompt; The input prompts and the names of the large AI models will generate a recommended query request. Send the recommendation query request to the Dify model gateway, invoke the AI big model to perform question-and-answer analysis, and receive the recommendation reasons returned by the AI big model.
5. A product intelligent recommendation system based on the Dify platform, comprising the method described in any one of claims 1-4, characterized in that, include: The knowledge base building module is used to upload structured product data and question-and-answer text to 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 the question-and-answer knowledge base for the best answer based on the extracted structured query object, and to call the AI big model to generate the best answer when the retrieval fails. The product search module is used to extract keywords from the best answers and use those keywords to filter the best products from the product knowledge base. The product recommendation results return module is used to return the best filtered products and matching answer text to the user.
6. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the product intelligent recommendation method based on the Dify platform as described in any one of claims 1 to 4.
7. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the product intelligent recommendation method based on the Dify platform as described in any one of claims 1 to 4.