kasinathansj/Categorization
0
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
Text Classification API
This is a FastAPI-based service that classifies text into predefined departments using the Mistral-7B-Instruct model.
Features
- Classifies input text into the most relevant department.
- Uses the Mistral-7B-Instruct model for classification.
- Returns structured JSON responses.
- Provides an API endpoint for classification.
- Logs execution time for performance analysis.
Space Configuration
This project is hosted on Hugging Face Spaces using Docker.
Setup & Installation
- Ensure the required dependencies are installed by specifying them in
requirements.txt:
fastapi
uvicorn
pydantic
llama-cpp-python
huggingface-hub
...- Place the model file
mistral-7b-instruct-v0.1.Q2_K.ggufin the project directory.
- Run the application using the following command:
uvicorn app:app --host 0.0.0.0 --port 7860API Endpoints
Base Url
https://kasinathansj-categorization.hf.space
Home
GET `/`
Response Body:
{
"message": "Text classification API is running!"
}Classify Text
POST `/classify`
Request Body:
{
"text": "The IT department needs new software updates.",
"departments": [
{"name": "IT", "description": "Handles software and hardware issues."},
{"name": "HR", "description": "Manages employee relations."}
]
}Response Body:
{
"text": "The IT department needs new software updates.",
"department": "IT",
"reason": "The text pertains to software and hardware issues.",
"time_taken": 1.23
}Logs
Application logs are visible in the Hugging Face Space runtime output.
License
MIT License
