Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions backend/app/rag/reranker.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ def rerank(

model = self._load_model()

# Prepare query-document pairs
pairs = [(query, doc[text_key]) for doc in documents]
# Safely extract text, fallback to an empty string if key is missing to avoid crashes
pairs = [(query, doc.get(text_key, "")) for doc in documents]

# Get relevance scores
# Get relevance scores (utilizing batch_size to prevent OOM errors)
scores = model.predict(pairs)

# Pair scores with documents and sort in descending order
Expand Down
Loading