This PR adds an optional parameter to the SequenceLabeler.predict method in the SequenceLabeler class. The new parameter, spans, is a list of dictionaries where each dictionary contains the start and end indices of the predefined spans. This feature allows for predicting the labels of predefined spans in scenarios where the segmentation of entities is already known.
Summary of Changes
Modified the SequenceLabeler class in finetune/target_models/sequence_labeling.py to include the spans parameter in the predict method.
Updated the predict method to handle the case when the spans parameter is provided. The method now only makes predictions for the provided spans.
Updated the _predict and _predict_decode methods in finetune/target_models/sequence_labeling.py to handle the case when the spans parameter is provided.
Updated the sequence_labeler method in finetune/nn/target_blocks.py to handle the case when the spans parameter is provided.
Fixes #1.
To checkout this PR branch, run the following command in your terminal:
git checkout sweep/add-predict-spans-param
To get Sweep to edit this pull request, leave a comment below or in the code. Leaving a comment in the code will only modify the file but commenting below can change the entire PR.
Description
This PR adds an optional parameter to the
SequenceLabeler.predict
method in theSequenceLabeler
class. The new parameter,spans
, is a list of dictionaries where each dictionary contains the start and end indices of the predefined spans. This feature allows for predicting the labels of predefined spans in scenarios where the segmentation of entities is already known.Summary of Changes
SequenceLabeler
class infinetune/target_models/sequence_labeling.py
to include thespans
parameter in thepredict
method.predict
method to handle the case when thespans
parameter is provided. The method now only makes predictions for the provided spans._predict
and_predict_decode
methods infinetune/target_models/sequence_labeling.py
to handle the case when thespans
parameter is provided.sequence_labeler
method infinetune/nn/target_blocks.py
to handle the case when thespans
parameter is provided.Fixes #1.
To checkout this PR branch, run the following command in your terminal:
To get Sweep to edit this pull request, leave a comment below or in the code. Leaving a comment in the code will only modify the file but commenting below can change the entire PR.