Skip to content

Instantly share code, notes, and snippets.

View bfpill's full-sized avatar
🤘

max bfpill

🤘
  • undergrad @ the university of melbourne
  • 07:25 (UTC -12:00)
View GitHub Profile
@bfpill
bfpill / lesswrong_finetune.py
Last active April 5, 2024 10:59
solving the alignment problem one step at a time
import os
import json
import time
import random
import requests
from bs4 import BeautifulSoup
from urllib.parse import urljoin
from colorama import init, Fore, Style
import tensorflow as tf
from transformers import AutoTokenizer, TFAutoModelForCausalLM
@bfpill
bfpill / transformer.py
Created April 2, 2024 02:37
tinygrad transformer example
import numpy as np
from tqdm import trange
from tinygrad.tensor import Tensor
from tinygrad.helpers import CI
from tinygrad.engine.jit import TinyJit
import random
from tinygrad.nn.state import get_parameters
from tinygrad.nn.optim import Adam
@bfpill
bfpill / smith_waterfield.py
Created March 31, 2024 05:44
Smith Waterman affine local sequence alignment on DNA
def align(s1, s2, gap_penalty, match_score = 1, mismatch_penalty = -1):
m, n = len(s1), len(s2)
H = [[0] * (n + 1) for _ in range(m + 1)]
max_score = 0
max_pos = (0, 0)
for i in range(1, len(s1) + 1):