huggingface/smollm

Everything about the SmolLM and SmolVLM family of models

SmollM – 来自 Hugging Face 的轻量级开源语言与视觉模型

是什么 – 一系列紧凑且完全开源的模型,可在装置端执行同时保持强大效能。旗舰模型为 SmolLM-3(3B 参数因果语言模型)与 SmolVLM(多模态视觉语言模型)。

为什么重要 – 大多数最先进的模型体积庞大,需要强大的服务器。SmollM 证明了透过精心的数据策划与训练技巧,3B 模型不仅能超越其他 3B 模型(如 Llama 3.2、Qwen2.5),甚至能与 4B 模型竞争,同时体积小到足以在 CPU 或中阶 GPU 上进行推论。

主要功能

  • SmolLM-3 – 3B 参数,使用 11T token 训练,支援 128k token 上下文(NoPE + YaRN)、双模式推理("think" / "no_think")以及六种语言的多语言指令。
  • SmolVLM – 视觉语言模型,可接收多张图片与文字,能回答视觉问题、描述图片并进行视觉叙事,针对装置端使用进行了优化。
  • 开源 – 模型权重、训练数据组合与完整训练配置皆已公开发布。
  • 易于使用 – 针对文字与视觉模型提供标准 Hugging Face transformers API,并附带用于本地推论的辅助脚本。

如何开始

# Text model
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "HuggingFaceTB/SmolLM3-3B"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name).to("cuda")

prompt = "Explain gravity in simple terms."
chat = [{"role": "user", "content": prompt}]
text = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
inputs = tokenizer([text], return_tensors="pt").to(model.device)
out_ids = model.generate(**inputs, max_new_tokens=32768)
print(tokenizer.decode(out_ids[0][len(inputs.input_ids[0]):], skip_special_tokens=True))
# Vision model
from transformers import AutoProcessor, AutoModelForVision2Seq
processor = AutoProcessor.from_pretrained("HuggingFaceTB/SmolVLM-Instruct")
model = AutoModelForVision2Seq.from_pretrained("HuggingFaceTB/SmolVLM-Instruct")

messages = [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What’s in this picture?"}]}]
# (use processor to encode image+text, then model.generate…) 

仓库结构

  • text/ – SmolLM 1-3 的代码、文档与资源。
  • vision/ – SmolVLM 的代码与文档。
  • tools/ – 共享工具与即用型推论脚本。

延伸阅读与资源

  • 模型卡片:HuggingFaceTB/SmolLM3-3B-Base, HuggingFaceTB/SmolLM3-3B, HuggingFaceTB/SmolVLM-Instruct。
  • 博客文章:https://hf.co/blog/smollm3
  • 论文:SmolLM2 paper (arXiv 2502.02737v1)。
  • 预训练数据集:SmolTalk, FineMath, FineWeb-Edu 等。

适合对象 – 对高效能 LLM 感兴趣的研究人员、开发装置端 AI 助理的开发者,以及任何需要小型且强大的语言或多模态模型且无专有限制的使用者。

相关

  • 项目
  • 项目
  • 项目
  • 项目