|
1 | 1 | # Conivel: CONtext In noVELs |
| 2 | + |
| 3 | +## Installing dependencies |
| 4 | + |
| 5 | +Use `poetry install` to install dependencies. You can then use `poetry shell` to obtain a shell with the created virtual environment activated. |
| 6 | + |
| 7 | + |
| 8 | +# The Role of Global and Local Context in Named Entity Recognition |
| 9 | + |
| 10 | +## Reproducing Results |
| 11 | + |
| 12 | +For all the scripts presented below, results can be found under the `runs` directory. To be able to reproduce plots for Figure 1, 2 and 4, results must be placed under `runs/short/` and named correctly. |
| 13 | + |
| 14 | +### No Retrieval |
| 15 | + |
| 16 | +The `no retrieval` baseline for experiments found in Figure 1, 2 and 4 |
| 17 | +can be reproduced by using the following bash script: |
| 18 | + |
| 19 | +```sh |
| 20 | +#!/bin/bash |
| 21 | + |
| 22 | +python xp_bare.py with\ |
| 23 | + k=5\ |
| 24 | + shuffle_kfolds_seed=0\ |
| 25 | + batch_size=8\ |
| 26 | + save_models=False\ |
| 27 | + runs_nb=3\ |
| 28 | + ner_epochs_nb=2\ |
| 29 | + ner_lr=2e-5\ |
| 30 | + dataset_name="dekker" |
| 31 | +``` |
| 32 | + |
| 33 | + |
| 34 | +### Retrieval Heuristics |
| 35 | + |
| 36 | + |
| 37 | +To reproduce the experiments presented in Figure 1, one can use: |
| 38 | + |
| 39 | +```sh |
| 40 | +#!/bin/bash |
| 41 | + |
| 42 | +for heuristic in "left" "right" "neighbors" "random" "bm25" "samenoun"; do |
| 43 | + |
| 44 | + sents_nb_list="[1, 2, 3, 4, 5, 6]" |
| 45 | + if [[ "${heuristic}" = "neighbors" ]]; then |
| 46 | + sents_nb_list="[2, 4, 6]" |
| 47 | + fi |
| 48 | + |
| 49 | + python xp_kfolds.py with\ |
| 50 | + k=5\ |
| 51 | + shuffle_kfolds_seed=0\ |
| 52 | + batch_size=8\ |
| 53 | + save_models=False\ |
| 54 | + runs_nb=3\ |
| 55 | + context_retriever="${heuristic}"\ |
| 56 | + context_retriever_kwargs='{}'\ |
| 57 | + sents_nb_list="${sents_nb_list}"\ |
| 58 | + ner_epochs_nb=2\ |
| 59 | + ner_lr=2e-5\ |
| 60 | + dataset_name="dekker" |
| 61 | + |
| 62 | +done |
| 63 | +``` |
| 64 | + |
| 65 | +The `plot_mean_test_f1.py` can then be used to plot the curves found |
| 66 | +in the paper. |
| 67 | + |
| 68 | + |
| 69 | +### Oracle Versions of Retrieval Heuristics |
| 70 | + |
| 71 | +Experiments found in Figure 2 can be reproduced with the following code: |
| 72 | + |
| 73 | +```sh |
| 74 | +#!/bin/bash |
| 75 | + |
| 76 | +for heuristic in "left" "right" "neighbors" "random" "bm25" "samenoun"; do |
| 77 | + |
| 78 | + sents_nb_list="[1, 2, 3, 4, 5, 6]" |
| 79 | + if [[ "${heuristic}" = "neighbors" ]]; then |
| 80 | + sents_nb_list="[2, 4, 6]" |
| 81 | + fi |
| 82 | + |
| 83 | + python xp_ideal_neural_retriever.py with\ |
| 84 | + k=5\ |
| 85 | + shuffle_kfolds_seed=0\ |
| 86 | + batch_size=8\ |
| 87 | + save_models=False\ |
| 88 | + runs_nb=3\ |
| 89 | + retrieval_heuristic="${heuristic}"\ |
| 90 | + retrieval_heuristic_inference_kwargs='{"sents_nb": 16}'\ |
| 91 | + sents_nb_list="${sents_nb_list}"\ |
| 92 | + ner_epochs_nb=2\ |
| 93 | + ner_lr=2e-5 |
| 94 | + |
| 95 | +done |
| 96 | +``` |
| 97 | + |
| 98 | +`plot_mean_test_f1.py -r` can be used to reproduce Figure 2. |
| 99 | + |
| 100 | + |
| 101 | +### Retrieved Sentences Distance Distribution |
| 102 | + |
| 103 | +Experiments in Figure 3 can be reproduced used `xp_dist.py -r -o dists.json`, and the plot in the paper can then be reproduced with `plot_dist.py -i dists.json`. |
| 104 | + |
| 105 | + |
| 106 | +### Restricted BM25 heuristic |
| 107 | + |
| 108 | +To reproduce the experiment found in Figure 4, use: |
| 109 | + |
| 110 | +```sh |
| 111 | +python xp_ideal_neural_retriever.py with\ |
| 112 | + k=5\ |
| 113 | + shuffle_kfolds_seed=0\ |
| 114 | + batch_size=8\ |
| 115 | + save_models=False\ |
| 116 | + runs_nb=3\ |
| 117 | + retrieval_heuristic="bm25_restricted"\ |
| 118 | + retrieval_heuristic_inference_kwargs='{"sents_nb": 16}'\ |
| 119 | + sents_nb_list='[1,2,3,4,5,6]'\ |
| 120 | + ner_epochs_nb=2\ |
| 121 | + ner_lr=2e-5 |
| 122 | +``` |
| 123 | + |
| 124 | +The plot can be reproduced with `plot_mean_test_f1 -e`. |
| 125 | + |
| 126 | + |
| 127 | +### Appendix: Dataset Details |
| 128 | + |
| 129 | +Figure 5 can be reproduced using `plot_dekker_books_len.py`. |
0 commit comments