תרגום מכונה · המקור באנגלית

Qwen3.5 Chat (On-Device LLM)

Qwen3.5-0.8B דלתא היברידית (לתשומת לב לינארית) + מודל ל- GatedAttention עם 24 שכבות (18 DeltaNet + 6 תשומת לב, כפיית INT4 עבור MLX (Metal GPU(ו) INT8 עבור CoreML (Neural Engine(ריצה) Mac באמצעות MLX או על iPhone ו Mac באמצעות CoreML עם הדור הזרמת טוקן, מיועד לצינורות קוליות שבו על-יד LLM מספק את "המוח" בין ASR ו TTS.

קו הקוסמטיקה מוכן

Qwen3.5 Chat משלב עם VoicePipeline כרכיב LLM ב ASR LLM TTS. ארכיטקטורת דלתא היברידית מספקת תשומת לב לינארית יעילה להקשרים ארוכים.

התחלה מהירה

import Qwen3Chat

let chat = try await Qwen35MLXChat.fromPretrained()

// Single response
let response = try chat.generate(messages: [
    ChatMessage(role: .system, content: "Answer briefly."),
    ChatMessage(role: .user, content: "What is Swift?")
])
print(response)

// Streaming tokens
let stream = chat.generateStream(messages: [
    ChatMessage(role: .system, content: "Be funny."),
    ChatMessage(role: .user, content: "Tell me a joke")
])
for try await token in stream {
    print(token, terminator: "")
}

ארכיטקטורה

Qwen3.5-0.8B הוא מודל היברידי עם 24 שכבות: 18 דלתאNet שכבות (התשומת לב לינארית עם הישנות חוק שערה ו-RMSNormGated) 6 שכבות של ריצוף (הופנה מהדף Dot-product Attention) MLX הגב רץ בהקצאה על Metal GPU עם משקלים בטוחים יותר CoreML backend משתמשת אדריכלות דוגמנית כפולה (prefill + decode) מותאם עבור Neural Engineשניהם תומכים KV cache עם קליגה מהירה ו- sampling (temperature, העליון-k, העליון-p, עונש החזרה).

מודל I/O

כיווןשם השםצורהתיאור תיאור
Inputinput_ids[1, Sq_len]ken IDs (Int32)
Inputattention_mask[1, Sq_len]מסכת קשב (Int32)
Inputkv_cacheper-layerהמונחים: key-value cache
Outputlogits[1, 1, 151936]הבא-token logits (Float16)
Outputkv_cache_outper-layerCV cache

מודלים

משתנההמונחיםגודלהמונחיםHuggingFace
Qwen3.5-0.8B ChatINT4418 MBMetal GPU (MLX)aufklarer/Qwen3.5-0.8B-Chat-MLX
Qwen3.5-0.8B ChatINT8981 MBNeural Engine (CoreML)aufklarer/Qwen3.5-0.8B-Chat-CoreML

בלבול

let config = ChatSamplingConfig(
    temperature: 0.7,
    topK: 40,
    topP: 0.9,
    maxTokens: 128,
    repetitionPenalty: 1.1
)
let response = try chat.generate(
    messages: [ChatMessage(role: .user, content: "Explain gravity")],
    sampling: config
)
ParameterDefaultתיאור תיאור
temperature0.6אקראיות (0 = חמדן, 1 = יצירתיות)
topK50עקבו אחרי Kמועמדים
topP0.95Nucleus sampling סף
maxTokens512Max Response tokens
repetitionPenalty1.1עונשים חוזרים
disableThinkingשקר כוזבמצב החשיבה
maxThinkingTokens100תגית: Tokens

שיחות מרובות-turn

let chat = try await Qwen35MLXChat.fromPretrained()

let history = [
    ChatMessage(role: .system, content: "Remember the user's name."),
    ChatMessage(role: .user, content: "My name is Alex"),
    ChatMessage(role: .assistant, content: "Nice to meet you, Alex!"),
    ChatMessage(role: .user, content: "What's my name?")
]
let response = try chat.generate(messages: history)
print(response)  // "Your name is Alex!"

chat.resetState()  // Clear inference state for a new conversation

ניהול זיכרון

// Check memory state
print(chat.isLoaded)        // true
print(chat.memoryFootprint) // 438304768 (~418 MB)

// Free memory under pressure
chat.unload()
print(chat.isLoaded)        // false

// Reload when needed
let chat = try await Qwen35MLXChat.fromPretrained()
iOS Memory Tip

ב-iPhone, Unloading LLM לפני TTS המונחים:418 MB (MB)INT4 MLX(או)981 MB (MB)INT8 CoreMLלמנוע הפסקת סילון כאשר ריצה מלאה ASR → LLM → TTS צינורות.

ביצועי ביצועים

התקןPrefillDecodeTokens/sec
M2 Max50ms65ms/tok15 Tok /s
אייפון 16 Pro1.5450ms/tok2.2 tok /s

המונחים:

MLX משקלים מומרים מהמקור Qwen3.5-0.8B מחסומים באמצעות MLX תסריט המרה CoreML המודלים משתמשים בתסריט ההמרה נפרד Neural Engine פריסה: משקלים מראש זמינים HuggingFace at at Aufklarer / Qwen3.5-0.8B-Chat-MLX (INT4: 418 MB) Aufklarer / Qwen3.5-0.8B-Chat-CoreML (INT8: 981 MB)