Skip to main content

Virtual Models บน LiteLLM Proxy: 1 โมเดล 10 profiles ใช้ให้เหมาะกับงาน

· 7 min read

ผมใช้ Qwen3.6-35B-A3B-NVFP4 เป็น backend model ตัวเดียว แล้วสร้าง Virtual Models ผ่าน LiteLLM Proxy เป็น 10 profiles ตามลักษณะงาน

ทุก profile ชี้ไปที่โมเดลเดียวกัน แต่ override sampling parameters ต่างกัน — ทำให้โมเดลเดียวกันตอบออกมา "คนละคน" ตาม use case

TL;DR

  • ใช้ Qwen3.6-35B-A3B-NVFP4 1 ตัว backend สร้าง 10 profiles ผ่าน LiteLLM Proxy
  • แต่ละ profile ตั้งค่า temperature, top_p, presence_penalty, max_tokens, thinking ต่างกันตามงาน
  • qwen-chat-think เป็น default ใช้บ่อยสุด 60% รองด้วย qwen-coder 15%, qwen-agent 10%, qwen-longctx 10% และอื่น ๆ 5%
  • ตัด qwen-reasoning-low และ qwen-agent-think ออก เพราะ overlap กันเกินไป แยกเป็น qwen-debug และ qwen-agent-creative ที่เห็นความต่างชัดกว่า
  • Routing ใน Hermes ตั้ง default_model: qwen-chat-think แล้ว override ตาม task

ตาราง 10 Virtual Profiles

ProfileTop-PTemperaturePresence PenaltyMax TokensThinkingSpecialUse Case
qwen-chat-think ⭐ Default0.950.60.08,192onparallel_tool_calls, preserve_thinkingGeneral Assistant, Web Search, News Summary, Daily Chat, Tool Calling
qwen-reasoning0.950.70.216,384onparallel_tool_calls, preserve_thinkingArchitecture Review, Research, Planning, System Design
qwen-debug0.950.30.016,384onparallel_tool_calls, preserve_thinkingDebugging, RCA, Log Analysis, Incident Investigation
qwen-coder0.950.20.08,192onparallel_tool_calls, preserve_thinkingPython, TypeScript, SQL, Docker, MCP, DevOps
qwen-agent0.900.10.08,192onparallel_tool_calls, preserve_thinkingDeterministic Tool Calling, Workflow Execution, Multi-Step Tasks
qwen-agent-creative0.950.80.312,288onparallel_tool_calls, preserve_thinkingResearch Agent, Brainstorming Agent, Content Agent
qwen-chat0.950.80.24,096offFast Chatbot, FAQ, Casual Conversation
qwen-longctx0.950.20.016,384onparallel_tool_calls, preserve_thinkingRAG, Codebase Analysis, Documentation, Long Reports
qwen-mini0.20.10.04,096offClassification, Extraction, Formatting, Commit Message
qwen-trading1.00.00.04,096on*seed=42Market Analysis, Signal Evaluation, Structured Financial Output

ทำไมต้องแยกเป็น 10 profiles

โมเดลตัวเดียวกัน แต่ sampling ต่างกัน ทำให้พฤติกรรมต่างกันอย่างเห็นได้ชัด

  • งานแชททั่วไปต้องการความเป็นธรรมชาติ → temperature สูงหน่อย
  • งาน coding ต้องการความแม่นยำ → temperature ต่ำ
  • งาน agent ต้องการ deterministic สูงสุด → temperature ต่ำมาก + top_p แคบ
  • งาน creative ต้องการแตกไอเดีย → temperature สูง + presence_penalty มีค่า

การแยก profile ช่วยให้ client เรียกง่าย เปลี่ยน backend ได้ภายหลัง และ debug ชัดเจนเพราะเห็นชื่อ profile ใน log

รายละเอียดแต่ละ Profile

qwen-chat-think ⭐ Default

  • Use Case: General Assistant, Web Search, News Summary, Daily Chat, Tool Calling
  • เหตุผล: เป็น Primary Model / Router ที่ตัดสินใจว่าจะตอบเองหรือส่งต่อให้ profile อื่น
  • temperature: 0.6 สมดุลระหว่างความเป็นธรรมชาติกับความแม่นยำ
  • presence_penalty: 0.0 ป้องกัน JSON ของ tool call พัง
  • max_tokens: 8192 เผื่อพื้นที่ thinking + คำตอบ
{
"min_p": 0,
"top_k": 20,
"top_p": 0.95,
"extra_body": {
"chat_template_kwargs": {
"enable_thinking": true,
"preserve_thinking": true
}
},
"guardrails": [],
"max_tokens": 8192,
"temperature": 0.6,
"presence_penalty": 0.0,
"repetition_penalty": 1,
"parallel_tool_calls": true
}

qwen-reasoning

  • Use Case: Architecture Review, Research, Planning, System Design
  • เหตุผล: เน้นคิดเชิงระบบ วางแผน ออกแบบ วิเคราะห์เชิงกลยุทธ์
{
"min_p": 0,
"top_k": 20,
"top_p": 0.95,
"extra_body": {
"chat_template_kwargs": {
"enable_thinking": true,
"preserve_thinking": true
}
},
"guardrails": [],
"max_tokens": 16384,
"temperature": 0.7,
"presence_penalty": 0.2,
"repetition_penalty": 1,
"parallel_tool_calls": true
}

qwen-debug

  • Use Case: Debugging, RCA, Log Analysis, Incident Investigation
  • เหตุผล: เน้นหาสาเหตุ ตรวจ log อ่าน stacktrace แก้ bug
{
"min_p": 0,
"top_k": 20,
"top_p": 0.95,
"extra_body": {
"chat_template_kwargs": {
"enable_thinking": true,
"preserve_thinking": true
}
},
"guardrails": [],
"max_tokens": 16384,
"temperature": 0.3,
"presence_penalty": 0.0,
"repetition_penalty": 1,
"parallel_tool_calls": true
}

qwen-coder

  • Use Case: Python, TypeScript, SQL, Docker, MCP, DevOps
  • เหตุผล: Coding ต้องการความถูกต้องสูง กด temperature ต่ำเพื่อลด hallucination
{
"min_p": 0,
"top_k": 20,
"top_p": 0.95,
"extra_body": {
"chat_template_kwargs": {
"enable_thinking": true,
"preserve_thinking": true
}
},
"guardrails": [],
"max_tokens": 8192,
"temperature": 0.2,
"presence_penalty": 0.0,
"repetition_penalty": 1,
"parallel_tool_calls": true
}

qwen-agent

  • Use Case: Deterministic Tool Calling, Workflow Execution, Multi-Step Tasks
  • เหตุผล: Agent ต้องการ deterministic สูงสุด เพื่อให้ parser อ่านได้แม่นยำ 100%
{
"min_p": 0,
"top_k": 20,
"top_p": 0.90,
"extra_body": {
"chat_template_kwargs": {
"enable_thinking": true,
"preserve_thinking": true
}
},
"guardrails": [],
"max_tokens": 8192,
"temperature": 0.1,
"presence_penalty": 0.0,
"repetition_penalty": 1,
"parallel_tool_calls": true
}

qwen-agent-creative

  • Use Case: Research Agent, Brainstorming Agent, Content Agent
  • เหตุผล: เน้นแตกไอเดีย ค้นคว้า สร้างเนื้อหา
{
"min_p": 0,
"top_k": 20,
"top_p": 0.95,
"extra_body": {
"chat_template_kwargs": {
"enable_thinking": true,
"preserve_thinking": true
}
},
"guardrails": [],
"max_tokens": 12288,
"temperature": 0.8,
"presence_penalty": 0.3,
"repetition_penalty": 1,
"parallel_tool_calls": true
}

qwen-chat

  • Use Case: Fast Chatbot, FAQ, Casual Conversation
  • เหตุผล: แชทธรรมดา ไม่ต้อง thinking ตอบเร็ว
{
"min_p": 0,
"top_k": 20,
"top_p": 0.95,
"extra_body": {
"chat_template_kwargs": {
"enable_thinking": false,
"preserve_thinking": false
}
},
"guardrails": [],
"max_tokens": 4096,
"temperature": 0.8,
"presence_penalty": 0.2,
"repetition_penalty": 1,
"parallel_tool_calls": false
}

qwen-longctx

  • Use Case: RAG, Codebase Analysis, Documentation, Long Reports
  • เหตุผล: ต้องการ faithfulness สูงสุดกับ context ยาว
{
"min_p": 0,
"top_k": 20,
"top_p": 0.95,
"extra_body": {
"chat_template_kwargs": {
"enable_thinking": true,
"preserve_thinking": true
}
},
"guardrails": [],
"max_tokens": 16384,
"temperature": 0.2,
"presence_penalty": 0.0,
"repetition_penalty": 1,
"parallel_tool_calls": true
}

qwen-mini

  • Use Case: Classification, Extraction, Formatting, Commit Message
  • เหตุผล: งานเล็ก ๆ ต้องการ output คงที่ deterministic สูงสุด
{
"min_p": 0,
"top_k": 20,
"top_p": 0.20,
"extra_body": {
"chat_template_kwargs": {
"enable_thinking": false,
"preserve_thinking": false
}
},
"guardrails": [],
"max_tokens": 4096,
"temperature": 0.1,
"presence_penalty": 0.0,
"repetition_penalty": 1,
"parallel_tool_calls": false
}

qwen-trading

  • Use Case: Market Analysis, Signal Evaluation, Structured Financial Output
  • เหตุผล: ต้องการ output แบบ reproducible สูงสุด
{
"min_p": 0,
"top_k": 20,
"top_p": 1.0,
"extra_body": {
"chat_template_kwargs": {
"enable_thinking": true,
"preserve_thinking": true
}
},
"guardrails": [],
"max_tokens": 4096,
"temperature": 0.0,
"presence_penalty": 0.0,
"repetition_penalty": 1,
"seed": 42,
"parallel_tool_calls": true
}

Note: qwen-trading ใช้ thinking: on* บางกรณีอาจ override จาก client ได้

หมายเหตุสำหรับ Qwen3.6-35B-A3B

จากประสบการณ์กับ Qwen รุ่น reasoning/thinking:

  • presence_penalty เกิน 0.5 มักเริ่มมีผลข้างเคียงมากกว่าประโยชน์
  • temperature ช่วง 0.5-0.7 เป็น sweet spot สำหรับงานทั่วไป
  • งาน Agent ควรใช้ temperature <= 0.2
  • งาน RAG/Codebase Analysis ควรใช้ temperature <= 0.3
  • งานเขียนคอนเทนต์หรือ brainstorming ควรใช้ temperature 0.8-1.0
  • repetition_penalty ควรคงไว้ที่ 1.0 เว้นแต่จะเจอปัญหาคำซ้ำจริง เพราะ Qwen รุ่นใหม่จัดการเรื่องนี้ได้ค่อนข้างดีอยู่แล้ว

ทำไมถึงตัด qwen-reasoning-low และ qwen-agent-think ออก

ชุดเดิมมี

qwen-reasoning
qwen-reasoning-low
qwen-agent-think

สามตัวนี้ overlap กันเยอะ — พฤติกรรมใกล้กันเกินไป ไม่เห็นความต่างชัดพอ

ผมแยกใหม่เป็น

qwen-reasoning
qwen-debug
qwen-agent-creative

ซึ่งเห็นความต่างชัดกว่า

qwen-reasoning

เน้น

คิดเชิงระบบ
วางแผน
ออกแบบ
วิเคราะห์เชิงกลยุทธ์

qwen-debug

เน้น

หาสาเหตุ
ตรวจ log
อ่าน stacktrace
แก้ bug

qwen-agent-creative

เน้น

แตกไอเดีย
ค้นคว้า
สร้างเนื้อหา

Profile ที่จะถูกเรียกใช้จริงบ่อยสุด

จากลักษณะงานที่ใช้งานจริงในช่วงที่ผ่านมา

Profileสัดส่วนการใช้งาน
qwen-chat-think60%
qwen-coder15%
qwen-agent10%
qwen-longctx10%
อื่น ๆ5%

ดังนั้นถ้าจะทำ routing ใน Hermes ผมจะตั้ง

default_model: qwen-chat-think

แล้วค่อย override ตาม task

Routing คร่าว ๆ

Docker / Linux / SQL
→ qwen-coder

MCP / Agent Workflow
→ qwen-agent

อ่าน repo ใหญ่
→ qwen-longctx

อ่านข่าว + web search
→ qwen-chat-think

Architecture Review
→ qwen-reasoning

Debug Log
→ qwen-debug

Brainstorm Blog / Content
→ qwen-agent-creative

ชุดนี้จะครอบคลุมงานสาย DevOps, Agent, RAG, MCP และงานวิเคราะห์เชิงเทคนิคได้ค่อนข้างสมดุล โดยไม่ต้องมี profile ที่พฤติกรรมใกล้กันเกินไป

Conclusion

การใช้โมเดลตัวเดียวกันแล้วสร้าง Virtual Models ผ่าน LiteLLM Proxy ช่วยให้แต่ละ profile ตอบสนองงานได้ตรงกับลักษณะงานมากขึ้น โดยไม่ต้องเพิ่มต้นทุน infrastructure

ชุด 10 profiles บน Qwen3.6-35B-A3B-NVFP4 นี้ครอบคลุมงานสาย DevOps, Agent, RAG, MCP และงานวิเคราะห์เชิงเทคนิคได้ค่อนข้างสมดุล โดยไม่ต้องมี profile ที่พฤติกรรมใกล้กันเกินไป

References

แชร์บทความ

เนื้อหานี้มีประโยชน์ไหม? ช่วยสนับสนุนค่ากาแฟให้ผู้เขียนสักแก้ว

Buy Me a Coffee
Loading...