Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.
Open
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion benchmarks/retrieval/retrieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
import logging
import os
import pprint
import time

import configargparse
Expand Down Expand Up @@ -83,13 +84,18 @@ def main():
retrieved = retriever.invoke(item[args.question_field])
item["retrieved"] = []
for doc_idx, doc in enumerate(retrieved):
pprint.pprint(doc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These documents can get extremely long. Could you just use logging.info() here, and then set the appropriate logging level whenever you want to see the documents?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stray print. removing

# The absolute value of the scores below does not affect the metrics; it merely determines the ranking of
# the retrieved documents. The key of the score varies depending on the underlying retriever. If there's no
# score, we use 1/(doc_idx+1) since it preserves the order of the documents.
score = doc.metadata.get("score", doc.metadata.get("relevance_score", 1 / (doc_idx + 1)))
retrieved_docs.append(ScoredDoc(query_id=query_id, doc_id=doc.metadata["file_path"], score=score))
# Update the output dictionary with the retrieved documents.
item["retrieved"].append({"file_path": doc.metadata["file_path"], "score": score})
item["retrieved"].append({"file_path": doc.metadata["file_path"],
"score": score,
"page_content": doc.page_content,
"start_byte": doc.metadata.get("start_byte", None),
"end_byte": doc.metadata.get("end_byte", None)})

if "answer" in item:
item.pop("answer") # Makes the output file harder to read.
Expand Down
Loading