Загрузка видео...

Не удалось загрузить видео

На главную

I trained a small model to do syntax highlighting in the browser with GPU. Meet gpu-lexer from Vercel Labs: Small (27.5KB), fast (runs on WebGPU), and language-agnostic (model guesses the syntax). It is experimental and built for learning!

799,826 просмотров • 1 месяц назад •via X (Twitter)

Комментарии: 46

Фото профиля Shu
Shu1 месяц назад

Perf is good thanks to WebGPU, especially when the source is large. Also it doesn’t block the main CPU thread. Keep in mind that all highlighters have different pipelines and use cases. This project can’t yet be used to fully replace any.

Фото профиля Shu
Shu1 месяц назад

Size is also impressive considering that it’s trained with 50+ languages (and it behaves okay for languages outside of the training group). The model itself is like 70% of the lib, inlined in the bundle.

Фото профиля Shu
Shu1 месяц назад

Correctness. I’m comparing every span types with Shiki, which is almost the golden standard today. It shows the weighted correctness of top 25 popular languages on GitHub. Shiki uses real AST while others might not, hence the differences.

Фото профиля Shu
Shu1 месяц назад

Why creating this? I’ve been struggling with syntax highlighting for years mostly because: 1) large language grammar bundles; 2) language detection and dynamic loading; 3) bad perf and slow down of main app. And it’s great to explore more possibilities and share!

Фото профиля Maximiliano Moxarella
Maximiliano Moxarella1 месяц назад

using matrix multiplication to turn the word function yellow is truly what alan turing died for

Фото профиля shadcn
shadcn1 месяц назад

🤯

Фото профиля Evil Rabbit
Evil Rabbit1 месяц назад

shu you are my hero

Фото профиля Shu
Shu1 месяц назад

Evil you’re mine too

Фото профиля Evil Rabbit
Evil Rabbit1 месяц назад

🤍🫂

Фото профиля Patrick Smith
Patrick Smith1 месяц назад

My new js-syntax-highlight-html.wasm is faster for three.min.js and gets within 99.9% agreement with Shiki. I really love the language-agnostic model idea so I’m fascinated to see how that evolves.

Фото профиля Shu
Shu1 месяц назад

Looks amazing & wasm makes a lot of sense, this is the way for accurate highlighting.

Фото профиля Patrick Smith
Patrick Smith1 месяц назад

I’m really excited to see how gpu-lexer evolves, I think I see it’s already updated on your site so I’m comparing again. I’m also curious if a small model executing on WebAssembly could be viable, especially with SIMD!

Фото профиля Aiden Bai
Aiden Bai1 месяц назад

frickin awesome

Фото профиля Guillaume Ausset - @ausset.me
Guillaume Ausset - @ausset.me1 месяц назад

That’s right, syntax highlighting goes into the transformer hole.

Фото профиля Aarav Dayal
Aarav Dayal1 месяц назад

IDK man its not that good.

Фото профиля Jingtao Wang
Jingtao Wang1 месяц назад

Marvellous! I'm particularly interested in how you trained it. Would you mind sharing it someday?

Фото профиля Brett Lamy
Brett Lamy1 месяц назад

Is this open source? Where do I download the model? Is there a NPM package I can install?

Фото профиля Evan Bacon 🥓
Evan Bacon 🥓1 месяц назад

This is wild, nice work!

Фото профиля Shu
Shu1 месяц назад

Thanks Evan!

Фото профиля Matias 🧉
Matias 🧉1 месяц назад

this is so cool

Фото профиля Max
Max1 месяц назад

This is sick!

Фото профиля Daniel White
Daniel White1 месяц назад

this is crazy work man, you're cooking as always !!

Фото профиля Mike Majara
Mike Majara1 месяц назад

@cramforce Incredible! Vid looks class to what did you use?

Фото профиля Shu
Shu1 месяц назад

@cramforce It's made with

Фото профиля Mendy
Mendy1 месяц назад

Will you share the process?

Фото профиля Duncan
Duncan1 месяц назад

wow

Фото профиля Ericoolen
Ericoolen1 месяц назад

Great experiment, but when I look at examples on cpp and haskell, its highlighting is pretty poor and inconsistent, and I think those languages should benefit most from such an approach for syntax highlighting, as normal ways cannot handle those complex and extendable syntaxes.

Фото профиля Anoop
Anoop1 месяц назад

Incredible 🤯 -- r u planning on writing article on the training process ?

Фото профиля Dominic Gannaway
Dominic Gannaway1 месяц назад

this is awesome! it's a shame it doesn't too well with tsrx though :(

Фото профиля Shu
Shu1 месяц назад

I can re-train it with some examples!

Фото профиля Dominic Gannaway
Dominic Gannaway1 месяц назад

that would be amazing! you can find plenty of examples here thank you!

Фото профиля Jesse
Jesse1 месяц назад

very nice

Фото профиля Duncan
Duncan1 месяц назад

this is really really good and impressive

Фото профиля Bola Banjo
Bola Banjo1 месяц назад

Insaneeeeee.

Фото профиля Pedro Duarte
Pedro Duarte1 месяц назад

🐐

Фото профиля Terry · OpenCreators
Terry · OpenCreators1 месяц назад

27KB GPU syntax highlighter in-browser — language-agnostic lexing is the part I want to steal.

Фото профиля Travis Fischer
Travis Fischer1 месяц назад

this is so dope dude would love more details on how you trained the model

Фото профиля Alex
Alex1 месяц назад

27.5KB doing syntax highlighting in-browser on WebGPU is the demo that sticks. once the model is a local primitive you ship with the page, latency and privacy stop being product features you apologize for.

Фото профиля Matthew Porteous
Matthew Porteous1 месяц назад

very cool

Фото профиля Zach
Zach1 месяц назад

Dude... what!? Incredible. Can you share your process for this?

Фото профиля Avinash
Avinash1 месяц назад

additionally - would be cool to have stories like this in aiconf asia -

Фото профиля Aryan Vichare
Aryan Vichare1 месяц назад

this is so cool

Фото профиля NSPG 911
NSPG 9111 месяц назад

or we could just use hljs?

Фото профиля Simon Le Marchant
Simon Le Marchant1 месяц назад

Now that's pretty damn cool

Фото профиля Enri
Enri1 месяц назад

magic!

Фото профиля Patrick Smith
Patrick Smith1 месяц назад

Many programming languages are context-sensitive so I imagine the attention of language models is a perfect fit. Very cool stuff!

Похожие видео