Video yükleniyor...

Video Yüklenemedi

Ana Sayfaya Dön

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!

663,024 görüntüleme • 2 gün önce •via X (Twitter)

46 Yorum

Shu profil fotoğrafı
Shu2 gün önce

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 profil fotoğrafı
Shu2 gün önce

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 profil fotoğrafı
Shu2 gün önce

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 profil fotoğrafı
Shu2 gün önce

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 profil fotoğrafı
Maximiliano Moxarella2 gün önce

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

shadcn profil fotoğrafı
shadcn2 gün önce

🤯

Evil Rabbit profil fotoğrafı
Evil Rabbit2 gün önce

shu you are my hero

Shu profil fotoğrafı
Shu2 gün önce

Evil you’re mine too

Evil Rabbit profil fotoğrafı
Evil Rabbit2 gün önce

🤍🫂

Patrick Smith profil fotoğrafı
Patrick Smith1 gün önce

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 profil fotoğrafı
Shu1 gün önce

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

Patrick Smith profil fotoğrafı
Patrick Smith1 gün önce

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 profil fotoğrafı
Aiden Bai2 gün önce

frickin awesome

Guillaume Ausset - @ausset.me profil fotoğrafı
Guillaume Ausset - @ausset.me2 gün önce

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

Aarav Dayal profil fotoğrafı
Aarav Dayal2 gün önce

IDK man its not that good.

Jingtao Wang profil fotoğrafı
Jingtao Wang2 gün önce

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

Brett Lamy profil fotoğrafı
Brett Lamy2 gün önce

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

Evan Bacon 🥓 profil fotoğrafı
Evan Bacon 🥓2 gün önce

This is wild, nice work!

Shu profil fotoğrafı
Shu1 gün önce

Thanks Evan!

Matias 🧉 profil fotoğrafı
Matias 🧉2 gün önce

this is so cool

Max profil fotoğrafı
Max2 gün önce

This is sick!

Daniel White profil fotoğrafı
Daniel White2 gün önce

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

Mike Majara profil fotoğrafı
Mike Majara2 gün önce

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

Shu profil fotoğrafı
Shu1 gün önce

@cramforce It's made with

Mendy profil fotoğrafı
Mendy2 gün önce

Will you share the process?

Duncan profil fotoğrafı
Duncan2 gün önce

wow

Ericoolen profil fotoğrafı
Ericoolen2 gün önce

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 profil fotoğrafı
Anoop2 gün önce

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

Dominic Gannaway profil fotoğrafı
Dominic Gannaway1 gün önce

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

Shu profil fotoğrafı
Shu1 gün önce

I can re-train it with some examples!

Dominic Gannaway profil fotoğrafı
Dominic Gannaway1 gün önce

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

Jesse profil fotoğrafı
Jesse2 gün önce

very nice

Duncan profil fotoğrafı
Duncan2 gün önce

this is really really good and impressive

Bola Banjo profil fotoğrafı
Bola Banjo2 gün önce

Insaneeeeee.

Pedro Duarte profil fotoğrafı
Pedro Duarte1 gün önce

🐐

Terry · OpenCreators profil fotoğrafı
Terry · OpenCreators2 gün önce

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

Travis Fischer profil fotoğrafı
Travis Fischer1 gün önce

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

Alex profil fotoğrafı
Alex2 gün önce

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 profil fotoğrafı
Matthew Porteous2 gün önce

very cool

Zach profil fotoğrafı
Zach2 gün önce

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

Avinash profil fotoğrafı
Avinash1 gün önce

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

Aryan Vichare profil fotoğrafı
Aryan Vichare2 gün önce

this is so cool

NSPG 911 profil fotoğrafı
NSPG 9111 gün önce

or we could just use hljs?

Simon Le Marchant profil fotoğrafı
Simon Le Marchant2 gün önce

Now that's pretty damn cool

Enri profil fotoğrafı
Enri2 gün önce

magic!

Patrick Smith profil fotoğrafı
Patrick Smith2 gün önce

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

Benzer Videolar