hazm icon indicating copy to clipboard operation
hazm copied to clipboard

`memoryview: a bytes-like object is required, not 'dict'` when loading spaCy model

Open ghominejad opened this issue 8 months ago • 2 comments

Description:

I'm encountering an issue when trying to load a spaCy model using the SpacyPOSTagger or even with spacy.load method. The error message I receive is:

memoryview: a bytes-like object is required, not 'dict'

Steps to Reproduce

  1. Clone the repository from spacy_pos_tagger_parsbertpostagger using:

    git clone --depth 1 https://huggingface.co/roshan-research/spacy_pos_tagger_parsbertpostagger
    
  2. Install dependencies:

    pip install --no-cache-dir scipy==1.11.4 spacy==3.6.0 srsly==2.4.5 Cython spacy-transformers==1.1.7 transformers==4.27.4 gensim hazm
    
  3. Run the following test script:

    import spacy
    from pathlib import Path
    
    def test_load_model(model_path):
        try:
            nlp = spacy.load(model_path)
            print("Model loaded successfully.")
        except Exception as e:
            print(f"Failed to load model: {e}")
    
    if __name__ == "__main__":
        model_path = "./models/spacy_pos_tagger_parsbertpostagger"  # Adjust the path accordingly
        test_load_model(model_path)
    

Expected Behavior

The model should load successfully without any errors.

Actual Behavior

The following error is encountered:

memoryview: a bytes-like object is required, not 'dict'

Environment

  • Python Version: 3.10
  • Installed Packages:
    • scipy==1.11.4
    • spacy==3.6.0
    • srsly==2.4.5
    • Cython
    • spacy-transformers==1.1.7
    • transformers==4.27.4
    • gensim
    • hazm

Additional Information

The error seems to occur when the spacy.load function is called. This suggests there might be an issue with the model files or the compatibility between the installed packages and the model.

Any guidance on resolving this issue would be greatly appreciated.

ghominejad avatar May 31 '24 19:05 ghominejad