Skip to content

Instantly share code, notes, and snippets.

View ahoho's full-sized avatar

Alexander Hoyle ahoho

View GitHub Profile
@ahoho
ahoho / prompt_alpaca_lora.py
Last active February 17, 2024 22:31
Create a huggingface pipeline with a lora-trained alpaca
View prompt_alpaca_lora.py
from typing import Optional, Any
import torch
from transformers.utils import is_accelerate_available, is_bitsandbytes_available
from transformers import (
AutoTokenizer,
AutoModelForCausalLM,
GenerationConfig,
pipeline,
@ahoho
ahoho / convert-hf-to-pth.py
Created April 2, 2023 19:35
Convert huggingface model to pytorch checkpoint (modified from alpaca-lora)
View convert-hf-to-pth.py
# Convert a huggingface LLaMA checkpoint to an (unsharded) pytorch checkpoint
# comes from https://github.com/tloen/alpaca-lora/blob/main/export_state_dict_checkpoint.py
import argparse
import json
from pathlib import Path
import torch
import transformers
from transformers import LlamaForCausalLM, LlamaTokenizer # noqa: E402