Skip to content

An AI-powered fashion recommendation chatbot built with Flask and Qdrant, leveraging LLaMA models for NLP to extract product attributes and deliver smart, personalized search results.

License

Notifications You must be signed in to change notification settings

priyam-hub/Trend-Setters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Cover Page

๐Ÿค– Trend Setters - E-Commerce Conversational Chatbot

Product submitted to Cognizant Kolkata through Digital Nurture TechnoVerse East Hackathon

Python PyTorch License FastAPI Code style: black

Features โ€ข Installation โ€ข Tech Stack โ€ข Usage โ€ข Future Enhancements

๐Ÿ“Œ Overview

๐Ÿ“ Project Overview

This project is an AI-powered conversational chatbot built for e-commerce platforms.
It enables users to discover and explore fashion products through natural conversations instead of traditional keyword searches.
By combining Natural Language Processing (NLP) with Vector Search (Qdrant), the chatbot delivers highly relevant and personalized product recommendations.
The system is designed with a Flask backend, an interactive frontend UI, and integrates state-of-the-art LLaMA models (via Groq API and Hugging Face) for intelligent query understanding and recommendation.


๐Ÿš€ Features

  • Conversational AI Assistant: Powered by LLaMA 3 (70B) via Groq API and Quantized meta-llama/Llama-3.1-8B via HF for natural and human-like conversations.
  • Intelligent Vector Search: Leverages Qdrant Vector Database to find the most relevant fashion products using semantic similarity.
  • Multi-Attribute Query Handling: Supports dynamic filtering based on brand, color, category, gender, size, and more.
  • Context-Aware Query Processing: Understands partial queries and prompts users for missing details to refine results.
  • Fallback Recommendation System: Displays 10 random trending products when no attributes are provided, ensuring the user always sees results.
  • Optimized Model Performance: Supports 4-bit Quantization (Linux/CUDA) and 8-bit LoRA (Windows) for faster, resource-efficient inference.
  • Scalable Architecture: Easily extendable to integrate new product categories, recommendation strategies, or external APIs.

๐Ÿ› ๏ธ Tech Stack


๐Ÿ“š Dataset - Fashion E-Commerce Data Set

๐Ÿ“Ž Source: Custom-curated dataset integrated with Qdrant Vector Database

The Fashion E-Commerce Data Set is a structured product dataset containing detailed information about fashion items.
It is used to power semantic search and AI-driven product recommendations in this project.

๐Ÿ“ Dataset Highlights:

  • Total Records: ~3,000 fashion products (expandable)
  • Type: Tabular (Structured)
  • Task: Product Recommendation & Attribute-based Retrieval

โœ… Why This Dataset?

  • Contains rich product attributes (brand, color, size, category, gender, ratings).
  • Enables multi-attribute filtering through natural conversations.
  • Optimized for semantic similarity search with vector embeddings.
  • Suitable for building personalized recommendation systems in e-commerce.

๐Ÿ”ง Installation

  1. Clone the repository

    git clone git@github.com:priyam-hub/Trend-Setters.git
    cd Trend-Setters
  2. Create Conda Environment and Install Dependencies

    # CONDA ENV CREATED ALONG WITH DEPENDENCY INSTALLED
    conda env create -f environment.yml
    
    # ACTIVATE CONDA ENVIRONMENT
    conda activate <env_name>
  3. Set up environment variables

    • Create a .env file in the root directory of the Project and add the following Credentials:
    GROQ_API_KEY              = "YOUR_GROQ_API_KEY"
    LLM_MODEL_NAME            = "YOUR_LLM_MODEL_NAME"
    HF_LLM_MODEL_NAME         = "YOUR_HF_LLM_MODEL_NAME"
    QDRANT_API_KEY            = "YOUR_QDRANT_API_KEY"
    QDRANT_CLUSTER_URL        = "YOUR_QDRANT_CLUSTER_URL"
    QDRANT_COLLECTION_NAME    = "YOUR_QDRANT_COLLECTION_NAME"
    HUGGINGFACE_LOGIN_TOKEN   = "YOUR_HUGGINGFACE_LOGIN_TOKEN"
  4. Run the Flask server

    python web/app.py
  5. Access the E-Commerce Platform Open http://127.0.0.1:5000 in your browser.


๐Ÿ” Usage

  1. Enter a Query: Type a product-related query (e.g., "Show me blue Adidas shoes").
  2. NLP Processing: The chatbot extracts attributes like brand, color, and category from your query.
  3. Smart Filtering:
    • If attributes are provided โ†’ Relevant products are displayed.
    • If attributes are missing โ†’ It suggests similar items and prompts for more details.
  4. Fallback Search: If no attributes are found, 10 random products are shown with a prompt to refine the search.

๐Ÿ“ธ Example Search Results

Query Result
"I am Looking for women Black Top" Search Result 1
"I am Looking for Women Red Kurtis" Search Result 2
"Show me women blue jeans" Search Result 3
"Show me Kurta-Sets for my wife" Search Result 4
"Show me tops to gift in birthday for my sister" Search Result 5

โšก Performance & Inference Time of the Model

We benchmarked meta-llama/Llama-3.1-8B across different hardware accelerators and configurations (4-bit & 8-bit).
The chart below shows the predicted inference time (in seconds) for different setups:

Performance and Inference Time

๐Ÿ“Š Summary Table

Model Hardware Config Predicted Time (s)
meta-llama/Llama-3.1-8B CPU 4-bit ~60
8-bit ~110
meta-llama/Llama-3.1-8B T4 GPU 4-bit 10
8-bit 17
meta-llama/Llama-3.1-8B A100 GPU 4-bit ~3โ€“4
8-bit ~6โ€“7
meta-llama/Llama-3.1-8B L4 GPU 4-bit ~5
8-bit ~9
meta-llama/Llama-3.1-8B v5e-1 TPU 4-bit ~8
8-bit ~13
meta-llama/Llama-3.1-8B v2-8 TPU (Deprecated) 4-bit ~15
8-bit ~25
meta-llama/Llama-3.1-8B v6e-1 TPU 4-bit ~6
8-bit ~11

๐Ÿ“‚ Project Structure

Trend-Setters/
โ”œโ”€โ”€ .env                                     # Optional environment variables for API keys, database URLs, and other secrets
โ”œโ”€โ”€ .gitignore                               # Git ignore rules to exclude unnecessary files from version control
โ”œโ”€โ”€ environment.yml                          # Conda environment configuration with all dependencies
โ”œโ”€โ”€ LICENSE                                  # MIT License for project usage and distribution
โ”œโ”€โ”€ main.py                                  # Main script to run the application (entry point)
โ”œโ”€โ”€ README.md                                # Project documentation and overview
โ”œโ”€โ”€ requirements.txt                         # Python package dependencies for pip installation
โ”œโ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ __init__.py                          # Marks config as a Python package
โ”‚   โ””โ”€โ”€ config.py                            # Configuration settings for API keys, model paths, and constants
โ”œโ”€โ”€ data/
โ”‚   โ””โ”€โ”€ V-1.01_Updated_Fashion_Dataset.csv   # Fashion dataset containing product attributes
โ”œโ”€โ”€ images/
โ”‚   โ”œโ”€โ”€ image.png                            # General images used in README or UI
โ”‚   โ”œโ”€โ”€ search_result_1.png                  # Example screenshot of search result 1
โ”‚   โ”œโ”€โ”€ search_result_2.png                  # Example screenshot of search result 2
โ”‚   โ””โ”€โ”€ search_result_3.png                  # Example screenshot of search result 3
โ”œโ”€โ”€ logger/
โ”‚   โ”œโ”€โ”€ __init__.py                          # Marks logger as a Python package
โ”‚   โ””โ”€โ”€ logger.py                            # Custom logging utility for tracking events and errors
โ”œโ”€โ”€ models/
โ”‚   โ””โ”€โ”€ meta-llama/Llama-3.1-8B/             # Pretrained Hugging Face LLaMA 3.1 8B model
โ”‚       โ”œโ”€โ”€ model/                           # Model weights and architecture
โ”‚       โ””โ”€โ”€ tokenizer/                       # Tokenizer files for text processing
โ”œโ”€โ”€ notebooks/
โ”‚   โ””โ”€โ”€ Trend-Setters.ipynb                  # Jupyter notebook for experiments, analysis, and prototyping
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ extractor/  
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py                      # Marks extractor as a Python package
โ”‚   โ”‚   โ””โ”€โ”€ extractor.py                     # Extracts product attributes from user queries
โ”‚   โ”œโ”€โ”€ llm/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py                      # Marks LLM module as a package
โ”‚   โ”‚   โ””โ”€โ”€ llm_builder.py                   # Loads and configures LLM models (Groq & Hugging Face)
โ”‚   โ”œโ”€โ”€ parser/   
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py                      # Marks parser as a Python package
โ”‚   โ”‚   โ””โ”€โ”€ parser.py                        # Parses extracted attributes into search-friendly format
โ”‚   โ””โ”€โ”€ searcher/
โ”‚       โ”œโ”€โ”€ __init__.py                      # Marks searcher as a Python package
โ”‚       โ””โ”€โ”€ extractor.py                     # Performs vector search on Qdrant and retrieves products
โ”œโ”€โ”€ test/
โ”‚   โ”œโ”€โ”€ __init__.py                          # Marks test folder as a Python package
โ”‚   โ””โ”€โ”€ test.py                              # Unit tests for different modules
โ””โ”€โ”€ web/
    โ”œโ”€โ”€ static/
    โ”‚   โ”œโ”€โ”€ css/
    โ”‚   โ”‚   โ”œโ”€โ”€ styles_home.css              # CSS for homepage
    โ”‚   โ”‚   โ””โ”€โ”€ styles.css                   # General styling for web pages
    โ”‚   โ”œโ”€โ”€ images/
    โ”‚   โ”‚   โ”œโ”€โ”€ icon/                        # Icons used in the UI
    โ”‚   โ”‚   โ”œโ”€โ”€ logo/                        # Logo images
    โ”‚   โ”‚   โ””โ”€โ”€ products/                    # Product images for frontend display
    โ”‚   โ””โ”€โ”€ js/
    โ”‚       โ”œโ”€โ”€ home.js                      # JS for homepage functionalities and search
    โ”‚       โ””โ”€โ”€ chatBot.js                   # JS for chatbot interactions and modal/chat window
    โ”œโ”€โ”€ templates/
    โ”‚   โ”œโ”€โ”€ index_home.html                  # Homepage template
    โ”‚   โ””โ”€โ”€ index.html                       # Main index page template
    โ”œโ”€โ”€ __init__.py                          # Marks web folder as a Python package
    โ””โ”€โ”€ app.py                               # Flask application file to run backend and route endpoints

๐Ÿ”ฎ Future Enhancements

๐Ÿš€ Phase 1 โ€“ Core Improvements

  • User Authentication: Enable login/logout with saved chat history.
  • Better Query Understanding: Improve NLP pipeline for more accurate attribute extraction.
  • UI/UX Enhancements: Add responsive chatbot widget with modern design.
  • Randomized Recommendations: Smarter fallback mechanism with trending products instead of purely random ones.

๐ŸŒ Phase 2 โ€“ Advanced Features

  • Multi-Language Support: Let users interact in multiple languages.
  • Voice Search: Integrate speech-to-text for hands-free chatbot queries.
  • Recommendation Engine: Personalized product suggestions using collaborative filtering.
  • Image-Based Search: Upload product images to get visually similar results.

โ˜๏ธ Phase 3 โ€“ Enterprise & Scalability

  • Real-Time Inventory Sync: Connect with live e-commerce databases to track stock availability.
  • Payment Integration: Allow direct checkout and transactions within chatbot.
  • Analytics Dashboard: Provide admins with insights on queries, popular searches, and conversion rates.
  • Cloud Deployment & Scaling: Deploy with Docker/Kubernetes on AWS/GCP/Azure for high availability.
  • Security Enhancements: Implement JWT authentication, role-based access, and encrypted APIs.

๐Ÿ“œ License

This project is licensed under the MIT License.

Made with โค๏ธ by Team Technocrats

โ†‘ Back to Top

About

An AI-powered fashion recommendation chatbot built with Flask and Qdrant, leveraging LLaMA models for NLP to extract product attributes and deliver smart, personalized search results.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published