hugging_face_ner
Hugging Face Named Entity Recognition (NER) Algorithm.
Classes
HuggingFaceNERInference
class HuggingFaceNERInference( datastructure: DataStructure, model_id: str, batch_size: int = 16, aggregation_strategy: _AggregationStrategy = 'simple', seed: int = 42, access_token: Optional[str] = None, postprocessors: Optional[list[dict[str, Any]]] = None,):Inference for pre-trained Hugging Face Named Entity Recognition (NER) models.
This algorithm extracts named entities from text using HuggingFace's token-classification pipeline.
Arguments
- **
**kwargs**: Additional keyword arguments. aggregation_strategy: Strategy to aggregate tokens into entities. Options are: "simple", "first", "average", "max", "none". Defaults to "simple".batch_size: The batch size for inference. Defaults to 16.datastructure: The data structure to use for the algorithm.model_id: HuggingFace model identifier for the NER model.seed: Sets the seed of the algorithm for reproducibility. Defaults to 42.
Attributes
aggregation_strategy: The token aggregation strategy.batch_size: The batch size for inference.class_name: The name of the algorithm class.fields_dict: A dictionary mapping all attributes that will be serialized in the class to their marshmallow field type. (e.g. fields_dict ={"class_name": fields.Str()}).model_id: The HuggingFace model identifier being used.nested_fields: A dictionary mapping all nested attributes to a registry that contains class names mapped to the respective classes. (e.g. nested_fields ={"datastructure": datastructure.registry})seed: The random seed for reproducibility.
Variables
- static
fields_dict : ClassVar[dict[str, marshmallow.fields.Field]]
Methods
create
def create(self, role: Union[str, Role], **kwargs: Any) ‑> Any:Create an instance representing the role specified.
modeller
def modeller( self, *, context: ProtocolContext, **kwargs: Any,) ‑> bitfount.federated.algorithms.hugging_face_algorithms.base._HFModellerSide:Returns the modeller side of the HuggingFaceNERInference algorithm.
worker
def worker( self, *, context: ProtocolContext, **kwargs: Any,) ‑> bitfount.federated.algorithms.hugging_face_algorithms.hugging_face_ner._WorkerSide:Returns the worker side of the HuggingFaceNERInference algorithm.