Skip to content

Instantly share code, notes, and snippets.

@Youpen-y
Youpen-y / microgpt.py
Created August 27, 2026 15:42 — forked from karpathy/microgpt.py
microgpt
"""
The most atomic way to train and run inference for a GPT in pure, dependency-free Python.
This file is the complete algorithm.
Everything else is just efficiency.
@karpathy
"""
import os # os.path.exists
import math # math.log, math.exp
@Youpen-y
Youpen-y / llm-wiki.md
Last active April 13, 2026 22:51 — forked from karpathy/llm-wiki.md
llm-wiki

LLM Wiki

A pattern for building personal knowledge bases using LLMs.

This is an idea file, it is designed to be copy pasted to your own LLM Agent (e.g. OpenAI Codex, Claude Code, OpenCode / Pi, or etc.). Its goal is to communicate the high level idea, but your agent will build out the specifics in collaboration with you.

The core idea

Most people's experience with LLMs and documents looks like RAG: you upload a collection of files, the LLM retrieves relevant chunks at query time, and generates an answer. This works, but the LLM is rediscovering knowledge from scratch on every question. There's no accumulation. Ask a subtle question that requires synthesizing five documents, and the LLM has to find and piece together the relevant fragments every time. Nothing is built up. NotebookLM, ChatGPT file uploads, and most RAG systems work this way.

@Youpen-y
Youpen-y / pictures.md
Last active September 20, 2025 04:47
Picture Collections
@Youpen-y
Youpen-y / stack-template.hpp
Created September 3, 2025 15:02
stack template
/* Implement a stack class template */
#include<iostream>
#include<vector>
#include<stdexcept>
using namespace std;
template <typename T>
class Stack{
private:
@Youpen-y
Youpen-y / alloca-vs-malloc.c
Created November 27, 2024 09:11
alloca (alloc on stack) vs malloc (alloc on heap)
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char **argv) {
struct timespec start, end;
int size = atoi(argv[1]);
// alloc memory on stack
clock_gettime(CLOCK_MONOTONIC, &start);
@Youpen-y
Youpen-y / atomic-vs-mutex-vs-semaphore.c
Last active December 5, 2024 10:07
atomic vs mutex vs semaphore cost comparsion
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <stdatomic.h>
#include <semaphore.h>
#include <time.h>
#define ITERATIONS 10000000
atomic_int atomic_lock = 0;