🚀 upskyy/ko-reranker-8k
ko-reranker-8kはBAAI/bge-reranker-v2-m3モデルに韓国語データをfine-tuningしたモデルです。
🚀 クイックスタート
このセクションでは、upskyy/ko-reranker-8k
モデルの使用方法を説明します。
📦 インストール
FlagEmbeddingを使用する場合
pip install -U FlagEmbedding
💻 使用例
基本的な使用法
FlagEmbeddingを使用する場合
関連性スコアを取得します(スコアが高いほど関連性が高いことを示します)。
from FlagEmbedding import FlagReranker
reranker = FlagReranker('upskyy/ko-reranker-8k', use_fp16=True)
score = reranker.compute_score(['query', 'passage'])
print(score)
score = reranker.compute_score(['query', 'passage'], normalize=True)
print(score)
scores = reranker.compute_score([['what is panda?', 'hi'], ['what is panda?', 'The giant panda (Ailuropoda melanoleuca), sometimes called a panda bear or simply panda, is a bear species endemic to China.']])
print(scores)
scores = reranker.compute_score([['what is panda?', 'hi'], ['what is panda?', 'The giant panda (Ailuropoda melanoleuca), sometimes called a panda bear or simply panda, is a bear species endemic to China.']], normalize=True)
print(scores)
Huggingface transformersを使用する場合
関連性スコアを取得します(スコアが高いほど関連性が高いことを示します)。
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained('upskyy/ko-reranker-8k')
model = AutoModelForSequenceClassification.from_pretrained('upskyy/ko-reranker-8k')
model.eval()
pairs = [['what is panda?', 'hi'], ['what is panda?', 'The giant panda (Ailuropoda melanoleuca), sometimes called a panda bear or simply panda, is a bear species endemic to China.']]
with torch.no_grad():
inputs = tokenizer(pairs, padding=True, truncation=True, return_tensors='pt', max_length=512)
scores = model(**inputs, return_dict=True).logits.view(-1, ).float()
print(scores)
📚 ドキュメント
引用
@misc{li2023making,
title={Making Large Language Models A Better Foundation For Dense Retrieval},
author={Chaofan Li and Zheng Liu and Shitao Xiao and Yingxia Shao},
year={2023},
eprint={2312.15503},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
@misc{chen2024bge,
title={BGE M3-Embedding: Multi-Lingual, Multi-Functionality, Multi-Granularity Text Embeddings Through Self-Knowledge Distillation},
author={Jianlv Chen and Shitao Xiao and Peitian Zhang and Kun Luo and Defu Lian and Zheng Liu},
year={2024},
eprint={2402.03216},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
参考文献
📄 ライセンス
このプロジェクトはApache-2.0ライセンスの下でライセンスされています。