question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

KeyError: "[E018] Can't retrieve string for hash while running movie sentiment example

See original GitHub issue

While running movie sentiment example I am getting the following error while running the code explainer = AnchorText(nlp, predict_fn):


KeyError Traceback (most recent call last) <ipython-input-12-184c1e0a132f> in <module>() ----> 1 explainer = AnchorText(nlp, predict_fn)

2 frames /usr/local/lib/python3.6/dist-packages/alibi/explainers/anchor_text.py in <listcomp>(.0) 43 self.w_prob = w_prob 44 # list with spaCy lexemes in vocabulary —> 45 self.to_check = [self.nlp.vocab[w] for w in self.nlp.vocab.vectors if self.nlp.vocab[w].prob >= self.w_prob] 46 self.n_similar = n_similar 47

vocab.pyx in spacy.vocab.Vocab.getitem()

lexeme.pyx in spacy.lexeme.Lexeme.init()

vocab.pyx in spacy.vocab.Vocab.get_by_orth()

strings.pyx in spacy.strings.StringStore.getitem()

KeyError: “[E018] Can’t retrieve string for hash ‘11580349482641876976’. This usually refers to an issue with the Vocab or StringStore.”

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
adrianeboydcommented, Jul 28, 2020

A workaround would be:

self.to_check = [self.nlp.vocab[w] for w in self.nlp.vocab.vectors if int(w) in self.nlp.vocab.strings and self.nlp.vocab[w].prob >= self.w_prob]

The keys in nlp.vocab.vectors are supposed to all be int, but in some v2.2 md models they’re accidentally numpy.uint64.

0reactions
jklaisecommented, Jul 28, 2020

@adrianeboyd thanks for the workaround. @devchaitu18 I’ll put this in the master shortly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python Spacy KeyError: "[E018] Can't retrieve string for hash
I get exactly the same error on a BananaPi M1 with Armbian while on Windows the code runs fine. I am using spacy...
Read more >
How to Develop Word Embeddings in Python with Gensim
Running the example prints the following output. ... We can retrieve all of the vectors from a trained model as follows:.
Read more >
KeyError Pandas – How To Fix - Data Independent
Pandas KeyError - This annoying error means that Pandas can not find your column name in your dataframe. Here's how to fix this...
Read more >
Natural Language Processing with Python - Scinapse
Skim the Python examples and dig into the interesting language analysis material ... and find quick answers when you need the most accurate,...
Read more >
Text Analytics with Python
While the advice and information in this book are believed to be true and accurate at the ... Sentiment Analysis of IMDb Movie...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found