Skip to content

pixano_inference.models.ner

NER (Named Entity Recognition) model base class.

The I/O types live in :mod:pixano_inference.schemas.ner and are re-exported here so from pixano_inference.models.ner import NERInput keeps working.

NERModel(config)

Bases: InferenceModel[NERInput, NEROutput]

Base class for named entity recognition models.

predict receives a :class:NERInput (the text to analyse) and returns a :class:NEROutput (the recognised entities). The interface property, when overridden, returns a :class:NERInterface: the entity types the model can return.

Example
@register_model("my-ner")
class MyNER(NERModel):
    def load_model(self):
        self.model = load_weights(self.config.model_params["path"])

    def predict(self, input: NERInput) -> NEROutput:
        return NEROutput(entities=[...])
Source code in pixano_inference/models/base.py
def __init__(self, config: ModelDeploymentConfig) -> None:
    """Initialize the model with deployment config.

    Args:
        config: Model deployment configuration.
    """
    self._config = config