Views
No views yet
MiniLM-L6 using Hugging Face Transformers.| Detail | Value |
|---|---|
| Base Model | nreimers/MiniLM-L6-H384-uncased |
| Task | Binary Text Classification |
| Framework | Hugging Face Transformers + PyTorch |
| Training Set | ~260 labeled queries |
| Validation Set | ~63 queries (20% split) |
| Classes | 0 = general, 1 = realtime |
| Query | Label |
|---|---|
| "Explain the theory of relativity" | general |
| "Who wrote Pride and Prejudice?" | general |
| "What is the current price of Bitcoin?" | realtime |
| "Latest news on the Ukraine war" | realtime |
| "Who is the Prime Minister of the UK right now?" | realtime |
pip install transformers torch1from query_classifier import QueryClassifier
2
3classifier = QueryClassifier()
4
5query = "What is the weather in Islamabad today?"
6category, confidence = classifier.classify(query)
7
8print(f"Category: {category}") # realtime
9print(f"Confidence: {confidence:.2f}") # e.g. 0.97Category: realtime
Confidence: 0.97query-classifier/
├── train_classifier.py # Fine-tuning script
├── query_classifier.py # Inference class (plug-and-play)
├── training_data.csv # Labeled dataset
├── trained_model/ # Saved model weights (after training)
│ ├── config.json
│ ├── tokenizer_config.json
│ └── model.safetensors
└── README.mdpython train_classifier.py1category, confidence = classifier.classify(user_query)
2
3if category == "realtime":
4 response = call_search_api(user_query) # Tavily, Serper, etc.
5else:
6 response = call_llm(user_query) # GPT-4, Claude, etc.