-
Notifications
You must be signed in to change notification settings - Fork 11
/
nlu-hyperopt.diff
153 lines (143 loc) · 3.81 KB
/
nlu-hyperopt.diff
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
diff --git a/.env b/.env
index 1bb6fa0..8318c17 100644
--- a/.env
+++ b/.env
@@ -1,8 +1,8 @@
INPUT_EXPERIMENT_KEY=default-experiment
INPUT_MONGO_URL=mongodb:27017/nlu-hyperopt
-INPUT_MAX_EVALS=10
-INPUT_DATA_DIRECTORY=/data
-INPUT_MODEL_DIRECTORY=/models
+INPUT_MAX_EVALS=50
+INPUT_DATA_DIRECTORY=/train_test_split
+INPUT_MODEL_DIRECTORY=models
INPUT_TARGET_METRIC=f1_score
INPUT_THRESHOLD=0.8
INPUT_ABOVE_BELOW_WEIGHT=0.5
diff --git a/Dockerfile b/Dockerfile
index 0393b8d..946e1ba 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,18 +1,22 @@
-FROM rasa/rasa:3.2.4-full
-
-COPY setup.py .
-COPY requirements.txt .
-COPY train_test_split /train_test_split
-COPY nlu_hyperopt /nlu_hyperopt
-COPY scripts /scripts
+ARG RASA_VERSION
+FROM rasa/rasa:${RASA_VERSION}-full
# Be root
USER root
+COPY scripts /scripts
+COPY setup.py .
+COPY requirements.txt .
RUN pip install -U pip && pip install -r requirements.txt && chmod -R +x /scripts
ENV PYTHONPATH "/"
+COPY train_test_split /train_test_split
+COPY nlu_hyperopt /nlu_hyperopt
+COPY pipeline /pipeline
+
+ENV DISABLE_FUZZYENTITYEXTRACTOR=1
+
ENTRYPOINT ["python"]
CMD ["-m", "nlu_hyperopt.app"]
diff --git a/Dockerfile-master b/Dockerfile-master
new file mode 100644
index 0000000..7d6e4ef
--- /dev/null
+++ b/Dockerfile-master
@@ -0,0 +1,18 @@
+FROM rasa/rasa:3.2.4-full
+
+# Be root
+USER root
+
+COPY scripts /scripts
+COPY setup.py .
+COPY requirements-master.txt requirements.txt
+RUN pip install -U pip && pip install -r requirements.txt && chmod -R +x /scripts
+
+ENV PYTHONPATH "/"
+
+COPY train_test_split /train_test_split
+COPY nlu_hyperopt /nlu_hyperopt
+
+ENTRYPOINT ["python"]
+
+CMD ["-m", "nlu_hyperopt.app"]
diff --git a/docker-compose.yml b/docker-compose.yml
index 291b899..6ea25ba 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -15,19 +15,23 @@ services:
hyperopt-master:
build:
context: .
- dockerfile: Dockerfile
+ dockerfile: Dockerfile-master
depends_on:
- mongodb
environment:
INPUT_EXP_KEY: ${INPUT_EXPERIMENT_KEY}
+ INPUT_DATA_DIRECTORY: ${INPUT_DATA_DIRECTORY}
INPUT_MAX_EVALS: ${INPUT_MAX_EVALS}
INPUT_MONGO_URL: ${INPUT_MONGO_URL}
+ INPUT_MODEL_DIRECTORY: ${INPUT_MODEL_DIRECTORY}
# Workers which train and evaluate the NLU model.
hyperopt-worker:
build:
context: .
dockerfile: Dockerfile
+ args:
+ RASA_VERSION: ${RASA_VERSION}
depends_on:
- hyperopt-master
- mongodb
diff --git a/nlu_hyperopt/optimization.py b/nlu_hyperopt/optimization.py
index a478e0d..e6f3f04 100644
--- a/nlu_hyperopt/optimization.py
+++ b/nlu_hyperopt/optimization.py
@@ -58,7 +58,7 @@ def run_trial(space):
# Creating temporary config file containing space variables
- os.makedirs(f'./{data_dir}/tmp', exist_ok=True)
+ os.makedirs(f'{data_dir}/tmp', exist_ok=True)
config_path = os.path.join(data_dir, "tmp/template_config.yml")
with open(os.path.join(data_dir, "template_config.yml")) as f:
@@ -66,6 +66,8 @@ def run_trial(space):
with open(config_path, 'w+') as temp_f:
temp_f.write(config_yml)
+ logger.info("Running with configuration: \n{}\n".format(config_yml))
+
# wrap in train and eval in try/except in case
# nlu_hyperopt proposes invalid combination of params
try:
diff --git a/requirements-master.txt b/requirements-master.txt
new file mode 100644
index 0000000..877174e
--- /dev/null
+++ b/requirements-master.txt
@@ -0,0 +1,7 @@
+rasa>3.0
+protobuf<3.20.0
+multidict<6.0
+hyperopt==0.2.7
+dill
+flask
+pymongo==3.12.0
diff --git a/requirements.txt b/requirements.txt
index 569277e..7fecd0a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,7 +1,5 @@
-rasa>3.0
-tensorflow-text<=2.7.3
-protobuf<3.20.0
-multidict<6.0
-hyperopt==0.2.7
dill
flask
+rapidfuzz
+hyperopt
+pymongo==3.12.0