File size: 1,059 Bytes
622d3c8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
---
datasets:
- bleugreen/typescript-instruct
language:
- en
tags:
- code
---
This model is a fune-tuned version of codet5-large on Typescript instruct-code pairs.
To run this model, you can use following example:
```
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'))
```
|