HuggingFace镜像/Qwen3.5-27B-Claude-4.6-Opus-Distilled-MLX-4bit
模型介绍文件和版本分析
下载使用量0

Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-4bit-MLX

由 BeastCode 进行量化

这是 Jackrong/Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled 的高性能4位MLX量化版本。专为Apple Silicon(M系列芯片)优化,可在本地提供深度、智能体级别的推理能力。

原始BF16权重大小为55.6 GB。经过此次转换后,模型体积缩减至14 GB,使得任何配备24 GB及以上统一内存的Mac都能流畅运行,且仍有足够空间支持大上下文窗口。


🧠 为何选择此模型?

大多数本地LLM属于"反应式"——它们在尚未完全梳理清楚逻辑之前就开始生成响应。而本模型则是深思熟虑型的。

它从最先进的Claude 4.6 Opus推理轨迹中蒸馏而来,采用高级思维链(CoT)框架。在给出最终答案前,它会进入一个内部</think>状态,在此状态下:

  • 解构复杂的多层提示,将其分解为可管理的子任务
  • 模拟不同的解决路径,并在您看到结果之前自我纠正逻辑错误
  • 减少冗余,采用Claude的结构化思维模式,而非基础推理模型中常见的循环思维

这使它成为Apple硬件上技术规划、复杂逻辑谜题和高风险决策支持的首选模型。


📊 性能基准测试

在Apple M4 Pro(64 GB)上测试 · mlx-lm 0.30.7 · macOS 15

指标结果
模型加载时间2.4秒
提示处理速度86.5 tokens/秒
生成速度15.7 tokens/秒
峰值内存占用15.6 GB
比特率4.501 bits/weight
最终大小14 GB(3个分片)

💻 系统要求

硬件Apple Silicon Mac(M1、M2、M3、M4或更高版本)
最低内存24 GB统一内存
推荐内存32 GB以上(为长上下文推理预留空间)
操作系统macOS 13.5或更高版本
Python3.10+(推荐Homebrew Python 3.12)

🚀 快速开始

1. 安装 MLX 库

pip install mlx-lm

2. 在终端中运行

python -m mlx_lm.chat \
  --model BeastCode/Qwen3.5-27B-Claude-4.6-Opus-Distilled-MLX-4bit

3. Python 集成 — 推荐方法

使用 apply_chat_template 并设置 enable_thinking=True。这是触发推理模式的规范方式,无需手动构建提示词。

from mlx_lm import load, generate

model, tokenizer = load("BeastCode/Qwen3.5-27B-Claude-4.6-Opus-Distilled-MLX-4bit")

messages = [
    {
        "role": "user",
        "content": (
            "A farmer needs to cross a river with a wolf, a goat, and a cabbage. "
            "The boat can only hold the farmer and one other item. "
            "If left alone, the wolf eats the goat, and the goat eats the cabbage. "
            "How can he get everything across safely?"
        ),
    }
]

# enable_thinking=True inserts the <think> prefix automatically
prompt = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True,
    enable_thinking=True,
)

response = generate(model, tokenizer, prompt=prompt, max_tokens=2048, verbose=True)
print(response)

提示: 将 enable_thinking=False(或省略该参数)设置为快速、直接的回答,不包含推理块——适用于简单查询或对延迟敏感的聊天场景。

手动预填充样式(高级)

如果您想确切了解底层发生的情况,可以手动构建提示并自行预填充 </think> 标记。这两种方法会产生完全相同的结果。

prompt = (
    "<|im_start|>system\n"
    "You are a highly analytical assistant.\n"
    "<|im_end|>\n"
    "<|im_start|>user\n"
    "A farmer needs to cross a river with a wolf, a goat, and a cabbage. "
    "The boat can only hold the farmer and one other item. "
    "If left alone, the wolf eats the goat, and the goat eats the cabbage. "
    "How can he get everything across safely?\n"
    "<|im_end|>\n"
    "<|im_start|>assistant\n"
    "<think>\n"
)

response = generate(model, tokenizer, prompt=prompt, max_tokens=2048, verbose=True)
print(response)

⚙️ 量化详情

属性值
方法4-bit 分组量化
精度混合(嵌入层/注意力头保留更高精度以确保稳定性)
工具mlx-lm.convert
基础模型Qwen 3.5 27B(密集架构)

复现此量化过程

python -m mlx_lm.convert \
  --hf-path Jackrong/Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled \
  --mlx-path ./Qwen3.5-27B-Claude-4.6-MLX \
  --quantize \
  --q-bits 4

🧩 移除推理模块

</think> 模块对于验证逻辑非常宝贵,但为了界面更简洁,你可能希望将其移除:

import re

def strip_thinking(text: str) -> str:
    """Remove the internal <think> process, returning only the final answer."""
    return re.sub(r'<think>.*?</think>\s*', '', text, flags=re.DOTALL).strip()

🏆 模型对比

模型大小推理风格硬件目标
本模型 (27B)14 GBClaude 4.6 蒸馏版24 GB+ 苹果电脑
Qwen3.5-9B~5 GB快速/直观基础款 8 GB / 16 GB 苹果电脑
Qwen3.5-72B~42 GB深度/详尽64 GB+ Ultra/Max 机型

🙏 致谢

  • 核心权重: 阿里巴巴 Qwen 团队 — Qwen 3.5 27B
  • 推理微调: Jackrong 所做的 Claude 4.6 Opus 蒸馏工作
  • 推理引擎: 苹果 MLX 团队,让苹果芯片实现高速本地推理成为可能