diff --git a/src/transformers/pipelines/token_classification.py b/src/transformers/pipelines/token_classification.py index a32a9aa9ad8b..42c5d927079c 100644 --- a/src/transformers/pipelines/token_classification.py +++ b/src/transformers/pipelines/token_classification.py @@ -503,7 +503,7 @@ def group_sub_entities(self, entities: List[dict]) -> dict: entities (`dict`): The entities predicted by the pipeline. """ # Get the first entity in the entity group - entity = entities[0]["entity"].split("-")[-1] + entity = entities[0]["entity"].split("-", 1)[-1] scores = np.nanmean([entity["score"] for entity in entities]) tokens = [entity["word"] for entity in entities]