chiron-data / code /domain_adapter /self_esteem.py
henry-yeh's picture htr234234's picture
Chiron data release
1b86964
Raw History Blame Contribute Delete
1.55 kB
"""Self-esteem (LoST) runtime adapter.
Source: Reddit posts labeled by clinical raters for low self-esteem screening.
"""
from __future__ import annotations
from pathlib import Path
from domain_adapter.base import DomainAdapter, Prediction, Sample
class SelfEsteemAdapter(DomainAdapter):
name = "self_esteem"
def data_source(self) -> str:
return "LoST: A Mental Health Dataset of Low Self-esteem in Reddit Posts"
def get_sample_id(self, sample: Sample) -> str:
return str(sample.extra_info["source_row_index"])
def default_input_path(self) -> Path:
return Path("data/raw/self-esteem/qa_jsonl/train.jsonl")
def record_context(self) -> str:
return "Below are Reddit posts written by this person."
def select_target_predictions(
self,
sample: Sample,
*,
seed: int,
sample_index: int,
max_questions: int,
min_questions: int = 1,
) -> list[Prediction]:
return list(sample.predictions[:1])
def format_question_block(self, questions: list[str]) -> str:
if len(questions) != 1:
raise ValueError(f"Self-esteem direct format expects one question, got {len(questions)}")
return questions[0].strip()
def format_answer_block(self, predictions: list[Prediction]) -> str:
if len(predictions) != 1:
raise ValueError(f"Self-esteem direct format expects one answer, got {len(predictions)}")
return f"Option {self.format_ground_truth(predictions[0].ground_truth)}"