Skip to content

Instantly share code, notes, and snippets.

View bmorphism's full-sized avatar
🦍
annealing information lattice since *2069*

Barton Rhodes bmorphism

🦍
annealing information lattice since *2069*
View GitHub Profile
@bmorphism
bmorphism / bayesball.jl
Created February 16, 2024 09:18 — forked from mschauer/bayesball.jl
Bayes ball
using CausalInference
V = [:U, :T, :P, :O]
g = digraph([1=>3, 2=>3, 3=>4, 2=>4, 1=>4])
# Can estimate total effect T=>O without observing U?
u = 2
v = 4
∅ = Set{Int}()
observed = 2:4
collect(list_covariate_adjustment(g, u, v, ∅, observed))
@mschauer
mschauer / bayesball.jl
Last active February 19, 2024 14:21
Bayes ball
using CausalInference, Graphs
V = [:U, :T, :P, :O]
ι = Dict(v=>i for (i,v) in enumerate(V))
g = digraph([1=>3, 2=>3, 3=>4, 2=>4, 1=>4])
# Can estimate total effect T=>O without observing U?
u = ι[:T]
v = ι[:O]
∅ = Set{Int}()
@VictorTaelin
VictorTaelin / itt-coc.ts
Last active March 2, 2024 15:53
ITT-Flavored Calculus of Constructions Type Checker
// A nano dependent type-checker featuring inductive types via self encodings.
// All computation rules are justified by interaction combinator semantics,
// resulting in major simplifications and improvements over old Kind-Core.
// Specifically, computable annotations (ANNs) and their counterpart (ANN
// binders) and a new self encoding based on equality (rather than dependent
// motives) greatly reduce code size. A more complete file, including
// superpositions (for optimal unification) is available on the
// Interaction-Type-Theory repository.
// Credits also to Franchu and T6 for insights.
#!/usr/bin/env fish
# Needs rg: `brew install ripgrep`
set -xg visitedLibs
function libdeps -a bin depth -d "Finds all dylibs that a binary depends on recursively and prints them on separate lines, sorted alphabetically"
if test -z "$depth"
set depth 0
end
@zanzix
zanzix / Fix.idr
Last active September 23, 2023 01:17
Fixpoints of indexed functors, graphs, multi-graphs, poly-graphs
infixr 5 ~> -- Morphism of indexed functors
infixr 5 ~~> -- Morphism of graphs/doubly-indexed functors
infixr 5 :~> -- Morphism of multi-graphs
infixr 5 :~:> -- Morphism of poly-graphs
namespace Fix1
-- Objects are Types
-- Morphisms are functions between types (->)
@norabelrose
norabelrose / kronecker_decompose.py
Last active December 27, 2023 21:31
Fast, optimal Kronecker decomposition
from einops import rearrange
from torch import Tensor
import torch
def kronecker_decompose(
A: Tensor, m: int, n: int, *, k: int = 1, niter: int = 10
) -> tuple[Tensor, Tensor]:
"""Frobenius-optimal decomposition of `A` into a sum of `k` Kronecker products.
@borkdude
borkdude / uuidv1.clj
Created September 15, 2023 09:18
UUID v1 in babashka / Clojure
;; based on code from https://www.baeldung.com/java-uuid
;; translated to Clojure by ChatGPT, minus the hex numbers which I evaluated in jshell
(defn get-64-least-significant-bits-for-version1 []
(let [random (java.util.Random.)
random-63-bit-long (bit-and (.nextLong random) 4611686018427387903)
variant-3-bit-flag -9223372036854775808]
(bit-or random-63-bit-long variant-3-bit-flag)))
(defn get-64-most-significant-bits-for-version1 []
@moyix
moyix / .env.local
Created August 19, 2023 22:40
Setup for locally hosted LLM chat using chat-ui and TGI with WizardLM-70B
MONGODB_URL=mongodb://localhost:27017
HF_ACCESS_TOKEN=<REDACTED>
# 'name', 'userMessageToken', 'assistantMessageToken' are required
MODELS=`[
{
"endpoints": [{"url": "http://localhost:8081"}],
"name": "WizardLM/WizardLM-70B-V1.0",
"description": "WizardLM: Empowering Large Pre-Trained Language Models to Follow Complex Instructions",
"websiteUrl": "https://huggingface.co/WizardLM/WizardLM-70B-V1.0",
@eugeneyan
eugeneyan / mandelbrot-mojo.md
Last active April 4, 2024 15:52
Benchmarking Mojo vs. Python on Mandelbrot sets

Mandelbrot in Mojo with Python plots

Not only Mojo is great for writing high-performance code, but it also allows us to leverage huge Python ecosystem of libraries and tools. With seamless Python interoperability, Mojo can use Python for what it's good at, especially GUIs, without sacrificing performance in critical code. Let's take the classic Mandelbrot set algorithm and implement it in Mojo.

We'll introduce a Complex type and use it in our implementation.

Mandelbrot in python

from langchain.document_loaders import YoutubeLoader
from langchain.indexes import VectorstoreIndexCreator
loader = YoutubeLoader.from_youtube_url("https://www.youtube.com/watch?v=fLn-WqliEQU&lc=UgyOc6oNr_4-YLGCL2R4AaABAg", add_video_info=False)
docs = loader.load()
index = VectorstoreIndexCreator()
index = index.from_documents(docs)