Understanding the Transformer Model P1

For my assignment, I have to partially implement the T5 transformer model. However, the only thing I have for implementing it is intuition. I don’t understand many parts of it deeply enough. And the full code for the implementation is sprawling - and also, because of its sprawling nature, makes breaking down the components difficult. There is quite a good guide for it here, where the authors take us through each aspect of its implementation with notes. I think this is a good starting point. ...

October 11, 2025 · 14 min · Lei

What I Learned Implementing a Shallow Neural Network for FashionMNIST

So I was playing with Pytorch over the weekend, trying to get my fundamentals right by following along to the tutorials in the documentations. In my first exercise, I wanted to try to implement a shallow neural network with 1 hidden layer (784-4-10) to try to classify images from the FashionMNIST dataset. I have learned quite a bit about what’s needed to get it right. Model illustration generated by ChatGPT: ...

September 21, 2025 · 5 min · Lei

Zhang Yimins 2018 Reflections

A historic event, reproduced below. Apology and reflection 今日头条的朋友们: Dear friends of Jinri Toutiao: 我真诚地向监管部门致歉,向用户及同事们道歉。 从昨天下午接到监管部门的通知到现在,我一直处在自责和内疚之中,一夜未眠。 I earnestly apologise to regulatory authorities, and to our users and colleagues. Since receiving the notice yesterday from regulatory authorities, I have been filled with remorse and guilt, entirely unable to sleep. 今日头条将永久关停“内涵段子”客户端软件及公众号。产品走错了路,出现了与社会主义核心价值观不符的内容,没有贯彻好舆论导向,接受处罚,所有责任在我。 Jinri Toutiao will shut down once and for all its “Neihan Duanzi” app and its public accounts. Our product took the wrong path, and content appeared that was incommensurate with socialist core values, that did not properly implement public opinion guidance — and I am personally responsible for the punishments we have received [as a result]. ...

March 31, 2024 · 5 min · Lei

Dropping Into Djikstra (P1)

My skateboard routine is fairly standard. I’ll pack my gear into my Adidas backpack, throw in a bottle and my keys, and head out the door grabbing my skateboard and the helmet. I don’t bother bringing my phone. I’ll get to my bike parked beneath my block, mount the skateboard onto the backseat, and cycle towards the direction of Bukit Batok MRT - passing by the station, passing by Princess Elizabeth Primary, over the green fields before reaching Yuhua, followed by Chinese Garden MRT, and then finally reaching the skatepark at Lakeside. The entire journey takes around 20mins or so, and I treat it as warm up. ...

January 27, 2024 · 7 min · Lei

Recap on Same Origin Policy CORS and CSRF

I had a fascinating lecture earlier this week with Prateek Saxena as part of my Web Security course, where we learned about a core pillar of web security, the same origin policy. Briefly speaking, the same origin policy disallows different web apps from accessing each other’s content and resources through the browser. It’s a framework for access control. Just like how User A cannot access User B’s files on a Mac OS, website A cannot access website B’s HTML, Javascript, CSS, by default. ...

January 27, 2024 · 8 min · Lei

Excel and VBA

In my first lesson of the current course I am taking, BMD5302 - Financial Modelling for Fintech professionals, I was introduced to first to VBA, and then to a couple of popular functions in Excel. I mean, I was mindblown a little bit by VBA. I’ve heard of it before, but I’ve never known what it does. Now I know: it is a way for you to control excel programmatically. The syntax seems easy enough, and very quickly I can see how it can be really powerful. It’ll allow you to automate almost everything that you need in excel. ...

January 19, 2024 · 3 min · Lei

Inside the Expansive Mind of Liu Cixin

Warning: massive spoiler alert for Death’s End. Reader’s discretion advised. A brain gets shipped to outerspace, embeds itself into Trisolaris civilization, finds success as a fairy tale writer, and rendevous with his crush deep in space to send a cryptic warning back to human civilization in the form of a fairy tale. Four dimensions collapsing into three, and three dimension ultimately collapsing into two. A tale that spans billions of years, dimensions, and universes, yet tied together by a singular thread of human (the writer’s?) warmth. ...

November 19, 2023 · 5 min · Lei

Server Location Matters in Vercel

My NextJs application had a problem: whenever it did CRUD operations, the server takes around 8 seconds to respond on first attempt, and then 2/3 seconds on subsequent attempts. This is the so called cold start problem that Vercel is known for. The source of the latency does not come from the DB as I’ve tested it in development mode against the same DB and there was no latency there. ...

September 1, 2023 · 2 min · Lei

Radians

Wow today I learned that 1 radian is actually the angle created by the length of the radius on a circle. And that 180degrees is simply 3.14 radians. Can’t believe I’ve never known this relationship.

August 21, 2023 · 1 min · Lei

OpenBB Blows My Mind

So I was researching for ways to get a company’s historical financials data because I hate clicking through pages of shitty UI and downloading files and all that when all I need is a couple of numbers - when I stumbled upon this open source project called OpenBB. To be fair, this wasn’t the first thing that came up in my endeavour. Basically, I want to be able to very quickly get the historical ratios, balance sheet, and income statement of a company, ideally through a light weight interface like the command line. Initially I thought I was going to use a couple of APIs and then cleaning the data through jq or something similar (which is still possible), and that led me to APIs like FinancialModelingPrep and EODHD. EODHD’s response design is more like a ‘bulk export’ approach, where with one call you get every single historical data of a company, whereas FMP’s responses are more streamlined and tailored to a specific need. The only thing is, with the free version, I could only get 5 years of historical data, whereas I need the data of way more years, so I was considering upgrading. Before commiting to it, I decided to look around to see if there are any alternatives to this, either in terms of workflow or in terms of data. ...

August 8, 2023 · 3 min · Lei