प्रशिक्षित टेक्स्ट जनरेशन मॉडल का मूल्यांकन
PyBooks टीम ने एक प्री-ट्रेंड GPT-2 मॉडल का उपयोग किया है, जिसके साथ आपने दिए गए प्रॉम्प्ट के आधार पर टेक्स्ट जनरेट करने का प्रयोग किया था. अब वे इस जनरेट किए गए टेक्स्ट की गुणवत्ता का मूल्यांकन करना चाहते हैं. इसे हासिल करने के लिए, उन्होंने आपको रेफरेंस टेक्स्ट का उपयोग करके जनरेटेड टेक्स्ट का मूल्यांकन करने का कार्य दिया है.
BLEUScore, ROUGEScore आपके लिए लोड कर दिए गए हैं.
यह अभ्यास पाठ्यक्रम का हिस्सा है
PyTorch के साथ टेक्स्ट के लिए डीप लर्निंग
अभ्यास निर्देश
torchmetrics.textसे दिए गए दो मेट्रिक्स (BLEU और ROUGE) को initialize करके शुरू कीजिए.- इन initialized मेट्रिक्स का उपयोग करके जनरेटेड टेक्स्ट और रेफरेंस टेक्स्ट के बीच स्कोर की गणना कीजिए.
- कैलकुलेट किए गए BLEU और ROUGE स्कोर दिखाइए.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
reference_text = "Once upon a time, there was a little girl who lived in a village near the forest."
generated_text = "Once upon a time, the world was a place of great beauty and great danger. The world of the gods was the place where the great gods were born, and where they were to live."
# Initialize BLEU and ROUGE scorers
bleu = ____()
rouge = ____()
# Calculate the BLEU and ROUGE scores
bleu_score = bleu([____], [[reference_text]])
rouge_score = rouge([generated_text], [[____]])
# Print the BLEU and ROUGE scores
print("BLEU Score:", bleu_score.____())
print("ROUGE Score:", rouge_score)