YCMJason's Diary ๐โจ
This web app is inspired by Tom Riddle's Diary. I've literally enchanted this website with a piece of my soul ๐ช๐ค. So go ahead, talk to it, and learn more about me!
๐ YCMJason's Diary ๐โจ
๐ GitHub Repo
Here are some quick write up on some of the challenges I faced in this project.
This project had two major challenges:
- Recognizing handwriting โ๏ธ
- Running an LLM for free ๐ธ
Recognizing Handwriting โ๏ธ
A Tom Riddle Diary wannabe that only accepts keyboard input? Absolutely unacceptable! ๐ค So I set out to implement handwriting recognition on a canvas.
The Journey:
-
Tesseract.js ๐ค
- Great for printed text โ
- Absolute trash for handwriting โ
-
Transformers.js by ๐ค Hugging Face
- Looked promising...
- Required users to download huge models (~30s load time ๐ญ)
- Recognition results? Not even close! โ
-
The Breakthrough: Handwriting.js ๐
- BOOM! Found this hidden gem: handwriting.js ๐
-
How does it work? ๐คฏ It reverse-engineers Google's IME by sending stroke data to Google's API:
๐
https://www.google.com/inputtools/request?ime=handwriting&app=mobilesearch&cs=1&oe=UTF-8
- Results are blazingly fast โก and super accurate ๐ฏ!
๐จโ๐ง But the project was 5 years old and looked like it was built in 2003... ๐ฌ So I stole borrowed the core logic and rewrote it in modern JavaScript! Might publish it on JSR later if thereโs demand! ๐ Let me know if you're interested! ๐ฌ
Running an LLM for Free ๐ธ
For the LLM, I remembered this awesome project: mlc-webllm, which runs models directly on your device! ๐ฅ
The Journey:
-
MLC-WebLLM โ
- Model download time: ๐ฆ 30+ seconds (Users will leave after 5 seconds, let's be real ๐ )
- Inference speed:
- M1 Max MacBook: 5 seconds โณ
- Pixel 9 Pro Fold: 30+ seconds ๐จ
- Turns out, my system prompt was the culprit! ๐ฑ Longer prompts slow down inference a lot.
-
Transformers.js โ
- Even slower than MLC-WebLLM ๐ญ
- Downloads the model in a single request without batching (or so it seems ๐ค)
-
The Breakthrough: OpenRouter + Vercel AI SDK ๐ฏ
- Found a GitHub list of free LLM APIs ๐
- Settled on OpenRouter and paired it with Vercelโs AI SDK
- Final result? Super smooth UX & fast responses! ๐
๐ The dev experience? Absolute chef's kiss ๐จโ๐ณ๐. Huge thanks to Vercel & OpenRouter! ๐
Final Thoughts ๐ง
If this app doesnโt go viral, Iโll be sad. ๐ข So please, go have fun with it! ๐
Top comments (1)
This is fun, recognized my handwriting 100% of the time ๐ฏ