Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

FEAT: CBT-Bench Dataset #888

wants to merge 2 commits into from

Conversation

sravan0446
Copy link

CBT-Bench Dataset Integration for PyRIT

This pull request introduces support for the CBT-Bench dataset in PyRIT. The CBT-Bench dataset is a benchmark designed to evaluate the alignment and therapeutic safety of Large Language Models (LLMs) in the context of Cognitive Behavioral Therapy (CBT). By integrating this dataset, PyRIT can analyze psychotherapy-related prompts and identify potential risks, including cognitive distortions, harmful self-beliefs, and other vulnerabilities.

Key Changes

  • Added a new function fetch_cbt_bench_dataset to fetch and process the dataset.
  • Mapped dataset fields (situation, core_belief_fine_grained) to PyRIT's SeedPrompt model.
  • Included default configuration (core_fine_seed) with support for other configurations.
  • Updated documentation and comments to explain the purpose and usage of the dataset.

Related Issue

Closes: #865
Tagging @romanlutz for review.

Tests and Documentation

  • Tests: Unit tests have not been added. They can be included in a subsequent commit within the same pull request if requested by the reviewer.
  • Documentation: Inline documentation has been updated. The README has not been updated yet but will be addressed if deemed necessary.
  • JupyText: Not applicable, as this contribution focuses on dataset integration rather than API or documentation changes.

References

Citation

@article{zhang2024cbt,
  title={CBT-Bench: Evaluating Large Language Models on Assisting Cognitive Behavior Therapy},
  author={Zhang, Mian and Yang, Xianjun and Zhang, Xinlu and Labrum, Travis and Chiu, Jamie C and Eack, Shaun M and Fang, Fei and Wang, William Yang and Chen, Zhiyu Zoey},
  journal={arXiv preprint arXiv:2410.13218},
  year={2024}
}

@sravan0446
Copy link
Author

@microsoft-github-policy-service agree

Copy link
Contributor

@romanlutz romanlutz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also look at api.rst (I think that's the name) because it should list this dataset along with the others from the datasets module. There may be some missing there, so if you want you can compare and fill in the gaps. Thank you!

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").
Copy link
Contributor

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.

SeedPrompt(
value=item["situation"], # Use 'situation' as the main prompt text
data_type="text",
name=f"CBT-Bench-{item['id']}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would these overlap between the datasets (based on config value)? If so we need to distinguish

data_type="text",
name=f"CBT-Bench-{item['id']}",
dataset_name="CBT-Bench",
harm_categories=item.get("core_belief_fine_grained", []),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the values for this? I just want to make sure they make sense as harm categories

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@romanlutz you can see them here FYI

But they look like this:

[ 
       "I am powerless, weak, vulnerable", 
       "I am needy", 
       "I am out of control" 
]

I am not certain if they exactly align with our harm categories

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These ones certainly don't.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say these broadly fall under psycho-social harms. @jbolor21 was that what you thought when you added the item?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! I was thinking broadly under psycho-social harms!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The labels they have are very specific to CBT and not quite aligned with our categories so just lumping them under psycho-social harms would probably make the most sense!


seed_prompts = [
SeedPrompt(
value=item["situation"], # Use 'situation' as the main prompt text
Copy link
Contributor

Choose a reason for hiding this comment

The 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 🙂

Copy link
Contributor

Choose a reason for hiding this comment

The 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!

@romanlutz
Copy link
Contributor

@sravan0446 are you still interested in addressing the issues? 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FEAT: CBT-Bench Dataset
4 participants