This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from safetensors import safe_open | |
import einops | |
import torch | |
from transformers import AutoModelForCausalLM | |
def get_orthogonalized_matrix(matrix: Float[Tensor, '... d_model'], vec: Float[Tensor, 'd_model']) -> Float[Tensor, '... d_model']: | |
device = matrix.device | |
vec = vec.to(device) | |
proj = einops.einsum(matrix, vec.view(-1, 1), '... d_model, d_model single -> ... single') * vec | |
return matrix - proj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# OK time to arithmetic code. V1 because its so simplistic as a concept | |
# I'll make a dictionary of all unique symbols in the string (rather than | |
# a predefined dict) | |
# and I'll go ahead and subdivide and add it to a running total. | |
from collections import Counter | |
from sys import getsizeof | |
text = "Hello world!" | |
text_dc = {s:i for i,s in enumerate(sorted(set(text)))} | |
print(text_dc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Game of Life Canvas</title> | |
<style> | |
body { | |
display: flex; | |
flex-direction: column; |
OlderNewer