PrompTrend is an advanced chat support system that combines intent classification and contextual bandit algorithms to provide personalized recommendations and responses. The system uses BERT for intent classification and implements a contextual multi-armed bandit approach for dynamic learning from user interactions.
- Intent classification using BERT
- Contextual bandit-based recommendation system
- Real-time user feedback processing
- Automatic question generation
- Redis caching for improved performance
- Comprehensive API documentation
- Robust error handling
- Database persistence with PostgreSQL
- Framework: FastAPI
- ML Models: BERT (Transformers), T5
- Database: PostgreSQL
- Caching: Redis
- ML Libraries: PyTorch, Scikit-learn
- Testing: Pytest
- Python 3.8+
- PostgreSQL
- Redis
- CUDA-compatible GPU (optional, for faster model training)
- Clone the repository:
git clone https://github.com/yourusername/promptrend.git
cd promptrend
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # Linux/Mac
# or
.\venv\Scripts\activate # Windows
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables:
python scripts/setup_env.py --env development
- Initialize the database:
alembic upgrade head
- Start the Redis server:
redis-server
- Start the application:
uvicorn main:app --reload
The API will be available at http://localhost:8000
The project includes comprehensive tests for all components. To run the tests:
# Run all tests
pytest
# Run tests with coverage report
pytest --cov=app tests/
# Run specific test file
pytest tests/test_intent_classifier.py
promptrend/
├── api/
│ └── routes.py # API endpoints
├── core/
│ ├── config.py # Configuration management
│ ├── database.py # Database setup
│ ├── models.py # Data models
│ └── cache.py # Redis cache implementation
├── services/
│ ├── intent_classifier.py # BERT classifier
│ ├── recommender.py # Contextual bandit
│ ├── recommendation_service.py
│ ├── question_generator.py # T5 question generator
│ └── error_handler.py # Error handling service
├── tests/
│ ├── test_intent_classifier.py
│ ├── test_recommender.py
│ ├── test_api.py
│ └── test_integration.py
├── scripts/
│ └── setup_env.py
├── main.py
├── requirements.txt
└── README.md
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Hugging Face for the Transformers library
- FastAPI team for the amazing framework
- The open-source community for various dependencies
For questions and feedback, please create an issue in the GitHub repository.