This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`") |