Datasets:
Download code/domain_adapter/self_esteem.py from chiron-group/chiron-data: direct link, hf CLI and curl.
- Browser
- Download file 1.55 kB
-
https://huggingface.co/datasets/chiron-group/chiron-data/resolve/main/code/domain_adapter/self_esteem.py
- Command line
-
hf download hf://datasets/chiron-group/chiron-data/code/domain_adapter/self_esteem.py
-
curl -L -o self_esteem.py https://huggingface.co/datasets/chiron-group/chiron-data/resolve/main/code/domain_adapter/self_esteem.py
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)}" | |