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.
- 🤖 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
- 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)
├── 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
-
Clone the repository:
git clone https://github.com/abrahao-dev/abrahao-labs-chatbot cd abrahao-labs-chatbot -
Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies:
pip install --upgrade pip pip install -r requirements.txt
-
Configure environment variables (optional for offline mode):
echo "HUGGINGFACE_API_KEY=your_api_key" > .env
-
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
- Option A (Recommended): Download from Google Drive and extract to
-
Run the application:
python app.py
-
Access the web interface at: http://localhost:8080
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.
The project fine-tunes a base model (distilgpt2) for digital marketing specialization:
- Data Preparation: Training conversations are formatted appropriately
- Tokenization: Text is converted to tokens
- Training: Model is fine-tuned with specific text generation settings
- Local Storage: Trained model is saved for offline use
- 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.pyto retrain with new data - Interface: Modify
templates/index.htmlandstatic/files
- Python 3.9 or higher
- Minimum 4GB RAM
- At least 1GB free disk space
- Dual-core processor or better
| 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) |
- 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
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
MIT License - © 2026 Abrahao Labs