# Qwen Multi-label Text Classifier ## Overview A multi-label text classifier based on Qwen-1.5B, fine-tuned for coding exercise classification. Supports: - Local CPU/GPU inference - Hugging Face API deployment - Batch evaluation - REST API via FastAPI - Docker deployment ## Features - **9 Label Classification**: Predicts multiple tags per text - **CLI Interface**: Run predictions/evaluations from terminal - **Dual Backend**: Choose between local or HF inference - **GPU Optimized**: CUDA support via Docker ## Installation ```bash git clone https://github.com/your-username/qwen-classifier cd qwen-classifier python3 -m venv .venv source .venv/bin/activate pip install -e . ``` ## Usage ### CLI Prediction ```bash # Local inference qwen-clf predict "Your coding exercise text" --backend local # HF Space inference qwen-clf predict "Your text" --backend hf --hf-token YOUR_TOKEN ``` ### Batch Evaluation ```bash qwen-clf evaluate dataset.zip --backend local ``` ### API Server ```bash uvicorn app:app --host 0.0.0.0 --port 7860 ``` #### API Endpoints | Endpoint | Method | Description | |----------|--------|-------------| | `/` | GET | Documentation | | `/predict` | POST | Single text prediction | | `/evaluate` | POST | Batch evaluation (ZIP) | | `/health` | GET | Service status | ## Docker Deployment ```bash # Build with GPU support docker build -t qwen-classifier . # Run container docker run -p 7860:7860 --gpus all qwen-classifier ``` ## Project Structure ``` . ├── app.py # FastAPI entry point ├── Dockerfile # GPU-optimized container setup ├── qwen_classifier/ # Core package │ ├── cli.py # Command line interface │ ├── model.py # Qwen classifier implementation │ ├── predict.py # Inference logic │ └── evaluate.py # Batch evaluation └── requirements.txt # Python dependencies ``` ## Configuration Edit `qwen_classifier/config.py` to set: - `TAG_NAMES`: List of 9 classification tags - `HF_REPO`: Default Hugging Face model repo - `DEVICE`: Auto-detected CUDA/CPU ## Hugging Face Space Live demo: [![HF Space](https://img.shields.io/badge/🤗%20Hugging%20Face-Space-blue)](https://huggingface.co/spaces/KeivanR/qwen-classifier-demo) ## License Apache 2.0 © Keivan Razban