A DistilBERT model fine-tuned to judge whether a retrieved text chunk is actually relevant to a user's question, for the
StudyWise RAG pipeline.
Meant as a lightweight re-ranking / filtering signal sitting after StudyWise's hybrid retriever (keyword + proposition + embedding search) and before answer generation — catching cases where the hybrid retriever's score doesn't reflect true relevance.
This is a small-scale training exercise tied to a specific student project, not a production-grade reranker. See Limitations before relying on it.
Built from StudyWise's own
rag_traces — real (question, retrieved-chunk, hybrid-retrieval-score) records logged by the app's retriever — plus explicit cross-document negatives, via
prepare_data.py:
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4tokenizer = AutoTokenizer.from_pretrained("REPO_ID")
5model = AutoModelForSequenceClassification.from_pretrained("REPO_ID")
6
7question = "What happens during the electron transport chain?"
8chunk = "The electron transport chain is located in the inner mitochondrial membrane."
9
10inputs = tokenizer(question, chunk, return_tensors="pt", truncation=True, max_length=256)
11with torch.no_grad():
12 logits = model(**inputs).logits
13prediction = model.config.id2label[logits.argmax().item()]
14print(prediction)