Skip to content

About

AI-powered chatbot for digital marketing, using LangChain, Hugging Face fine-tuning (DistilGPT2), and RAG techniques with PDF, CSV, and TXT file support.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

Abrahao Labs AI Chatbot

An intelligent chatbot specialized in digital marketing for Abrahao Labs, built with Python, LangChain, and Hugging Face fine-tuned models. Features RAG (Retrieval Augmented Generation) for contextual responses from external knowledge bases.

Python Flask LangChain License

Features

  • 🤖 Automated Customer Service: Natural conversations about digital marketing services
  • 🔍 RAG-Powered Responses: Retrieves context from PDF, CSV, and TXT documents
  • 📚 Knowledge Base: Integrates information from multiple file formats
  • 💼 Service Presentation: Explains available digital marketing services
  • 💰 Personalized Recommendations: Suggests plans based on customer profiles
  • 🔄 Context Retention: Maintains conversation history for coherent interactions
  • 🎯 Lead Qualification: Identifies customer needs and qualifies leads automatically

Tech Stack

  • Python 3.9+: Core programming language
  • LangChain: Framework for LLM applications and RAG
  • Hugging Face Transformers: Fine-tuned language model (distilgpt2)
  • Flask: Web framework for the chat interface
  • FAISS: Vector storage for efficient semantic search
  • Sentence-Transformers: Semantic embeddings generation
  • PyPDF2 & Pandas: Document processing (PDF, CSV)

Project Structure

├── app/
│   ├── __init__.py
│   ├── chatbot.py              # Main ChatBot class
│   ├── conversation_manager.py # Conversation state & lead qualification
│   ├── data_loader.py          # Document loading (PDF, CSV, TXT)
│   ├── prompt_manager.py       # LLM prompt templates
│   ├── vector_store.py         # FAISS vector storage
│   └── fine_tuning.py          # Model fine-tuning module
├── data/
│   ├── faq.csv                 # FAQ about digital marketing
│   ├── pricing_plans.csv       # Plans and pricing information
│   ├── lead_qualification_script.txt  # Lead qualification script
│   └── agency_services.pdf     # Detailed service descriptions
├── fine_tuned_model/           # Fine-tuned model (local)
├── vectorstore/                # FAISS vector database
├── templates/
│   └── index.html              # Web chat interface
├── static/
│   ├── logo.png                # Abrahao Labs logo
│   ├── script.js               # Frontend JavaScript
│   └── style.css               # CSS styles
├── app.py                      # Flask server
├── run_fine_tuning.py          # Fine-tuning script
├── .env                        # Environment variables
└── requirements.txt            # Dependencies

Installation

  1. Clone the repository:

    git clone https://github.com/abrahao-dev/abrahao-labs-chatbot
    cd abrahao-labs-chatbot
  2. Create and activate a virtual environment:

    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  3. Install dependencies:

    pip install --upgrade pip
    pip install -r requirements.txt
  4. Configure environment variables (optional for offline mode):

    echo "HUGGINGFACE_API_KEY=your_api_key" > .env
  5. Get the fine-tuned model files:

    The fine-tuned model files are not included in the repository due to GitHub size limits.

    • Option A (Recommended): Download from Google Drive and extract to fine_tuned_model/
    • Option B: Run fine-tuning locally (may take several hours):
      python run_fine_tuning.py
  6. Run the application:

    python app.py
  7. Access the web interface at: http://localhost:8080

How It Works

RAG (Retrieval Augmented Generation)

The chatbot uses RAG to enhance responses with relevant information from:

  • agency_services.pdf: Digital marketing service descriptions
  • faq.csv: Frequently asked questions with answers
  • pricing_plans.csv: Plan details and pricing
  • lead_qualification_script.txt: Lead qualification workflow

Documents are processed, indexed, and stored in a FAISS vector database for efficient semantic search.

Fine-Tuning

The project fine-tunes a base model (distilgpt2) for digital marketing specialization:

  1. Data Preparation: Training conversations are formatted appropriately
  2. Tokenization: Text is converted to tokens
  3. Training: Model is fine-tuned with specific text generation settings
  4. Local Storage: Trained model is saved for offline use

Customization

  • Prompts: Customize LLM instructions in app/prompt_manager.py
  • Training Data: Edit files in data/ to update the knowledge base
  • Fine-tuning: Run python run_fine_tuning.py to retrain with new data
  • Interface: Modify templates/index.html and static/ files

System Requirements

  • Python 3.9 or higher
  • Minimum 4GB RAM
  • At least 1GB free disk space
  • Dual-core processor or better

Troubleshooting

Issue Solution
Model loading error Verify fine-tuned model files are in fine_tuned_model/
Dependency errors Run pip install -r requirements.txt again
Slow performance Reduce document count in knowledge base
Port in use Change port in app.py (default: 8080)

Known Limitations

  • Fine-tuning can be slow on machines without GPU
  • Fine-tuned model may occasionally generate lower quality responses
  • Short messages may be difficult to process for lead qualification
  • Some edge cases in vector storage integration need refinement

Authors

Developed as an AI course project at Universidade São Francisco (USF).

  • Matheus Abrahão Martins Alvares
  • Cauê Becker Rossi
  • Bruno Ricci Zanoni
  • Giulio Passetti Figueiredo

License

MIT License - © 2026 Abrahao Labs

About

AI-powered chatbot for digital marketing, using LangChain, Hugging Face fine-tuning (DistilGPT2), and RAG techniques with PDF, CSV, and TXT file support.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages