การจำแนกข้อความที่สร้างขึ้นสำหรับ RLHF
ขั้นตอนต่อไปคือการจัดหมวดหมู่รีวิวที่สร้างขึ้น วิธีหนึ่งในการประเมินผลลัพธ์คือการวัดความเป็นเชิงบวกของรีวิวโดยใช้ตัวจำแนก lvwerra/distilbert-imdb ซึ่งสามารถสร้างได้ผ่าน Hugging Face pipelines
ไลบรารี pipeline ถูกนำเข้าไว้แล้วจาก transformers โมเดล lvwerra/distilbert-imdb ถูกโหลดไว้แล้วในชื่อ model และ tokenizer ถูกโหลดไว้แล้วในชื่อ tokenizer
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Reinforcement Learning from Human Feedback (RLHF)
คำแนะนำการฝึกหัด
- ใช้ฟังก์ชัน
pipelineเพื่อสร้าง sentiment-analysis pipeline พร้อมกับโมเดลที่กำหนด - จำแนกความรู้สึก (sentiment) ของรีวิวที่ให้มา
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Create a sentiment analysis pipeline
sentiment_analyzer = pipeline(____, model=____, tokenizer=____)
review_text = "Surprisingly, the film is a very good one"
# Classify the sentiment of the review
sentiment = sentiment_analyzer(____)
print(f"Sentiment Analysis Result: {sentiment}")