CoolFace
Apppublic

kasinathansj/Categorization

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
README.md95 linesDownload Raw Back to root
1---2title: Categorization3emoji: 🐨4colorFrom: gray5colorTo: pink6sdk: docker7pinned: false8---9 10Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference11 12 13# Text Classification API14 15This is a FastAPI-based service that classifies text into predefined departments using the Mistral-7B-Instruct model.16 17## Features18- Classifies input text into the most relevant department.19- Uses the Mistral-7B-Instruct model for classification.20- Returns structured JSON responses.21- Provides an API endpoint for classification.22- Logs execution time for performance analysis.23 24## Space Configuration25This project is hosted on **Hugging Face Spaces** using Docker.26 27## Setup & Installation281. Ensure the required dependencies are installed by specifying them in `requirements.txt`:29 30   ```bash31   fastapi32   uvicorn33   pydantic34   llama-cpp-python35   huggingface-hub36   ...37   ```38 392. Place the model file `mistral-7b-instruct-v0.1.Q2_K.gguf` in the project directory.40 413. Run the application using the following command:42 43   ```bash44   uvicorn app:app --host 0.0.0.0 --port 786045   ```46 47## API Endpoints48 49## Base Url50https://kasinathansj-categorization.hf.space51 52### Home53**GET `/`**54 55#### Response Body:56```json57{58    "message": "Text classification API is running!"59}60```61 62### Classify Text63**POST `/classify`**64 65#### Request Body:66```json67{68    "text": "The IT department needs new software updates.",69    "departments": [70        {"name": "IT", "description": "Handles software and hardware issues."},71        {"name": "HR", "description": "Manages employee relations."}72    ]73}74```75 76#### Response Body:77```json78{79    "text": "The IT department needs new software updates.",80    "department": "IT",81    "reason": "The text pertains to software and hardware issues.",82    "time_taken": 1.2383}84```85 86## Logs87Application logs are visible in the Hugging Face Space runtime output.88 89## License90MIT License91 92## Author93[Kasinathan SJ](https://huggingface.co/kasinathansj)94 95