Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jph00's full-sized avatar
🦘

Jeremy Howard jph00

🦘
View GitHub Profile
@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_
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 / 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
@jph00
jph00 / deploy.yml
Last active September 16, 2022 23:42
Deploy quarto website via gh actions
name: Quarto Publish
on:
workflow_dispatch:
push: { branches: master }
jobs:
build-deploy:
runs-on: ubuntu-latest
permissions: {contents: write}
steps:
- uses: actions/checkout@v2
@jph00
jph00 / index2.ipynb
Created July 27, 2022 02:37
Using jupyter to create qmd
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jph00
jph00 / sweep.csv
Last active June 17, 2022 19:45
fastai_timm wandb sweep results
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 9 columns, instead of 6. in line 8.
model_name,learning_rate,pool,dataset,GPU_mem,error_rate,valid_loss,train_loss,fit_time
efficientnetv2_rw_t,0.0001,concat,pets,2.3203125,0.18335586786270142,0.5982086062431335,0.99508398771286,135.1381552380044
efficientnetv2_rw_s,0.0001,concat,pets,3.146484375,0.1779431700706482,0.5593751072883606,0.8270677328109741,145.79841202299576
efficientnetv2_rw_m,0.0001,concat,pets,5.56640625,0.15899866819381714,0.5119925141334534,0.7437679171562195,214.4970937330509
efficientnet_lite0,0.0001,concat,pets,1.51953125,0.19418132305145264,0.6388306021690369,1.144728422164917,67.13226824696176
efficientnet_es_pruned,0.0001,concat,pets,1.53515625,0.1637347936630249,0.5296803712844849,0.9239290952682496,69.60124204796739
efficientnet_es,0.0001,concat,pets,1.53515625,0.1400541067123413,0.44839274883270264,0.8084487915039062,72.84359885391314
efficientnet_b0,0.0001,concat,pets,1.666015625,0.19418132305145264,0.65826016664505,1.157211184501648,85.95306042104494
efficientnetv2_rw_t,0.0004,concat,pets,2.3203125,0.114343702793121