2025年4月6日,HuggingFace 正式发布了 Transformers v4.51.0,本次更新堪称 AI 界的“超级大礼包”!不仅新增了 Meta 的 Llama 4、微软的 Phi4-Multimodal、深度求索的 DeepSeek-V3 以及 Qwen3 四大重量级模型,还优化了多项功能,修复了诸多 Bug,让 AI 开发者们直呼“真香”!
本文将深入解析 v4.51.0 的核心更新,包括:
如果你是 AI 开发者、研究人员,或者对前沿 AI 技术感兴趣,这篇文章绝对不容错过!
Meta 此次推出的 Llama 4 采用了 混合专家(Mixture-of-Experts, MoE)架构,并分为两个版本:
两者均支持 多模态输入(文本+图像),并在 200 种语言数据上进行了训练,其中 12 种语言(如阿拉伯语、西班牙语、德语、印地语)进行了专门的微调。
from transformers import AutoProcessor, Llama4ForConditionalGeneration
import torch
model_id = "meta-llama/Llama-4-Maverick-17B-128E-Instruct"
processor = AutoProcessor.from_pretrained(model_id)
model = Llama4ForConditionalGeneration.from_pretrained(
model_id,
attn_implementation="flex_attention",
device_map="auto",
torch_dtype=torch.bfloat16,
)
url1 = "https://example.com/rabbit.jpg"
url2 = "https://example.com/cat.png"
messages = [
{
"role": "user",
"content": [
{"type": "image", "url": url1},
{"type": "image", "url": url2},
{"type": "text", "text": "描述这两张图片的异同?"},
]
},
]
inputs = processor.apply_chat_template(messages, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256)
response = processor.batch_decode(outputs)[0]
print(response)
运行方式:
torchrun --nproc-per-instance=8 script.py # 需要 8 张 GPU
模态 | 支持语言 |
---|---|
文本 | 阿拉伯语、中文、英语、法语、德语等 23 种 |
视觉 | 英语 |
音频 | 英语、中文、德语、法语、日语等 8 种 |
在多项基准测试中,DeepSeek-V3 超越开源模型,接近闭源顶级模型(如 GPT-4)。
虽然 Qwen3 的模型尚未正式发布,但 Transformers v4.51.0 已支持其架构,预计阿里很快会推出新版本。
HuggingFace/Transformers v4.51.0 的发布,标志着 AI 开源生态的又一次飞跃!
如果你是 AI 开发者,赶快升级体验吧!
pip install -U transformers[hf_xet]
未来,AI 的边界在哪里?HuggingFace 正在一步步给出答案! 🚀
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有