Skip to content

Instantly share code, notes, and snippets.

View andrewnc's full-sized avatar

Andrew Carr andrewnc

View GitHub Profile
from collections import defaultdict
import random
from huggingface_hub import hf_hub_download
from datasets import Dataset
import numpy as np
import pandas as pd
from transformers import AutoTokenizer
from rich.console import Console
from rich.table import Table
from trl import DPOTrainer
ChrisHayduk /
Last active July 13, 2024 19:27
Merging QLoRA weights with quantized model
The code below combines approaches published by both @eugene-yh and @jinyongyoo on Github.
Thanks for the contributions guys!
import torch
import peft
rain-1 /
Last active July 11, 2024 18:17
LLM Introduction: Learn Language Models


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

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


Neural network links before starting with transformers.

Helw150 /
Last active May 10, 2023 14:52
Flan T5 Parallel Usage
from transformers import AutoTokenizer, T5ForConditionalGeneration
# Model Init
n_gpu = 8
tokenizer = AutoTokenizer.from_pretrained("google/flan-ul2")
model = T5ForConditionalGeneration.from_pretrained("google/flan-ul2")
heads_per_gpu = len(model.encoder.block) // n_gpu
device_map = {
gpu: list(
karpathy /
Last active July 17, 2024 06:48
hacky stablediffusion code for generating videos
stable diffusion dreaming
creates hypnotic moving videos by smoothly walking randomly through the sample space
example way to run this script:
$ python --prompt "blueberry spaghetti" --name blueberry
to stitch together the images, e.g.:
$ ffmpeg -r 10 -f image2 -s 512x512 -i blueberry/frame%06d.jpg -vcodec libx264 -crf 10 -pix_fmt yuv420p blueberry.mp4
breandan / .ideavimrc
Last active December 22, 2020 05:13
Mathematical symbol macros for [idea]vim
" To only apply these macros in e.g. Python files, prepend 'autocmd FileType py', e.g.:
" autocmd FileType py inoremap \mu μ
inoremap \alpha α
inoremap \beta β
inoremap \gamma γ
inoremap \delta δ
inoremap \epsilon ε
inoremap \zeta ζ
inoremap \eta η
tangentstorm / animation.ijs
Created August 12, 2019 14:58
Basic animation in J
NB. Code from the "Basic Animation In J" video
NB. ------------------------------------------------------------------------
NB. animation demo
load 'viewmat'
wd 'pc w0 closeok' NB. parent control (window) named 'w0'