Skip to content

Instantly share code, notes, and snippets.

View TimRChen's full-sized avatar

tim chen TimRChen

View GitHub Profile

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.

"""
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
@Elandlord
Elandlord / use-keydown.js
Created September 17, 2021 09:37
Vue 3 use-keydown composable (Composition API)
import {onBeforeUnmount} from "vue";
let useKeyDown = (keyCombos) => {
let onKeyDown = (event) => {
let kc = keyCombos.find(kc => kc.key === event.key);
if(kc) {
kc.fn();
}
}
@TimRChen
TimRChen / useActiveVersionDetect.ts
Last active March 11, 2021 03:39
pc浏览器 active version detect hooks
import axios, { AxiosInstance } from 'axios'
import { Button, notification } from 'ant-design-vue'
import { h } from 'vue'
/**
* 无http请求最大时长
*/
const EXPIRE_TIME = 24 * 3600 * 1000 // 24小时
/**
* http请求最后活跃时间
@TimRChen
TimRChen / useInfiniteScroll.ts
Last active December 2, 2022 06:34
vue 3 pc浏览器 infinite scroll hook - useInfiniteScroll
import { unref, isRef, Ref, onUnmounted } from 'vue'
type IntersectTarget = Element | Ref
/**
* 采用Intersection Observer API 实现无限滚动
* more_help: https://developer.mozilla.org/zh-CN/docs/Web/API/Intersection_Observer_API#intersection_observer_%E7%9A%84%E6%A6%82%E5%BF%B5%E5%92%8C%E7%94%A8%E6%B3%95
* @author <timrchen@foxmail.com>
* @param target 目标元素,可在可增加列表末尾设置一个标志标签
* @param callback 正在相交时执行回调,请注意!如果有一些耗时的操作需要执行,建议使用 Window.requestIdleCallback() 方法
* @param options IntersectionObserver()构造函数的 options 对象,可选值参考:https://developer.mozilla.org/zh-CN/docs/Web/API/IntersectionObserver/IntersectionObserver#%E5%8F%82%E6%95%B0
*/