Skip to content

Instantly share code, notes, and snippets.

@rain-1
rain-1 / LLM.md
Last active May 3, 2024 10:05
LLM Introduction: Learn Language Models

Purpose

Bootstrap knowledge of LLMs ASAP. With a bias/focus to GPT.

Avoid being a link dump. Try to provide only valuable well tuned information.

Prelude

Neural network links before starting with transformers.

@Hirrolot
Hirrolot / CoC.ml
Last active April 5, 2024 15:34
How to implement dependent types in 80 lines of code
type term =
| Lam of (term -> term)
| Pi of term * (term -> term)
| Appl of term * term
| Ann of term * term
| FreeVar of int
| Star
| Box
let unfurl lvl f = f (FreeVar lvl)
import sys
from time import sleep
import random
import cursor
class Renderer:
def __init__(self, width, height):
@fnky
fnky / ANSI.md
Last active May 3, 2024 17:31
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@Leonidas-from-XIV
Leonidas-from-XIV / lwt_ppx_let.ml
Last active January 2, 2022 15:10
Using Lwt with ppx_let instead of ppx_lwt
module Let_syntax = struct
let return = Lwt.return
let (>>=) = Lwt.Infix.(>>=)
let (>>|) = Lwt.Infix.(>|=)
module Let_syntax = struct
let bind m ~f = Lwt.bind m f
end
end
@porglezomp
porglezomp / Leftpad.idr
Last active October 7, 2023 23:25
Taking on Hillel's challenge to formally verify leftpad (https://twitter.com/Hillelogram/status/987432181889994759)
import Data.Vect
-- `minus` is saturating subtraction, so this works like we want it to
eq_max : (n, k : Nat) -> maximum k n = plus (n `minus` k) k
eq_max n Z = rewrite minusZeroRight n in rewrite plusZeroRightNeutral n in Refl
eq_max Z (S _) = Refl
eq_max (S n) (S k) = rewrite sym $ plusSuccRightSucc (n `minus` k) k in rewrite eq_max n k in Refl
-- The type here says "the result is" padded to (maximum k n), and is padding plus the original
leftPad : (x : a) -> (n : Nat) -> (xs : Vect k a)
@keleshev
keleshev / xml.ml
Last active April 16, 2020 08:21
Simple XML pretty-printing in OCaml using Format module
#! /usr/bin/env ocaml
let fprintf = Format.fprintf
type t =
| Tag of {name: string; attributes: (string * string) list; body: t list}
| String of string
let format_attribute f (key, value) = fprintf f " %s=\"%s\"" key value
@Drup
Drup / difflist.ml
Last active June 12, 2023 17:26
Difference lists and Miniformat
type ('ty,'v) t =
| Nil : ('v, 'v) t
| Cons : 'a * ('ty, 'v) t -> ('a -> 'ty, 'v) t
let cons x l = Cons (x,l)
let plus1 l = Cons ((),l)
let one x = Cons (x,Nil)
// Hello! I'm Leo Tindall, the SilverWingedSeraph, and this is a follow-up to my tutorial on
// using match expressions in Rust.
// In my last video, we created a finite state machine to parse and modify some simple markup.
// In this video, we'll make the machine more abstract and more concise.
// We'll start out the same way: defining the four states of the machine.
// However, we'll use a neat trick that Rust
// provides to make things easier later on. We'll ask the compiler to derive the Copy and Clone
// traits on MachineState, so we don't have to worry about borrowing and ownership.

Interactive Machine Learning

Taught by Brad Knox at the MIT Media Lab in 2014. Course website. Lecture and visiting speaker notes.