class
SequenceResult
[source]
SequenceResult
(sentences
:List
[Sentence
],class_names
:list
=None
) ::SentenceResult
A result class designed for Sequence Classification models
Parameters:
sentences
:typing.List[flair.data.Sentence]
A list of flair `Sentence`'s
class_names
:<class 'list'>
, optionalA potential list of class names
SequenceResult.probabilities
[source]
The probabilities returned for each classification
SequenceResult.predictions
[source]
A list of the best classification for each input
SequenceResult.to_dict
[source]
SequenceResult.to_dict
(detail_level
:DetailLevel
='low'
)
Return self
as a dictionary
Parameters:
detail_level
:<class 'fastcore.basics.DetailLevel'>
, optionalA level of detail to return
Returns:
<class 'dict'>
class
TransformersSequenceClassifier
[source]
TransformersSequenceClassifier
(tokenizer
:PreTrainedTokenizer
,model
:PreTrainedModel
) ::AdaptiveModel
Adaptive model for Transformer's Sequence Classification Model
Parameters:
tokenizer
:<class 'transformers.tokenization_utils.PreTrainedTokenizer'>
A tokenizer object from Huggingface's transformers (TODO)and tokenizers
model
:<class 'transformers.modeling_utils.PreTrainedModel'>
A transformers Sequence Classification model
TransformersSequenceClassifier.load
[source]
TransformersSequenceClassifier.load
(model_name_or_path
:Union
[HFModelResult
,str
])
Class method for loading and constructing this classifier
Parameters:
model_name_or_path
:typing.Union[adaptnlp.model_hub.HFModelResult, str]
A key string of one of Transformer's pre-trained Sequence Classifier Model or a `HFModelResult`
Returns:
<class 'adaptnlp.model.AdaptiveModel'>
TransformersSequenceClassifier.predict
[source]
TransformersSequenceClassifier.predict
(text
:Union
[List
[Sentence
],Sentence
,List
[str
],str
],mini_batch_size
:int
=32
, **kwargs
)
Predict method for running inference using the pre-trained sequence classifier model
Parameters:
text
:typing.Union[typing.List[flair.data.Sentence], flair.data.Sentence, typing.List[str], str]
Sentences to run inference on
mini_batch_size
:<class 'int'>
, optionalMini batch size
kwargs
:<class 'inspect._empty'>
Returns:
typing.List[flair.data.Sentence]
Returns a list of `Sentence` predictions
class
FlairSequenceClassifier
[source]
FlairSequenceClassifier
(model_name_or_path
:str
) ::AdaptiveModel
Adaptive Model for Flair's Sequence Classifier
Parameters:
model_name_or_path
:<class 'str'>
A key string of one of Flair's pre-trained Sequence Classifier Model
example_text = ["This didn't work at all"]*3
sentences = classifier.predict(text=example_text,mini_batch_size=3)
FlairSequenceClassifier.load
[source]
FlairSequenceClassifier.load
(model_name_or_path
:Union
[HFModelResult
,FlairModelResult
,str
])
Class method for loading a constructing this classifier
Parameters:
model_name_or_path
:typing.Union[adaptnlp.model_hub.HFModelResult, adaptnlp.model_hub.FlairModelResult, str]
A key string of one of Flair's pre-trained Sequence Classifier Model or a `HFModelResult`
Returns:
<class 'adaptnlp.model.AdaptiveModel'>
FlairSequenceClassifier.predict
[source]
FlairSequenceClassifier.predict
(text
:Union
[List
[Sentence
],Sentence
,List
[str
],str
],mini_batch_size
:int
=32
, **kwargs
)
Predict method for running inference using the pre-trained sequence classifier model
Parameters:
text
:typing.Union[typing.List[flair.data.Sentence], flair.data.Sentence, typing.List[str], str]
Sentences to run inference on
mini_batch_size
:<class 'int'>
, optionalMini batch size
kwargs
:<class 'inspect._empty'>
Returns:
typing.List[flair.data.Sentence]
A list of predicted `Sentence`s
EasySequenceClassifier.tag_text
[source]
EasySequenceClassifier.tag_text
(text
:Union
[List
[Sentence
],Sentence
,List
[str
],str
],model_name_or_path
:Union
[str
,FlairModelResult
,HFModelResult
]='en-sentiment'
,mini_batch_size
:int
=32
,detail_level
:DetailLevel
='low'
,class_names
:list
=None
, **kwargs
)
Tags a text sequence with labels the sequence classification models have been trained on
Parameters:
text
:typing.Union[typing.List[flair.data.Sentence], flair.data.Sentence, typing.List[str], str]
String, list of strings, `Sentence`, or list of `Sentence`s to be classified
model_name_or_path
:typing.Union[str, adaptnlp.model_hub.FlairModelResult, adaptnlp.model_hub.HFModelResult]
, optionalThe model name key or model path
mini_batch_size
:<class 'int'>
, optionalThe mini batch size for running inference
detail_level
:<class 'fastcore.basics.DetailLevel'>
, optionalA level of detail to return
class_names
:<class 'list'>
, optionalA list of labels
kwargs
:<class 'inspect._empty'>
Returns:
typing.List[flair.data.Sentence]
A list of Flair's `Sentence`'s
EasySequenceClassifier.tag_all
[source]
EasySequenceClassifier.tag_all
(text
:Union
[List
[Sentence
],Sentence
,List
[str
],str
],mini_batch_size
:int
=32
,detail_level
:DetailLevel
='low'
,class_names
:list
=None
, **kwargs
)
Tags text with all labels from all sequence classification models
Parameters:
text
:typing.Union[typing.List[flair.data.Sentence], flair.data.Sentence, typing.List[str], str]
Text input, it can be a string or any of Flair's `Sentence` input formats
mini_batch_size
:<class 'int'>
, optionalThe mini batch size for running inference
detail_level
:<class 'fastcore.basics.DetailLevel'>
, optionalA level of detail to return
class_names
:<class 'list'>
, optionalA list of labels
kwargs
:<class 'inspect._empty'>
Returns:
typing.List[flair.data.Sentence]
A list of Flair's `Sentence`'s