Skip to content

Instantly share code, notes, and snippets.

View zachschillaci27's full-sized avatar

Zach Schillaci zachschillaci27

View GitHub Profile
@mlabonne
mlabonne / merge_peft.py
Last active March 3, 2025 05:36
Merge base model and peft adapter and push it to HF hub
# Example usage:
# python merge_peft.py --base_model=meta-llama/Llama-2-7b-hf --peft_model=./qlora-out --hub_id=alpaca-qlora
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
import argparse
def get_args():
@smartm13
smartm13 / streamlit_helper.py
Last active January 11, 2023 16:36
Decorate this before st.experimental_memo and later check if function has already cached a given set of args+kwargs
import functools
def st_cache_monitor(func):
""" A decorator to handle query_cache=hit/miss utility """
@functools.wraps(func)
def wrapper_func(*args, _querying_cache=None, **kwargs):
""" Wrapper to original func to handle special argument _querying_cache """
if _querying_cache is Ellipsis:
raise LookupError("_querying_cache=`miss`")