Skip to content

Instantly share code, notes, and snippets.

View koke2c95's full-sized avatar

名無しKさん koke2c95

View GitHub Profile
@koke2c95
koke2c95 / merge_qlora_with_quantized_model.py
Created August 26, 2023 10:44 — forked from ChrisHayduk/merge_qlora_with_quantized_model.py
Merging QLoRA weights with quantized model
import torch
import peft
import json
import shutil
from peft.utils import _get_submodules
import os
import bitsandbytes as bnb
from bitsandbytes.functional import dequantize_4bit
from peft import PeftModel
from transformers import AutoModelForCausalLM, LlamaForCausalLM, LlamaTokenizer, BitsAndBytesConfig, CodeLlamaTokenizer
@koke2c95
koke2c95 / semantic_search_with_gzip.py
Created July 15, 2023 11:31 — forked from kyo-takano/lexical_search_with_gzip.py
Semantic Search with gzip (gzipによるセマンティック検索)
import gzip
def gzip_search(query: str, candidate_chunks: list[str], top_k: int=1):
"""
文字列ベースで類似したテキストチャンクを推定するアルゴリズム.
`query`, `chunk`, および`query + " " + chunk`をそれぞれgzipで圧縮し、編集距離のようなものをベースに評価する.
Parameters:
query (str): 検索クエリとして使用する文字列.
top_k (int, optional): 返される類似チャンクの上位k個を指定する (default: 1).
@koke2c95
koke2c95 / imagenet_class_index.json
Created May 16, 2022 04:46 — forked from PonDad/imagenet_class_index.json
imagenetのラベルを日本語化するjsonです。
[
{
"num": "n01440764",
"en": "tench",
"ja": "テンチ"
},
{
"num": "n01443537",
"en": "goldfish",
"ja": "金魚"