from transformers import T5Tokenizer, T5ForConditionalGeneration | |
# تحميل النموذج والمدخلات | |
model = T5ForConditionalGeneration.from_pretrained("Salesforce/codet5-base") | |
tokenizer = T5Tokenizer.from_pretrained("Salesforce/codet5-base") | |
# اختبار النموذج على نص | |
input_text = "translate Python to Java: def add(a, b): return a + b" | |
inputs = tokenizer(input_text, return_tensors="pt") | |
outputs = model.generate(**inputs) | |
print(tokenizer.decode(outputs[0], skip_special_tokens=True)) | |