LLaMA全称是Large Language Model Meta AI,是由Meta AI研究职员发布的一个预训练语言模子。与最近爆火的ChatGPT相比,LLaMA架构更小,但训练过程和单GPU推理速度更快,成本更低。本日在刷推特的时间偶然中看到了如许一条消息,@ggerganov在GitHub上发布了llama.cpp,使用了4-bit量化将模子尽可能缩小,并能在多种移动装备上运行。这我就不淡定了,正妙手里有个闲置的Raspberry Pi 4B 4GB版本,赶紧搞起。
Added a new section to my post highlighting the advances we’ve already seen in the last two days: LLaMA runs on a 4GB RaspberryPi and a Pixel 6 phone now! https://t.co/pWOv6PP85b
— Simon Willison (@simonw) March 13, 2023
配置树莓派
假如你已经配置好了树莓派,且gcc版本为10以上的就可以跳过这一部分了
以下是我配置树莓派的步骤
起首通过Raspberry Pi Imager刷入系统至SD卡 - 系统版本为Ubuntu Server 22.10 (64 bit) - 注意这里一定要使用64 bit的系统,不然后续可能无法编译
配置系统
直接用命令行升级软件包并安装相干依赖,这里给出参考命令
这个题目比力坑爹。我一开始以为是编译器的题目,换了好几种选项都不可。后来发现是作者在03.14针对Apple Sillicon做的一个优化 Use vdotq_s32 to improve performance #67 - Merged。现在暂不清楚为什么树莓派无法处理这个,已经向作者反馈了。既然无法针对性的做处理,我实验了直接revert对应的commit。之后就没有编译错误可以继续了。在我报出这个题目之后两小时,另一位贡献者@Ronsor已经提出了一个PR去修复这个题目了 Don't use vdotq_s32 if it's not available #139,点赞。
预处理模子
# obtain the original LLaMA model weights and place them in ./models
./main -m ./models/7B/ggml-model-q4_0.bin -p "Building a website can be done in 10 simple steps:" -t 8 -n 512
复制代码
Building a website can be done in 10 simple steps:
Start with the end goal. Think about what your audience wants to achieve before they ever visit you site – and once there, how do these users interact on it? This is an important step as it will help formulate all of those great ideas into something that makes sense for their target marketplace!
2) Get Inspired & Develop a Mood Board: It's always good to have some kinda inspiration board. If you’re thinking about starting from scratch, use Pinterest or other sources (like Behance and Dribbble), as they will give your ideas a direction when it comes time for the visual design phase!
3) Strategize Your Content: Here's where things start to get tricky. You need some kinda content strategy in place here – do you have all of that information ready at hand? Now is also a good time as any to think about wireframes and how users will interact with your site once its built!
4) Do It With A Purpose: Are there particular goals for the user’s journey on this website, or simply trying to build an online presence? If so you may want to consider using marketing automation software like Hubspot that allows marketers and salespeople to work together better. This will help them organize your content into a more logical hierarchy – which is one of those things we love doing!
5) Visual Design: It's time for the fun part, where you think about colors (orange!) layout & typography, etcetera - and then start to design it using Illustrator or Photoshop. At this point in your project its important that all parties involved have a clear understanding of what needs to be done!
6) User Interface Design: This is when the UI designer comes into play – they should know how things interact with one another, understand user goals and create an experience so seamless it feels like second nature. The better this step goes down, you will end up having a much more engaging website at hand!
7) Coding Starts: After all of that planning is done here’s where the coding process begins – usually with HTML & CSS first and then followed by Javascript to make sure your site works flawlessly across multiple browsers.
8 ) Test, Test Again And Then Test Some More…: This phase can go on for a while (we know this from experience
main: mem per token = 14434244 bytes
main: load time = 4570.61 ms
main: sample time = 448.29 ms
main: predict time = 138987.47 ms / 271.99 ms per token
除开性能之外,项目的指引还需要更加完善一些才能够更好的帮到各人。
但无论如何,在训练和运行语言模子渐渐要求海量算力的本日,能有如许一个模子让个人装备也能跑起来一个以致还挺好用的模子,照旧挺让人感动的。不知道是巧合照旧什么,第一个跑通的老兄在Raspberry Pi 4 4GB #58里面展示的例句是:“The first man on the moon was Neil Armstrong…" 总要有人实验,去发现,去做第一个登上月球的人,不是吗?
参考文献
假如你想进一步相识相干内容的话,可以阅读下面的文章
ChatGPT论文阅读系列-LLaMA: Open and Efficient Foundation Language Models