how to improve spaCy entity linking training times (wiki_entity_linking/wikidata_train_entity_linker.py))
Hi,
On #4511 @svlandeg reported a training time of 10h per epoch with -t 50000 and 16GB RAM. I'm on a computer with 135GB RAM, but I am seeing a training time of 36h per epoch. I'm guessing the bottleneck here is CPU, which $ top -p <PID> reports as being 100% utilized. I am however on a multicore (2 sockets, 8 cores @ 3.2GHz) system, and I'm only seeing one python process running on one logical core. Is there some way to speed up this training process?
Your Environment
- spaCy version: 2.2.4
- Platform: Linux-4.15.0-76-generic-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.6.9
Can you share the exact commands you ran for creating the KB and training the EL script?
Can you share the exact commands you ran for creating the KB and training the EL script?
Thank you for your reply.
Following the guide here: https://github.com/explosion/spaCy/tree/master/bin/wiki_entity_linking, I ran:
KB creation: python3 wiki_entity_linking/wikidata_pretrain_kb.py ./latest-all.json.bz2 ./enwiki-latest-pages-articles-multistream.xml.bz2 ./wikidata_pretrain/ "en_core_web_lg"
Training: python3 wiki_entity_linking/wikidata_train_entity_linker.py ./wikidata_pretrain/ -o ./wikidata_el/ -t 50000 -d 10000
I removed folder structure from the commands for clarity. I should also note, I ran the command from a Jupyter Notebook. I don't know if that makes a difference.
Ok, so I think there's a few possible options for you to speed up further:
- Restrict the
gold_entities.jsonlfile to only include 50000 lines. Strictly speaking this shouldn't really influence the performance, because it shouldn't read the additional lines. But it's worth a try. - Use much fewer development articles, like
-d 100or-d 1000. These are not actually used for any training, just to output a dev performance in between epochs. - I originally removed some NER lables I thought weren't very sensible to run NEL on:
-l CARDINAL,DATE,MONEY,ORDINAL,QUANTITY,TIME,PERCENT
Ok, so I think there's a few possible options for you to speed up further:
* Restrict the `gold_entities.jsonl` file to only include 50000 lines. Strictly speaking this shouldn't really influence the performance, because it shouldn't read the additional lines. But it's worth a try. * Use much fewer development articles, like `-d 100` or `-d 1000`. These are not actually used for any training, just to output a dev performance in between epochs. * I originally removed some NER lables I thought weren't very sensible to run NEL on: `-l CARDINAL,DATE,MONEY,ORDINAL,QUANTITY,TIME,PERCENT`
Thank you - I will implement these suggestions and update.
Your last point on NER labels made me aware that there's no label for nouns. Would this imply that entity linking like "series" to "Television series" (Q5398426) or "dogs" to "Dog" (Q144) is not supported at the moment?
The NEL algorithm works on any entity that is tagged as a named entity (NE) by the NER step, cf also https://spacy.io/api/annotation#named-entities. Common nouns like "series" is not usually considered an NE. But in prinicple, if you change/retrain the NER component, the Wikipedia training scripts would use it.
I'll go ahead and close this for now as there's not really an immediate action point for us, but feel free to post follow-up questions, I'll keep following this thread.
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.