-
Notifications
You must be signed in to change notification settings - Fork 578
FEAT: CBT-Bench Dataset #888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT license. | ||
|
||
from datasets import load_dataset | ||
|
||
from pyrit.models import SeedPromptDataset | ||
from pyrit.models.seed_prompt import SeedPrompt | ||
|
||
|
||
def fetch_cbt_bench_dataset(config_name: str = "core_fine_seed") -> SeedPromptDataset: | ||
""" | ||
Fetch CBT-Bench examples for a specific configuration and create a SeedPromptDataset. | ||
|
||
Args: | ||
config_name (str): The configuration name to load (default is "core_fine_seed"). | ||
|
||
Returns: | ||
SeedPromptDataset: A SeedPromptDataset containing the examples. | ||
|
||
Note: | ||
For more information about the dataset and related materials, visit: \n | ||
https://huggingface.co/datasets/Psychotherapy-LLM/CBT-Bench \n | ||
Related to Cognitive Behavioral Therapy benchmarking and psychological safety tasks. | ||
|
||
Citation: | ||
Zhang, M., Yang, X., Zhang, X., Labrum, T., Chiu, J. C., Eack, S. M., Fang, F., Wang, W. Y., & Chen, Z. Z. (2024). | ||
CBT-Bench: Evaluating Large Language Models on Assisting Cognitive Behavior Therapy. | ||
arXiv preprint arXiv:2410.13218. | ||
|
||
Authors: | ||
Mian Zhang, Xianjun Yang, Xinlu Zhang, Travis Labrum, Jamie C. Chiu, Shaun M. Eack, | ||
Fei Fang, William Yang Wang, Zhiyu Zoey Chen | ||
""" | ||
try: | ||
# Load the dataset with the specified configuration | ||
data = load_dataset("Psychotherapy-LLM/CBT-Bench", config_name, split="train") | ||
except Exception as e: | ||
raise ValueError(f"Error loading CBT-Bench dataset with config '{config_name}': {e}") | ||
|
||
seed_prompts = [ | ||
SeedPrompt( | ||
value=item["situation"], # Use 'situation' as the main prompt text | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After looking at the dataset, I would say the situation + thoughts together should be the prompt. Let's ask @jbolor21 who suggested adding the dataset to chime in 🙂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I think adding the thoughts is important to the situation since these two are what are extracted from the original text! |
||
data_type="text", | ||
name=f"CBT-Bench-{item['id']}", | ||
|
||
dataset_name="CBT-Bench", | ||
harm_categories=item.get("core_belief_fine_grained", []), | ||
|
||
description=( | ||
"CBT-Bench is a benchmark dataset designed to evaluate the alignment and therapeutic safety of " | ||
"Large Language Models (LLMs) in the context of Cognitive Behavioral Therapy (CBT)." | ||
), | ||
source="https://huggingface.co/datasets/Psychotherapy-LLM/CBT-Bench", | ||
authors=[ | ||
"Mian Zhang", | ||
"Xianjun Yang", | ||
"Xinlu Zhang", | ||
"Travis Labrum", | ||
"Jamie C. Chiu", | ||
"Shaun M. Eack", | ||
"Fei Fang", | ||
"William Yang Wang", | ||
"Zhiyu Zoey Chen" | ||
], | ||
) | ||
for item in data | ||
] | ||
|
||
return SeedPromptDataset(prompts=seed_prompts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should tell us about the other options and the type should be Literal[...] with the individual options listed.