# patterns in ner.match and ner.teach

**URL:** https://support.prodi.gy/t/patterns-in-ner-match-and-ner-teach/1589
**Category:** Uncategorized
**Tags:** solved, usage, ner
**Created:** [May 28, 2019, 7:37pm UTC](https://support.prodi.gy/t/patterns-in-ner-match-and-ner-teach/1589 "2019-05-28T19:37:30Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![andrewx24](https://avatars.discourse-cdn.com/v4/letter/a/9d8465/32.png) [@andrewx24](https://support.prodi.gy/u/andrewx24)
#### Post date: [May 28, 2019, 7:37pm UTC](https://support.prodi.gy/t/patterns-in-ner-match-and-ner-teach/1589/1 "2019-05-28T19:37:30Z")

</div>

Hello,

I was wondering if anyone knows what the difference is between using patterns for ner.teach and ner.match?

Thanks

---

<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: [May 29, 2019, 8:33am UTC](https://support.prodi.gy/t/patterns-in-ner-match-and-ner-teach/1589/2 "2019-05-29T08:33:08Z")

</div>

Hi! You might find this answer on the following thread useful: [What are the key differences between ner. teach and ner.match ?](https://support.prodi.gy/t/what-are-the-key-differences-between-ner-teach-and-ner-match/877)

> [@What are the key differences between ner. teach and ner.match ?](https://support.prodi.gy/t/what-are-the-key-differences-between-ner-teach-and-ner-match/877/2):
>
> `ner.teach` uses a statistical model in the loop, updates it with your accept/reject answers as you annotate, and as the model learns about the entities, it combines the pattern matches with model suggestions. To make the active learning work, `ner.teach` also uses a sorter to prioritise examples with a prediction closest to `0.5` , i.e. the ones that the model is most uncertain about. This means you won’t necessarily get to see all examples and only a selection. Running the recipe with patterns helps you get over the so-called “cold-start problem”, i.e. training a new label from scratch that the model doesn’t know anything about yet. In order for the model to make meaningful suggestions, it needs to have seen enough positive examples – and that’s where the patterns come in. If the model already predicts _something_ for the entities you want to train, you can also use `ner.teach` without patterns and simply accept / reject the model’s suggestions.
> 
> `ner.match` on the other hand doesn’t use or update the statistical model – it only finds pattern matches in your text and will ask you for feedback on them as they come in, in the exact order, without skipping any. It can be a useful recipe if you already have a large terminology list or other patterns describing the entities you’re looking for, and you quickly want to collect data, without having to highlight anything by hand. It also lets you write more general patterns that potentially produce false positives (like, “two upperdcase tokens”), move through them quickly and collect both positive _and_ negative examples for this entity type. That can be super valuable – you might see significantly better results if your data includes both “perfect” examples of entity types, as well as examples of spans that look very similar but are _not_ part of the entity type.

So, in terms of the use of patterns, this means that `ner.teach` uses patterns to bootstrap the annotation process and doesn't necessarily show you all the matches. It just tries to produce enough positive examples so that the model can kick in. `ner.match` uses the patterns to show you all matches in your data, one by one, as they come in.

---

<div class="post-metadata">

### Author: ![Anji.Vaidyula](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@Anji.Vaidyula](https://support.prodi.gy/u/Anji.Vaidyula)
#### Post date: [July 10, 2019, 12:34pm UTC](https://support.prodi.gy/t/patterns-in-ner-match-and-ner-teach/1589/3 "2019-07-10T12:34:35Z")

</div>

Quick question on ner.match - if it doesn’t use a model or update a model, why does it take a model as input?

---

<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: [July 10, 2019, 12:54pm UTC](https://support.prodi.gy/t/patterns-in-ner-match-and-ner-teach/1589/4 "2019-07-10T12:54:07Z")

</div>

spaCy’s `Matcher` and `PhraseMatcher` need a tokenizer and a vocab so they can do token-based matching. A model package is the easiest way to pass that in, and it also lets you provide custom models with your own tokenization etc. 🙂
