# only some entities in task recognized in ner.teach

**URL:** <https://support.prodi.gy/t/only-some-entities-in-task-recognized-in-ner-teach/3664>\
**Category:** Uncategorized\
**Tags:** usage, ner, solved\
**Created:** [November 25, 2020, 9:31am UTC](https://support.prodi.gy/t/only-some-entities-in-task-recognized-in-ner-teach/3664 "2020-11-25T09:31:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![az1373](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@az1373](https://support.prodi.gy/u/az1373)\
**Post date:** [November 25, 2020, 9:31am UTC](https://support.prodi.gy/t/only-some-entities-in-task-recognized-in-ner-teach/3664/1 "2020-11-25T09:31:35Z")

</div>

In a scenario of using ner.teach with only one label,

I know that if only a partial word of an entity is recognized in a task, the task need to be rejected.  
However, I face multiple cases where only one entity is recognized in the task and the others are ignored or will come up in the next task. What should be the decision here to support the active learning model?

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [November 26, 2020, 12:12am UTC](https://support.prodi.gy/t/only-some-entities-in-task-recognized-in-ner-teach/3664/2 "2020-11-26T00:12:11Z")

</div>

Hi! The concept of `ner.teach` is to show you different suggestions, **one entity at a time** , with different confidence scores. So you'll get to focus on one single suggestion at a time, and the accept/reject feedback only applies to the given highlighted span, not the full parse. If the highlighted span is correct, you should accept – if not, you should reject 🙂

If you want to see the model's best prediction of all entities in the current text, check out the `ner.correct` workflow. It doesn't update a model in the loop, but it lets you make manual corrections and create gold-standard training data.

---

<div class="post-metadata">

**Author:** ![az1373](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@az1373](https://support.prodi.gy/u/az1373)\
**Post date:** [November 26, 2020, 8:55am UTC](https://support.prodi.gy/t/only-some-entities-in-task-recognized-in-ner-teach/3664/3 "2020-11-26T08:55:31Z")

</div>

It's clear now. Many thanks.

---

<div class="post-metadata">

**Author:** ![az1373](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@az1373](https://support.prodi.gy/u/az1373)\
**Post date:** [November 27, 2020, 12:24pm UTC](https://support.prodi.gy/t/only-some-entities-in-task-recognized-in-ner-teach/3664/4 "2020-11-27T12:24:56Z")

</div>

Hi @ines  
I have a large corpus with most of the text containing no entities. Currently, I don't get any true negative examples because of setting the all\_examples=Fasle in ner.manual (PatternMatcher). The model is performing well, but Is this a good practice?

I could do so for ner.manual, but would it be also possible for the ner.correct?

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [November 30, 2020, 12:36am UTC](https://support.prodi.gy/t/only-some-entities-in-task-recognized-in-ner-teach/3664/5 "2020-11-30T00:36:02Z")

</div>

Focusing on the examples that contain given words and phrases you're interested is fine for bootstrapping an initial training set IMO and getting over the "cold start problem", especially if your data is a bit imbalanced. If there's no shortage of examples with no entities, you definitely want to make sure that you're getting enough examples _with_ entities in there that your model can learn from. Once you're ready to train, you can always mix in some texts without entities (which should be really quick to annotate as well, because you can do it as a simple yes/no selection).

---

<div class="post-metadata">

**Author:** ![az1373](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@az1373](https://support.prodi.gy/u/az1373)\
**Post date:** [November 30, 2020, 8:27am UTC](https://support.prodi.gy/t/only-some-entities-in-task-recognized-in-ner-teach/3664/6 "2020-11-30T08:27:11Z")

</div>

Many thanks for your feedback!  
So, is there a way to only get the highlighted examples in ner.correct recipe as well?  
There is no PatternMatchter, so I can't use the "all\_examples=False" workaround.

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [November 30, 2020, 9:50am UTC](https://support.prodi.gy/t/only-some-entities-in-task-recognized-in-ner-teach/3664/7 "2020-11-30T09:50:18Z")

</div>

Yes, the `ner.correct` recipe will always show you all examples by default, including those with no predictions made by the model (which is also a prediction in itself).

But you could write a simple filter function that only sends out examples with spans:

```python
def filter_examples(stream):
    for eg in stream:
        if eg.get("spans", []):
            yield eg

```

And then you can apply that at the end of your recipe, after the predictions have been added:

```python
stream = filter_examples(stream)

```

---

<div class="post-metadata">

**Author:** ![az1373](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@az1373](https://support.prodi.gy/u/az1373)\
**Post date:** [November 30, 2020, 12:23pm UTC](https://support.prodi.gy/t/only-some-entities-in-task-recognized-in-ner-teach/3664/8 "2020-11-30T12:23:24Z")

</div>

Great. That's really helpful.  
It works just as expected now.  
Many thnaks!
