newsmode
search
Меню
arrow_back Назад

Raspberry-LLM - Making My Raspberry Pico a Little Smarter

auto_awesomeКраткое саммари

Юджин Ян описывает свой эксперимент raspberry-llm: Raspberry Pico с e-ink экраном, который получает RSS-ленты WSJ и HackerNews, обращается к сторонним LLM API и генерирует контент в разных стилях — от рифм в духе Доктора Сьюза до фейковых цитат знаменитостей и троллинговых комментариев в духе HackerNews. Проект начался с рифмованных часов и постепенно разросся. Главным вызовом стала работа всего с 8 КБ памяти на Micro Python, из-за чего привычные библиотеки вроде json и xmltodict оказались недоступны. Автору пришлось парсить RSS-ленты посимвольно, отслеживать потребление памяти на каждом шаге и активно использовать gc.collect(). Код доступен на GitHub — достаточно склонировать репозиторий и прописать свои Wi-Fi и OpenAI credentials в secrets.py.

Raspberry-LLM - Making My Raspberry Pico a Little Smarter

Raspberry-LLM — как я сделал свой Raspberry Pico немного умнее

[ llm 🛠 ] · 2 min read

[ llm 🛠 ] · 2 мин чтения

As I continue my exploration with large language models, I wondered how they might be used in a low-resource setting, such as a household appliance or a Raspberry Pico. I was also curious about how good they were with generating content in a particular style (e.g., Dr. Seuss), humour (e.g., fake WSJ quotes), and toxic (e.g., HackerNews troll comments).

Продолжая свои эксперименты с большими языковыми моделями, я задумался, как их можно использовать в условиях ограниченных ресурсов — например, в бытовой технике или на Raspberry Pico. Мне также было любопытно, насколько хорошо они справляются с генерацией контента в определённом стиле (скажем, Доктора Сьюза), с юмором (фейковые цитаты из WSJ) и с токсичными высказываниями (комментарии троллей с HackerNews).

To satisfy my curiosity, I hacked on raspberry-llm (Github). It’s a simple Raspberry Pico with an e-ink screen that calls WSJ and HackerNews RSS feeds, 3rd-party LLM APIs, and generates some content. It started with a rhyming clock, and then… well you’ll see.

Чтобы удовлетворить своё любопытство, я собрал raspberry-llm (Github). Это простой Raspberry Pico с e-ink экраном, который обращается к RSS-лентам WSJ и HackerNews, дёргает сторонние LLM API и генерирует контент. Всё началось с рифмующихся часов, а дальше… ну, сами увидите.

• • •

• • •

While some use LLMs to disrupt industries and more,

Кто-то LLM применяет, чтоб целые рынки взрывать,

Others build ChatGPT plugins, pushing boundaries galore.

Кто-то плагины к ChatGPT мастерит, чтоб границы менять.

Yet here I am with my Raspberry Pi loose,

А я тут с Raspberry Pi сижу, ни шатко, ни валко,

Using LLMs to explain headlines via Dr. Seuss.

И стилем Доктора Сьюза новости пересказать пытаюсь жалко.

You'll find that it can be quite witty,

Иногда выходит остроумно, не зря,

Making up fake quotes from celebrity.

Фейковые цитаты звёзд сочиняет, бля.

It can also pose as a hackernews troll,

Может прикинуться троллем с HackerNews,

Slinging mean comments, and being quite an a$$hole.

Кидаться злыми комментами, будто бы он не лез.

It all started with getting it to tell the time,

Всё началось с того, чтоб время сказать умело,

With a little quirk, with a little rhyme.

С маленькой странностью, с рифмой — несмело.

• • •

• • •

Overall, it was a fun experience learning how to work with only 8kb of memory(!) and Micro Python. Given the memory constraints, common libraries (e.g., json, xmltodict) were unavailable on the Pico. And even if they were, I couldn’t load the entire RSS feed into memory before parsing it via xmltodict.parse().

В целом это был забавный опыт — учиться работать всего с 8 КБ памяти(!) и Micro Python. Из-за ограничений по памяти привычные библиотеки (например, json, xmltodict) на Pico недоступны. Да даже если бы и были, я всё равно не смог бы загрузить всю RSS-ленту в память целиком, чтобы потом распарсить её через xmltodict.parse().

As a result, I had to parse RSS feeds character by character, learn how much memory was consumed at each step, and do lots of gc.collect(). It was also fun learning to draw on an e-ink screen (the helper functions made it easier than expected).

В итоге пришлось парсить RSS-ленты посимвольно, разбираться, сколько памяти потребляется на каждом шаге, и активно вызывать gc.collect(). А ещё было интересно научиться рисовать на e-ink экране (вспомогательные функции сделали это проще, чем я ожидал).

To try it, clone this GitHub repo and update your wifi and OpenAI credentials in secrets.py.

Чтобы попробовать самому, склонируйте этот GitHub-репозиторий и пропишите свои данные Wi-Fi и OpenAI в secrets.py.

OG image prompt on MidJourney: “An e-ink display connected to a raspberry pi displaying some text –ar 2:1”

Промпт для OG-картинки в MidJourney: «An e-ink display connected to a raspberry pi displaying some text –ar 2:1»

If you found this useful, please cite this write-up as:

Если этот материал оказался полезным, ссылайтесь на него так:

Yan, Ziyou. (Apr 2023). Raspberry-LLM - Making My Raspberry Pico a Little Smarter. eugeneyan.com. https://eugeneyan.com/writing/raspberry-llm/.

Yan, Ziyou. (Apr 2023). Raspberry-LLM - Making My Raspberry Pico a Little Smarter. eugeneyan.com. https://eugeneyan.com/writing/raspberry-llm/.

or

или

@article{yan2023raspberry, title = {Raspberry-LLM - Making My Raspberry Pico a Little Smarter}, author = {Yan, Ziyou}, journal = {eugeneyan.com}, year = {2023}, month = {Apr}, url = {https://eugeneyan.com/writing/raspberry-llm/} }

@article{yan2023raspberry, title = {Raspberry-LLM - Making My Raspberry Pico a Little Smarter}, author = {Yan, Ziyou}, journal = {eugeneyan.com}, year = {2023}, month = {Apr}, url = {https://eugeneyan.com/writing/raspberry-llm/} }



Join 11,800+ readers getting updates on machine learning, RecSys, LLMs, and engineering.

Присоединяйтесь к 11 800+ читателям, получающим новости о machine learning, RecSys, LLM и инженерии.