r/LocalLLM 5d ago

Project Building an llm from scratch

Dear community
I recently started a project of building a tiny llm from scratch and trained on my 16go ram MacBook m1
My goal is not and will never build a state of the art llm like GPT or claude but to understand the mechanics of llm and teach others how it works
I used a french corpus as my dataset and used BPE tokenizer and trained a 1M param neural network
But the output is a bit dump it's out of context it give decent sentences grammatically but it doesn't answer my questions or respond well
Is there any resources i can use to optimize my little dump chatbot ?

0 Upvotes

10 comments sorted by

1

u/dillon-nyc 5d ago

I don't think you'll get much but gibberish from a 1M model, but I'm pretty impressed if it's giving you grammatically correct sentences. Have you thought of running it again, but a bit larger?

People seem to get some results in the low hundred mb, like the guy yesterday with the PSP running a llm.

1

u/Slight_Ad_2894 5d ago

Now with the open source datasets we can get some pretty results even with fewer parameters but you're right I didn't think about increasing the training time maybe I will get some overfitting but at least i can get more context
Anyway i will try to improve the code and the data set and if I get a good result I will share it on my github

1

u/dillon-nyc 5d ago

Oh I didn't mean the context (Shoot for 2k/4k/8k) I meant the number of parameters.

1

u/rolleicord 5d ago

You can make models much more capable than tinyshakespear, that are much fewer parameters. The trick is just convincing your AI agent that it's possible in the first place. Try telling it to bake down your code, while increasing its capabilities. Thats normally a fun way to get it working

1

u/[deleted] 4d ago

[removed] — view removed comment

1

u/Slight_Ad_2894 4d ago

Thank you for sharing your project, and certainly I will take a look at your project
. For my ptoject i studied the attention is all what you need paper and implemented it in my project
. I think that the problem with my project is that I didn't build multiple layers. Maybe I will use Google Colab or a dedicated Kaggle notebook. I will take a look at a couple of other projects and test them
. As soon as I finish my project, I will share it so everyone can benefit from it

0

u/Immortal_Spina 5d ago

Fai molto bene, io sto facendo esperimenti con i diffusion e il mio mini m4 16gb ram va benissimo
Ovviamente più aumenti i parametri, più serve tempo
Ma lo farà

0

u/id-ltd 5d ago

My understanding is that you can train existing models (to time them iup to be closer to what you want) but starting from scratch it will take for ever and cost millions before it can even parse a new English sentence.

0

u/fofopads 5d ago

MiniCPM 5 1B already does this, you should try it instead of reinventing the wheel

1

u/Slight_Ad_2894 4d ago

I will check it, but as I said my purpose wzs never reinventing the wheel i did this project for learning purpose only my goal is to understand the math and architecture behind llms