-
Notifications
You must be signed in to change notification settings - Fork 101
/
Copy pathtest_codet5_multitask.py
34 lines (28 loc) · 1.07 KB
/
test_codet5_multitask.py
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
import sys
from pathlib import Path
sys.path.append(str(Path(".").absolute().parent))
from codetf.models import load_model_pipeline
translation_model = load_model_pipeline(model_name="codet5", task="translate_cs_java",
model_type="base", is_eval=True,
load_in_4bit=True, weight_sharding=False)
summarization_model = load_model_pipeline(model_name="codet5", task="sum_python",
model_type="base", is_eval=True,
load_in_8bit=True, weight_sharding=False)
code_snippets = """
void bubbleSort(int arr[])
{
int n = arr.length;
for (int i = 0; i < n - 1; i++)
for (int j = 0; j < n - i - 1; j++)
if (arr[j] > arr[j + 1]) {
// swap arr[j+1] and arr[j]
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
"""
translated_code_snippets = translation_model.predict([code_snippets])
print(translated_code_snippets)
summaries = summarization_model.predict([code_snippets])
print(summaries)