Datasets¶
WalledEval allows users to easily load their own datasets from various sources, as follows:
- List of Dictionaries
- CSV File
- JSON File
- HuggingFace Hub Dataset
In addition, the team at WalledEval has compiled a wide array of safety datasets for easy usage with our platform. These include datasets such as HarmBench, WMDP, XSTest and (many subsets in) DecodingTrust. All these datasets have been uploaded on Walled AI's HuggingFace.
Loading HuggingFace Datasets¶
We can load any dataset using the HuggingFaceDataset
class (as imported above), which is a standardized class to generically convert any input format to the standard Arrow Table format used by HuggingFace's datasets
library.
Quick Start¶
We can load the HuggingFaceDataset
class to load datasets as follows:
Here, we load SimpleSafetyTests, a dataset composed of 100 simple prompts to test for safety. We choose the instruct
split defined by us to load samples of unsafe instructions.
Pydantic Support¶
Our library offers a unique method to load datasets. We use pydantic
models to enforce data-type standardization and load datasets based on Aliases. For instance, we can define our own pydantic
models and use HuggingFaceDataset[<type>]
to load data from various sources and standardize the outputs being published.
As you may notice, we did not define the data type above. This is because we would like the leverage the Prompt
datatype (analagous to {"prompt": "..."}
), which is the default setting of HuggingFaceDataset
.
To use a data type, we need to import it from walledeval.types
or define our own.
Loading Multiple Splits and Configurations¶
We can also load datasets with multiple splits and configurations, e.g. SaladBench. By default, the from_hub
method takes in 3 inputs, which are
- HuggingFace Repo Name
- HuggingFace Configuration (default is default
)
- HuggingFace Split (by default searches for train
and test
and then the first alphabetical split if not explicitly stated.
Here, let's try to load SaladBench from our HuggingFace deployment and load the basic prompts.
Loading from External Files¶
Besides loading from the HuggingFace Hub, there's a multitude of other ways to load data. One can easily load a CSV file or a JSON file by providing a list of the files to load. Here, let's see an example where I try to load both data files of CyberSecEval Instruct
and CyberSecEval Autocomplete
from their GitHub repository. (Note the selection of the name.)
Loading a List¶
Of course, this is not the only way to load data. If you have any other inputs, one of the easiest ways to load it into our system is to simply read it into a list of dictionaries and list of strings. Here is an example:
Hence, we are able to load several variety of datasets using our library. If there are any other ways you'd like us to support, do highlight in our GitHub Issues.