Each module in promptbench can be easily extended. In the following, we provide basic guidelines for customizing your own datasets, models, prompt engineering methods, and evaluation metrics.
Adding new datasets involves two steps:
- Implementing a New Dataset Class: Datasets are supposed to be implemented in
dataload/dataset.pyand inherit from theDatasetclass. For your custom dataset, implement the__init__method to load your dataset. We recommend organizing your data samples as dictionaries to facilitate the input process. - Adding an Interface: After customizing the dataset class, register it in the
DataLoaderclass withindataload.py.
Similar to adding new datasets, the addition of new models also consists of two steps.
- Implementing a New Model Class: Models should be implemented in
models/model.py, inheriting from theLLMModelclass. In your customized model, you should implementself.tokenizerandself.model. You may also customize your ownpredictfunction for inference. If thepredictfunction is not customized, the defaultpredictfunction inherited fromLLMModelwill be used. - Adding an Interface: After customizing the model class, register it in the
_create_modelfunction within theclass LLMModelandMODEL_LISTdictionary in__init__.py.
Adding new methods in prompt engineering is similar to steps of adding new datasets and models.
- Implementing a New Methods Class: Methods should be implemented in \
prompt\_engineeringModule. Firstly, create a new.pyfile for your methods. Then implement two functions:\_\_init\_\_andquery. For unified management, two points need be noticed: 1. all methods should inherits fromBaseclass that has common code for prompt engineering methods. 2. prompts used in methods should be stored inprompts/method\_oriented.py. - Adding an Interface: After implementing a new methods, register it in the
METHOD\_MAPthat is used to map method names to their corresponding class.
New evaluation metrics should be implemented as static functions in class Eval within the metrics module. Similarly, new input/output process functions should be implemented as static functions in class InputProcess and class OutputProcess in the utils module.