New strategies additionΒΆ
- An AL query strategy should be designed as a function that:
Receives 3 positional arguments and additional strategy kwargs:
model
of inherited classTransformersBaseWrapper
orPytorchEncoderWrapper
orFlairModelWrapper
: model wrapper;X_pool
of classDataset
orTransformersDataset
: dataset with the unlabeled instances;n_instances
of classint
: number of instances to query;kwargs
: additional strategy-specific arguments.
Outputs 3 objects in the following order:
query_idx
of classarray-like
: array with the indices of the queried instances;query
of classDataset
orTransformersDataset
: dataset with the queried instances;uncertainty_estimates
of classnp.ndarray
: uncertainty estimates of the instances fromX_pool
. The higher the value - the more uncertain the model is in the instance.
The function with the strategy should be named the same as the file where it is placed (e.g. function def my_strategy
inside a file path_to_strategy/my_strategy.py
).
Use your strategy, setting al.strategy=PATH_TO_FILE_YOUR_STRATEGY
in the experiment config.
The example is presented in examples/benchmark_custom_strategy.ipynb