# How to make spacy lemmatization process fast?

I am applying spacy lemmatization on my dataset, but already 20-30 mins passed and the code is still running.

Is there anyway to make it faster? Is there any option to do this process using GPU?

My dataset size is 20k number of rows & 3 columns

• Are you using spacy.io/api/lemmatizer? I don't know how lemmatization works, but have you tried to parallelize your code? For example, can you split your dataset into sub-datasets and perform lemmatization on each subset on its separate CPU core or GPU?
– nbro
Jun 17 '20 at 14:48

https://spacy.io/api/lemmatizer just uses lookup tables and the only upstream task it relies on is POS tagging, so it should be relatively fast. For large amounts of text, SpaCy recommends using nlp.pipe, which can work in batches and has built in support for multiprocessing (with the n_process keyword), rather than than simply nlp.

Also, make sure you disable any pipeline elements that you don't plan to use, as they'll just waste processing time. If you're only doing lemmatization, you'll pass disable=["parser", "ner"] to the nlp.pipe call.

Example code that takes all of the above into account is below.

import spacy
$$$$
`