- Clone the repo with
git clone https://github.com/rsvp-ai/bertserini.git
pip install -r requirements.txt
We have indexed the 2018 Wikipedia Chinese dump. You can download the prepared index here:
wget https://rgw.cs.uwaterloo.ca/JIMMYLIN-bucket0/pyserini-indexes/lucene-index.zhwiki-20181201-paragraphs.tar.gz
After unzipping these files, put them under the root path of this repo, and then you are ready to go. Take the following folder structure as an example:
bertserini
+--- indexes
| +--- lucene-index.zhwiki-20181201-paragraphs
| | +--- ...
+--- other files under this repo
We have uploaded the finetuned checkpoints to the huggingface models:
bertserini-bert-base-cmrc
To run our finetuned model, just set --model_name_or_path rsvp-ai/<MODEL_NAME>
.
For example: --model_name_or_path rsvp-ai/bertserini-bert-base-cmrc
.
cd data
wget https://worksheets.codalab.org/rest/bundles/0xb70e5e281fcd437d9aa8f1c4da107ae4/contents/blob/
mv index.html cmrc2018_dev.json
wget https://worksheets.codalab.org/rest/bundles/0x72252619f67b4346a85e122049c3eabd/contents/blob/
mv index.html cmrc2018_dev_squad.json
For rsvp-ai/bertserini-bert-base-cmrc
python -m bertserini.experiments.inference --dataset_path data/cmrc2018_dev_squad.json \
--index_path indexes/lucene-index.zhwiki-20181201-paragraphs \
--model_name_or_path rsvp-ai/bertserini-bert-base-cmrc \
--output prediction/cmrc2018_pred.json \
--topk 10 \
--language zh
mkdir temp
python -m bertserini.experiments.evaluate --eval_data data/cmrc2018_dev.json \
--search_file prediction/cmrc2018_pred.json \
--output_path temp \
--dataset cmrc
Expected results:
## rsvp-ai/bertserini-bert-base-cmrc, this is bert-base-chinese finetuned on the chinese reading comprehension dataset(CMRC)
(0.5, {'f1_score': 68.0033167812909, 'exact_match': 51.164958061509786, 'total_count': 3219, 'skip_count': 1})
replicated Mar 10 2022 by @amyxie361 (0.5, {'f1_score': 65.64519666259483, 'exact_match': 49.98446722584654, 'total_count': 3219, 'skip_count': 0})