Text Classification
Transformers
French
Arabic
English
reranker
cross-encoder
retrieval
rag
legal
banking
bct
Instructions to use slim0001/bct-l12-reranker with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use slim0001/bct-l12-reranker with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="slim0001/bct-l12-reranker")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("slim0001/bct-l12-reranker", dtype="auto") - Notebooks
- Google Colab
- Kaggle
BCT L12 Reranker
This is a cross-encoder reranker fine-tuned for retrieval-augmented generation over Banque Centrale de Tunisie regulatory documents. It scores (query, passage) pairs and is intended to reorder candidate chunks returned by a
first-stage hybrid retriever.
The model is fine-tuned from cross-encoder/ms-marco-MiniLM-L12-v2.
Model Details
- Developed by: slim0001
- Model type: Cross-encoder sequence classification reranker
- Language(s): French primarily, with some Arabic/English metadata and queries
- Base model:
cross-encoder/ms-marco-MiniLM-L12-v2 - Task: Passage reranking for BCT regulatory RAG
- License: Other / internal-use unless changed by owner
Intended Use
Direct Use
Use this model to score candidate regulatory text chunks for a user query. Higher scores indicate higher relevance.
Typical pipeline:
- Retrieve candidates using dense/BM25/hybrid retrieval.
- Score the top candidates with this reranker.
- Sort candidates by reranker score.
- Send the top passages to an answer-generation model.
Recommended setting from development experiments:
rerank_top_k = 10
final_top_k = 5-8
max_length = 512
### Out-of-Scope Use
This model is not an answer-generation model. It should not be used to generate legal, banking, or compliance advice directly. It only ranks passages.
It is not validated outside the BCT regulatory corpus and may perform poorly on unrelated domains.
## Training Data
The model was trained using generated and curated question/chunk supervision derived from a BCT regulatory document corpus.
Main training experiment:
training/eval source: qwen_bct_questions_5k.jsonl
split: 80% train / 10% validation / 10% test
train queries: ~4000
validation queries: ~500
test queries: ~500
Gold chunks were resolved from the indexed BCT corpus. Training used top-10 hybrid retriever candidates with injected gold chunks when missing.
## Training Procedure
The model was trained with a hybrid reranker distillation objective:
total_loss =
0.1 * teacher_distillation_loss
+ 3.0 * gold_pairwise_loss
Teacher model:
BAAI/bge-reranker-v2-m3
Student/base model:
cross-encoder/ms-marco-MiniLM-L12-v2
Important hyperparameters:
hybrid_candidate_top_k: 10
learning_rate: 1e-5
num_epochs: 5
max_length: 512
batch_size: 16
selection_metric: hit@1
## Evaluation
Evaluation was performed on a strict top-10 candidate split without injected gold chunks or injected hard negatives. This better reflects real retrieval behavior, where the reranker cannot recover chunks that the first-stage
retriever did not retrieve.
### 5k Strict Test Results
βββββββββββββββββββββ¬βββββββββ¬βββββββββ¬βββββββββ¬βββββββββ¬βββββββββ¬ββββββββββ
β System β Hit@1 β Hit@3 β Hit@5 β Hit@10 β MRR@10 β NDCG@10 β
βββββββββββββββββββββΌβββββββββΌβββββββββΌβββββββββΌβββββββββΌβββββββββΌββββββββββ€
β No reranker β 0.7120 β 0.8760 β 0.9060 β 0.9480 β 0.8009 β 0.8290 β
β BGE v2-m3 teacher β 0.8380 β 0.9220 β 0.9400 β 0.9480 β 0.8827 β 0.8913 β
β This model β 0.8260 β 0.9180 β 0.9360 β 0.9480 β 0.8744 β 0.8838 β
βββββββββββββββββββββ΄βββββββββ΄βββββββββ΄βββββββββ΄βββββββββ΄βββββββββ΄ββββββββββ
The model nearly matches the BGE v2-m3 teacher on this generated 5k strict test split.
### Latency
Measured on Kaggle GPU over top-10 reranking:
βββββββββββββββββββββ¬ββββββββββββ¬ββββββββββββ¬ββββββββββββ¬ββββββββββββ
β Model β Avg/query β P50/query β P95/query β Pairs/sec β
βββββββββββββββββββββΌββββββββββββΌββββββββββββΌββββββββββββΌββββββββββββ€
β BGE v2-m3 teacher β 0.1920s β 0.2013s β 0.2153s β 52.10 β
β This model β 0.0998s β 0.1014s β 0.1063s β 100.24 β
βββββββββββββββββββββ΄ββββββββββββ΄ββββββββββββ΄ββββββββββββ΄ββββββββββββ
Approximate speedup:
1.92x faster than BGE v2-m3
## Limitations
- Evaluation is strongest on generated 5k questions; additional testing on real/manual queries is recommended.
- The model may incorrectly demote relevant chunks when the query is ambiguous or when multiple similar regulatory articles exist.
- It should be used with source display and human verification for compliance-sensitive workflows.
- It is optimized for BCT regulatory retrieval, not general legal or financial retrieval.
## Example Usage
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_id = "slim0001/bct-l12-reranker"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)
model.eval()
query = "Quelles sont les obligations de communication Γ la BCT ?"
passages = [
"Article ... texte rΓ©glementaire ...",
"Autre passage ..."
]
inputs = tokenizer(
[query] * len(passages),
passages,
padding=True,
truncation=True,
max_length=512,
return_tensors="pt",
)
with torch.no_grad():
logits = model(**inputs).logits
scores = logits.squeeze(-1) if logits.shape[-1] == 1 else logits[:, -1]
ranked = sorted(zip(scores.tolist(), passages), reverse=True)
print(ranked)
## Recommended Production Use
Use as a reranker inside a RAG system:
first-stage retrieval: BGE-M3 dense + BM25 + RRF
rerank_top_k: 10
final_top_k: 5-8
answer generation: separate LLM
## Contact
Model owner: slim0001
Model tree for slim0001/bct-l12-reranker
Base model
microsoft/MiniLM-L12-H384-uncased Quantized
cross-encoder/ms-marco-MiniLM-L12-v2