Skip to content

Feeding long(ish) documents leads to large memory allocation #8

Description

@kuchenrolle

I'm trying to use your newest model "pl_spacy_model_morfeusz_big" to parse some documents and I run into a memory error when the size of the documents grows too big. One document is about 4000 words big and this is the traceback:


Traceback (most recent call last):
  File "scripts/annotate.py", line 51, in <module>
    annotate_corpus(infile=CORPUS, outfile=ANNOTATED, drop_tags={})
  File "scripts/annotate.py", line 28, in annotate_corpus
    parsed = parser(" ".join(document))
  File "/home/kuchenrolle/miniconda3/envs/ndl/lib/python3.7/site-packages/spacy/language.py", line 430, in __call__
    doc = self.make_doc(text)
  File "/home/kuchenrolle/miniconda3/envs/ndl/lib/python3.7/site-packages/spacy/language.py", line 454, in make_doc
    return self.tokenizer(text)
  File "/home/kuchenrolle/miniconda3/envs/ndl/lib/python3.7/site-packages/pl_spacy_model_morfeusz_big/preprocessor/__init__.py", line 234, in __call__
    return self.process(text)
  File "/home/kuchenrolle/miniconda3/envs/ndl/lib/python3.7/site-packages/pl_spacy_model_morfeusz_big/preprocessor/__init__.py", line 203, in process
    tags = self.toygger.process(non_white_analysis, doc)
  File "/home/kuchenrolle/miniconda3/envs/ndl/lib/python3.7/site-packages/pl_spacy_model_morfeusz_big/preprocessor/Toygger/__init__.py", line 85, in process
    X_s[5] = zeros((len(data), MAX_WORDS, self.settings.WORD2VEC_DIM))
MemoryError: Unable to allocate 38.1 GiB for an array with shape (4126, 4126, 300) and data type float64

I can't really look into this more right now, but at first look it seems that it might be trying to allocate an array that is square in the size of the number of tokens (times the embedding size). If I split the document into chunks and run the parser on each chunk separately, it runs through fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions