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
ChrisHayduk / merge_qlora_with_quantized_model.py
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
rain-1 / LLM.md
Last active July 11, 2024 18:17
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.

@Helw150
Helw150 / parallel_t5.py
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(
range(
@karpathy
karpathy / stablediffusionwalk.py
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 stablediffusionwalk.py --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
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
tangentstorm / animation.ijs
Created August 12, 2019 14:58
Basic animation in J
NB. Code from the "Basic Animation In J" video
NB. https://www.youtube.com/watch?v=uL-70fMTVnw
NB. ------------------------------------------------------------------------
NB. animation demo
load 'viewmat'
coinsert'jgl2'
wd 'pc w0 closeok' NB. parent control (window) named 'w0'