salesforce / CodeT5

Home of CodeT5: Open Code LLMs for Code Understanding and Generation
https://arxiv.org/abs/2305.07922
BSD 3-Clause "New" or "Revised" License
2.66k stars 391 forks source link

`Config.json` missing error when launching custom trained model #87

Open rjra2611 opened 1 year ago

rjra2611 commented 1 year ago

Hi, I trained a model on my own task and subtask but when running the model I get the below error 1 that config.json is missing. When I look at the model directory I can confirm that it was never generated when training the model. Is there a way I can get the config.json that is required.

I tried to fetch the config.json from https://storage.googleapis.com/sfr-codet5-data-research/pretrained_models/codet5_base/config.json but I believe it's not valid for my fine tuned model. I got the below error 2 when using this config

from transformers import RobertaTokenizer, T5ForConditionalGeneration

model_name_or_path = 'D:/CodeT5/sh/saved_models/qcbot/codet5_small_all_lr5_bs32_src256_trg128_pat2_e1/checkpoint-best-ppl'  #  Path to the folder created earlier.

tokenizer = RobertaTokenizer.from_pretrained('Salesforce/codet5-small')
model = T5ForConditionalGeneration.from_pretrained(model_name_or_path)

text = "Sums two sequence of items."

input_ids = tokenizer(text, return_tensors="pt").input_ids
generated_ids = model.generate(input_ids)

print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))
SBhat2615 commented 10 months ago

@rjra2611 could you resolve the above error ?? We trained on the same data provided by salesforce again to generate checkpoint of the form bin file. Got the same error while providing the path for the file ??