模型:
mishasadhaker/codet5_large_typescript
这个模型是在Typescript instruct-code对上优化后的codet5-large版本。
要运行此模型,您可以使用以下示例:
import torch device = torch.device('cuda:0') if torch.cuda.is_available() else None from transformers import AutoTokenizer, T5ForConditionalGeneration def generate_code(task_description): # Prepare the task description input_ids = tokenizer.encode(task_description, return_tensors='pt').to(device) # Generate the output with torch.no_grad(): output_ids = model.generate(input_ids, max_length=200, temperature=0.7, num_beams=5) # Decode the output output = tokenizer.decode(output_ids[0], skip_special_tokens=True) return output model = T5ForConditionalGeneration.from_pretrained('mishasadhaker/codet5_large_typescript').to(device) tokenizer = AutoTokenizer.from_pretrained('mishasadhaker/codet5_large_typescript') print(generate_code('write function for sum of two numbers and return it'))