CoolFace
Modelpublic

CuongCao/oe-bge-m3-LoRA-ft-v2

sourceHugging Faceapache-2.0updated 3mo agoView on Hugging Face
0likes
Model Card

BGE-M3 LoRA — Finetuned on OE Support Knowledge Base

This is a LoRA-finetuned version of BAAI/bge-m3 trained on an internal Order Express (OE) support knowledge base to improve retrieval accuracy for customer support queries.

Training Summary

ItemDetail
Base modelBAAI/bge-m3
MethodPEFT LoRA + CachedMultipleNegativesRankingLoss
LoRA rank (r)32
LoRA alpha64
Target modulesquery, value
Training epochs3
Batch size8 (gradient accumulation × 4)
Learning rate3e-5
Warmup ratio0.1
Max sequence length512
Train queries3,116 (85% of golden test set)
Eval queries~550 (15% of golden test set)
CorpusFull KB: 6,756 documents
Train/eval split85/15 stratified by difficulty (Easy / Medium / Hard)

Training Process

image

Usage

With sentence-transformers (merged model — recommended for inference)

python
import os
from huggingface_hub import snapshot_download
from langchain_huggingface import HuggingFaceEmbeddings

model_kwargs = {'device': 'cuda' if torch.cuda.is_available() else 'cpu'}
encode_kwargs = {'normalize_embeddings': True}

print("Downloading merged model files...")
local_model_dir = snapshot_download(
    repo_id="CuongCao/oe-bge-m3-LoRA-ft-v2",
    allow_patterns=["merged/*", "merged/**/*"]
)
merged_path = os.path.join(local_model_dir, "merged")

print("Loading model into LangChain wrapper...")
model = HuggingFaceEmbeddings(
    model_name=merged_path,       
    model_kwargs=model_kwargs,     
    encode_kwargs=encode_kwargs    
)

query = "How do I reset my password?"
documents = ["Password reset procedure", "Account settings guide", ...]

query_emb = model.encode(query)
doc_embs = model.encode(documents)

# Cosine similarity
scores = query_emb @ doc_embs.T

Repo Structure

CuongCao/oe-bge-m3-LoRA-ft-v2/
├── lora-adapters/      # LoRA adapter weights only (~12 MB)
│   ├── adapter_config.json
│   └── adapter_model.safetensors
└── merged/             # Full merged model (~2.2 GB, ready for inference)
    ├── config.json
    ├── model.safetensors
    └── ...

Citation

If you use this model, please cite the original BGE-M3 paper:

bibtex
@article{bge-m3,
  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},
  journal={arXiv preprint arXiv:2402.03216},
  year={2024}
}