Skip navigation
llm.c by Hand✍️ C programming + matrix multiplication by hand This combination is perhaps as low as…
0:00 / 0:44

llm.c by Hand✍️ C programming + matrix multiplication by hand This combination is perhaps as low as…

Tom Yeh

@ProfTomYeh65K followers

Visit on X
2,828 likesDownloadOriginal post

311,845 views

llm.c by Hand✍️ C programming + matrix multiplication by hand This combination is perhaps as low as we can get to explain how the Transformer works. Special thanks to Andrej Karpathy for encouraging early feedback and tetsuo for helping me understand the pragma magic. I hope this exercise can help people peak further into the LLM black box.

11 Comments

Comments from the original post on X (Twitter)

  • Yuchen Jin's profile picture

    @Yuchenj_UW

    @karpathy @7etsuo Awesome! Looking forward to an llm.c Attention episode

    20 likes

  • Tom Yeh's profile picture

    @ProfTomYeh

    @karpathy @7etsuo This is a great suggestion! Thanks!

    16 likes

  • Antonio Linares's profile picture

    @zencloud

    @karpathy @7etsuo Is there a way to load a single layer of a LLM (in example Llama3-70B) and process it layer by layer so it fits on a normal PC memory ? Could you explain how to do it ?

    3 likes

  • Tom Yeh's profile picture

    @ProfTomYeh

    @karpathy @7etsuo It is possible. But it would be quite slow. To generate each token, the model has to evaluate every one of the hundreds of layers. Say loading each layer takes 1 second. It would take 100 seconds to load 100 layers for one token. Then you multiple that by 1000 tokens. Very slow.

    3 likes

  • rakesh's profile picture

    @shark_T_T

    @karpathy @7etsuo Goated acc

    1 like

  • ed's profile picture

    @ed_astra_

    @karpathy @7etsuo Amazing 🔥

    1 like

  • Cuhmunity Notes's profile picture

    @My2sense_Byron

    @karpathy @7etsuo 🔥

    1 like

  • Byron Hsu's profile picture

    @hsu_byron

    @karpathy @7etsuo This is awesome

    1 like

  • Filippo Broggini's profile picture

    @olgias

    @karpathy @7etsuo Is this also available elsewhere online?

    1 like

  • George D Gregory's profile picture

    @reinforce2020

    @karpathy @7etsuo Can these be made into the notebooks!? That would be awesome.

    1 like

  • Tom Yeh's profile picture

    @ProfTomYeh

    @karpathy @7etsuo I am waiting for a notebook ninja to step up to help.😄

    1 like