New strategies additionΒΆ
- An AL query strategy should be designed as a function that:
Receives 3 positional arguments and additional strategy kwargs:
modelof inherited classTransformersBaseWrapperorPytorchEncoderWrapperorFlairModelWrapper: model wrapper;X_poolof classDatasetorTransformersDataset: dataset with the unlabeled instances;n_instancesof classint: number of instances to query;kwargs: additional strategy-specific arguments.
Outputs 3 objects in the following order:
query_idxof classarray-like: array with the indices of the queried instances;queryof classDatasetorTransformersDataset: dataset with the queried instances;uncertainty_estimatesof 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