“Transformer挑战者”Mamba,用Macbook也能跑了!GitHub半天斩获500+星

1,155次阅读
没有评论

克雷西 发自 凹非寺
量子位 | 公众号 QbitAI

“Transformer的挑战者”Mamba,用MacBook也能跑了!

有大佬在GitHub上共享了一份笔记,让人们可以用最简单的方式运行Mamba。

这份共享中,算上说明书一共只有三个文件,而且发布不到一天,就斩获了500+星标。

“Transformer挑战者”Mamba,用Macbook也能跑了!GitHub半天斩获500+星

Mamba是一种新的大模型架构,在语言任务上的表现可以与两倍规模的Transformer一决雌雄。

但官方给出的只有模型文件,需要一定专业知识才能部署使用,而且要Linux+N卡才能运行。

“Transformer挑战者”Mamba,用Macbook也能跑了!GitHub半天斩获500+星

有了这份笔记,Mamba的运行步骤大大简化,而且也不再要求N卡,M系列的MacBook也能跑了。

从事相关专业的网友看了表示,这种简单化的模型实在是太棒了,希望自己的工作也能朝着这个方向进展。

“Transformer挑战者”Mamba,用Macbook也能跑了!GitHub半天斩获500+星

原版Mamba的作者Tri Dao和Albert Gu也转发了这份笔记,并对它的简洁性和易读性给予了肯定。

“Transformer挑战者”Mamba,用Macbook也能跑了!GitHub半天斩获500+星

那么,这份笔记该如何使用呢?

两个文件即可运行

首先,打开一个能运行PyTorch笔记的工具,比如Jupyter、VSCode,或者在线的谷歌Colab等。

然后下载作者的笔记和Python脚本,用Colab的话也可以使用GitHub导入功能。

如果在本地运行,需要把两个文件放到同一个目录;如果用Colab,则需要在连接成功后把model.py上传。

“Transformer挑战者”Mamba,用Macbook也能跑了!GitHub半天斩获500+星

如果不上传,会出现“找不到‘model’”的报错

之后是安装所需的依赖环境,Colab需要手动安装的是einops,其他工具可以根据报错信息判断缺少的依赖。

!pip install 需要安装的依赖名称

“Transformer挑战者”Mamba,用Macbook也能跑了!GitHub半天斩获500+星

解决好依赖问题后,就可以点击笔记第一组中的运行按钮了,这里可以对模型规模进行选择,默认370M。

“Transformer挑战者”Mamba,用Macbook也能跑了!GitHub半天斩获500+星

接下来是初始化,直接点击运行按钮即可。

这里也可以对输出token的数量进行调节,默认是50。

“Transformer挑战者”Mamba,用Macbook也能跑了!GitHub半天斩获500+星

接着,笔记中给出了一些实例,我们也可以修改单引号之间的prompt内容(换行用n表示),然后点击运行。

不过需要注意的是,这里的prompt和我们平时用ChatGPT等bot型应用的方式有所区别。

“Transformer挑战者”Mamba,用Macbook也能跑了!GitHub半天斩获500+星

这里可以借用一下Hugging Face中Llama 2的系统提示词:

Below are a series of dialogues between various people and an AI assistant. The AI tries to be helpful, polite, honest, sophisticated, emotionally aware, and humble-but-knowledgeable. The assistant is happy to help with almost anything, and will do its best to understand exactly what is needed. It also tries to avoid giving false or misleading information, and it caveats when it isn’t entirely sure about the right answer. That said, the assistant is practical and really does its best, and doesn’t let caution get too much in the way of being useful.
User: 想问的问题
Assistant:

“Transformer挑战者”Mamba,用Macbook也能跑了!GitHub半天斩获500+星

性能上,在默认的规模和输出长度(370M,50token)下,输入Once Upon a time,在纯CPU版Colab中需用时约1分钟,在TPU上的用时则约为30秒,内存消耗在3到4GB之间。

“Transformer挑战者”Mamba,用Macbook也能跑了!GitHub半天斩获500+星

在M1芯片的Mac上,以相同设置处理同样的内容,则需花费1分半左右。

“Transformer挑战者”Mamba,用Macbook也能跑了!GitHub半天斩获500+星

不过作者也解释道,出于易读性的考虑,去掉了原版Mamba中的一些加速指令。

“Transformer挑战者”Mamba,用Macbook也能跑了!GitHub半天斩获500+星

参考链接:
https://news.ycombinator.com/item?id=38708730

—  —

点这里👇关注我,记得标星哦~

一键三连「分享」、「点赞」和「在看」

科技前沿进展日日相见 ~ 

“Transformer挑战者”Mamba,用Macbook也能跑了!GitHub半天斩获500+星

 

Read More 

正文完
可以使用微信扫码关注公众号(ID:xzluomor)
post-qrcode
 0
评论(没有评论)

文心AIGC

2023 年 12 月
 123
45678910
11121314151617
18192021222324
25262728293031
文心AIGC
文心AIGC
人工智能ChatGPT,AIGC指利用人工智能技术来生成内容,其中包括文字、语音、代码、图像、视频、机器人动作等等。被认为是继PGC、UGC之后的新型内容创作方式。AIGC作为元宇宙的新方向,近几年迭代速度呈现指数级爆发,谷歌、Meta、百度等平台型巨头持续布局
文章搜索
热门文章
清库存!DeepSeek突然补全R1技术报告,训练路径首次详细公开

清库存!DeepSeek突然补全R1技术报告,训练路径首次详细公开

清库存!DeepSeek突然补全R1技术报告,训练路径首次详细公开 Jay 2026-01-08 20:18:...
2025最大AI赢家的凡尔赛年度总结,哈萨比斯Jeff Dean联手执笔

2025最大AI赢家的凡尔赛年度总结,哈萨比斯Jeff Dean联手执笔

2025最大AI赢家的凡尔赛年度总结,哈萨比斯Jeff Dean联手执笔 鹭羽 2025-12-24 09:1...
AI Coding新王登场!MiniMax M2.1拿下多语言编程SOTA

AI Coding新王登场!MiniMax M2.1拿下多语言编程SOTA

AI C++oding新王登场!MiniMax M2.1拿下多语言编程SOTA 克雷西 2025-12-24 ...
智能体落地元年,Agent Infra是关键一环|对话腾讯云&Dify

智能体落地元年,Agent Infra是关键一环|对话腾讯云&Dify

智能体落地元年,Agent Infra是关键一环|对话腾讯云&Dify 鹭羽 2025-12-23 1...
最新评论
ufabet ufabet มีเกมให้เลือกเล่นมากมาย: เกมเดิมพันหลากหลาย ครบทุกค่ายดัง
tornado crypto mixer tornado crypto mixer Discover the power of privacy with TornadoCash! Learn how this decentralized mixer ensures your transactions remain confidential.
ดูบอลสด ดูบอลสด Very well presented. Every quote was awesome and thanks for sharing the content. Keep sharing and keep motivating others.
ดูบอลสด ดูบอลสด Pretty! This has been a really wonderful post. Many thanks for providing these details.
ดูบอลสด ดูบอลสด Pretty! This has been a really wonderful post. Many thanks for providing these details.
ดูบอลสด ดูบอลสด Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.
Obrazy Sztuka Nowoczesna Obrazy Sztuka Nowoczesna Thank you for this wonderful contribution to the topic. Your ability to explain complex ideas simply is admirable.
ufabet ufabet Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.
ufabet ufabet You’re so awesome! I don’t believe I have read a single thing like that before. So great to find someone with some original thoughts on this topic. Really.. thank you for starting this up. This website is something that is needed on the internet, someone with a little originality!
ufabet ufabet Very well presented. Every quote was awesome and thanks for sharing the content. Keep sharing and keep motivating others.
热评文章
易烊千玺的华为绿手机,真的AI了

易烊千玺的华为绿手机,真的AI了

Failed to fetch content Read More 
AI狼人杀大决战!GPT、Qwen、DeepSeek大乱斗,人类高玩汗流浃背

AI狼人杀大决战!GPT、Qwen、DeepSeek大乱斗,人类高玩汗流浃背

AI狼人杀大决战!GPT、Qwen、DeepSeek大乱斗,人类高玩汗流浃背 鹭羽 2025-12-23 14...
长城首个VLA车型发布,魏建军回应「赌上姓氏造车」

长城首个VLA车型发布,魏建军回应「赌上姓氏造车」

长城首个VLA车型发布,魏建军回应「赌上姓氏造车」 贾浩楠 2025-12-23 13:57:25 来源:量子...