Skip to content

Instantly share code, notes, and snippets.

View thesephist's full-sized avatar
🍷
Ridin' in a getaway car

Linus Lee thesephist

🍷
Ridin' in a getaway car
View GitHub Profile
@thesephist
thesephist / 0_basic.ts
Created November 12, 2024 01:53
Polymer LM programming API example
/**
* Implementation of a naïve retrieval-based question answering LLM program.
*/
import {
Document,
formatPromptLines,
getCompletionImpl,
loggers,
polymer,
@thesephist
thesephist / extensions.txt
Last active September 28, 2024 20:31
Cursor settings
anysphere.pyright
apollographql.vscode-apollo
bradlc.vscode-tailwindcss
dbaeumer.vscode-eslint
denoland.vscode-deno
eamodio.gitlens
esbenp.prettier-vscode
github.vscode-pull-request-github
ms-azuretools.vscode-docker
ms-python.black-formatter
@thesephist
thesephist / flux.py
Created August 2, 2024 09:57
Flux 1 Schnell
import torch
from diffusers import FluxPipeline, AutoencoderKL
from diffusers.image_processor import VaeImageProcessor
from transformers import T5EncoderModel, T5TokenizerFast, CLIPTokenizer, CLIPTextModel
ckpt_id = "black-forest-labs/FLUX.1-dev"
revision = "refs/pr/1"
@thesephist
thesephist / fixStyles.js
Created June 25, 2024 15:32
Make talk titles in the Config agenda readable w this one line of JavaScript!
(()=>{let a=document.querySelectorAll('.bigmarker-cg-agenda-card-talk-name');for(const e of a)Object.assign(e.style,{overflow:'initial',display:'initial'})})()
@thesephist
thesephist / rankedSummarize.ts
Created December 26, 2023 22:52
Ranked summarize with Cascade.
import { cascade } from "../src/cascade.ts";
export const summarize = cascade
.chatCompletion("summarize", {
model: "gpt-3.5-turbo",
renderPrompt: (context: { title: string; content: string }) => [
{
type: "user",
content: [
`Write a one sentence summary about ${context.title}.\n\n${context.content}.`,
@thesephist
thesephist / pull-all.lisp
Last active December 12, 2023 08:52
A Klisp script to run "git pull" en masse on all of my folders. Run with `pull-all ~/src`, etc.
; pull-all
;
; Run "git pull" en masse on all git repositories with a default remote under a
; specific directory.
(defn indent (s bit)
(-> s
(split '\n')
(map (fn (line)
(if (empty? line)
@thesephist
thesephist / gpt2_xl_perplexities.py
Created September 4, 2023 20:23
Code (most of it) for my GPT2 perplexities visualizer UI: https://twitter.com/thesephist/status/1617747154231259137
import torch
import torch.nn as nn
import torch.nn.functional as F
from transformers import GPT2Tokenizer, GPT2LMHeadModel
ppl_model_name = 'gpt2-xl' if device == 'cuda' else 'gpt2'
ppl_tokenizer = GPT2Tokenizer.from_pretrained(ppl_model_name)
load_opts = {
'device_map': 'auto',
// Code to measure selection rects
// NOTE: this isn't actually JS... it's Oak. But I think the code is readable if you know JS :/
// NOTE: I *think* this event listener only works when attached to `document`.
with document.addEventListener('selectionchange') fn handleSelectionChange {
if active := document.activeElement {
? -> ?
_ -> if active.classList.contains('textarea-itself') {
false -> ?
@thesephist
thesephist / prepare_data.py
Created December 15, 2022 01:57
Data prep script to fine-tune GPT-3 on my past writing
#!/usr/bin/env python
import os
import json
from tqdm import tqdm
from transformers import GPT2TokenizerFast
os.environ['TOKENIZERS_PARALLELISM'] = 'false'
FILENAME = './thesephist.jsonl'
@thesephist
thesephist / options.oak
Created November 14, 2022 22:09
Collection of useful Stable Diffusion prompt modifiers
{ name: 'Lighting', options: [
'golden hour, warm glow'
'blue hour, twilight, ISO12000'
'midday, direct lighting, overhead sunlight'
'overcast, whitebox, flat lighting, diffuse'
'dreamlike diffuse ethereal lighting'
'dramatic lighting, dramatic shadows, illumination'
'studio lighting, professional lighting, well-lit'
'flash photography'
'low-key lighting, dimly lit'