title: Can not find the pytorch model when loading BERT model in Python
body: <p>I am following <a href="https://towardsdatascience.com/how-to-compute-sentence-similarity-using-bert-and-word2vec-ab0663a5d64" rel="nofollow noreferrer">this</a> article to find the text similarity.
  The code I have is this:</p>
  <pre><code>from sentence_transformers import SentenceTransformer
  from tqdm import tqdm
  from sklearn.metrics.pairwise import cosine_similarity
  import numpy as np
  import pandas as pd
  
  documents = [
           &quot;Vodafone Wins ₹ 20,000 Crore Tax Arbitration Case Against Government&quot;,
           &quot;Voda Idea shares jump nearly 15% as Vodafone wins retro tax case in Hague&quot;,
           &quot;Gold prices today fall for 4th time in 5 days, down ₹6500 from last month high&quot;,
           &quot;Silver futures slip 0.36% to Rs 59,415 per kg, down over 12% this week&quot;,
           &quot;Amazon unveils drone that films inside your home. What could go wrong?&quot;,
           &quot;IPHONE 12 MINI PERFORMANCE MAY DISAPPOINT DUE TO THE APPLE B14 CHIP&quot;,
           &quot;Delhi Capitals vs Chennai Super Kings: Prithvi Shaw shines as DC beat CSK to post second consecutive win in IPL&quot;,
           &quot;French Open 2020: Rafael Nadal handed tough draw in bid for record-equaling 20th Grand Slam&quot;
  ]
  
  model = SentenceTransformer('sentence-transformers/bert-base-nli-mean-tokens')
  </code></pre>
  <p>I get an error when running the above code:</p>
  <p><strong>Full:</strong></p>
  <pre><code>---------------------------------------------------------------------------
  ValueError                                Traceback (most recent call last)
  ~\anaconda3\envs\py3_nlp\lib\tarfile.py in nti(s)
      188             s = nts(s, &quot;ascii&quot;, &quot;strict&quot;)
  --&gt; 189             n = int(s.strip() or &quot;0&quot;, 8)
      190         except ValueError:
  
  ValueError: invalid literal for int() with base 8: 'ld_tenso'
  
  During handling of the above exception, another exception occurred:
  
  InvalidHeaderError                        Traceback (most recent call last)
  ~\anaconda3\envs\py3_nlp\lib\tarfile.py in next(self)
     2298             try:
   -&gt; 2299                 tarinfo = self.tarinfo.fromtarfile(self)
     2300             except EOFHeaderError as e:
  
   ~\anaconda3\envs\py3_nlp\lib\tarfile.py in fromtarfile(cls, tarfile)
     1092         buf = tarfile.fileobj.read(BLOCKSIZE)
   -&gt; 1093         obj = cls.frombuf(buf, tarfile.encoding, tarfile.errors)
     1094         obj.offset = tarfile.fileobj.tell() - BLOCKSIZE
  
   ~\anaconda3\envs\py3_nlp\lib\tarfile.py in frombuf(cls, buf, encoding, errors)
      1034 
   -&gt; 1035         chksum = nti(buf[148:156])
      1036         if chksum not in calc_chksums(buf):
  
    ~\anaconda3\envs\py3_nlp\lib\tarfile.py in nti(s)
      190         except ValueError:
  --&gt; 191             raise InvalidHeaderError(&quot;invalid header&quot;)
      192     return n
  
   InvalidHeaderError: invalid header
  
   During handling of the above exception, another exception occurred:
  
   ReadError                                 Traceback (most recent call last)
   ~\anaconda3\envs\py3_nlp\lib\site-packages\torch\serialization.py in _load(f, map_location, 
   pickle_module, **pickle_load_args)
       594         try:
   --&gt; 595             return legacy_load(f)
       596         except tarfile.TarError:
  
   ~\anaconda3\envs\py3_nlp\lib\site-packages\torch\serialization.py in legacy_load(f)
      505 
  --&gt; 506         with closing(tarfile.open(fileobj=f, mode='r:', format=tarfile.PAX_FORMAT)) as 
  tar, \
      507                 mkdtemp() as tmpdir:
  
   ~\anaconda3\envs\py3_nlp\lib\tarfile.py in open(cls, name, mode, fileobj, bufsize, **kwargs)
      1590                 raise CompressionError(&quot;unknown compression type %r&quot; % comptype)
   -&gt; 1591             return func(name, filemode, fileobj, **kwargs)
      1592 
  
  ~\anaconda3\envs\py3_nlp\lib\tarfile.py in taropen(cls, name, mode, fileobj, **kwargs)
     1620             raise ValueError(&quot;mode must be 'r', 'a', 'w' or 'x'&quot;)
  -&gt; 1621         return cls(name, mode, fileobj, **kwargs)
     1622 
  
   ~\anaconda3\envs\py3_nlp\lib\tarfile.py in __init__(self, name, mode, fileobj, format, tarinfo, dereference, ignore_zeros, encoding, errors, pax_headers, debug, errorlevel, copybufsize)
     1483                 self.firstmember = None
  -&gt; 1484                 self.firstmember = self.next()
     1485 
  
  ~\anaconda3\envs\py3_nlp\lib\tarfile.py in next(self)
     2310                 elif self.offset == 0:
   -&gt; 2311                     raise ReadError(str(e))
     2312             except EmptyHeaderError:
  
   ReadError: invalid header
  
   During handling of the above exception, another exception occurred:
  
   RuntimeError                              Traceback (most recent call last)
   ~\anaconda3\envs\py3_nlp\lib\site-packages\transformers\modeling_utils.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
      1210                 try:
   -&gt; 1211                     state_dict = torch.load(resolved_archive_file, map_location=&quot;cpu&quot;)
      1212                 except Exception:
  
   ~\anaconda3\envs\py3_nlp\lib\site-packages\torch\serialization.py in load(f, map_location, pickle_module, **pickle_load_args)
       425             pickle_load_args['encoding'] = 'utf-8'
   --&gt; 426         return _load(f, map_location, pickle_module, **pickle_load_args)
       427     finally:
  
   ~\anaconda3\envs\py3_nlp\lib\site-packages\torch\serialization.py in _load(f, map_location, pickle_module, **pickle_load_args)
      598                 # .zip is used for torch.jit.save and will throw an un-pickling error here
    --&gt; 599                 raise RuntimeError(&quot;{} is a zip archive (did you mean to use torch.jit.load()?)&quot;.format(f.name))
       600             # if not a tarfile, reset file offset and proceed
  
   RuntimeError: C:\Users\user1/.cache\torch\sentence_transformers\sentence-transformers_bert-base-nli-mean-tokens\pytorch_model.bin is a zip archive (did you mean to use torch.jit.load()?)
  
   During handling of the above exception, another exception occurred:
  
   OSError                                   Traceback (most recent call last)
   &lt;ipython-input-3-bba56aac60aa&gt; in &lt;module&gt;
   ----&gt; 1 model = SentenceTransformer('sentence-transformers/bert-base-nli-mean-tokens')
  
   ~\anaconda3\envs\py3_nlp\lib\site-packages\sentence_transformers\SentenceTransformer.py in __init__(self, model_name_or_path, modules, device, cache_folder)
       88 
       89             if os.path.exists(os.path.join(model_path, 'modules.json')):    #Load as SentenceTransformer model
  ---&gt; 90                 modules = self._load_sbert_model(model_path)
       91             else:   #Load with AutoModel
       92                 modules = self._load_auto_model(model_path)
  
   ~\anaconda3\envs\py3_nlp\lib\site-packages\sentence_transformers\SentenceTransformer.py in _load_sbert_model(self, model_path)
       820         for module_config in modules_config:
       821             module_class = import_from_string(module_config['type'])
   --&gt; 822             module = module_class.load(os.path.join(model_path, module_config['path']))
      823             modules[module_config['name']] = module
      824 
  
   ~\anaconda3\envs\py3_nlp\lib\site-packages\sentence_transformers\models\Transformer.py in load(input_path)
       122         with open(sbert_config_path) as fIn:
       123             config = json.load(fIn)
   --&gt; 124         return Transformer(model_name_or_path=input_path, **config)
       125 
       126 
  
   ~\anaconda3\envs\py3_nlp\lib\site-packages\sentence_transformers\models\Transformer.py in __init__(self, model_name_or_path, max_seq_length, model_args, cache_dir, tokenizer_args, do_lower_case, tokenizer_name_or_path)
       27 
       28         config = AutoConfig.from_pretrained(model_name_or_path, **model_args, cache_dir=cache_dir)
  ---&gt; 29         self.auto_model = AutoModel.from_pretrained(model_name_or_path, config=config, cache_dir=cache_dir)
      30         self.tokenizer = AutoTokenizer.from_pretrained(tokenizer_name_or_path if tokenizer_name_or_path is not None else model_name_or_path, cache_dir=cache_dir, **tokenizer_args)
     31 
  
    ~\anaconda3\envs\py3_nlp\lib\site-packages\transformers\models\auto\auto_factory.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
      393         if type(config) in cls._model_mapping.keys():
      394             model_class = _get_model_class(config, cls._model_mapping)
  --&gt; 395             return model_class.from_pretrained(pretrained_model_name_or_path, *model_args, config=config, **kwargs)
      396         raise ValueError(
      397             f&quot;Unrecognized configuration class {config.__class__} for this kind of AutoModel: {cls.__name__}.\n&quot;
  
   ~\anaconda3\envs\py3_nlp\lib\site-packages\transformers\modeling_utils.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
      1212                 except Exception:
      1213                     raise OSError(
   -&gt; 1214                         f&quot;Unable to load weights from pytorch checkpoint file for '{pretrained_model_name_or_path}' &quot;
      1215                         f&quot;at '{resolved_archive_file}'&quot;
      1216                         &quot;If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True. &quot;
  
   OSError: Unable to load weights from pytorch checkpoint file for 'C:\Users\user1/.cache\torch\sentence_transformers\sentence-transformers_bert-base-nli-mean-tokens\' at 'C:\Users\user1/.cache\torch\sentence_transformers\sentence-transformers_bert-base-nli-mean-tokens\pytorch_model.bin'If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.
  </code></pre>
  <p><strong>Short:</strong></p>
  <p>OSError: Unable to load weights from pytorch checkpoint file for 'C:\Users\user1/.cache\torch\sentence_transformers\sentence-transformers_bert-base-nli-mean-tokens' at 'C:\Users\user1/.cache\torch\sentence_transformers\sentence-transformers_bert-base-nli-mean-tokens\pytorch_model.bin'If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.</p>
  <p>I do have the pytorch_model.bin in the '.cache\torch\sentence_transformers\sentence-transformers_bert-base-nli-mean-tokens' folder.</p>
  <p>Why am I getting this error?</p>