-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
113 lines (94 loc) · 3.31 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
include .env
.PHONY: install install-dev format download index first-stage zero-shot knn query-fine-tune meta-query-fine-tune rank-fusion help
.DEFAULT_GOAL := help
DOCKER_AVAILABLE := $(shell dockerdd -v 2>/dev/null)
ES_DIR := ./elasticsearch-7.11.2
## Install dependencies. Note: Activate virtualenv before running this command.
install:
pip install --upgrade pip
pip install -r requirements.txt
## Install development dependencies. Note: Activate virtualenv before running this command.
install-dev:
pip install --upgrade pip
pip install -r requirements.dev.txt
pre-commit install
## Format code base.
format:
isort --profile black .
black .
## Download datasets according to the configuration in .env.
download:
python inc_rel/download.py
es-up:
ifdef DOCKER_AVAILABLE
@echo Runnig Elasticsearch in docker
docker run -d \
-v $(INC_REL_ES_DATA_DIR):/usr/share/elasticsearch/data \
-p 9200:9200 \
-e "discovery.type=single-node" \
-e "indices.query.bool.max_clause_count=16384" \
--name inc-rel-es \
elasticsearch:7.11.2
else
@echo Running Elasticsearch on host
$(ES_DIR)/bin/elasticsearch -Ediscovery.type=single-node -Eindices.query.bool.max_clause_count=16438 -d -p $(PWD)/es.pid
endif
bash -c "until curl -s -o /dev/null http://localhost:9200; do echo 'Waiting for Elasticsearch'; sleep 3; done"
es-down:
ifdef DOCKER_AVAILABLE
docker rm -s inc-rel-es
else
kill `cat es.pid`
endif
generate-first-stage:
IR_DATASETS_HOME=$(IR_DATASETS_HOME) python inc_rel/first_stage.py --dataset $(dataset) || $(MAKE) es-down
first-stage: dataset:=$(dataset)
## Get first stage retrieval results using BM25.
first-stage: es-up generate-first-stage es-down
generate-few-shot:
IR_DATASETS_HOME=$(IR_DATASETS_HOME) python inc_rel/generate_few_shot.py --dataset $(dataset) || $(MAKE) es-down
index: dataset:=$(dataset)
## Create an elasticsearch index; perform first and second stage retrieval and generate the few-shot dataset.
index: es-up generate-few-shot es-down
## Evaluate zero-shot re-ranking.
zero-shot:
python inc_rel/zero_shot.py $(args)
knn-index:
python inc_rel/knn_index.py $(args)
knn-similarities:
python inc_rel/knn_similarities.py $(args)
knn-eval:
python inc_rel/knn_eval.py $(args)
knn: args:=$(args)
## Evaluate knn re-ranking.
knn: knn-index knn-similarities knn-eval
@echo args=$(args)
## Fine-tune the re-ranker per query on the few-shot examples.
query-ft:
python inc_rel/query_fine_tune.py $(args)
## Pre-train the re-ranker using supervised or meta learning, then Fine-tune per query on the few-shot examples.
pre-train-query-ft:
python inc_rel/pre_train.py $(args)
## Fuse two or more rankings together.
rank-fusion:
python inc_rel/rank_fusion.py $(args)
# COLORS
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
RESET := $(shell tput -Txterm sgr0)
## Show this help.
help:
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)