Skip to content

Instantly share code, notes, and snippets.

@rohitg00
rohitg00 / llm-wiki.md
Last active May 7, 2026 02:59 — forked from karpathy/llm-wiki.md
LLM Wiki v2 — extending Karpathy's LLM Wiki pattern with lessons from building agentmemory

LLM Wiki v2

A pattern for building personal knowledge bases using LLMs. Extended with lessons from building agentmemory, a persistent memory engine for AI coding agents.

This builds on Andrej Karpathy's original LLM Wiki idea file. Everything in the original still applies. This document adds what we learned running the pattern in production: what breaks at scale, what's missing, and what separates a wiki that stays useful from one that rots.

What the original gets right

The core insight is correct: stop re-deriving, start compiling. RAG retrieves and forgets. A wiki accumulates and compounds. The three-layer architecture (raw sources, wiki, schema) works. The operations (ingest, query, lint) cover the basics. If you haven't read the original, start there.

"""
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
@NohTow
NohTow / train_reason_moderncolbert.py
Created May 22, 2025 12:43
Boilerplate to reproduce the training of Reason-ModernColBERT
from datasets import load_dataset
from sentence_transformers import (
SentenceTransformerTrainer,
SentenceTransformerTrainingArguments,
)
from pylate import losses, models, utils
def main():
# As ReasonIR do not re-upload the BRIGHT data, we need to load it from the original source
@richardsheridan
richardsheridan / map_concurrently_in_subthread_trio.py
Last active January 2, 2023 22:14
map_concurrently_in_subthread_trio
import queue
import random
from functools import partial
from time import sleep, perf_counter
import trio
CONCURRENCY_LIMIT = 8
limiter = trio.CapacityLimiter(CONCURRENCY_LIMIT)
@jordanisaacs
jordanisaacs / sessioncookie.py
Created April 3, 2021 22:13
Basic implementation with example of a FastAPI SessionCookie (compatible with OpenAPI and dependency injection)
from datetime import timedelta, datetime
from typing import Type, Optional, Dict, Any, Tuple
from uuid import uuid4
from abc import ABC, abstractmethod
from fastapi import FastAPI, Request, Depends, HTTPException, Response
from fastapi.security.api_key import APIKeyBase, APIKey, APIKeyIn
from base64 import b64encode, b64decode
from itsdangerous import TimestampSigner
from itsdangerous.exc import BadTimeSignature, SignatureExpired
@nathanrpage97
nathanrpage97 / test_live.py
Created October 13, 2020 15:34
Showcase of the Live feature branch
import inspect
import random
import time
from typing import Dict, List, Tuple
from rich.console import Console, RenderGroup
from rich.live import Live
from rich.panel import Panel
from rich.progress import Progress
from rich.syntax import Syntax
@beardicus
beardicus / .block
Last active March 19, 2024 21:44
Paper.js Vector Erase
license: mit
border: yes
height: 640
@Evgenus
Evgenus / test_flask_sqlalchemy_txns.py
Last active February 27, 2024 12:45
Proper SQLAlchemy transactions example
from contextlib import contextmanager
import threading
from thread import get_ident
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
#!/bin/bash
# file descriptor
# Change 400000 to increase or decrease number of file descriptor
echo "* soft nofile 400000" >> /etc/security/limits.conf
echo "* hard nofile 400000" >> /etc/security/limits.conf
# Changing kernal parameters (modify value if required)
@SandeepThomas
SandeepThomas / datepickerLocaldateDirective.js
Last active March 8, 2021 00:23 — forked from weberste/gist:354a3f0a9ea58e0ea0de
Dates only with Angular-UI Bootstrap datepicker - In Epoch time / Unix time
app.directive('datepickerLocaldate', ['$parse', function ($parse) {
var directive = {
restrict: 'A',
require: ['ngModel'],
link: link
};
return directive;
function link(scope, element, attr, ctrls) {
var ngModelController = ctrls[0];