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

By combining large language model and shopping basket analysis, personalized recommendation of the intelligent retail recommendation system is realized, solving the problems of user needs understanding and unstructured information utilization, providing efficient and personalized product recommendations, improving user experience and Sales conversion rate.

CN119166900APending Publication Date: 2024-12-20周佺喜
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411372678.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2024-12-20

AI Technical Summary

Technical Problem

The existing e-commerce recommendation system lacks a deep understanding of user's natural language input, is difficult to adapt to changes in user needs, is difficult to utilize unstructured information, is single interaction method and insufficient response speed, resulting in poor personalized recommendation results.

Method used

Using an intelligent retail recommendation system that combines large language model and shopping basket analysis, mining association rules through FP-Growth algorithm, combining knowledge enhancement with LangChain tool, and efficient storage and retrieval using Chroma vector database and PostgreSQL database. FastAPI provides a high-performance API Service, realize natural language dialogue and personalized recommendations.

Benefits of technology

It realizes natural and smooth human-computer interaction, provides accurate and relevant product recommendations, enhances the accuracy and diversity of recommendations, ensures the system's high concurrency processing capabilities and rapid response, and the system design is modular and easy to expand.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119166900A_ABST
    Figure CN119166900A_ABST
Patent Text Reader

Abstract

The invention discloses an intelligent retail recommendation system based on a large language model and shopping basket analysis, and belongs to the technical field of artificial intelligence and data mining. The system comprises a large language model module, a shopping basket analysis module, a vector database, a relational database, a retrieval enhancement generation module, a FastAPI back-end interface and a front-end interface. The workflow comprises the steps of data preprocessing, shopping basket analysis, document index construction, user interaction, query processing, knowledge retrieval, recommendation generation, response synthesis, result presentation and the like. According to the method, the natural language processing capability of the large language model and the data insight of shopping basket analysis are combined, organic unification of intelligent dialogue and personalized recommendation is realized, user demands can be accurately understood, commodity recommendation with high correlation and high timeliness is provided, and the user experience and the sales conversion rate are effectively improved. Due to the modular and extensible design, the system is suitable for retail businesses of various scales, and has wide application prospects and commercial value.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of artificial intelligence, natural language processing and data mining technology, and in particular to an intelligent retail recommendation system that combines a large language model with shopping basket analysis. Background Art

[0002] In the field of e-commerce, personalized recommendation systems play an increasingly important role in improving user experience and increasing sales. Traditional recommendation systems are mainly based on collaborative filtering or content filtering. Although they can provide certain personalized recommendations, they often lack in-depth understanding of user needs and the ability to respond flexibly.

[0003] In recent years, large language models (such as the GPT series) have made breakthrough progress in the field of natural language processing, demonstrating powerful language understanding and generation capabilities. At the same time, shopping basket analysis, as a classic data mining method, can effectively discover association rules between products. However, there is currently a lack of an intelligent recommendation system that combines the language capabilities of large language models with the data insights of shopping basket analysis to achieve more intelligent and personalized product recommendations.

[0004] The prior art has the following problems: 1. Lack of deep understanding of user natural language input makes it difficult to accurately grasp users’ real needs and purchasing intentions.

[0005] 2. Recommendation results are often limited to historical data and are difficult to adapt to changes in users’ immediate needs.

[0006] 3. It is difficult to effectively utilize unstructured product descriptions and review information to enhance the accuracy and diversity of recommendations.

[0007] 4. The recommendation system has a single way of interacting with users and lacks the ability to have natural and smooth conversations.

[0008] 5. It is difficult to provide high-quality personalized recommendations while ensuring system response speed. Summary of the invention

[0009] The purpose of the present invention is to provide an intelligent retail recommendation system based on a large language model and shopping basket analysis, aiming to solve the problems existing in the prior art. The system can understand the user's natural language input, combine the association rules of historical transaction data and rich product information, and provide users with accurate and personalized product recommendations through intelligent dialogue.

[0010] To achieve the above object, the present invention adopts the following technical solutions: An intelligent retail recommendation system based on large language model and shopping basket analysis, including: 1. Large language model module: It uses advanced large language models (such as Azure OpenAI's GPT-4) as the core to understand user input, generate responses, and extract relevant product information.

[0011] 2. Shopping basket analysis module: Based on historical transaction data, the FP-Growth algorithm is used to mine association rules and generate association rules between products.

[0012] 3. Vector database: Use Chroma vector database to store document embeddings for efficient similarity retrieval.

[0013] 4. Relational database: Use PostgreSQL to store the association rules generated by shopping basket analysis.

[0014] 5. Retrieval Enhancement Generation (RAG) module: Combined with LangChain tools, it realizes knowledge enhancement based on document retrieval.

[0015] 6. FastAPI backend: provides high-performance API services, handles user requests and coordinates interactions between modules.

[0016] 7. Front-end interface: Provides a simple and intuitive user interaction interface that supports natural language conversations and real-time recommendation displays.

[0017] The workflow of the present invention is as follows: 1. Data preparation and preprocessing: Clean, transform and frequency filter the raw transaction data to prepare for market basket analysis.

[0018] 2. Shopping basket analysis: Use the FP-Growth algorithm to mine product association rules and store the results in the PostgreSQL database.

[0019] 3. Document index construction: Generate embedding vectors for product-related documents through a large language model and store them in the Chroma vector database.

[0020] 4. User interaction: Users enter natural language queries through the front-end interface.

[0021] 5. Query processing: The FastAPI backend receives user queries and calls the large language model for understanding and processing.

[0022] 6. Knowledge retrieval: Use RAG technology to retrieve relevant product information from the vector database.

[0023] 7. Recommendation generation: Based on the user query and the retrieved information, relevant product association rules are queried from PostgreSQL.

[0024] 8. Response synthesis: The large language model comprehensively considers user queries, retrieved product information and association rules to generate personalized answers and recommendations.

[0025] 9. Result presentation: The generated answers and recommendations are presented to the user through the front-end interface.

[0026] Beneficial effects of the present invention: 1. Intelligent interaction: Utilize the powerful language understanding and generation capabilities of the large language model to achieve natural and fluent human-computer dialogue.

[0027] 2. Personalized recommendations: Combined with data insights from shopping basket analysis, more accurate and relevant product recommendations are provided.

[0028] 3. Knowledge enhancement: Through RAG technology, structured and unstructured product information are organically combined to provide more comprehensive and accurate answers.

[0029] 4. High performance: Adopt technologies such as FastAPI and vector database to ensure the system's high concurrent processing capability and fast response.

[0030] 5. Scalability: The modular design makes the system easy to maintain and expand, and each component can be flexibly adjusted or upgraded according to needs. BRIEF DESCRIPTION OF THE DRAWINGS Figure 1 It is a system architecture diagram of the present invention.

[0032] Figure 2 It is a work flow chart of the present invention.

[0033] Figure 3 It is a schematic diagram of the user interaction interface. DETAILED DESCRIPTION The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments.

[0035] Example: 1. Data Preprocessing Use the pandas library to clean and transform the raw transaction data: ```Python import pandas as pd # Load the dataset tran_df = pd.read_csv('online_retail_II.csv', encoding='latin1') # Data cleaning conditions = [ (tran_df['Invoice'].notnull()), (tran_df['Quantity'] > 0), (tran_df['Customer ID'].notnull()), (tran_df['StockCode'].notnull()), (tran_df['Description'].notnull()) tran_df = tran_df[pd.concat(conditions, axis=1).all(axis=1)] # De-duplication and date formatting tran_df = tran_df.drop_duplicates(['Invoice', 'StockCode', 'Description', 'Quantity', 'InvoiceDate']) tran_df['InvoiceDate'] = pd.to_datetime(tran_df['InvoiceDate']) tran_df['transaction_date'] = tran_df['InvoiceDate'].dt.date # Frequency filtering freq_items = tran_df['Description'].value_counts() freq_items_df = freq_items[freq_items > 350].reset_index() freq_items_list = set(freq_items_df['Description']) tran_df_filtered = tran_df[tran_df['Description'].isin(freq_items_list)] # Final dataset preparation cols = ['Customer ID', 'Description', 'trans_date', 'Quantity'] ​tran_df_final = tran_df_filtered[cols] 2. Shopping basket analysis Use the mlxtend library to implement the FP-Growth algorithm: ```Python from mlxtend.frequent_patterns import fpgrowth, association_rules # Pivot basket = tran_df_final.groupby(['Customer ID', 'Description'])['Quantity'].sum().unstack().fillna(0) basket_encoded = basket.applymap(lambda x: 1 if x > 0 else 0) # FP-Growth algorithm frequent_itemsets = fpgrowth(basket_encoded, min_support=0.01, use_colnames=True) frequent_itemsets['length'] = frequent_itemsets['itemsets'].apply(len) filtered_itemsets = frequent_itemsets[(frequent_itemsets['length'] <=4) & (frequent_itemsets['length'] > 2)] # Generate association rules rules = association_rules(filtered_itemsets, metric="confidence",min_threshold=0.5) 3. Data Storage Store the generated association rules in the PostgreSQL database: ```Python from sqlalchemy import create_engine conn_str = 'postgresql: / / username:password@host:port / database' engine = create_engine(conn_str) rules.to_sql('basket_rules', engine, if_exists='replace', index=False) ``` 4. Document index construction Building a document index using LangChain and Chroma: ```Python from langchain.document_loaders import TextLoader from langchain.text_splitter import CharacterTextSplitter from langchain_openai import AzureOpenAIEmbeddings from langchain_chroma import Chroma # Load the document loader = TextLoader("product_descriptions.txt", encoding='UTF-8') documents = loader.load() # Text segmentation text_splitter = CharacterTextSplitter(chunk_size=300, chunk_overlap=30) chunks = text_splitter.split_documents(documents) # Create a vector database embeddings = AzureOpenAIEmbeddings( deployment='textembedding3large', model='text-embedding-3-large', azure_endpoint=AZURE_ENDPOINT, openai_api_key=OPENAI_API_KEY ) vectordb = Chroma.from_documents(documents=chunks, embedding=embeddings, persist_directory=". / chroma_db") ``` 5. FastAPI Backend Implementation ```python from fastapi import FastAPI, HTTPException from pydantic import BaseModel from langchain_openai import AzureChatOpenAI from langchain.chains import ConversationalRetrievalChain from langchain.memory import ConversationBufferWindowMemory app = FastAPI() class ChatRequest(BaseModel): question: str @app.post(" / chat") async def chat_endpoint(chat_request: ChatRequest): try: question = chat_request.question # Call the large language model chat_model = AzureChatOpenAI( openai_api_version="2024-03-01-preview", azure_deployment="gpt4", temperature=0.4 ) # Set the retrieval chain retriever = vectordb.as_retriever() memory = ConversationBufferWindowMemory(k=5, memory_key="chat_history", input_key="question", output_key='answer', return_messages=True) qa_chain = ConversationalRetrievalChain.from_llm( llm=chat_model, retriever=retriever, memory=memory ) # Generate an answer result = qa_chain({"question": question}) answer = result['answer'] # Extract product names product_names = extract_product_names(answer) # Query recommendations if product_names: recommendations = query_recommendations(product_names) if recommendations: answer += f"\n\nRecommended products: {', '.join(recommendations)}" return {"answer": answer} except Exception as e: raise HTTPException(status_code=500, detail=str(e)) def extract_product_names(text): # Implement product name extraction logic pass def query_recommendations(product_names): # Implement database query recommendation logic pass ``` 6. Front-end implementation Implement a simple chat interface using HTML and JavaScript: ```html <!DOCTYPE html> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title> Smart Retail Assistant< / title> <style> / * 样式代码 * / < / style> <form id="chat-form"> <input type="text" id="user-input" placeholder="请输入您的问题..."> <button type="submit"> send< / button> < / form> <script> / / JavaScript代码document.getElementById('chat-form').onsubmit = async function(e) {e.preventDefault();const question = document.getElementById('user-input').value;document.getElementById('user-input').value = ''; / / 显示用户输入addMessage('user', question); / / 发送请求到后端const response = await fetch(' / chat', {method: 'POST',headers: { 'Content-Type': 'application / json'},body: JSON.stringify({ question})});const data = await response.json(); / / 显示助手回复addMessage('assistant', data.answer);}function addMessage(sender, content) {const messageDiv = document.createElement('div');messageDiv.className = `message ${sender}`;messageDiv.textContent = content;document.getElementById('chat-history').appendChild(messageDiv);}< / script> ``` Advantages and innovations of the present invention: 1. Fusion of large language model and shopping basket analysis: This invention uniquely combines the natural language processing capabilities of large language models with the data insights of shopping basket analysis, achieving the organic unity of intelligent dialogue and personalized recommendations. This fusion enables the system to understand the complex needs of users and provide more accurate and relevant product recommendations.

[0036] 2. Retrieval-augmented generation (RAG) technology: By integrating advanced RAG tools such as LangChain, the system is able to retrieve and utilize a large amount of structured and unstructured product information in real time during the conversation, greatly enhancing the accuracy and comprehensiveness of the answers.

[0037] 3. Efficient data storage and retrieval: The Chroma vector database is used to store document embeddings, which enables efficient indexing and similarity retrieval of large-scale product information. At the same time, the PostgreSQL relational database is used to store association rules for shopping basket analysis, ensuring fast response to recommendation queries.

[0038] 4. Real-time performance optimization: FastAPI is selected as the backend framework, which makes full use of its asynchronous characteristics, can efficiently handle concurrent requests, and ensure the system response speed under high load conditions.

[0039] 5. Modular and scalable design: The system adopts a modular architecture with loose coupling between components, which is easy to maintain and upgrade. This design allows the system to flexibly adapt to the needs of retail businesses of different sizes and can easily integrate new algorithms or models.

[0040] 6. User-friendly interactive interface: It provides a simple and intuitive web front-end interface and supports natural language dialogue, allowing users to easily obtain product information and personalized recommendations just like talking to human customer service.

[0041] 7. Continuous learning and optimization: The system design takes into account future scalability. By collecting user feedback and interaction data, the large language model and recommendation algorithm can be continuously optimized to achieve continuous improvement in system performance.

[0042] Application scenarios: 1. E-commerce platform: It can be integrated into existing online shopping websites or mobile applications to provide users with intelligent customer service and personalized shopping recommendation services. The system can understand complex user queries, such as "I want to find a breathable T-shirt suitable for outdoor sports in summer", and recommend related products based on the user's description and historical purchase behavior.

[0043] 2. Physical retail stores: It can be deployed as an in-store kiosk or mobile application to help customers quickly find the goods they need and recommend related products to improve shopping experience and sales. For example, when a customer asks about a pair of sports shoes, the system can not only provide detailed information about the shoes, but also recommend matching sportswear or accessories.

[0044] 3. Omni-channel retail: Supports online and offline integrated intelligent recommendations to provide users with a seamless omni-channel shopping experience. The system can provide consistent personalized recommendations across different channels based on the user’s online browsing history and offline purchase records.

[0045] 4. Customer Relationship Management: It can be integrated into the CRM system to help customer service staff better understand and meet customer needs and provide more personalized services. The system can quickly retrieve customer history and provide relevant product information and recommendations based on the customer's query intention.

[0046] 5. Marketing campaigns: It can be used to design and execute precision marketing campaigns, and push personalized promotional information based on user interests and purchase history. For example, the system can identify users who are interested in a certain type of product but have not yet purchased it, and push relevant discount information to them.

[0047] 6. Product Development: By analyzing user queries and feedback, the system provides valuable market insights to the product development team. The system can identify product features that users often ask about but are missing in the current product line, providing direction for new product development.

[0048] 7. Inventory management: Combine user query and recommendation data to optimize inventory management strategies. The system can predict which products may see an increase in demand due to relevant recommendations, so as to adjust inventory levels in advance.

[0049] Summarize: The present invention provides an innovative intelligent retail recommendation system, which realizes the organic combination of intelligent dialogue and personalized recommendation by integrating large language model, shopping basket analysis and retrieval enhancement generation technology. The system can not only accurately understand user needs, but also provide highly relevant and timely product recommendations, effectively improving user experience and sales conversion rate. Its modular and scalable design makes it suitable for retail businesses of all sizes, and has broad application prospects and commercial value.

[0050] By continuously collecting user feedback and interaction data, combined with machine learning technology, the system has the potential to continuously optimize its recommendation algorithm and dialogue model to achieve continuous performance improvement. In the future, with the further development of large language models and data mining technology, this system can integrate more advanced natural language processing and AI recommendation algorithms, opening up new possibilities for intelligent and personalized services in the retail industry.

Claims

1. An intelligent retail recommendation system based on large language model and shopping basket analysis, characterized in that: include: A large language model module to understand user input, generate responses, and extract relevant product information; The shopping basket analysis module is used to generate association rules between commodities based on historical transaction data; A vector database for storing document embeddings and enabling efficient similarity retrieval; A relational database to store association rules generated by shopping basket analysis; Retrieval Enhancement Generation (RAG) module, which is used to achieve knowledge enhancement based on document retrieval; FastAPI backend, used to process user requests and coordinate interactions between modules; The front-end interface is used to provide user interaction and display recommendation results.

2. The intelligent retail recommendation system according to claim 1, characterized in that: The large language model module adopts the GPT-4 model of Azure OpenAI, the shopping basket analysis module uses the FP-Growth algorithm to mine association rules, the vector database is implemented using Chroma, the relational database is implemented using PostgreSQL, and the retrieval enhancement generation module is implemented using the LangChain tool.

3. An intelligent retail recommendation method based on large language model and shopping basket analysis, characterized in that: The following steps are involved: (1) Data preprocessing: cleaning, conversion, and frequency filtering of raw transaction data; (2) Shopping basket analysis: Use the FP-Growth algorithm to mine product association rules and store the results in a relational database; (3) Document index construction: Generate embedding vectors for product-related documents through a large language model and store them in a vector database; (4) User interaction: receiving natural language queries from users through the front-end interface; (5) Query processing: using large language models to understand and process user queries; (6) Knowledge retrieval: Retrieve relevant product information from the vector database using RAG technology; (7) Recommendation generation: Based on the user query and the retrieved information, relevant product association rules are queried from the relational database; (8) Response synthesis: The large language model comprehensively considers user queries, retrieved product information, and association rules to generate personalized answers and recommendations; (9) Result presentation: The generated answers and recommendations are presented to the user through the front-end interface.

4. The method according to claim 3, characterized in that The data preprocessing step includes: Load raw transaction data; Remove records containing missing or invalid values; Remove duplicate records; Convert transaction dates to a standard format; Perform frequency filtering on products and retain products with a frequency higher than a predetermined threshold.

5. The method according to claim 3, characterized in that: The query processing step is implemented using a conversational search chain, including: Set up a conversation memory module to save recent conversation history; Use large language models to understand and process user queries; Generate optimized search queries by combining conversation history; Retrieve relevant information from the knowledge base based on optimized search queries; Generate personalized responses by taking into account the retrieved information and conversation history.

6. The method according to claim 3, characterized in that It also includes continuous optimization steps: Collect user interaction data and feedback between the system and the system; Regularly update association rules for market basket analysis; Use the collected data to fine-tune large language models and improve their performance in specific domains.

Citation Information

Cited By

  • E-commerce recommendation method for extracting consumption behavior characteristics based on large language model

    CN119887340A

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

    CN120670546A