setfit ag news endpoint
philschmidIntroduction
The SETFIT AG News model is a text classification model fine-tuned using the SetFit approach on the AG News dataset. It achieves high accuracy with minimal training data, outperforming larger models like GPT-3. The model is available for use as an inference endpoint.
Architecture
SetFit (arxiv:2209.11055) is an efficient approach for text classification, allowing for high accuracy with limited labeled data. The model utilizes the sentence-transformers/all-mpnet-base-v2
as its base architecture and has been trained with only 32 samples.
Training
- Dataset: AG News
- Training Samples: 32 (8 per class)
- Test Accuracy: 0.87
The model leverages the SetFit methodology, which is shown to outperform GPT-3 in several tasks despite being significantly smaller.
Guide: Running Locally
To run the model locally, you can interact with the inference endpoint using Python or cURL.
Python Example
- Install necessary packages:
pip install requests
- Use the following script to send a request:
import requests as r ENDPOINT_URL = "" # URL of your endpoint HF_TOKEN = "" # Your Hugging Face token headers = { "Authorization": f"Bearer {HF_TOKEN}", "Content-Type": "application/json" } payload = { "inputs": "Your input text here" } response = r.post(ENDPOINT_URL, headers=headers, json=payload) print(response.json())
cURL Example
curl https://YOURDOMAIN.us-east-1.aws.endpoints.huggingface.cloud \
-X POST \
-d '{"inputs": "Your input text here"}' \
-H "Authorization: Bearer YOUR_HF_TOKEN" \
-H "Content-Type: application/json"
Cloud GPUs
For enhanced performance, consider using cloud GPU services like AWS or Azure to deploy the model.
License
The model is licensed under the MIT License, allowing for open use and distribution with minimal restrictions.