Error loading Starcoder model
#31
by
Polaris715
- opened
I encountered the following error when loading the locally downloaded starcoder2.
Traceback (most recent call last): File "/home/star/sgz/GraphCoder-main/patch_predictor.py", line 428, in main(args) ^^^^^^^^^^ File "/home/star/sgz/GraphCoder-main/patch_predictor.py", line 380, in main predictor = PatchCorrectnessPredictor( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/star/sgz/GraphCoder-main/patch_predictor.py", line 66, in init raise ValueError(f"Error loading Starcoder model: {str(e)}") ValueError: Error loading Starcoder model: The checkpoint you are trying to load has model type starcoder2 but Transformers does not recognize this architecture. This could be because of an issue with the checkpoint, or because your version of Transformers is out of date
My code
elif model.startswith('Starcoder2-'):
# # Starcoder2 family (e.g. starcoder2-7b, starcoder2-15b)
model_path = os.path.join(models_cache_dir, model)
tokenizer_path = os.path.join(models_cache_dir, f"{model}-tokenizer")
try:
self.model = AutoModelForCausalLM.from_pretrained(
model_path,
torch_dtype=torch.float16,
device_map = "auto",
# low_cpu_mem_usage=True,
).to(self.device)
tokenizer_raw = AutoTokenizer.from_pretrained(tokenizer_path, trust_remote_code=True)
if getattr(tokenizer_raw, "pad_token", None) is None and getattr(tokenizer_raw, "eos_token",
None) is not None:
tokenizer_raw.pad_token = tokenizer_raw.eos_token
from utils.utils import StarCoderTokenizer
self.tokenizer = StarCoderTokenizer(tokenizer_raw)
self.raw_tokenizer = tokenizer_raw
self.max_context_tokens = (16000 - 16)
self.model_type = "huggingface"
self.generation_config = GenerationConfig(
max_new_tokens=16,
do_sample=False,
#temperature=0,
eos_token_id=tokenizer_raw.eos_token_id,
pad_token_id=tokenizer_raw.pad_token_id,
)
except Exception as e:
raise ValueError(f"Error loading Starcoder model: {str(e)}")