CoolFace
Modelpublic

tomatosauce-hg/sentiment-analysis-for-psychological-profiling

sourceHugging Faceupdated 10mo agoView on Hugging Face
0likes14downloads
Model Card

Sentiment Analysis for Psychological Profiling (EN/TL/Taglish)

Model ID: tomatosauce-hg/sentiment-analysis-for-psychological-profiling Base model: `xlm-roberta-base` (multilingual)

A fine-tuned XLM-R sentence-level sentiment classifier targeted at short free-text responses to psychological questionnaire items. It handles English, Tagalog (Filipino), and Taglish (code-mixed) answers and returns one of three labels:

  • 1 → POS (positive/hopeful/supportive tone)
  • 0 → NEG (negative/distressed/adverse tone)
  • 2 → NEU (neutral/mixed/descriptive tone)
⚠️ Not a clinical tool. This model estimates sentiment only. Do not use it to diagnose or screen for mental health conditions.

Intended Use

  • Rapid sentiment scoring of open-ended questionnaire responses (e.g., “How do you view yourself?”, “How do you respond to life changes?”).
  • Works best when you prepend the question to the answer during inference (see “Input formatting”).

How to use

1) Quick pipeline

python
from transformers import pipeline

model_id = "tomatosauce-hg/sentiment-analysis-for-psychological-profiling"

clf = pipeline(
    "text-classification",
    model=model_id,
    tokenizer=model_id,
    truncation=True,
    top_k=None,          # set to None to return only top label
    return_all_scores=False
)

text = "Minsan nahihirapan pero kaya pa naman, sinusubukan kong mag-adjust."
print(clf(text))
# [{'label': 'POS', 'score': 0.83}]  (example)

2) With question + answer (recommended)

python
from transformers import pipeline

model_id = "tomatosauce-hg/sentiment-analysis-for-psychological-profiling"
clf = pipeline("text-classification", model=model_id, tokenizer=model_id, truncation=True)

question = "How do you usually react to life changes? How do you adjust?"
answer   = "Nai-stress ako sa simula, pero inaayos ko routine ko at humihinga muna."
qa_text  = f"[Q] {question}\n[A] {answer}"

print(clf(qa_text))

3) Raw model

python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

model_id = "tomatosauce-hg/sentiment-analysis-for-psychological-profiling"
tok = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)

inputs = tok("Okay lang, unti-unti kong tinatanggap at inaayos.", return_tensors="pt", truncation=True)
logits = model(**inputs).logits
pred = torch.argmax(logits, dim=-1).item()
id2label = model.config.id2label  # {'0':'POS','1':'NEG','2':'NEU'}
print(id2label[str(pred)])

Input formatting

The model was trained on answers to specific psychosocial questions. For best results:

  • If you know the prompt/question, feed `[Q] ... [A] ...`:
  [Q] How do you view the world?
  [A] Generally positive; may challenges pero kakayanin.
  • If you don’t have the question, passing the answer text alone still works.

Max length: 256 WordPiece tokens (XLM-R). Most responses are well under this length.


Training data

  • Size: ~1,000 synthetic examples (after cleaning/deduping and split: train 733 / val 158 / test 158).
  • Languages: English, Tagalog, Taglish (code-mixed).
  • Source: Synthetic generation from a fixed questionnaire set.
  • Privacy: No real user data. Each sample is synthetic and non-identifiable.

Training details

  • Base: xlm-roberta-base
  • Objective: 3-way sentiment classification (POS/NEG/NEU)
  • Tokenizer: XLM-R SentencePiece
  • Max length: 256
  • Batch sizes: train 16, eval 32
  • Optimizer / LR: AdamW, 2e-5
  • Epochs: 6 (early stopping enabled)
  • Warmup: ~6% of total steps
  • Class weighting: inverse frequency (to stabilize slight skew)
  • Seed: 42
  • Hardware: single-GPU/single-machine (modest)

Evaluation (held-out test set, n=158)

  • Accuracy: 0.82
  • Macro-F1: 0.82

Per-class (precision / recall / F1):

LabelPRF1Support
POS (1)0.900.850.8855
NEG (0)0.790.880.8351
NEU (2)0.780.730.7552

Observations

  • NEU is the hardest class (common in sentiment tasks).
  • POS/NEG are strong and balanced.
  • Performance is solid for a first pass on synthetic data; expect gains after fine-tuning on small amounts of real data from your domain.

Limitations & risks

  • Synthetic domain gap: Real client language may differ; expect some drift.
  • Not a diagnostic tool: This model measures tone, not mental health status.
  • Code-mixing edge cases: Extremely slangy or heavily code-mixed text may reduce confidence.
  • Question dependence: Including the question often improves robustness.

Reproducing

This repo includes:

  • config.json, model.safetensors, tokenizer files
  • You can fine-tune further with standard Hugging Face Trainer on your dataset (same id2label/label2id mapping).

Label mapping

json
"id2label": {"1": "POS", "0": "NEG", "2": "NEU"},
"label2id": {"POS": 1, "NEG": 0, "NEU": 2}

Example batch inference

python
from transformers import pipeline

model_id = "tomatosauce-hg/sentiment-analysis-for-psychological-profiling"
clf = pipeline("text-classification", model=model_id, tokenizer=model_id, truncation=True)

batch = [
    "Okay naman ako physically; minsan pagod lang.",
    "Di ko gusto ang nangyayari, sobrang nakakapagod na.",
    "Neutral lang—may good at bad, pero tuloy lang."
]
print([x['label'] for x in clf(batch)])

Citation

If you use this model, please cite:

@software{tomatosauce_hg_sentiment_psych_2025,
  title  = {Sentiment Analysis for Psychological Profiling (EN/TL/Taglish)},
  author = {tomatosauce-hg},
  year   = {2025},
  url    = {https://huggingface.co/tomatosauce-hg/sentiment-analysis-for-psychological-profiling}
}

License

  • Base model: xlm-roberta-base (MIT).
  • Fine-tuned weights: Apache-2.0 ---

Contact / Issues

Open an issue on the model repo if you hit problems or have improvement ideas (e.g., real-data fine-tuning, calibration, question-aware prompts).