NLP คืออะไร?
Natural Language Processing (NLP) เป็นสาขาของ AI ที่ทำให้คอมพิวเตอร์เข้าใจและประมวลผลภาษามนุษย์
1. แอปพลิเคชันของ NLP
| แอปพลิเคชัน | ตัวอย่าง |
|---|---|
| Chatbot | ChatGPT, Customer Service Bot |
| Translation | Google Translate |
| Sentiment Analysis | วิเคราะห์ความคิดเห็นลูกค้า |
| Text Summarization | สรุปเอกสารอัตโนมัติ |
| Named Entity Recognition | ระบุชื่อคน, สถานที่ |
2. ขั้นตอนการประมวลผลภาษา
ขั้นตอนที่ 1: Tokenization
- แบ่งประโยคเป็นคำ
- ตัวอย่าง: I love coding → [I, love, coding]
ขั้นตอนที่ 2: Stopword Removal
- ลบคำที่ไม่สำคัญ (a, the, is)
ขั้นตอนที่ 3: Stemming/Lemmatization
- ลดคำให้เหลือรากศัพท์
- ตัวอย่าง: running → run
ขั้นตอนที่ 4: Vectorization
- แปลงคำเป็นตัวเลข
- ใช้ TF-IDF หรือ Word Embeddings
3. โมเดล NLP ยอดนิยม
| โมเดล | คุณสมบัติ | ใช้ใน |
|---|---|---|
| BERT | เข้าใจบริบททั้งซ้าย-ขวา | ค้นหา, ตอบคำถาม |
| GPT | สร้างข้อความอัตโนมัติ | เขียนบทความ, Chatbot |
| T5 | แปลงงานทุกอย่างเป็น Text-to-Text | แปล, สรุป |
4. ตัวอย่างโค้ด Python
from transformers import pipeline
# Sentiment Analysis
classifier = pipeline('sentiment-analysis')
result = classifier('I love this product!')
print(result) # [{'label': 'POSITIVE', 'score': 0.99}]
# Text Summarization
summarizer = pipeline('summarization')
text = 'Your long text here...'
summary = summarizer(text, max_length=50)
print(summary)
5. NLP ในงานวิศวกรรม
- รายงานอัตโนมัติ: สรุปข้อมูลจากเซ็นเซอร์
- ค้นหาเอกสาร: ค้นหาคู่มือเครื่องจักร
- วิเคราะห์ Feedback: วิเคราะห์ความคิดเห็นพนักงาน
- แปลภาษา: แปลมาตรฐานต่างประเทศ