Skip to content

Instantly share code, notes, and snippets.

View ddh0's full-sized avatar
🤗

ddh0 ddh0

🤗
  • 00:15 (UTC -05:00)
View GitHub Profile
@ddh0
ddh0 / tensor-type-testing.md
Last active April 3, 2025 20:14
tensor-type-testing
@ddh0
ddh0 / train.py
Created February 6, 2025 19:46
Janky pretraining script for small llama models using HF fineweb - modify according to your needs
import os
import torch
import psutil
import datasets
import glob
from transformers import (
AutoTokenizer, LlamaConfig, LlamaForCausalLM, Trainer, TrainingArguments,
DataCollatorForLanguageModeling
)
@ddh0
ddh0 / hfget.py
Last active June 10, 2024 06:03
Python script to download Hugging Face repos with an optional download speed limit
# hfget.py
# Python 3.11.2
# Hugging Face Filesystem API:
# https://huggingface.co/docs/huggingface_hub/en/guides/hf_file_system
import os
import sys
import time
from typing import Union
@ddh0
ddh0 / voice_chat.py
Created May 12, 2024 03:40
Make Siri speak for your LLM, using macOS `say` and easy-llama
import easy_llama as ez
from subprocess import run
USER = ez.utils.USER_STYLE
BOT = ez.utils.BOT_STYLE
DIM = ez.utils.DIM_STYLE
RESET = ez.utils.RESET_ALL
def say(something: str) -> None:
run(['say', something])
Llama3 = ez.Model(
'Meta-Llama-3-8B-Instruct-q8_0.gguf',
@ddh0
ddh0 / safetensors_convert_fp16_to_8bit.py
Last active August 26, 2024 08:14
Python code to convert SDXL fp16 safetensors to 8-bit safetensors
# safetensors_convert_fp16_to_8bit.py
# Python 3.11.7
import safetensors.torch
import safetensors
import torch
import os
# blacklist takes priority over whitelist
# a tensor will only be cast if it matches the whitelist but not the blacklist