
sentiment-classifier.yaml. It creates an InferenceService called sentiment-classifier in the kserve-inference namespace and selects the Hugging Face runtime to load a DistilBERT-based model. The manifest includes a startup arg (for example --return_all_scores) so the runtime returns probability scores for each class (both negative and positive) instead of only the single winning class — that extra detail is visible in the response.
Apply the manifest to the cluster:
READY False while the model downloads and the pod initializes. DistilBERT is relatively small (~250 MB), so readiness often follows quickly, though actual timing depends on network and model registry availability. When READY True appears, the endpoint is live.
You may also see a route URL such as:
http://sentiment-classifier-kserve-inference.example.com
To access the service from your local machine, open a port-forward to the predictor service (run it in the background so you can keep using the same terminal for curl requests):
Classifiers use an Open Inference Protocol (OIP) style endpoint rather than the OpenAI-compatible chat/completion endpoints used by conversational models (e.g., Qwen). Conversational models accept a
messages array on endpoints like /openai/v1/chat/completions. Classifiers receive text inputs as OIP tensors via /v2/models/<model-name>/infer.
Sample response (formatted):
outputs[0].data[0]contains a string encoding of class probabilities mapping class index → probability.- In this example, key
0= negative sentiment and key1= positive sentiment. - The example indicates ~0.0001 probability for negative and ~0.9999 for positive — ~99.99% confidence that the sentence is positive.
- Strongly negative: “This course is a waste of time. Nothing worked the way it was supposed to.” → high probability for
0(negative). - Ambiguous: “It was fine, I guess.” → probabilities closer together (e.g., ~60% vs ~40%), showing model uncertainty that would be hidden by a bare class label.
If you run port-forward in the background, remember to kill the job when finished (e.g.,
kill %1 or use pkill -f "kubectl port-forward ..."). Leaving processes running can keep ports occupied or leak credentials in some environments.- Clear, unambiguous inputs tend to produce high-confidence scores (>99%).
- Ambiguous or neutral sentences produce probabilities that are closer together, which is exactly why returning scores (instead of just labels) gives better insight into model uncertainty.
- Use multiple example sentences to validate expected behavior across edge cases.