Skip to content

Instantly share code, notes, and snippets.

View jph00's full-sized avatar
🦘

Jeremy Howard jph00

🦘
View GitHub Profile
#!/usr/bin/env bash
###
# NB: You probably don't want this gist any more.
# Instead, use this version from `fastsetup`:
# https://github.com/fastai/fastsetup/blob/master/setup-conda.sh
###
set -e
cd
@jph00
jph00 / install.sh
Created January 31, 2024 05:42
Install python GPU basics
conda install cuda -c nvidia/label/cuda-12.1.0
conda install 'pytorch>2.0.1' torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
conda install scipy matplotlib pandas notebook
@jph00
jph00 / qlora.py
Created November 1, 2023 01:40
Manual qlora inference example
import torch, time, os, safetensors
from torch import nn
from peft import get_peft_model, LoraConfig, TaskType
from bitsandbytes.nn import Linear4bit, Linear8bitLt
from transformers import AutoTokenizer, LlamaForCausalLM, AutoConfig, LlamaPreTrainedModel, BitsAndBytesConfig
from transformers.utils import hub, WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_INDEX_NAME
from transformers.integrations.bitsandbytes import replace_with_bnb_linear
@jph00
jph00 / fast_peft.py
Last active October 18, 2023 21:08
Make get_peft_model() fast
from bitsandbytes.nn.modules import Linear8bitLt, Linear4bit
from contextlib import contextmanager
def noop (x=None, *args, **kwargs):
"Do nothing"
return x
@contextmanager
def no_kaiming():
old_iku = init.kaiming_uniform_
@jph00
jph00 / AliasSampling.ipynb
Created January 21, 2018 17:53
Fast weighted sampling using the alias method in numba
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import torch
from datasets import load_dataset
import argparse
import os
import math
from itertools import chain
from datetime import timedelta
from torch.utils.data import DataLoader
from accelerate import Accelerator
from accelerate.utils import (DummyOptim, DummyScheduler,
@jph00
jph00 / embodiment.md
Created March 26, 2023 03:48
Bing chat about embodiment and grounding

Bing Chat at 2023-3-26 13:47:19

1

Q: Bing AI

2

Q: Some philosophers and AI researchers have claimed that AI can not be sentient, or be AGI, due to lack of "embodiment" or "grounding". Could you please summarize these claims, and points for and against? Who are the main people on each side of this debate?

@jph00
jph00 / blog_test.ipynb
Created January 19, 2020 22:03
/nbs/blog_test.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jph00
jph00 / task.py
Created October 5, 2022 02:07
Example of using `prepare_for_task` in Hugging Face Datasets
from datasets.tasks import ImageClassification
t = train.rename_columns({'image':'a', 'label':'b'})
t2 = t.prepare_for_task(ImageClassification(image_column='a', label_column='b'))
t2.features
@jph00
jph00 / pull-all.sh
Last active September 25, 2022 15:42
Update in parallel all repos listed in ~/git/repos, and print status of any that are dirty
#!/usr/bin/env bash
for f in $(<~/git/repos); do
cd ~/git/$f
git pull > /dev/null &
cd - > /dev/null
done
wait < <(jobs -p)
for f in $(<~/git/repos); do