Skip to content

Instantly share code, notes, and snippets.

@lewtun
lewtun / sft_trainer.py
Last active April 12, 2024 14:51
Fine-tuning Mistral 7B with TRL & DeepSpeed ZeRO-3
# This is a modified version of TRL's `SFTTrainer` example (https://github.com/huggingface/trl/blob/main/examples/scripts/sft_trainer.py),
# adapted to run with DeepSpeed ZeRO-3 and Mistral-7B-V1.0. The settings below were run on 1 node of 8 x A100 (80GB) GPUs.
#
# Usage:
# - Install the latest transformers & accelerate versions: `pip install -U transformers accelerate`
# - Install deepspeed: `pip install deepspeed==0.9.5`
# - Install TRL from main: pip install git+https://github.com/huggingface/trl.git
# - Clone the repo: git clone github.com/huggingface/trl.git
# - Copy this Gist into trl/examples/scripts
# - Run from root of trl repo with: accelerate launch --config_file=examples/accelerate_configs/deepspeed_zero3.yaml --gradient_accumulation_steps 8 examples/scripts/sft_trainer.py
@jhorsman
jhorsman / main.cpp
Created January 26, 2018 18:09
Blink for Node MCU; Blinking the builtin led on GPIO pin 2.
/**
* Blink for Node MCU
* also see https://arduino.stackexchange.com/questions/38477/does-the-node-mcu-v3-lolin-not-have-a-builtin-led
*
* Turns on an LED on for one second,
* then off for one second, repeatedly.
*/
#include "Arduino.h"
// On a NodeMCU board the built-in led is on GPIO pin 2
@tokestermw
tokestermw / machine_learned_index.py
Last active April 9, 2019 08:41
Using deep learning to approximate a B-Tree index from this paper: https://arxiv.org/abs/1712.01208 (The Case for Learned Index Structures)
import click
import torch
import torch.autograd
import torch.nn.functional as F
from torch.autograd import Variable
import os
import random
import math
@andyrbell
andyrbell / scanner.sh
Last active April 5, 2024 09:01
Make a pdf look scanned using ImageMagick
# use ImageMagick convert
# the order is important. the density argument applies to input.pdf and resize and rotate to output.pdf
convert -density 90 input.pdf -rotate 0.5 -attenuate 0.2 +noise Multiplicative -colorspace Gray output.pdf
@pheuter
pheuter / sc-dl.js
Created March 5, 2012 20:44
Bookmarklet that generates download link for a Soundcloud upload
(function(d) {
var dl = d.createElement('a');
dl.innerText = 'Download MP3';
dl.href = "http://media.soundcloud.com/stream/"+d.querySelector('#main-content-inner img[class=waveform]').src.match(/\.com\/(.+)\_/)[1];
dl.download = d.querySelector('em').innerText+".mp3";
d.querySelector('.primary').appendChild(dl);
dl.style.marginLeft = '10px';
dl.style.color = 'red';
dl.style.fontWeight = 700;
})(document);