Instructions to use AbdullahImran/Fine-Tuned-SBERT-MiniLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use AbdullahImran/Fine-Tuned-SBERT-MiniLM with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("AbdullahImran/Fine-Tuned-SBERT-MiniLM") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
Fine-Tuned SBERT MiniLM for Mental Health Classification
A fine-tuned Sentence-BERT (SBERT) model based on
sentence-transformers/all-MiniLM-L6-v2, developed for binary
mental-health text classification.
The model generates 384-dimensional sentence embeddings using
the fine-tuned SBERT encoder. These embeddings are passed to a trained
Logistic Regression classifier to classify text into Non-MH or MH.
Model Pipeline
Input Text
|
v
Fine-Tuned SBERT
(all-MiniLM-L6-v2)
|
v
Mean Pooling
|
v
L2 Normalization
|
v
384-Dimensional Embedding
|
v
Logistic Regression
|
v
Non-MH / MH
Model Details
| Property | Value |
|---|---|
| Base Model | sentence-transformers/all-MiniLM-L6-v2 |
| Architecture | BERT / MiniLM |
| Transformer Layers | 6 |
| Attention Heads | 12 |
| Hidden Size | 384 |
| Embedding Dimension | 384 |
| Pooling | Mean Pooling |
| Normalization | L2 Normalization |
| Project Max Sequence Length | 32 tokens |
| Downstream Classifier | Logistic Regression |
| Number of Classes | 2 |
| Labels | Non-MH, MH |
Logistic Regression Configuration
C = 1.0
class_weight = balanced
max_iter = 1000
Repository Contents
.
βββ 1_Pooling/
β βββ config.json
βββ config.json
βββ config_sentence_transformers.json
βββ logistic_regression_classifier.joblib
βββ model.safetensors
βββ modules.json
βββ sentence_bert_config.json
βββ special_tokens_map.json
βββ tokenizer.json
βββ tokenizer_config.json
βββ vocab.txt
Key Files
model.safetensorsβ fine-tuned SBERT model weightsconfig.jsonβ Transformer model configurationconfig_sentence_transformers.jsonβ Sentence Transformers configurationmodules.jsonβ Sentence Transformers module configuration1_Pooling/config.jsonβ mean-pooling configurationtokenizer.jsonβ tokenizertokenizer_config.jsonβ tokenizer configurationvocab.txtβ vocabularylogistic_regression_classifier.joblibβ trained Logistic Regression classifier
Installation
pip install sentence-transformers scikit-learn joblib
Usage
1. Load the Fine-Tuned SBERT Model
from sentence_transformers import SentenceTransformer
encoder = SentenceTransformer(
"AbdullahImran/Fine-Tuned-SBERT-MiniLM"
)
2. Generate Sentence Embeddings
texts = [
"I have been feeling very anxious lately.",
"The weather is beautiful today."
]
embeddings = encoder.encode(texts)
print(embeddings.shape)
The resulting embeddings have 384 dimensions.
3. Load the Classifier
Download logistic_regression_classifier.joblib from this repository and load it:
import joblib
classifier = joblib.load(
"logistic_regression_classifier.joblib"
)
4. Perform Classification
predictions = classifier.predict(embeddings)
print(predictions)
The classifier uses the following label encoding:
0 β Non-MH
1 β MH
For example:
for text, prediction in zip(texts, predictions):
label = "MH" if prediction == 1 else "Non-MH"
print(f"{text} -> {label}")
Complete Example
from sentence_transformers import SentenceTransformer
import joblib
# Load the fine-tuned encoder
encoder = SentenceTransformer(
"AbdullahImran/Fine-Tuned-SBERT-MiniLM"
)
# Load the trained classifier
classifier = joblib.load(
"logistic_regression_classifier.joblib"
)
# Input text
texts = [
"I have been feeling overwhelmed and anxious recently.",
"I went to the park and enjoyed the sunny weather."
]
# Generate embeddings
embeddings = encoder.encode(texts)
# Classify
predictions = classifier.predict(embeddings)
# Display results
for text, prediction in zip(texts, predictions):
label = "MH" if prediction == 1 else "Non-MH"
print(f"{label}: {text}")
Intended Use
This model is intended for:
- NLP research
- Mental-health text classification research
- Sentence embedding experimentation
- Development and evaluation of binary text classification pipelines
This model is not a medical or clinical diagnostic system and should not be used to diagnose, treat, or make clinical decisions about individuals.
Limitations
Mental-health-related language is highly contextual and can be ambiguous. Model performance depends on the quality, distribution, and representativeness of the training data.
Performance may vary when the model is applied to text from domains, populations, writing styles, or distributions that differ from the training data.
Predictions should therefore be treated as machine-learning outputs rather than clinical assessments.
The Logistic Regression classifier is serialized using joblib.
Loading it may require compatible Python and scikit-learn versions.
Project Context
This model is part of a broader Mental Health NLP project involving:
- Dataset preparation and cleaning
- Mental-health and non-mental-health text classification
- SBERT fine-tuning
- Sentence embedding generation
- Logistic Regression classification
- Deployment-oriented model packaging
The repository contains the final fine-tuned SBERT encoder and the associated downstream classifier used by the classification pipeline.
- Downloads last month
- 60
Model tree for AbdullahImran/Fine-Tuned-SBERT-MiniLM
Base model
nreimers/MiniLM-L6-H384-uncased