Quest 11 - Model Architecture Classifier
Quest 11: Model Architecture Classifier
hard 30 minutes🎯 Learning Objectives
- The differences between BERT, GPT, and T5 architectures
- How attention type determines model behavior
- How to classify models by their configuration properties
- The engineering habit: KNOW YOUR TOOLS
📖 Concept: Model Architectures
ไม่ใช่ LLM ทุกตัวจะเหมือนกัน — มี architecture หลัก 3 แบบ:
BERT (Encoder-Only)
- Attention: Bidirectional (มองทั้งซ้ายและขวา)
- Use case: Classification, NER, Q&A
- ตัวอย่าง: “The cat [MASK] on the mat” -> ทำนายว่า “sat”
GPT (Decoder-Only)
- Attention: Causal (มองแค่ซ้าย — ไม่เห็นอนาคต)
- Use case: Text generation, completion
- ตัวอย่าง: “The cat sat on” -> ทำนายว่า “the mat”
T5 (Encoder-Decoder)
- Attention: Both (bidirectional encoder + causal decoder)
- Use case: Translation, summarization
- ตัวอย่าง: “translate English to French: Hello” -> “Bonjour”
⚙️ How It Works
Classification Rules
function classifyArchitecture(config) { const { type, attentionType } = config;
// BERT: encoder-only + bidirectional if (type === 'encoder-only' && attentionType === 'bidirectional') { return 'BERT'; }
// GPT: decoder-only + causal if (type === 'decoder-only' && attentionType === 'causal') { return 'GPT'; }
// T5: encoder-decoder + both if (type === 'encoder-decoder' && attentionType === 'both') { return 'T5'; }
return 'UNKNOWN';}Configuration Examples
// BERT configconst bertConfig = { type: 'encoder-only', attentionType: 'bidirectional', useCase: 'text classification'};
// GPT configconst gptConfig = { type: 'decoder-only', attentionType: 'causal', useCase: 'text generation'};
// T5 configconst t5Config = { type: 'encoder-decoder', attentionType: 'both', useCase: 'translation'};💡 Example: Why Attention Type Matters
// Bidirectional (BERT) — มองทั้งซ้ายและขวา// Input: "The cat [MASK] on the mat"// BERT เห็น: "The", "cat", "on", "the", "mat" -> ทำนาย "sat"
// Causal (GPT) — มองแค่ซ้าย// Input: "The cat sat on"// GPT เห็น: "The", "cat", "sat", "on" -> ทำนาย "the"
// Both (T5) — encoder มองทั้งสองข้าง, decoder มองแค่ซ้าย// Input: "translate: Hello"// T5 encoder เห็น: "translate", "Hello"// T5 decoder สร้าง: "Bonjour"⚠️ Common Mistakes
Mistake 1: ใช้แค่ type ในการ classify
คิดว่า decoder-only = GPT เสมอ -> ต้อง check
attentionTypeด้วย — decoder-only + bidirectional ไม่ใช่ GPT
Mistake 2: สับสน bidirectional กับ causal
คิดว่า BERT ใช้ causal attention -> BERT ใช้ bidirectional, GPT ใช้ causal
Mistake 3: ไม่ handle UNKNOWN
ลืม return ‘UNKNOWN’ สำหรับ config ที่ไม่ match -> ต้อง return ‘UNKNOWN’ สำหรับ architecture ที่ไม่รู้จัก
Mistake 4: ไม่ test edge cases
ไม่ test กับ config ที่ไม่ match rule ใดเลย -> ต้อง test กับ invalid config
📝 Knowledge Check
📝 Knowledge Check
Q1:What type of attention does BERT use?
Q2:A model with config { type: 'decoder-only', attentionType: 'bidirectional' } should be classified as?
Q3:Which architecture uses both bidirectional encoder and causal decoder attention?
🏋️ Quest: Model Architecture Classifier
เขียน function ที่ classify model architecture จาก configuration
-
Download ไฟล์เริ่มต้นของ quest:
Terminal window npx bluebeltdojo download quest-11-model-arch-classifiercd quest-11-model-arch-classifier -
เปิด
problem.jsใน editor ของคุณพร้อม AI tool -
ให้ AI ช่วย implement
classifyArchitecture(config)ตาม rules -
ตรวจสอบ:
Terminal window node test.js -
ทดสอบ: BERT, GPT, T5, UNKNOWN configurations
-
ส่งคำตอบ:
Terminal window npx bluebeltdojo submit
💡 Tip: ถ้า AI classify แค่จาก
typeให้บอกว่า “Check both type AND attentionType”
คำใบ้
- อ่าน instructions ใน
problem.jsอย่างละเอียด — มี classification rules ระบุไว้ - ตรวจสอบทั้ง
typeและattentionType - ทดสอบ edge case: decoder-only + bidirectional ต้อง return UNKNOWN
- ถ้าติดขัด ลอง search “BERT vs GPT vs T5 architecture”