Loading checkpoint shards: 25%|████▌ | 1/4 [00:07<00:23, 7.92s/it]
Traceback (most recent call last):
File "/home/ps/anaconda3/envs/pt/lib/python3.10/site-packages/transformers/modeling_utils.py", line 442, in load_state_dict
return torch.load(checkpoint_file, map_location="cpu")
File "/home/ps/anaconda3/envs/pt/lib/python3.10/site-packages/torch/serialization.py", line 797, in load
with _open_zipfile_reader(opened_file) as opened_zipfile:
File "/home/ps/anaconda3/envs/pt/lib/python3.10/site-packages/torch/serialization.py", line 283, in init
super().init(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ps/anaconda3/envs/pt/lib/python3.10/site-packages/transformers/modeling_utils.py", line 446, in load_state_dict
if f.read(7) == "version":
File "/home/ps/anaconda3/envs/pt/lib/python3.10/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 128: invalid start byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/data/MyStudio/stableLM.py", line 5, in
model = AutoModelForCausalLM.from_pretrained("stabilityai/stablelm-tuned-alpha-7b")
File "/home/ps/anaconda3/envs/pt/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py", line 468, in from_pretrained
return model_class.from_pretrained(
File "/home/ps/anaconda3/envs/pt/lib/python3.10/site-packages/transformers/modeling_utils.py", line 2795, in from_pretrained
) = cls._load_pretrained_model(
File "/home/ps/anaconda3/envs/pt/lib/python3.10/site-packages/transformers/modeling_utils.py", line 3110, in _load_pretrained_model
state_dict = load_state_dict(shard_file)
File "/home/ps/anaconda3/envs/pt/lib/python3.10/site-packages/transformers/modeling_utils.py", line 458, in load_state_dict
raise OSError(
OSError: Unable to load weights from pytorch checkpoint file for '/home/ps/.cache/huggingface/hub/models--stabilityai--stablelm-tuned-alpha-7b/snapshots/25071b093c15c0d1cb2b2876c6deb621b764fcf5/pytorch_model-00002-of-00004.bin' at '/home/ps/.cache/huggingface/hub/models--stabilityai--stablelm-tuned-alpha-7b/snapshots/25071b093c15c0d1cb2b2876c6deb621b764fcf5/pytorch_model-00002-of-00004.bin'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.
It looks like one or more of the .bin files are corrupted. It may not be finished downloading, or there may have been an error while downloading. You'll likely have to delete and redownload them.
i run these codes from reade doc:
`import torch from transformers import AutoModelForCausalLM, AutoTokenizer, StoppingCriteria, StoppingCriteriaList
tokenizer = AutoTokenizer.from_pretrained("stabilityai/stablelm-tuned-alpha-7b") model = AutoModelForCausalLM.from_pretrained("stabilityai/stablelm-tuned-alpha-7b") model.half().cuda()
class StopOnTokens(StoppingCriteria): def call(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool: stop_ids = [50278, 50279, 50277, 1, 0] for stop_id in stop_ids: if input_ids[0][-1] == stop_id: return True return False
system_prompt = """<|SYSTEM|># StableLM Tuned (Alpha version)
prompt = f"{system_prompt}<|USER|>What's your mood today?<|ASSISTANT|>"
inputs = tokenizer(prompt, return_tensors="pt").to("cuda") tokens = model.generate( **inputs, max_new_tokens=64, temperature=0.7, do_sample=True, stopping_criteria=StoppingCriteriaList([StopOnTokens()]) ) print(tokenizer.decode(tokens[0], skip_special_tokens=True))`
And I got this error:
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/ps/anaconda3/envs/pt/lib/python3.10/site-packages/transformers/modeling_utils.py", line 446, in load_state_dict if f.read(7) == "version": File "/home/ps/anaconda3/envs/pt/lib/python3.10/codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 128: invalid start byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/data/MyStudio/stableLM.py", line 5, in
model = AutoModelForCausalLM.from_pretrained("stabilityai/stablelm-tuned-alpha-7b")
File "/home/ps/anaconda3/envs/pt/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py", line 468, in from_pretrained
return model_class.from_pretrained(
File "/home/ps/anaconda3/envs/pt/lib/python3.10/site-packages/transformers/modeling_utils.py", line 2795, in from_pretrained
) = cls._load_pretrained_model(
File "/home/ps/anaconda3/envs/pt/lib/python3.10/site-packages/transformers/modeling_utils.py", line 3110, in _load_pretrained_model
state_dict = load_state_dict(shard_file)
File "/home/ps/anaconda3/envs/pt/lib/python3.10/site-packages/transformers/modeling_utils.py", line 458, in load_state_dict
raise OSError(
OSError: Unable to load weights from pytorch checkpoint file for '/home/ps/.cache/huggingface/hub/models--stabilityai--stablelm-tuned-alpha-7b/snapshots/25071b093c15c0d1cb2b2876c6deb621b764fcf5/pytorch_model-00002-of-00004.bin' at '/home/ps/.cache/huggingface/hub/models--stabilityai--stablelm-tuned-alpha-7b/snapshots/25071b093c15c0d1cb2b2876c6deb621b764fcf5/pytorch_model-00002-of-00004.bin'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.
how to fix this ?