Create Doled.py
Browse files
Doled.py
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
2 |
+
|
3 |
+
# تحميل النموذج والمدخلات
|
4 |
+
model = T5ForConditionalGeneration.from_pretrained("Salesforce/codet5-base")
|
5 |
+
tokenizer = T5Tokenizer.from_pretrained("Salesforce/codet5-base")
|
6 |
+
|
7 |
+
# اختبار النموذج على نص
|
8 |
+
input_text = "translate Python to Java: def add(a, b): return a + b"
|
9 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
10 |
+
outputs = model.generate(**inputs)
|
11 |
+
|
12 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|