Skip to content

Using pipeline('ner'), partial tokens returned when grouped_entities=True #5730

Description

@JamesDeAntonis

🐛 Bug

Information

Model I am using (Bert, XLNet ...): pipeline('ner', grouped_entities=True)

Language I am using the model on (English, Chinese ...): English

The problem arises when using:

  • the official example scripts: (give details below)
  • my own modified scripts: (give details below)

The tasks I am working on is:

  • an official GLUE/SQUaD task: (give the name)
  • my own task or dataset: (give details below)

To reproduce

Steps to reproduce the behavior:

from transformers import pipeline
ner = pipeline('ner', grouped_entities=True)
ner("the sapodilla tree is native to Central America")

Expected behavior

The output says that "##di" is one of the named entities. It doesn't seem like partial tokens should possibly be returned as predicted named entities. Instead, I imagine that the desired result is that either the entire word "sapodilla" is determined to be an entity group or nothing at all. Is this a bug or was this quirk consciously chosen to be allowed?

As a side note, another similar quirk here is that something like "U.S." occasionally gives just "U" or "S" as individual named entities, where "U.S." is desired. I consider this related to the above issue.

Environment info

  • transformers version: 3.0.2
  • Platform: Linux-5.3.0-1032-azure-x86_64-with-glibc2.10
  • Python version: 3.8.1
  • PyTorch version (GPU?): 1.5.1 (False)
  • Tensorflow version (GPU?): not installed (NA)
  • Using GPU in script?: no
  • Using distributed or parallel set-up in script?: no

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions