Commit
·
622d3c8
1
Parent(s):
558face
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
datasets:
|
3 |
+
- bleugreen/typescript-instruct
|
4 |
+
language:
|
5 |
+
- en
|
6 |
+
tags:
|
7 |
+
- code
|
8 |
+
---
|
9 |
+
|
10 |
+
This model is a fune-tuned version of codet5-large on Typescript instruct-code pairs.
|
11 |
+
|
12 |
+
To run this model, you can use following example:
|
13 |
+
|
14 |
+
```
|
15 |
+
import torch
|
16 |
+
device = torch.device('cuda:0') if torch.cuda.is_available() else None
|
17 |
+
from transformers import AutoTokenizer, T5ForConditionalGeneration
|
18 |
+
|
19 |
+
def generate_code(task_description):
|
20 |
+
# Prepare the task description
|
21 |
+
input_ids = tokenizer.encode(task_description, return_tensors='pt').to(device)
|
22 |
+
|
23 |
+
# Generate the output
|
24 |
+
with torch.no_grad():
|
25 |
+
output_ids = model.generate(input_ids, max_length=200, temperature=0.7, num_beams=5)
|
26 |
+
|
27 |
+
# Decode the output
|
28 |
+
output = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
29 |
+
|
30 |
+
return output
|
31 |
+
|
32 |
+
model = T5ForConditionalGeneration.from_pretrained('mishasadhaker/codet5_large_typescript').to(device)
|
33 |
+
tokenizer = AutoTokenizer.from_pretrained('mishasadhaker/codet5_large_typescript')
|
34 |
+
|
35 |
+
print(generate_code('write function for sum of two numbers and return it'))
|
36 |
+
```
|