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.py
and inherit from theDataset
class. 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
DataLoader
class 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
dataload/model.py
, inheriting from theLLMModel
class. In your customized model, you should implementself.tokenizer
andself.model
. You may also customize your ownpredict
function for inference. If thepredict
function is not customized, the defaultpredict
function inherited fromLLMModel
will be used. - Adding an Interface: After customizing the model class, register it in the
_create_model
function within theclass LLMModel
in__init__.py
.
Adding new methods in prompt engineering is similar to steps of C.1 and C.2.
- Implementing a New Methods Class: Methods should be implemented in \
prompt\_engineering
Module. Firstly, create a new.py
file for your methods. Then implement two functions:\_\_init\_\_
andquery
. For unified management, two points need be noticed: 1. all methods should inherits fromBase
class 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\_MAP
that 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.