Taste
ระบบเรียนรู้ preference แบบ local-first — จากสัญญาณ accept/reject/edit/lint/test สู่กฎที่ปรับแต่งได้
Taste เรียนรู้สไตล์โค้ดของคุณจากสัญญาณ accept, reject, edit, test, lint และกฎที่ผู้ใช้กำหนด มันรวมกฎสัญลักษณ์, การให้คะแนน preference เชิงความหมาย, และ contextual bandit optimization เพื่อปรับให้ Clew ตอบสนองตรงตามความต้องการของคุณ
มันไม่ได้ fine-tune LLM — การเรียนรู้ทั้งหมดเป็น local, online, และ preference-based
เทคนิคและหลักการ
เหตุใดต้องใช้ Preference Learning แทนที่จะใช้ Prompt เพียงอย่างเดียว?
CLAUDE.md และ system prompt กำหนดกฎแบบ static — ใช้ได้ดีสำหรับกฎที่คุณรู้ล่วงหน้า แต่ไม่สามารถปรับตัวตาม feedback จริงได้:
- คุณไม่รู้ทุกกฎล่วงหน้า — บางทีคุณอาจไม่รู้ด้วยซ้ำว่าตัวเองชอบ pattern แบบไหนจนกว่าจะเห็นผลลัพธ์
- กฎเปลี่ยนตามโปรเจค — React project กับ Python library มีสไตล์ต่างกันโดยสิ้นเชิง
- มนุษย์สื่อสาร preference ได้ไม่สมบูรณ์ — "เขียนโค้ดให้ดี" ไม่ใช่ instruction ที่ชัดเจนพอสำหรับ LLM
Taste เรียนรู้จากพฤติกรรมของคุณแทน — ถ้าคุณ accept output ที่ใช้ const แทน let บ่อยๆ มันจะเรียนรู้ ถ้าคุณ reject หรือแก้ไข มันจะลดน้ำหนัก
Online Feedback Loop — ไม่ใช่ Batch Training
Taste ใช้online learning — เรียนรู้ทันทีจากทุก interaction:
User interaction ──► Signal collector ──► Reward model (+1.0 / -1.0 / +0.4)
│
▼
Rule confidence update
│
┌───────────────┼───────────────┐
▼ ▼ ▼
Confidence ↑ Confidence ↓ Decay if unused
(accept/ (reject/edit) (30 day half-life)
test pass)
Multi-Signal Reward Model
ไม่ใช่แค่ accept/reject — ใช้หลายสัญญาณประกอบกัน:
| สัญญาณ | Reward | เหตุผล |
|---|---|---|
| Accept | +1.0 | ผู้ใช้พอใจ — สัญญาณบวกแรงที่สุด |
| Reject | -1.0 | ผู้ใช้ปฏิเสธ — สัญญาณลบแรงที่สุด |
| Edit (small) | -0.3 | แก้ไขเล็กน้อย — เกือบพอใจ |
| Edit (large) | -0.7 | แก้ไขเยอะ — output ห่างจากที่ต้องการ |
| Test pass | +0.4 | โค้ดถูกต้องทางเทคนิค |
| Test fail | -0.6 | โค้ดมี bug |
| Lint pass | +0.2 | ตรงตาม style convention |
| Tool result OK | +0.3 | เลือกใช้ tool ถูกต้อง |
Contextual Bandit — เลือกกลยุทธ์ตามบริบท
ไม่ใช่ทุกงานต้องการสไตล์เดียวกัน — refactor เน้น architecture, bug fix เน้น safety:
- ε-greedy bandit 6 แขน — minimal, strict_style, architecture_first, test_first, safety_first, refactor_heavy
- Context features — วิเคราะห์ task context แล้วเลือกแขนที่ให้ reward สูงสุดในอดีต
- Exploration vs exploitation — ε โอกาสสุ่มลองแขนใหม่ (explore), 1-ε เลือกที่รู้ว่าดี (exploit) — default ε = 0.1
- ทำไมต้อง bandit? — กฎ "use const" อาจขัดกับ "minimal changes" ในบางบริบท Bandit ช่วย balance หลาย objective
Three-Tier Rule Engine
ไม่ใช่ทุกกฎที่สำคัญเท่ากัน — แบ่งเป็น 3 ระดับตาม confidence:
- Tier 1 — Symbolic (≥ 0.85) — block การแก้ไขที่ไม่ตรง: เช่น "ห้ามใช้
any" → block + แจ้งเหตุผล - Tier 2 — Prompt Injection (≥ 0.55) — ใส่ใน system prompt เป็น
<clew_taste>block (max 8 rules) - Tier 3 — Scored (< 0.55) — ใช้ neural scorer (Jaccard/TF-IDF) เทียบ relevance แต่ไม่ inject
Auto-Learn — AI วิเคราะห์ Codebase
TasteCodebaseAnalyzer อ่าน .editorconfig, biome.json, tsconfig.json, สุ่ม 20 source files, git log 50 commits → ส่งให้ fast model วิเคราะห์ → หา patterns → เสนอเป็น suggestion ให้ผู้ใช้ accept/reject
Decay — ป้องกัน Stale Rules
- Half-life decay — confidence ลดลงครึ่งทุก 30 วันถ้าไม่ใช้
- Cooldown — หลัง reject → cooldown 30 นาทีก่อนเสนอใหม่
- ทำไม? — โปรเจคเปลี่ยน, สไตล์ทีมเปลี่ยน, toolchain upgrade — กฎเก่าอาจไม่เกี่ยวข้องแล้ว
Privacy-First
ทุกอย่าง local — ไม่ส่งข้อมูลไป cloud, event log เป็น append-only JSONL, export/import เกิดเมื่อผู้ใช้สั่งเท่านั้น
สิ่งที่ระบบเรียนรู้
- Code style — formatting, naming conventions, preferred patterns
- Architecture — module structure, dependency direction, layering
- Tooling — preferred build tools, linters, test frameworks
- Testing — test style, coverage expectations, mocking patterns
- Naming — variable, function, and class naming conventions
- Security — safe patterns vs unsafe patterns
- Performance — efficient algorithms, caching, resource management
- UI patterns — component structure, state management, styling approach
- Workflow — commit style, review preferences, deployment habits
สิ่งที่ Taste ไม่ทำ
- ไม่ fine-tune หรือแก้ไข base LLM
- ไม่ส่งข้อมูลไปยัง remote services
- ไม่ block การแก้ไขโดยไม่แสดงเหตุผล
- ไม่แทนที่ memory, skills, หรือ CLAUDE.md
สถาปัตยกรรม
╔══════════════════════════════════════════════════════════════════════════════╗
║ TASTE — PREFERENCE LEARNING RUNTIME ║
╚══════════════════════════════════════════════════════════════════════════════╝
┌──────────────────────────┐
│ USER INTERACTION │
│ accept / reject / edit │
│ test pass / lint signal │
└────────────┬─────────────┘
│
┌─────────────────────────────┼─────────────────────────────┐
│ │ │
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ AcceptReject │ │ DiffSignal │ │EditDistance │
│ Tracker │ │ Extractor │ │ Reward │
└───────┬───────┘ └───────┬───────┘ └───────┬───────┘
│ │ │
└──────────────────────────┼───────────────────────────┘
│
▼
┌─────────────────────┐
│ TasteSignalCollector │
│ (unified event hub) │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ TasteRewardModel │
│ signal → reward map │
└──────────┬──────────┘
│
┌───────────────┼───────────────┐
│ │ │
▼ ▼ ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│TasteBandit │ │AutoLearn │ │TasteDecay │
│ε-greedy (6 │ │Engine │ │confidence ↓ │
│strategy arms)│ │pattern→rule │ │over time │
└──────┬───────┘ └──────┬───────┘ └──────┬───────┘
│ │ │
│ ┌───────────┘ │
│ │ │
▼ ▼ │
┌──────────────────┐ │
│ TasteRuntime │◄────────────────────┘
│ (orchestrator) │
└────────┬─────────┘
│
┌─────────────┼─────────────┬──────────────────┐
│ │ │ │
▼ ▼ ▼ ▼
┌─────────┐ ┌──────────┐ ┌──────────────┐ ┌────────────────┐
│Symbolic │ │Neural │ │PromptInjector│ │ TasteEventLog │
│Engine │ │Scorer │ │injects │ │ append-only │
│compile │ │Jaccard/ │ │<clew_taste> │ │ JSONL │
│rules→ │ │TF-IDF │ │block (max 8 │ │ │
│check │ │relevance │ │rules) │ │ │
└────┬────┘ └────┬─────┘ └──────┬───────┘ └────────────────┘
│ │ │
▼ │ ▼
┌─────────┐ │ ┌────────────────┐
│validate │ │ │ SYSTEM PROMPT │
│Edit() │ └────►│ (taste block) │
│block if │ │ │
│conf ≥ │ │ → AI adapts │
│0.85 │ │ output style │
└─────────┘ └────────────────┘
═══ CODEBASE AUTO-LEARN ═══
Codebase ──► TasteCodebaseAnalyzer ──► PatternDetector ──► AutoLearnEngine
(อ่าน conventions) (ค้นหา patterns) (สร้าง rules)
│
▼
TasteProfileStore
.clew/taste/profile.json
คำสั่ง
| คำสั่ง | คำอธิบาย |
|---|---|
/taste | เปิดเมนู interactive |
/taste status | แสดงสถานะ |
/taste profile | แสดง rules ทั้งหมด |
/taste learn <rule> | เพิ่ม rule เอง |
/taste forget <id> | ลบ rule |
/taste suggest | ดูข้อเสนอจาก auto-learn |
/taste accept <id> | ยอมรับ suggestion |
/taste reject <id> | ปฏิเสธ suggestion |
ความเป็นส่วนตัว
- ข้อมูล taste ทั้งหมดอยู่ local
- โปรไฟล์และ event log ใน
.clew/taste/หรือ~/.clew/taste/ - ไม่ส่งข้อมูลไป cloud หรือ training
- Export/import เกิดเมื่อผู้ใช้สั่งเท่านั้น