Skip to content

Instantly share code, notes, and snippets.

View baljanak's full-sized avatar
🎯
Focusing

Balaji Janakiram baljanak

🎯
Focusing
View GitHub Profile
@baljanak
baljanak / llm-wiki.md
Created April 10, 2026 05:40 — 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.

@baljanak
baljanak / llm_wiki_learning_filter.md
Created April 10, 2026 05:00
LLM Wiki: Adding a Learning Filter - extending Karpathy's LLM Wiki with identity-aware filtering

LLM Wiki: Adding a Learning Filter

Karpathy's LLM Wiki nailed something. LLMs are perfect for the bookkeeping that kills knowledge bases. Updating cross-references, flagging contradictions, keeping pages consistent - that's what they're good at. Humans curate, LLMs maintain. The wiki compounds because maintenance cost drops to zero.

I've been running a version of this for months. One thing kept breaking.

What happens at month 6

LLM Wiki has three layers: raw sources (immutable), the wiki (LLM-maintained), and a schema (configuration). The schema tells the LLM how to structure the wiki.

#!/usr/env python
def merge_and_count_split_inversions(A, B, C):
""" O(n)"""
i = 0
j = 0
inv = 0
@baljanak
baljanak / QuickSort10.txt
Last active March 16, 2016 07:00
Quick Sort sample
3
9
8
4
6
10
2
5
7
1
@baljanak
baljanak / merge_sort.py
Created March 16, 2016 05:36
sample merge sorting algo
#!/usr/env python
def merge(A, B, C):
""" O(n)"""
i = 0
j = 0
for k in range(len(A) + len(B)):
@baljanak
baljanak / kargerMinCut.txt
Last active March 16, 2016 05:35
Karger Min Cut
1 37 79 164 155 32 87 39 113 15 18 78 175 140 200 4 160 97 191 100 91 20 69 198 196
2 123 134 10 141 13 12 43 47 3 177 101 179 77 182 117 116 36 103 51 154 162 128 30
3 48 123 134 109 41 17 159 49 136 16 130 141 29 176 2 190 66 153 157 70 114 65 173 104 194 54
4 91 171 118 125 158 76 107 18 73 140 42 193 127 100 84 121 60 81 99 80 150 55 1 35 23 93
5 193 156 102 118 175 39 124 119 19 99 160 75 20 112 37 23 145 135 146 73 35
6 155 56 52 120 131 160 124 119 14 196 144 25 75 76 166 35 87 26 20 32 23
7 156 185 178 79 27 52 144 107 78 22 71 26 31 15 56 76 112 39 8 113 93
8 185 155 171 178 108 64 164 53 140 25 100 133 9 52 191 46 20 150 144 39 62 131 42 119 127 31 7
9 91 155 8 160 107 132 195 26 20 133 39 76 100 78 122 127 38 156 191 196 115
10 190 184 154 49 2 182 173 170 161 47 189 101 153 50 30 109 177 148 179 16 163 116 13 90 185
@baljanak
baljanak / pyc2py.py
Created March 16, 2016 04:18
decompile pyc to py
import os
import ast
import marshal
import uuid
import meta
def pyc2py(pyc_file, path='/tmp'):
@baljanak
baljanak / gist:3979567
Created October 30, 2012 10:46
Playing with threads, greenlets and ZMQ
import gevent
from gevent import monkey; monkey.patch_all()
from gevent_zeromq import zmq
import simplejson as json
import threading
import time
def server(context):
poll = zmq.Poller()
@baljanak
baljanak / ZMQ_REP_REQ.py
Created October 30, 2012 10:09
Playing with threads, greenlets and ZMQ
import gevent
from gevent import monkey; monkey.patch_all()
from gevent_zeromq import zmq
import simplejson as json
import threading
import time
def server(context):
""" server routine """
@baljanak
baljanak / ServerRack.py
Created September 18, 2012 10:40 — forked from denik/ServerRack.py
class for managing multiple servers in gevent
# Class for managing multiple servers or anything with start() and stop() methods
class ServerRack(object):
def __init__(self, servers):
self.servers = servers
def start(self):
started = []
try: