bge small en v1.5
简介
核心亮点
- 由智源研究院开发,英文检索精度领先
- 模型体积小,推理速度快,极低资源占用
- RAG 架构首选,大幅提升知识库检索效率
- MIT 协议开源,支持本地私有化灵活部署
使用方法
# 安装 Hugging Face transformers
pip install transformers torch
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained("michaelfeil/bge-small-en-v1.5")
tokenizer = AutoTokenizer.from_pretrained("michaelfeil/bge-small-en-v1.5")
Hugging Face 下载
我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。
操作指引:在下载前,请先通过如下命令安装 huggingface_hub:
pip install -U huggingface_hub
命令行下载
下载完整模型库
huggingface-cli download michaelfeil/bge-small-en-v1.5
下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download michaelfeil/bge-small-en-v1.5 config.json --local-dir ./dir
SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('michaelfeil/bge-small-en-v1.5')
Git 下载
请确保 lfs 已经被正确安装
git lfs install
git clone https://huggingface.co/michaelfeil/bge-small-en-v1.5
如果您希望跳过 lfs 大文件下载,可以使用如下命令
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/michaelfeil/bge-small-en-v1.5
模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。
PyTorch / Transformers 使用
安装 Transformers
pip install -U transformers torch
模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained('michaelfeil/bge-small-en-v1.5')
tokenizer = AutoTokenizer.from_pretrained('michaelfeil/bge-small-en-v1.5')
完整文档
---
tags:
- sentence-transformers
- feature-extraction
- sentence-similarity
- transformers
license: mit
language:
- en
---
<h1 align="center">Infinity Embedding Model</h1>
This is the stable default model for infinity.
pip install infinity_emb[all]More details about the infinity inference project please refer to the Github: Infinity.
Usage for Embedding Model via infinity in Python
To deploy files with the infinity_emb pip package.
Recommended is device="cuda", engine="torch" with flash attention on gpu, and device="cpu", engine="optimum" for onnx inference.
import asyncio
from infinity_emb import AsyncEmbeddingEngine, EngineArgs
sentences = ["Embed this is sentence via Infinity.", "Paris is in France."]
engine = AsyncEmbeddingEngine.from_args(
EngineArgs(
model_name_or_path = "michaelfeil/bge-small-en-v1.5",
device="cuda",
# or device="cpu"
engine="torch",
# or engine="optimum"
compile=True # enable torch.compile
))
async def main():
async with engine:
embeddings, usage = await engine.embed(sentences=sentences)
asyncio.run(main())
CLI interface
The same args
pip install infinity_emb
infinity_emb --model-name-or-path michaelfeil/bge-small-en-v1.5 --port 7997Contact
If you have any question or suggestion related to this project, feel free to open an issue or pull request. You also can email Michael Feil (infinity at michaelfeil.eu).Citation
If you find this repository useful, please consider giving a star :star: and citation
@software{Feil_Infinity_2023,
author = {Feil, Michael},
month = oct,
title = {{Infinity - To Embeddings and Beyond}},
url = {https://github.com/michaelfeil/infinity},
year = {2023}
}