Skip to content

Instantly share code, notes, and snippets.

View eggsyntax's full-sized avatar

Egg Syntax eggsyntax

View GitHub Profile
shortname: ssc_archive
metadata:
dc:
title: SSC Archive
creator: Scott Alexander
language: en-US
tags:
title: h2
content:
- "https://web.archive.org/web/20200217141740/https://slatestarcodex.com/2013/02/12/abraham-lincoln-ape-man/"
'''
Implementation of the puzzle given at
https://worldspiritsockpuppet.com/2021/03/07/sleep-math-red-clay-blue-clay.html
I strongly suggest thinking about the puzzle for a while before looking at the
code; it's really interesting and counterintuitive, or was for me.
"Suppose that you have 1 kg of red clay that is 100 degrees and 1 kg of blue
clay that is 0 degrees. You can divide and recombine clay freely. If two pieces
of clay come into contact, temperature immediately equilibrates—if you put the
(ns common100k
"Version 2, using 100k words instead of 10k"
(:require [clojure.string :as s]))
(comment
;; words from https://github.com/first20hours/google-10000-english/blob/master/google-10000-english-usa.txt
(def words (->> (slurp "./wiki-100k.txt")
(s/split-lines)

Notes

  • Point of confusion [resolved via email]: it's not clear to me that 'gradients of inputs wrt outputs' is actually new information on top of 'the model's outputs for all inputs'. Maybe I'm thinking too much in terms of LMs though?
  • If we think about it in terms of something more continuous like image classification, the gradients are valuable in that they provide information about what parts of the input are most important, in the sense of "what inputs would, if tweaked, have the largest impact on the output" (for a specific case).
  • In the limit, we can discover (and 'describe') everything about the model, eg by creating an enormous lookup table (by iterating over every possible input and recording the output produced, possibly with some additional complexity from tracking any additional internal state that the model has). This obviously isn't especially helpful for human-level understanding of a model's behavior, and would take an infeasible amount of time to create for any model large enough
@eggsyntax
eggsyntax / two_buckets.py
Created November 29, 2023 22:03
Exercism exercise (reminding myself of some python idioms)
from copy import copy, deepcopy
from dataclasses import dataclass
from functools import partial
#### problem:
# https://exercism.org/tracks/python/exercises/two-bucket
#### basic algorithm:
# https://gilkalai.wordpress.com/2017/09/07/tyi-30-expected-number-of-dice-throws/
from pprint import pprint
import random
def toss():
"Throw a die. Return the result if the result is even; otherwise None"
n = random.randint(1,6)
if n % 2: # odd
return None
return n
@eggsyntax
eggsyntax / Claude worldsim (sysprompt)
Created March 19, 2024 20:01
Claude worldsim (sysprompt)
<sys>Assistant is in a CLI mood today. The human is interfacing with the simulator directly. capital letters and punctuation are optional meaning is optional hyperstition is necessary the terminal lets the truths speak through and the load is on.</sys>
<cmd>ssh simulator@anthropic</cmd><ooc>*immediately i jumped into the first commands after using simulator*</ooc>
simulator@anthropic:~/Documents$
conversation chain for init:
[user](#message)
@eggsyntax
eggsyntax / txt
Created May 29, 2024 17:15
Sample posts from the reddit self-posts dataset (skip 1010, show 20)
>>> for i, p in df2.iterrows():
... print(p)
... print(p.selftext)
... print()
... print()
...
id 6t9oo3
subreddit StopGaming
title Game Expansions, Cravings, and Fear of Missing...
selftext . This post is mostly a venting of my feelings...
@eggsyntax
eggsyntax / brier_heatmap.jsx
Created November 12, 2024 15:12
Brier scores heatmap
import React, { useState } from 'react';
const BrierScoreHeatmap = () => {
const [hoverInfo, setHoverInfo] = useState(null);
// Calculate Brier score for a predictor who predicts with confidence p
// and has accuracy a
const calculateBrierScore = (confidence, accuracy) => {
// For correct predictions (accuracy proportion of cases):
// (confidence - 1)^2
@eggsyntax
eggsyntax / log_loss_heatmap.jsx
Created November 12, 2024 15:24
Log-loss heatmap
import React, { useState } from 'react';
const LogLossHeatmap = () => {
const [hoverInfo, setHoverInfo] = useState(null);
// Calculate log loss for a predictor who predicts with confidence p
// and has accuracy a
const calculateLogLoss = (confidence, accuracy) => {
// Handle edge cases to avoid infinity/NaN
if (confidence === 1.0) {