Download evaluation/scripts/build_bm25_index.py from EllaNAM/rag-assignment-processed-bm25: direct link, hf CLI and curl.
- Browser
- Download file 689 Bytes
-
https://huggingface.co/datasets/EllaNAM/rag-assignment-processed-bm25/resolve/main/evaluation/scripts/build_bm25_index.py
- Command line
-
hf download hf://datasets/EllaNAM/rag-assignment-processed-bm25/evaluation/scripts/build_bm25_index.py
-
curl -L -o build_bm25_index.py https://huggingface.co/datasets/EllaNAM/rag-assignment-processed-bm25/resolve/main/evaluation/scripts/build_bm25_index.py
689 Bytes
| #!/usr/bin/env python3 | |
| """Build the bm25s index from processed_corpus.jsonl.""" | |
| import argparse | |
| from pathlib import Path | |
| from rag_assignment.corpus import ProcessedCorpus | |
| from rag_assignment.retriever.bm25 import build_bm25_index | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--corpus", type=Path, default=Path("data/processed_corpus.jsonl")) | |
| parser.add_argument("--index-dir", type=Path, default=Path("data/index/bm25-sparse")) | |
| args = parser.parse_args() | |
| with ProcessedCorpus(args.corpus) as corpus: | |
| build_bm25_index(corpus, args.index_dir) | |
| print(args.index_dir) | |
| if __name__ == "__main__": | |
| main() | |