spaCy icon indicating copy to clipboard operation
spaCy copied to clipboard

Can't create a custom model for detecting "Organizations"

Open lakshay1296 opened this issue 8 years ago • 3 comments

Shouldn't my model produce the same entities, like it did for example mentioned in spaCy documentation? And can we do modifications to the existing "en_core_web_sm" model? I want the model to just recognize 'ORG' with 'Inc', 'Ltd', 'LLC' etc. The existing model is good, but it is also giving some junk values. For example there is a term 'AGREEMENT' in doc, the model is giving 'AGREEMENT' as 'ORG'. How can I avoid that? I'll be attaching a screenshot for your reference. Thanks for the help. In the screenshot, we can see that "Employee Assistance Program" is not an organization. output

Your Environment

  • Operating System: Windows 10
  • Python Version Used: python- 2.7 (Anaconda2)
  • spaCy Version Used: 2.0.12
  • Environment Information: Pycharm Community

I have attached the code below. Model.txt

lakshay1296 avatar Sep 27 '18 09:09 lakshay1296

The process of recognising named entities is statistical – so the English model has no deeper knowledge of what a an "organization" is or how it's defined. It only predicts what label is most likely in this context and which span to apply it to, based on the data the model was trained on.

In this case, "Employee Assistance Program" does look pretty similar to an organization, and it may have been used in a similar context, too. Similarly, a string all in caps may also score very high for an ORG in certain contexts, because it's very similar to other entity names where that label applies. Statistical models aren't perfect – even a state-of-the-art model that's 90% accurate will make a mistake on every 10th prediction.

It's also important to keep in mind that the pre-trained models distributed with the library are baseline models that were tuned for the best possible compromise of speed, size, and accuracy and make it easy to get started building your own systems. You almost always want to adjust the model to your specific domain if extracting named entities is important to you. You can find more details on this in the documentation on training and updating models.

In spaCy v2.0, all models can be updated with more examples, so you can use the en_core_web_sm as the baseline model and show it more examples of entities in context that it previously got wrong to improve it. Make sure to always include examples that the model previously got right. Otherwise, it may overfit on the new data and "forget" what it previously knew, resulting in worse predictions overall.

ines avatar Sep 27 '18 10:09 ines

Thanks!

lakshay1296 avatar Sep 27 '18 10:09 lakshay1296

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Oct 27 '18 11:10 lock[bot]