🚀 upskyy/ko-reranker-8k
ko-reranker-8k是在BAAI/bge-reranker-v2-m3模型的基础上,使用韩语数据进行微调得到的模型。
🚀 快速开始
📦 安装指南
使用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许可证。