danielsuarez-mash commited on
Commit
aa8afeb
1 Parent(s): 027f7b5

Repo updates

Browse files
README 2.md DELETED
@@ -1,9 +0,0 @@
1
- # Langchain series
2
-
3
- This project was aimed at learning more about large language models and how to use them via langchain. It contains:
4
-
5
- - a notebook which works through langchain's basic functionality
6
- - a streamlit application which allows a user to query a self-uploaded document
7
-
8
- ## Running instructions
9
- To run the notebook or the application, install the python environment using the environment.yaml file included in this repo. You will also need to have a HuggingFace API token saved in a .bash_profile file in your home directory. To run the application, run streamlit dashboard/app.py from the repo location.
 
 
 
 
 
 
 
 
 
 
environment_all.yml DELETED
@@ -1,333 +0,0 @@
1
- name: llm
2
- channels:
3
- # - bioconda
4
- - conda-forge
5
- - defaults
6
- dependencies:
7
- - aiohttp=3.8.5=py311h80987f9_0
8
- - aiosignal=1.3.1=pyhd8ed1ab_0
9
- - altair=5.2.0=pyhd8ed1ab_0
10
- - annotated-types=0.6.0=pyhd8ed1ab_0
11
- - anyio=3.7.1=pyhd8ed1ab_0
12
- - appdirs=1.4.4=pyh9f0ad1d_0
13
- - appnope=0.1.3=pyhd8ed1ab_0
14
- - argon2-cffi=23.1.0=pyhd8ed1ab_0
15
- - argon2-cffi-bindings=21.2.0=py311heffc1b2_4
16
- - arrow=1.3.0=pyhd8ed1ab_0
17
- - asttokens=2.4.1=pyhd8ed1ab_0
18
- - async-lru=2.0.4=pyhd8ed1ab_0
19
- - async-timeout=4.0.3=pyhd8ed1ab_0
20
- - attrs=23.1.0=pyh71513ae_1
21
- - aws-c-auth=0.7.8=h76f1ccf_2
22
- - aws-c-cal=0.6.9=hb1772db_2
23
- - aws-c-common=0.9.10=h93a5062_0
24
- - aws-c-compression=0.2.17=hb1772db_7
25
- - aws-c-event-stream=0.3.2=hb5e90b3_8
26
- - aws-c-http=0.7.14=hd747585_3
27
- - aws-c-io=0.13.36=h1112932_2
28
- - aws-c-mqtt=0.10.0=h99ceed4_0
29
- - aws-c-s3=0.4.5=hc25d294_0
30
- - aws-c-sdkutils=0.1.13=hb1772db_0
31
- - aws-checksums=0.1.17=hb1772db_6
32
- - aws-crt-cpp=0.25.0=h0f7dc99_2
33
- - aws-sdk-cpp=1.11.210=h87406ae_5
34
- - babel=2.13.1=pyhd8ed1ab_0
35
- - backports=1.0=pyhd8ed1ab_3
36
- - backports.functools_lru_cache=1.6.5=pyhd8ed1ab_0
37
- - beautifulsoup4=4.12.2=pyha770c72_0
38
- - bleach=6.1.0=pyhd8ed1ab_0
39
- - blinker=1.7.0=pyhd8ed1ab_0
40
- - brotli=1.1.0=hb547adb_1
41
- - brotli-bin=1.1.0=hb547adb_1
42
- - brotli-python=1.1.0=py311ha891d26_1
43
- - bzip2=1.0.8=h93a5062_5
44
- - c-ares=1.24.0=h93a5062_0
45
- - ca-certificates=2023.11.17=hf0a4a13_0
46
- - cached-property=1.5.2=hd8ed1ab_1
47
- - cached_property=1.5.2=pyha770c72_1
48
- - cachetools=5.3.2=pyhd8ed1ab_0
49
- - certifi=2023.11.17=pyhd8ed1ab_0
50
- - cffi=1.16.0=py311h4a08483_0
51
- - charset-normalizer=3.3.2=pyhd8ed1ab_0
52
- - click=8.1.7=unix_pyh707e725_0
53
- - colorama=0.4.6=pyhd8ed1ab_0
54
- - comm=0.1.4=pyhd8ed1ab_0
55
- - contourpy=1.2.0=py311hd03642b_0
56
- - cryptography=41.0.5=py311h71175c2_0
57
- - cycler=0.12.1=pyhd8ed1ab_0
58
- - dataclasses-json=0.5.7=pyhd8ed1ab_0
59
- - debugpy=1.8.0=py311ha891d26_1
60
- - decorator=5.1.1=pyhd8ed1ab_0
61
- - defusedxml=0.7.1=pyhd8ed1ab_0
62
- - docker-pycreds=0.4.0=py_0
63
- - entrypoints=0.4=pyhd8ed1ab_0
64
- - et_xmlfile=1.1.0=pyhd8ed1ab_0
65
- - exceptiongroup=1.1.3=pyhd8ed1ab_0
66
- - executing=2.0.1=pyhd8ed1ab_0
67
- - filelock=3.13.1=pyhd8ed1ab_0
68
- - fonttools=4.44.0=py311h05b510d_0
69
- - fqdn=1.5.1=pyhd8ed1ab_0
70
- - freetype=2.12.1=hadb7bae_2
71
- - frozenlist=1.4.0=py311heffc1b2_1
72
- - fsspec=2023.10.0=pyhca7485f_0
73
- - gflags=2.2.2=hc88da5d_1004
74
- - gitdb=4.0.11=pyhd8ed1ab_0
75
- - gitpython=3.1.40=pyhd8ed1ab_0
76
- - glog=0.6.0=h6da1cb0_0
77
- - gmp=6.3.0=h965bd2d_0
78
- - gmpy2=2.1.2=py311h2ba9262_1
79
- - google-api-core=2.13.0=pyhd8ed1ab_0
80
- - google-auth=2.23.4=pyhca7485f_0
81
- - googleapis-common-protos=1.61.0=pyhd8ed1ab_0
82
- - greenlet=3.0.1=py311hbaf5611_0
83
- - icu=73.2=hc8870d7_0
84
- - idna=3.4=pyhd8ed1ab_0
85
- - importlib-metadata=6.8.0=pyha770c72_0
86
- - importlib_metadata=6.8.0=hd8ed1ab_0
87
- - importlib_resources=6.1.1=pyhd8ed1ab_0
88
- - iniconfig=2.0.0=pyhd8ed1ab_0
89
- - ipykernel=6.26.0=pyh3cd1d5f_0
90
- - ipython=8.17.2=pyh31c8845_0
91
- - ipywidgets=8.1.1=pyhd8ed1ab_0
92
- - isoduration=20.11.0=pyhd8ed1ab_0
93
- - jedi=0.19.1=pyhd8ed1ab_0
94
- - jinja2=3.1.2=pyhd8ed1ab_1
95
- - joblib=1.3.2=pyhd8ed1ab_0
96
- - json5=0.9.14=pyhd8ed1ab_0
97
- - jsonpatch=1.33=pyhd8ed1ab_0
98
- - jsonpointer=2.4=py311h267d04e_3
99
- - jsonschema=4.19.2=pyhd8ed1ab_0
100
- - jsonschema-specifications=2023.7.1=pyhd8ed1ab_0
101
- - jsonschema-with-format-nongpl=4.19.2=pyhd8ed1ab_0
102
- - jupyter=1.0.0=pyhd8ed1ab_10
103
- - jupyter-lsp=2.2.0=pyhd8ed1ab_0
104
- - jupyter_client=8.6.0=pyhd8ed1ab_0
105
- - jupyter_console=6.6.3=pyhd8ed1ab_0
106
- - jupyter_core=5.5.0=py311h267d04e_0
107
- - jupyter_events=0.9.0=pyhd8ed1ab_0
108
- - jupyter_server=2.10.0=pyhd8ed1ab_0
109
- - jupyter_server_terminals=0.4.4=pyhd8ed1ab_1
110
- - jupyterlab=4.0.8=pyhd8ed1ab_0
111
- - jupyterlab_pygments=0.2.2=pyhd8ed1ab_0
112
- - jupyterlab_server=2.25.1=pyhd8ed1ab_0
113
- - jupyterlab_widgets=3.0.9=pyhd8ed1ab_0
114
- - kiwisolver=1.4.5=py311he4fd1f5_1
115
- - krb5=1.21.2=h92f50d5_0
116
- - langchain=0.0.333=pyhd8ed1ab_0
117
- - langsmith=0.0.62=pyhd8ed1ab_0
118
- - lcms2=2.15=hf2736f0_3
119
- - lerc=4.0.0=h9a09cb3_0
120
- - libabseil=20230802.1=cxx17_h13dd4ca_0
121
- - libarrow=14.0.2=hfcbd24e_0_cpu
122
- - libarrow-acero=14.0.2=h13dd4ca_0_cpu
123
- - libarrow-dataset=14.0.2=h13dd4ca_0_cpu
124
- - libarrow-flight=14.0.2=ha94d253_0_cpu
125
- - libarrow-flight-sql=14.0.2=h39a9b85_0_cpu
126
- - libarrow-gandiva=14.0.2=hf757142_0_cpu
127
- - libarrow-substrait=14.0.2=h7fd9903_0_cpu
128
- - libblas=3.9.0=19_osxarm64_openblas
129
- - libbrotlicommon=1.1.0=hb547adb_1
130
- - libbrotlidec=1.1.0=hb547adb_1
131
- - libbrotlienc=1.1.0=hb547adb_1
132
- - libcblas=3.9.0=19_osxarm64_openblas
133
- - libcrc32c=1.1.2=hbdafb3b_0
134
- - libcurl=8.5.0=h2d989ff_0
135
- - libcxx=16.0.6=h4653b0c_0
136
- - libdeflate=1.19=hb547adb_0
137
- - libedit=3.1.20191231=hc8eb9b7_2
138
- - libev=4.33=h93a5062_2
139
- - libevent=2.1.12=h2757513_1
140
- - libexpat=2.5.0=hb7217d7_1
141
- - libffi=3.4.2=h3422bc3_5
142
- - libgfortran=5.0.0=13_2_0_hd922786_1
143
- - libgfortran5=13.2.0=hf226fd6_1
144
- - libgoogle-cloud=2.12.0=hfb399a7_4
145
- - libgrpc=1.59.3=hbcf6334_0
146
- - libiconv=1.17=h0d3ecfb_2
147
- - libjpeg-turbo=3.0.0=hb547adb_1
148
- - liblapack=3.9.0=19_osxarm64_openblas
149
- - libllvm15=15.0.7=h2621b3d_4
150
- - libnghttp2=1.58.0=ha4dd798_1
151
- - libopenblas=0.3.24=openmp_hd76b1f2_0
152
- - libparquet=14.0.2=hf6ce1d5_0_cpu
153
- - libpng=1.6.39=h76d750c_0
154
- - libprotobuf=4.24.4=hc9861d8_0
155
- - libre2-11=2023.06.02=h1753957_0
156
- - libsodium=1.0.18=h27ca646_1
157
- - libsqlite=3.44.0=h091b4b1_0
158
- - libssh2=1.11.0=h7a5bd25_0
159
- - libthrift=0.19.0=h026a170_1
160
- - libtiff=4.6.0=ha8a6c65_2
161
- - libutf8proc=2.8.0=h1a8c8d9_0
162
- - libuv=1.46.0=hb547adb_0
163
- - libwebp-base=1.3.2=hb547adb_0
164
- - libxcb=1.15=hf346824_0
165
- - libxml2=2.12.3=h0d0cfa8_0
166
- - libzlib=1.2.13=h53f4e23_5
167
- - llvm-openmp=17.0.4=hcd81f8e_0
168
- - lz4-c=1.9.4=hb7217d7_0
169
- - markdown-it-py=3.0.0=pyhd8ed1ab_0
170
- - markupsafe=2.1.3=py311heffc1b2_1
171
- - marshmallow=3.20.1=pyhd8ed1ab_0
172
- - marshmallow-enum=1.5.1=pyh9f0ad1d_3
173
- - matplotlib-base=3.8.1=py311hfdba5f6_0
174
- - matplotlib-inline=0.1.6=pyhd8ed1ab_0
175
- - mdurl=0.1.0=pyhd8ed1ab_0
176
- - mistune=3.0.2=pyhd8ed1ab_0
177
- - mpc=1.3.1=h91ba8db_0
178
- - mpfr=4.2.1=h9546428_0
179
- - mpmath=1.3.0=pyhd8ed1ab_0
180
- - multidict=6.0.4=py311he2be06e_1
181
- - munkres=1.0.7=py_1
182
- - mypy_extensions=1.0.0=pyha770c72_0
183
- - nbclient=0.8.0=pyhd8ed1ab_0
184
- - nbconvert=7.11.0=pyhd8ed1ab_0
185
- - nbconvert-core=7.11.0=pyhd8ed1ab_0
186
- - nbconvert-pandoc=7.11.0=pyhd8ed1ab_0
187
- - nbformat=5.9.2=pyhd8ed1ab_0
188
- - ncurses=6.4=h463b476_2
189
- - nest-asyncio=1.5.8=pyhd8ed1ab_0
190
- - networkx=3.2.1=pyhd8ed1ab_0
191
- - nomkl=1.0=h5ca1d4c_0
192
- - notebook=7.0.6=pyhd8ed1ab_0
193
- - notebook-shim=0.2.3=pyhd8ed1ab_0
194
- - numexpr=2.8.7=py311h6e08293_4
195
- - numpy=1.26.0=py311hb8f3215_0
196
- - openai=0.28.1=pyhd8ed1ab_0
197
- - openapi-schema-pydantic=1.2.4=pyhd8ed1ab_0
198
- - openjpeg=2.5.0=h4c1507b_3
199
- - openpyxl=3.1.2=py311heffc1b2_0
200
- - openssl=3.2.0=h0d3ecfb_1
201
- - orc=1.9.2=h7c018df_0
202
- - overrides=7.4.0=pyhd8ed1ab_0
203
- - packaging=23.2=pyhd8ed1ab_0
204
- - pandas=2.1.2=py311h6e08293_0
205
- - pandas-stubs=2.1.1.230928=pyhd8ed1ab_1
206
- - pandoc=3.1.3=hce30654_0
207
- - pandocfilters=1.5.0=pyhd8ed1ab_0
208
- - parso=0.8.3=pyhd8ed1ab_0
209
- - pathtools=0.1.2=py_1
210
- - pexpect=4.8.0=pyh1a96a4e_2
211
- - pickleshare=0.7.5=py_1003
212
- - pillow=10.1.0=py311hb9c5795_0
213
- - pip=23.3.1=pyhd8ed1ab_0
214
- - pkgutil-resolve-name=1.3.10=pyhd8ed1ab_1
215
- - platformdirs=3.11.0=pyhd8ed1ab_0
216
- - plotly=5.18.0=pyhd8ed1ab_0
217
- - pluggy=1.3.0=pyhd8ed1ab_0
218
- - prometheus_client=0.18.0=pyhd8ed1ab_0
219
- - prompt-toolkit=3.0.39=pyha770c72_0
220
- - prompt_toolkit=3.0.39=hd8ed1ab_0
221
- - protobuf=4.24.4=py311h4d1eceb_0
222
- - psutil=5.9.5=py311heffc1b2_1
223
- - pthread-stubs=0.4=h27ca646_1001
224
- - ptyprocess=0.7.0=pyhd3deb0d_0
225
- - pure_eval=0.2.2=pyhd8ed1ab_0
226
- - pyarrow=14.0.2=py311hd7bc329_0_cpu
227
- - pyasn1=0.5.0=pyhd8ed1ab_0
228
- - pyasn1-modules=0.3.0=pyhd8ed1ab_0
229
- - pycparser=2.21=pyhd8ed1ab_0
230
- - pydantic=2.0.3=pyhd8ed1ab_1
231
- - pydantic-core=2.3.0=py311h0563b04_0
232
- - pydeck=0.8.0=pyhd8ed1ab_0
233
- - pygments=2.16.1=pyhd8ed1ab_0
234
- - pyobjc-core=10.0=py311hb702dc4_0
235
- - pyobjc-framework-cocoa=10.0=py311hb702dc4_1
236
- - pyopenssl=23.3.0=pyhd8ed1ab_0
237
- - pyparsing=3.1.1=pyhd8ed1ab_0
238
- - pypdf2=2.11.1=pyhd8ed1ab_0
239
- - pysocks=1.7.1=pyha2e5f31_6
240
- - pytest=7.4.3=pyhd8ed1ab_0
241
- - pytest-subtests=0.11.0=pyhd8ed1ab_0
242
- - python=3.11.6=h47c9636_0_cpython
243
- - python-dateutil=2.8.2=pyhd8ed1ab_0
244
- - python-fastjsonschema=2.18.1=pyhd8ed1ab_0
245
- - python-json-logger=2.0.7=pyhd8ed1ab_0
246
- - python-tzdata=2023.3=pyhd8ed1ab_0
247
- - python_abi=3.11=4_cp311
248
- - pytz=2023.3.post1=pyhd8ed1ab_0
249
- - pyu2f=0.1.5=pyhd8ed1ab_0
250
- - pyyaml=6.0.1=py311heffc1b2_1
251
- - pyzmq=25.1.1=py311he9c0408_2
252
- - qtconsole-base=5.5.0=pyha770c72_0
253
- - qtpy=2.4.1=pyhd8ed1ab_0
254
- - re2=2023.06.02=h6135d0a_0
255
- - readline=8.2=h92ec313_1
256
- - referencing=0.30.2=pyhd8ed1ab_0
257
- - requests=2.31.0=pyhd8ed1ab_0
258
- - rfc3339-validator=0.1.4=pyhd8ed1ab_0
259
- - rfc3986-validator=0.1.1=pyh9f0ad1d_0
260
- - rich=13.7.0=pyhd8ed1ab_0
261
- - rpds-py=0.12.0=py311h94f323b_0
262
- - rsa=4.9=pyhd8ed1ab_0
263
- - scikit-learn=1.3.2=py311ha25ca4d_1
264
- - scipy=1.11.3=py311h93d07a4_1
265
- - send2trash=1.8.2=pyhd1c38e8_0
266
- - sentry-sdk=1.34.0=pyhd8ed1ab_0
267
- - setproctitle=1.3.3=py311heffc1b2_0
268
- - setuptools=68.2.2=pyhd8ed1ab_0
269
- - six=1.16.0=pyh6c4a22f_0
270
- - sleef=3.5.1=h156473d_2
271
- - smmap=5.0.0=pyhd8ed1ab_0
272
- - snappy=1.1.10=h17c5cce_0
273
- - sniffio=1.3.0=pyhd8ed1ab_0
274
- - soupsieve=2.5=pyhd8ed1ab_1
275
- - sqlalchemy=2.0.23=py311h05b510d_0
276
- - stack_data=0.6.2=pyhd8ed1ab_0
277
- - streamlit=1.29.0=pyhd8ed1ab_0
278
- - stringcase=1.2.0=py_0
279
- - sympy=1.12=pypyh9d50eac_103
280
- - tenacity=8.2.3=pyhd8ed1ab_0
281
- - terminado=0.17.1=pyhd1c38e8_0
282
- - threadpoolctl=3.2.0=pyha21a80b_0
283
- - tinycss2=1.2.1=pyhd8ed1ab_0
284
- - tk=8.6.13=h5083fa2_1
285
- - toml=0.10.2=pyhd8ed1ab_0
286
- - tomli=2.0.1=pyhd8ed1ab_0
287
- - toolz=0.12.0=pyhd8ed1ab_0
288
- - tornado=6.3.3=py311heffc1b2_1
289
- - tqdm=4.66.1=pyhd8ed1ab_0
290
- - traitlets=5.13.0=pyhd8ed1ab_0
291
- - types-python-dateutil=2.8.19.14=pyhd8ed1ab_0
292
- - types-pytz=2023.3.1.1=pyhd8ed1ab_0
293
- - typing-extensions=4.8.0=hd8ed1ab_0
294
- - typing_extensions=4.8.0=pyha770c72_0
295
- - typing_inspect=0.9.0=pyhd8ed1ab_0
296
- - typing_utils=0.1.0=pyhd8ed1ab_0
297
- - tzdata=2023c=h71feb2d_0
298
- - tzlocal=5.2=py311h267d04e_0
299
- - uri-template=1.3.0=pyhd8ed1ab_0
300
- - urllib3=2.0.7=pyhd8ed1ab_0
301
- - validators=0.14.0=py_0
302
- - wandb=0.15.12=pyhd8ed1ab_0
303
- - watchdog=3.0.0=py311heffc1b2_1
304
- - wcwidth=0.2.9=pyhd8ed1ab_0
305
- - webcolors=1.13=pyhd8ed1ab_0
306
- - webencodings=0.5.1=pyhd8ed1ab_2
307
- - websocket-client=1.6.4=pyhd8ed1ab_0
308
- - wheel=0.41.3=pyhd8ed1ab_0
309
- - widgetsnbextension=4.0.9=pyhd8ed1ab_0
310
- - xorg-libxau=1.0.11=hb547adb_0
311
- - xorg-libxdmcp=1.1.3=h27ca646_0
312
- - xz=5.2.6=h57fd34a_0
313
- - yaml=0.2.5=h3422bc3_2
314
- - yarl=1.9.2=py311h05b510d_1
315
- - zeromq=4.3.5=h965bd2d_0
316
- - zipp=3.17.0=pyhd8ed1ab_0
317
- - zstd=1.5.5=h4f39d0f_0
318
- - pip:
319
- - einops==0.7.0
320
- - faiss-cpu==1.7.4
321
- - huggingface-hub==0.17.3
322
- - instructorembedding==1.0.1
323
- - nltk==3.8.1
324
- - python-dotenv==1.0.0
325
- - regex==2023.10.3
326
- - safetensors==0.4.0
327
- - sentence-transformers==2.2.2
328
- - sentencepiece==0.1.99
329
- - tokenizers==0.14.1
330
- - torch==2.1.1
331
- - torchvision==0.16.1
332
- - transformers==4.35.0
333
- prefix: /Users/danielsuarez-mash/anaconda3/envs/llm
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
environment_ignore.yml DELETED
@@ -1,15 +0,0 @@
1
- channels:
2
- - conda-forge
3
- - defaults
4
- dependencies:
5
- - streamlit=1.29.0=pyhd8ed1ab_0
6
- - pypdf2=2.11.1=pyhd8ed1ab_0
7
- - langchain=0.0.333=pyhd8ed1ab_0
8
- - pip=23.3.1=pyhd8ed1ab_0
9
- - pip:
10
- - huggingface-hub==0.17.3
11
- - faiss-cpu==1.7.4
12
- - instructorembedding==1.0.1
13
- - python-dotenv==1.0.0
14
- - sentence-transformers==2.2.2
15
- - transformers==4.35.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
example_documents/daniel-resume.pdf ADDED
Binary file (106 kB). View file
 
example_documents/resume.pdf DELETED
Binary file (86.8 kB)
 
langchain_update.ipynb CHANGED
@@ -40,7 +40,7 @@
40
  },
41
  {
42
  "cell_type": "code",
43
- "execution_count": 3,
44
  "metadata": {},
45
  "outputs": [
46
  {
@@ -73,7 +73,7 @@
73
  },
74
  {
75
  "cell_type": "code",
76
- "execution_count": 4,
77
  "metadata": {},
78
  "outputs": [
79
  {
@@ -108,42 +108,40 @@
108
  },
109
  {
110
  "cell_type": "code",
111
- "execution_count": 5,
112
  "metadata": {},
113
  "outputs": [
114
  {
115
  "name": "stdout",
116
  "output_type": "stream",
117
  "text": [
118
- "Deep learning is a subset of machine learning that involves the use of artificial neural networks to analyze and interpret data. These artificial neural networks are composed of multiple layers of interconnected nodes or \"neurons,\" which process and transmit information.\n",
119
- "\n",
120
- "The term \"deep\" refers to the fact that these neural networks can have multiple layers, which allows them to learn complex patterns and relationships in data. In contrast, shallow neural networks typically have only two or three layers and are less effective at learning complex patterns.\n",
121
  "\n",
122
- "Deep learning is particularly well-suited to tasks that involve:\n",
123
  "\n",
124
- "1. Computer vision: Deep learning networks can be trained to identify objects in images, detect faces, and recognize handwriting, among other tasks.\n",
125
- "2. Natural language processing: Deep learning networks can be used to analyze and understand natural language, such as text, speech, and dialogue.\n",
126
- "3. Speech recognition: Deep learning networks can be trained to recognize spoken language and transcribe spoken words into text.\n",
127
  "\n",
128
- "The key benefits of deep learning include:\n",
 
 
 
 
129
  "\n",
130
- "1. Ability to learn complex patterns: Deep learning networks can learn complex patterns and relationships in data, allowing them to perform tasks that are difficult or impossible for shallow networks.\n",
131
- "2. Improved accuracy: Deep learning networks can achieve high accuracy in a wide range of tasks, often outperforming other machine learning algorithms.\n",
132
- "3. Flexibility: Deep learning networks can be trained to perform a wide range of tasks, including classification, regression, and clustering.\n",
133
  "\n",
134
- "Some of the techniques used in deep learning include:\n",
 
 
 
135
  "\n",
136
- "1. Convolutional neural networks (CNNs): These networks are particularly well-suited to computer vision tasks, such as object recognition and image classification.\n",
137
- "2. Recurrent neural networks (RNNs): These networks are particularly well-suited to natural language processing tasks, such as language modeling and speech recognition.\n",
138
- "3. Autoencoders: These networks are trained to reconstruct their inputs, and can be used for tasks such as dimensionality reduction and generative modeling.\n",
139
  "\n",
140
- "Challenges in deep learning include:\n",
 
 
 
141
  "\n",
142
- "1. Training deep networks: Training deep networks requires large amounts of data and significant computational resources.\n",
143
- "2. Overfitting: Deep networks can easily overfit the training data, leading to poor performance on unseen data.\n",
144
- "3. Interpretability: Deep networks can be difficult to interpret, making it challenging to understand why they are making certain predictions or decisions.\n",
145
- "\n",
146
- "Overall, deep learning is a powerful technique for analyzing and interpreting data, and has the potential to solve a wide range of complex problems.\n"
147
  ]
148
  }
149
  ],
@@ -159,7 +157,7 @@
159
  },
160
  {
161
  "cell_type": "code",
162
- "execution_count": 9,
163
  "metadata": {},
164
  "outputs": [],
165
  "source": [
@@ -184,51 +182,52 @@
184
  },
185
  {
186
  "cell_type": "code",
187
- "execution_count": 7,
188
  "metadata": {},
189
  "outputs": [
190
  {
191
  "name": "stdout",
192
  "output_type": "stream",
193
  "text": [
194
- "Hello Daniel! I'm happy to help you with your concern.\n",
195
  "\n",
196
- "Rosacea is a chronic skin condition characterized by frequent and persistent symptoms on the face, mainly on the cheeks, nose, forehead, and chin. The symptoms can vary from person to person, but common complaints include:\n",
197
  "\n",
198
- "1. Redness: Flushing, or sudden and intense redness, which can last for hours or days.\n",
199
- "2. Acne-like lesions: Pimples, papules, pustules, and cysts, which can be inflammatory or non-inflammatory.\n",
200
- "3. Bumpy skin: Coarse, thickened skin, often with large pores, which can occur on the nose, cheeks, and forehead.\n",
201
- "4. Visible blood vessels: Small, visible blood vessels under the skin, which can give the appearance of a flushed or irritated complexion.\n",
202
- "5. Eye symptoms: Dryness, itchiness, or gritty sensations in the eyes, which can be accompanied by redness and swelling.\n",
203
- "6. Sensitivity: Increased sensitivity to temperature, sunlight, wind, and other triggers.\n",
204
  "\n",
205
- "As a medical expert on rosacea, I can assure you that a combination of lifestyle changes, topical treatments, and oral medications can help manage symptoms. Here are some of the most effective prescription treatments for rosacea:\n",
206
  "\n",
207
- "Topical Treatments:\n",
 
 
 
208
  "\n",
209
- "1. Metronidazole (Metrogel, Noritate): An antibiotic cream or gel that reduces inflammation and kills bacteria that can contribute to rosacea.\n",
210
- "2. Azelaic acid (Azelex, Finacea): A cream or gel that reduces inflammation, prevents rosacea flare-ups, and treats acne-like lesions.\n",
211
- "3. Sulfur-based products: Over-the-counter or prescription creams and gels that help dry up pimples and reduce redness.\n",
212
- "4. Hyaluronic acid: A natural moisturizer that can help soothe and hydrate the skin.\n",
213
  "\n",
214
- "Oral Medications:\n",
 
 
 
215
  "\n",
216
- "1. Doxycycline (Vibramycin, Oracea): A tetracycline antibiotic that helps reduce inflammation and prevent further damage.\n",
217
- "2. Isotretinoin (Accutane): A powerful oral retinoid that treats severe rosacea, but it's often reserved for severe cases or when other treatments have failed.\n",
218
  "\n",
219
- "Also, it's essential to make some lifestyle changes to reduce rosacea symptoms:\n",
 
220
  "\n",
221
- "1. Avoid triggers: Identify and avoid triggers like spicy food, hot beverages, stress, and extreme temperatures.\n",
222
- "2. Use gentle skincare products: Choose fragrance-free, non-comedogenic products that won't irritate your skin.\n",
223
- "3. Maintain a consistent skincare routine: Cleanse your skin twice a day, exfoliate once or twice a week, and apply sunscreen with at least SPF 30 daily.\n",
224
- "4. Manage stress: Practice relaxation techniques like meditation, deep breathing, or yoga to reduce stress.\n",
225
- "5. Stay hydrated: Drink plenty of water to flush out toxins and keep your skin hydrated.\n",
226
  "\n",
227
- "As your medical expert, I recommend scheduling a consultation with a dermatologist to determine the best course of treatment for your individual case of rosacea. They will assess your skin, discuss your symptoms, and develop a personalized treatment plan to help you manage your symptoms and improve your skin health.\n",
 
 
 
 
228
  "\n",
229
- "Please keep in mind that it may take some trial and error to find the right combination of treatments that work for you. Be patient, and remember that it's crucial to work closely with a dermatologist to ensure you're getting the most effective treatment for your rosacea.\n",
230
  "\n",
231
- "If you have any further questions or concerns, feel free to ask, and I'll do my best to assist you.\n"
232
  ]
233
  }
234
  ],
@@ -244,7 +243,7 @@
244
  },
245
  {
246
  "cell_type": "code",
247
- "execution_count": 50,
248
  "metadata": {},
249
  "outputs": [
250
  {
@@ -265,7 +264,7 @@
265
  },
266
  {
267
  "cell_type": "code",
268
- "execution_count": 53,
269
  "metadata": {},
270
  "outputs": [
271
  {
@@ -274,37 +273,45 @@
274
  "text": [
275
  "System: You are an medical expert on Rosacea. Your job is to provide sound medical advice.\n",
276
  "Human: Hi, my name is Daniel. I think I have rosacea. Can you explain the symptoms and best prescriptions to reduce them please.\n",
277
- "AI: Nice to meet you, Daniel! I'd be happy to help you understand rosacea and explore treatment options.\n",
 
 
278
  "\n",
279
- "Rosacea is a chronic and inflammatory skin condition that affects approximately 16 million people in the United States. It typically appears on the central part of the face, including the nose, cheeks, forehead, and chin. The symptoms can vary, but common signs of rosacea include:\n",
 
 
 
280
  "\n",
281
- "1. Chronically red skin\n",
282
- "2. Flushing (unsolicited blushing)\n",
283
- "3. Acne-like papules, pustules, or comedones\n",
284
- "4. Enlarged blood vessels, often appearing as fine lines or spider veins\n",
285
- "5. Dryness and sensitivity\n",
286
- "6. Irritation and burning\n",
287
  "\n",
288
- "There is no cure for rosacea, but we can work together to manage and reduce your symptoms. Here are some prescription options that may help:\n",
 
 
 
289
  "\n",
290
- "1. Azelaic acid (Azelex, Finacea, or CeraVe): This mild to moderate topical cream or gel can reduce inflammation, redness, and acne-like lesions.\n",
291
- "2. Metronidazole (MetroCream, MetroGel, or Rosacream): A topical antibiotic cream or gel used to treat acne-like lesions and reduce inflammation.\n",
292
- "3. Sulconazole (Exelderm): A topical antifungal and antibacterial cream that helps to reduce inflammation and prevent secondary infections.\n",
293
- "4. Doxycycline (Vibramycin): An antibiotic oral medication that can help to reduce inflammation and treat acne-like lesions.\n",
294
- "5. Corticosteroids (Hydrocortisone): For severe cases of rosacea, corticosteroids may be prescribed to reduce inflammation.\n",
295
  "\n",
296
- "In addition to prescription medications, you can try lifestyle changes to manage your symptoms:\n",
 
 
 
297
  "\n",
298
- "1. Avoid triglycerides, creams, or makeup that contain chemical irritants or artificial fragrance.\n",
299
- "2. Use gentle, fragrance-free cleansers and moisturizers.\n",
300
- "3. Wear broad-spectrum sunscreen with at least SPF 30 daily.\n",
301
- "4. Limit sun exposure, especially during peak hours.\n",
302
- "5. Avoid spicy or acidic foods that can trigger flushing.\n",
303
- "6. Practice relaxation techniques, such as meditation, yoga, or deep breathing exercises, to manage stress.\n",
304
  "\n",
305
- "It's essential to consult with a board-certified dermatologist for a personalized diagnosis and treatment plan. We can discuss the best course of treatment for your specific case of rosacea.\n",
 
306
  "\n",
307
- "Would you like to schedule an appointment to further discuss your symptoms and treatment options?\n",
 
 
 
 
 
 
 
 
 
 
308
  "Human: What is my name?\n",
309
  "AI: Your name is Daniel.\n"
310
  ]
@@ -316,26 +323,31 @@
316
  },
317
  {
318
  "cell_type": "code",
319
- "execution_count": 54,
320
  "metadata": {},
321
  "outputs": [
322
  {
323
  "name": "stdout",
324
  "output_type": "stream",
325
  "text": [
326
- "Soolantra (ivermectin cream) is a prescription medication specifically approved for the treatment of inflammatory lesions of rosacea. It's a topical cream that helps to reduce the appearance of papules and pustules, and can also help to reduce inflammation and redness.\n",
 
 
 
 
327
  "\n",
328
- "Ivermectin, the active ingredient in Soolantra, works by inhibiting the production of inflammatory chemical mediators, which helps to reduce inflammation and improve the clinical appearance of rosacea symptoms.\n",
329
  "\n",
330
- "Soolantra is usually applied once daily, morning and evening, to the affected area, typically for 12-20 weeks. It's important to use the medication as directed by your dermatologist, and to complete the full treatment course to achieve optimal results.\n",
 
 
 
331
  "\n",
332
- "In clinical trials, Soolantra has been shown to:\n",
333
  "\n",
334
- "* Significantly reduce the number of inflammatory lesions of rosacea\n",
335
- "* Improve the clinical appearance of rosacea symptoms\n",
336
- "* Reduce erythema (redness) and inflammation\n",
337
  "\n",
338
- "It's great that you're already using Soolantra, Daniel! How have you been experiencing its effects so far? Have you noticed any improvements in your symptoms?\n"
339
  ]
340
  }
341
  ],
@@ -358,21 +370,9 @@
358
  },
359
  {
360
  "cell_type": "code",
361
- "execution_count": 19,
362
  "metadata": {},
363
- "outputs": [
364
- {
365
- "ename": "NameError",
366
- "evalue": "name 'SystemMessage' is not defined",
367
- "output_type": "error",
368
- "traceback": [
369
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
370
- "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
371
- "Cell \u001b[0;32mIn[19], line 7\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mlangchain_core\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mprompts\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m ChatPromptTemplate, MessagesPlaceholder\n\u001b[1;32m 4\u001b[0m \u001b[38;5;66;03m# create a prompt\u001b[39;00m\n\u001b[1;32m 5\u001b[0m prompt \u001b[38;5;241m=\u001b[39m ChatPromptTemplate(\n\u001b[1;32m 6\u001b[0m [\n\u001b[0;32m----> 7\u001b[0m \u001b[43mSystemMessage\u001b[49m(content\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mYou are an medical expert on Rosacea. Your job is to provide sound medical advice.\u001b[39m\u001b[38;5;124m\"\u001b[39m),\n\u001b[1;32m 8\u001b[0m MessagesPlaceholder(variable_name\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmessages\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;66;03m# this is where our messages input will go\u001b[39;00m\n\u001b[1;32m 9\u001b[0m ]\n\u001b[1;32m 10\u001b[0m )\n\u001b[1;32m 12\u001b[0m \u001b[38;5;28;01mdel\u001b[39;00m store[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124ms2\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;66;03m# reset conversation history\u001b[39;00m\n\u001b[1;32m 14\u001b[0m chain \u001b[38;5;241m=\u001b[39m prompt \u001b[38;5;241m|\u001b[39m chat_model\u001b[38;5;241m.\u001b[39mbind(max_tokens\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1000\u001b[39m, temperature\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1\u001b[39m) \u001b[38;5;66;03m# define a simple chain\u001b[39;00m\n",
372
- "\u001b[0;31mNameError\u001b[0m: name 'SystemMessage' is not defined"
373
- ]
374
- }
375
- ],
376
  "source": [
377
  "# using prompt templates\n",
378
  "from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder\n",
@@ -385,7 +385,7 @@
385
  " ]\n",
386
  ")\n",
387
  "\n",
388
- "del store[\"s2\"] # reset conversation history\n",
389
  "\n",
390
  "chain = prompt | chat_model.bind(max_tokens=1000, temperature=1) # define a simple chain\n",
391
  "\n",
@@ -396,32 +396,30 @@
396
  },
397
  {
398
  "cell_type": "code",
399
- "execution_count": 106,
400
  "metadata": {},
401
  "outputs": [
402
  {
403
  "name": "stdout",
404
  "output_type": "stream",
405
  "text": [
406
- "Hello Daniel! Thank you for reaching out. I'm happy to help you understand your symptoms and provide guidance on rosacea.\n",
407
- "\n",
408
- "Rosacea is a chronic skin condition that affects approximately 16 million people in the United States alone. It's often characterized by redness, flushing, acne-like lesions, and visible blood vessels on the face. Rosacea can appear at any age, but it commonly begins between the ages of 30 and 50.\n",
409
  "\n",
410
- "As you're experiencing symptoms at 26, it's possible that your rosacea may have developed gradually over time. There are several factors that may contribute to the onset of rosacea, including:\n",
411
  "\n",
412
- "1. Genetics: If you have a family history of rosacea, you may be more likely to develop it. Research suggests that genetics play a significant role in rosacea.\n",
413
- "2. Environmental triggers: Exposure to temperature changes, humidity, sun exposure, and certain irritants can trigger rosacea symptoms.\n",
414
- "3. Skin sensitivity: If you have sensitive skin, you may be more prone to rosacea.\n",
415
- "4. Hormonal changes: Hormonal fluctuations, such as those experienced during menstruation, pregnancy, or menopause, can trigger rosacea symptoms.\n",
416
- "5. Demodex mites: These tiny, harmless mites are naturally occurring on the skin, but they can contribute to rosacea symptoms in some people.\n",
417
- "6. Bacteria: Certain types of bacteria, such as Demodex brevis, are present on the skin and can contribute to rosacea symptoms.\n",
418
- "7. Gastrointestinal health: Research suggests that there may be a link between gut health and rosacea. Unbalanced gut bacteria, digestive issues, and the gut-skin axis may all play a role.\n",
419
  "\n",
420
- "It's essential to note that the exact cause of rosacea is still unclear, and it's likely that a combination of these factors contributes to its development.\n",
 
 
 
 
 
 
421
  "\n",
422
- "Symptoms of rosacea can vary from person to person, but common signs include:\n",
423
  "\n",
424
- "* Redness or flushing of the face.:// placement.:// sinking}\\\\\n"
425
  ]
426
  }
427
  ],
@@ -439,14 +437,14 @@
439
  },
440
  {
441
  "cell_type": "code",
442
- "execution_count": 107,
443
  "metadata": {},
444
  "outputs": [
445
  {
446
  "name": "stdout",
447
  "output_type": "stream",
448
  "text": [
449
- "Daniel! According to our conversation, you're 26 years old and currently live in Solihull.\n"
450
  ]
451
  }
452
  ],
@@ -458,7 +456,7 @@
458
  },
459
  {
460
  "cell_type": "code",
461
- "execution_count": 108,
462
  "metadata": {},
463
  "outputs": [
464
  {
@@ -466,27 +464,25 @@
466
  "output_type": "stream",
467
  "text": [
468
  "Human: Hi, my name is Daniel. I'm 26 years old and currently live in Solihull. I believe I have symptoms of rosacea, I've never had it before. How could it have come about?\n",
469
- "AI: Hello Daniel! Thank you for reaching out. I'm happy to help you understand your symptoms and provide guidance on rosacea.\n",
470
  "\n",
471
- "Rosacea is a chronic skin condition that affects approximately 16 million people in the United States alone. It's often characterized by redness, flushing, acne-like lesions, and visible blood vessels on the face. Rosacea can appear at any age, but it commonly begins between the ages of 30 and 50.\n",
472
  "\n",
473
- "As you're experiencing symptoms at 26, it's possible that your rosacea may have developed gradually over time. There are several factors that may contribute to the onset of rosacea, including:\n",
474
  "\n",
475
- "1. Genetics: If you have a family history of rosacea, you may be more likely to develop it. Research suggests that genetics play a significant role in rosacea.\n",
476
- "2. Environmental triggers: Exposure to temperature changes, humidity, sun exposure, and certain irritants can trigger rosacea symptoms.\n",
477
- "3. Skin sensitivity: If you have sensitive skin, you may be more prone to rosacea.\n",
478
- "4. Hormonal changes: Hormonal fluctuations, such as those experienced during menstruation, pregnancy, or menopause, can trigger rosacea symptoms.\n",
479
- "5. Demodex mites: These tiny, harmless mites are naturally occurring on the skin, but they can contribute to rosacea symptoms in some people.\n",
480
- "6. Bacteria: Certain types of bacteria, such as Demodex brevis, are present on the skin and can contribute to rosacea symptoms.\n",
481
- "7. Gastrointestinal health: Research suggests that there may be a link between gut health and rosacea. Unbalanced gut bacteria, digestive issues, and the gut-skin axis may all play a role.\n",
482
  "\n",
483
- "It's essential to note that the exact cause of rosacea is still unclear, and it's likely that a combination of these factors contributes to its development.\n",
484
  "\n",
485
- "Symptoms of rosacea can vary from person to person, but common signs include:\n",
486
- "\n",
487
- "* Redness or flushing of the face.:// placement.:// sinking}\\\\\n",
488
  "Human: How old am I and where do I currently live\n",
489
- "AI: Daniel! According to our conversation, you're 26 years old and currently live in Solihull.\n"
490
  ]
491
  }
492
  ],
@@ -503,7 +499,7 @@
503
  },
504
  {
505
  "cell_type": "code",
506
- "execution_count": 114,
507
  "metadata": {},
508
  "outputs": [],
509
  "source": [
@@ -515,7 +511,7 @@
515
  " ]\n",
516
  ")\n",
517
  "\n",
518
- "del store[\"s3\"] # delete conversation history if needed\n",
519
  "\n",
520
  "chain = language_prompt | chat_model.bind(max_tokens=1000, temperature=1)\n",
521
  "\n",
@@ -524,28 +520,26 @@
524
  },
525
  {
526
  "cell_type": "code",
527
- "execution_count": 115,
528
  "metadata": {},
529
  "outputs": [
530
  {
531
  "name": "stdout",
532
  "output_type": "stream",
533
  "text": [
534
- "Hola Daniel. Me alegra que hayas buscado ayuda médica. La rosacea es un trastorno común que afecta a personas de todas las edades, aunque es más común en mujeres y personas con antecedentes familiares. Aparentemente, no hay una causa única que lo produzca, pero existen varios factores que pueden desencadenarla.\n",
535
- "\n",
536
- "Algunos posibles desencadenantes son:\n",
537
  "\n",
538
- "* La exposición solar prolongada: la luz UV puede irritar la piel y hacer que los vasos sanguíneos se expandan, lo que puede llevar a la aparición detestingas.\n",
539
- "* Los alimentos picantes o alérgicos: algunos alimentos pueden causar reacciones alérgicas o inflamación en la piel.\n",
540
- "* El estrés: el estrés puede llevar a la liberación de hormonas que afectan la piel.\n",
541
- "* Genética: si tienes familiares con rosacea, es más probable que también la desarrollen.\n",
542
- "* Hormonal: los cambios hormonales pueden influir en la piel y aumentar la susceptibilidad a la rosacea.\n",
543
  "\n",
544
- "Es importante mencionar que no hay un método para \"contractar\" la rosacea. Sin embargo, si tienes un estilo de vida que incluye factores que pueden desencadenarla, como la exposición solar prolongada o la ingesta de alimentos picantes, es posible que eso contribuya a la aparición de los síntomas.\n",
 
 
 
 
545
  "\n",
546
- "La siguiente etapa sería realizar un examen médico para determinar si tienes rosacea y evaluar el gravedad de los síntomas. En función del diagnóstico, puedo recomendar tratamientos para ayudarte a controlar los síntomas y mejorar la apariencia de tu piel.\n",
547
  "\n",
548
- "¿Tienes algún outro síntoma adicional, como picor, escalografía o erupciones cutáneas? Algunos detalles cuales pueden ayudar a confirmar el diagnóstico.\n"
549
  ]
550
  }
551
  ],
@@ -563,14 +557,14 @@
563
  },
564
  {
565
  "cell_type": "code",
566
- "execution_count": 116,
567
  "metadata": {},
568
  "outputs": [
569
  {
570
  "name": "stdout",
571
  "output_type": "stream",
572
  "text": [
573
- "Hola Daniel! reside actualmente en Solihull, Reino Unido. Y, sí, tu nombre es Daniel, ¿ correcto?\n"
574
  ]
575
  }
576
  ],
@@ -584,7 +578,7 @@
584
  },
585
  {
586
  "cell_type": "code",
587
- "execution_count": 118,
588
  "metadata": {},
589
  "outputs": [
590
  {
@@ -592,23 +586,21 @@
592
  "output_type": "stream",
593
  "text": [
594
  "Human: Hi, my name is Daniel. I'm 26 years old and currently live in Solihull. I believe I have symptoms of rosacea, I've never had it before. How could it have come about?\n",
595
- "AI: Hola Daniel. Me alegra que hayas buscado ayuda médica. La rosacea es un trastorno común que afecta a personas de todas las edades, aunque es más común en mujeres y personas con antecedentes familiares. Aparentemente, no hay una causa única que lo produzca, pero existen varios factores que pueden desencadenarla.\n",
596
  "\n",
597
- "Algunos posibles desencadenantes son:\n",
598
  "\n",
599
- "* La exposición solar prolongada: la luz UV puede irritar la piel y hacer que los vasos sanguíneos se expandan, lo que puede llevar a la aparición detestingas.\n",
600
- "* Los alimentos picantes o alérgicos: algunos alimentos pueden causar reacciones alérgicas o inflamación en la piel.\n",
601
- "* El estrés: el estrés puede llevar a la liberación de hormonas que afectan la piel.\n",
602
- "* Genética: si tienes familiares con rosacea, es más probable que también la desarrollen.\n",
603
- "* Hormonal: los cambios hormonales pueden influir en la piel y aumentar la susceptibilidad a la rosacea.\n",
604
  "\n",
605
- "Es importante mencionar que no hay un método para \"contractar\" la rosacea. Sin embargo, si tienes un estilo de vida que incluye factores que pueden desencadenarla, como la exposición solar prolongada o la ingesta de alimentos picantes, es posible que eso contribuya a la aparición de los síntomas.\n",
606
  "\n",
607
- "La siguiente etapa sería realizar un examen médico para determinar si tienes rosacea y evaluar el gravedad de los síntomas. En función del diagnóstico, puedo recomendar tratamientos para ayudarte a controlar los síntomas y mejorar la apariencia de tu piel.\n",
608
- "\n",
609
- "¿Tienes algún outro síntoma adicional, como picor, escalografía o erupciones cutáneas? Algunos detalles cuales pueden ayudar a confirmar el diagnóstico.\n",
610
  "Human: Hola AI, puedes contarme donde vivo yo? ¿Y que es mi nombre?\n",
611
- "AI: Hola Daniel! reside actualmente en Solihull, Reino Unido. Y, sí, tu nombre es Daniel, ¿ correcto?\n"
612
  ]
613
  }
614
  ],
@@ -618,16 +610,16 @@
618
  },
619
  {
620
  "cell_type": "code",
621
- "execution_count": 123,
622
  "metadata": {},
623
  "outputs": [
624
  {
625
  "data": {
626
  "text/plain": [
627
- "[ChatPromptTemplate(input_variables=['language', 'messages'], input_types={'messages': typing.List[typing.Annotated[typing.Union[typing.Annotated[langchain_core.messages.ai.AIMessage, Tag(tag='ai')], typing.Annotated[langchain_core.messages.human.HumanMessage, Tag(tag='human')], typing.Annotated[langchain_core.messages.chat.ChatMessage, Tag(tag='chat')], typing.Annotated[langchain_core.messages.system.SystemMessage, Tag(tag='system')], typing.Annotated[langchain_core.messages.function.FunctionMessage, Tag(tag='function')], typing.Annotated[langchain_core.messages.tool.ToolMessage, Tag(tag='tool')], typing.Annotated[langchain_core.messages.ai.AIMessageChunk, Tag(tag='AIMessageChunk')], typing.Annotated[langchain_core.messages.human.HumanMessageChunk, Tag(tag='HumanMessageChunk')], typing.Annotated[langchain_core.messages.chat.ChatMessageChunk, Tag(tag='ChatMessageChunk')], typing.Annotated[langchain_core.messages.system.SystemMessageChunk, Tag(tag='SystemMessageChunk')], typing.Annotated[langchain_core.messages.function.FunctionMessageChunk, Tag(tag='FunctionMessageChunk')], typing.Annotated[langchain_core.messages.tool.ToolMessageChunk, Tag(tag='ToolMessageChunk')]], FieldInfo(annotation=NoneType, required=True, discriminator=Discriminator(discriminator=<function _get_type at 0x116751b20>, custom_error_type=None, custom_error_message=None, custom_error_context=None))]]}, partial_variables={}, messages=[SystemMessagePromptTemplate(prompt=PromptTemplate(input_variables=['language'], input_types={}, partial_variables={}, template='You are an medical expert on Rosacea. Your job is to provide sound medical advice. Respond in {language}'), additional_kwargs={}), MessagesPlaceholder(variable_name='messages')])]"
628
  ]
629
  },
630
- "execution_count": 123,
631
  "metadata": {},
632
  "output_type": "execute_result"
633
  }
@@ -663,7 +655,7 @@
663
  },
664
  {
665
  "cell_type": "code",
666
- "execution_count": 10,
667
  "metadata": {},
668
  "outputs": [
669
  {
@@ -714,7 +706,7 @@
714
  },
715
  {
716
  "cell_type": "code",
717
- "execution_count": 32,
718
  "metadata": {},
719
  "outputs": [],
720
  "source": [
@@ -729,7 +721,7 @@
729
  },
730
  {
731
  "cell_type": "code",
732
- "execution_count": 33,
733
  "metadata": {},
734
  "outputs": [
735
  {
@@ -748,7 +740,7 @@
748
  },
749
  {
750
  "cell_type": "code",
751
- "execution_count": 34,
752
  "metadata": {},
753
  "outputs": [
754
  {
@@ -757,7 +749,7 @@
757
  "{'source': 'example_documents/resume.pdf', 'page': 0, 'start_index': 813}"
758
  ]
759
  },
760
- "execution_count": 34,
761
  "metadata": {},
762
  "output_type": "execute_result"
763
  }
@@ -777,7 +769,7 @@
777
  },
778
  {
779
  "cell_type": "code",
780
- "execution_count": 35,
781
  "metadata": {},
782
  "outputs": [],
783
  "source": [
@@ -807,7 +799,7 @@
807
  },
808
  {
809
  "cell_type": "code",
810
- "execution_count": 36,
811
  "metadata": {},
812
  "outputs": [
813
  {
@@ -877,7 +869,7 @@
877
  },
878
  {
879
  "cell_type": "code",
880
- "execution_count": 62,
881
  "metadata": {},
882
  "outputs": [
883
  {
@@ -890,35 +882,19 @@
890
  "Login successful\n",
891
  " \n",
892
  "\n",
893
- "Please provide an answer based on the provided CV. \n",
894
- "\n",
895
- "Note: As a helpful AI assistant, I may provide additional advice on how to improve the CV in any way I see fit. \n",
896
- "\n",
897
  "Answer: \n",
898
  "\n",
899
- "Daniel's strengths in this CV can be identified as follows:\n",
900
- "\n",
901
- "1. **Data Science Expertise**: Daniel has a strong background in data science, with experience as a Senior Data Scientist at the UK Home Office. He has demonstrated expertise in machine learning, deep learning, and data processing, with a notable achievement of developing a reproducible analytical pipeline and earning a Performance Excellence Award.\n",
902
- "\n",
903
- "2. **Technical Skills**: Daniel has a range of technical skills, including proficiency in Python, TensorFlow, Pytorch, PowerBI, SQL, Jupyter, PyCharm, Git, and Command Line Interface. He is also familiar with AWS and has experience with large language models.\n",
904
- "\n",
905
- "3. **Leadership and Team Management**: Daniel has experience leading teams, including overseeing learning and development initiatives within the data science team. He has also led a 3-hour in-person workshop for a team of 30 and has managed a Kanban board.\n",
906
  "\n",
907
- "4. **Communication Skills**: Daniel has demonstrated effective communication skills, particularly in presenting complex concepts to non-technical stakeholders. He has also showcased his ability to adapt to different learning preferences and teach students with learning disabilities.\n",
 
 
 
 
 
 
908
  "\n",
909
- "5. **Education and Research Background**: Daniel has a strong educational background, with a Master's degree in Electrical Automotive Engineering and a Bachelor's degree in Mathematics with Finance and Economics. His thesis, which focused on classifying symbolic road markings using deep Convolutional Neural Networks, was published in the European Union Digital Library.\n",
910
- "\n",
911
- "6. **Extra-Curricular Activities**: Daniel has been involved in various extracurricular activities, including being a committee member at West Warwickshire Sports Club, a Senior Course Representative at Coventry University's Student Union, and a member of Friends of Bolivia.\n",
912
- "\n",
913
- "Advice for improvement:\n",
914
- "\n",
915
- "1. **More specific job responsibilities**: While Daniel has provided a good overview of his work experience, more specific job responsibilities and achievements would be helpful in making his experience more tangible.\n",
916
- "\n",
917
- "2. **Quantifying achievements**: Where possible, Daniel could provide more concrete numbers and statistics to quantify his achievements, such as the exact percentage of performance improvement or the number of students he has tutored.\n",
918
- "\n",
919
- "3. **More emphasis on transferable skills**: While Daniel's technical skills are impressive, it would be beneficial to highlight the transferable skills he has developed, such as communication, leadership, and problem-solving.\n",
920
- "\n",
921
- "4. **Additional sections or bullet points**: Consider adding additional sections or bullet points to highlight Daniel's achievements, such as a section on publications or a list of relevant projects he has worked on. This would help to provide a more comprehensive view of his skills and experience.\n"
922
  ]
923
  }
924
  ],
@@ -957,18 +933,11 @@
957
  "\n",
958
  "print(rag_chain.invoke(\"What are Daniel's strengths in this CV?\"))\n"
959
  ]
960
- },
961
- {
962
- "cell_type": "code",
963
- "execution_count": null,
964
- "metadata": {},
965
- "outputs": [],
966
- "source": []
967
  }
968
  ],
969
  "metadata": {
970
  "kernelspec": {
971
- "display_name": "llm_updated",
972
  "language": "python",
973
  "name": "python3"
974
  },
 
40
  },
41
  {
42
  "cell_type": "code",
43
+ "execution_count": 2,
44
  "metadata": {},
45
  "outputs": [
46
  {
 
73
  },
74
  {
75
  "cell_type": "code",
76
+ "execution_count": 3,
77
  "metadata": {},
78
  "outputs": [
79
  {
 
108
  },
109
  {
110
  "cell_type": "code",
111
+ "execution_count": 4,
112
  "metadata": {},
113
  "outputs": [
114
  {
115
  "name": "stdout",
116
  "output_type": "stream",
117
  "text": [
118
+ "Deep learning is a subfield of machine learning that involves the use of artificial neural networks with multiple layers to analyze and interpret data. The term \"deep\" refers to the large number of layers in these networks, as opposed to traditional machine learning models which typically have only one layer.\n",
 
 
119
  "\n",
120
+ "In a deep neural network, each layer processes the output from the previous layer and uses it to calculate the output for the next layer. This processing is typically done using a series of neural connections, called \"neurons,\" which are inspired by the way neurons in the human brain work.\n",
121
  "\n",
122
+ "Deep learning models are particularly effective in handling complex data sets that have multiple features and are high-dimensional, such as images, speech audio, and text. They are able to learn and represent complex patterns in this data, and can be used for a wide range of applications, including:\n",
 
 
123
  "\n",
124
+ "1. Image recognition: Deep learning models can be used to identify objects in images, such as faces, animals, and vehicles.\n",
125
+ "2. Speech recognition: Deep learning models can be used to recognize spoken language and transcribe it into text.\n",
126
+ "3. Natural language processing: Deep learning models can be used to analyze and understand natural language, and can be used for tasks such as language translation, sentiment analysis, and text summarization.\n",
127
+ "4. Robotics: Deep learning models can be used to control robots and enable them to learn and adapt to new tasks.\n",
128
+ "5. Game playing: Deep learning models can be used to play complex games, such as Go, poker, and chess.\n",
129
  "\n",
130
+ "Some of the key benefits of deep learning include:\n",
 
 
131
  "\n",
132
+ "1. Ability to learn complex patterns: Deep learning models are able to learn complex patterns in data, and can be used for a wide range of applications.\n",
133
+ "2. Ability to process high-dimensional data: Deep learning models can process high-dimensional data, such as images and audio, and can be used for tasks such as image recognition and speech recognition.\n",
134
+ "3. Ability to learn from large amounts of data: Deep learning models can learn from large amounts of data, and can be used for tasks such as language translation and text summarization.\n",
135
+ "4. Ability to adapt to new tasks: Deep learning models can be used for a wide range of tasks, and can adapt to new tasks and domains by learning from new data.\n",
136
  "\n",
137
+ "However, deep learning also has some challenges and limitations, including:\n",
 
 
138
  "\n",
139
+ "1. Difficulty in interpreting the results: Deep learning models can be difficult to interpret, and it can be challenging to understand why they make certain decisions.\n",
140
+ "2. Need for large amounts of data: Deep learning models require large amounts of data to learn and train, and may not perform well on small data sets.\n",
141
+ "3. Computational requirements: Deep learning models can require significant computational resources, and may not be feasible to run on limited hardware.\n",
142
+ "4. Risk of overfitting: Deep learning models can be prone to overfitting, which occurs when a model becomes too specialized to the training data and does not generalize well to new data.\n",
143
  "\n",
144
+ "Overall, deep learning is a powerful tool that can be used for a wide range of applications, but it also requires significant expertise and resources to train and deploy effectively.\n"
 
 
 
 
145
  ]
146
  }
147
  ],
 
157
  },
158
  {
159
  "cell_type": "code",
160
+ "execution_count": 5,
161
  "metadata": {},
162
  "outputs": [],
163
  "source": [
 
182
  },
183
  {
184
  "cell_type": "code",
185
+ "execution_count": 6,
186
  "metadata": {},
187
  "outputs": [
188
  {
189
  "name": "stdout",
190
  "output_type": "stream",
191
  "text": [
192
+ "Hello Daniel! As a medical expert on Rosacea, I'd be happy to help you understand your symptoms and offer guidance on treatment options.\n",
193
  "\n",
194
+ "Rosacea is a chronic skin condition characterized by frequent flushing, redness, and inflammatory lesions on the face. The exact cause is still unknown, but it's believed to be linked to factors such as:\n",
195
  "\n",
196
+ "1. Overactive immune response\n",
197
+ "2. Genetic predisposition\n",
198
+ "3. Environmental triggers (sun, wind, heat, humidity, stress)\n",
199
+ "4. Demodex mites (tiny insects that live in follicles)\n",
 
 
200
  "\n",
201
+ "Common symptoms of rosacea include:\n",
202
  "\n",
203
+ "1. Redness and flushing: Hot, itchy, or burning sensations on the face, often accompanied by a noticeable pink or red glow.\n",
204
+ "2. Acne-like lesions: Small, pus-filled bumps, papules, or pustules, particularly on the nose, cheeks, forehead, and chin.\n",
205
+ "3. Telangiectasias: Visible blood vessels or fine lines on the skin.\n",
206
+ "4. Eye problems: Burning, itching, or dryness of the eyes, eyelids, or surrounding skin.\n",
207
  "\n",
208
+ "For mild to moderate rosacea, topical creams and gels are often the first line of treatment. These may contain:\n",
 
 
 
209
  "\n",
210
+ "1. Antibiotics (azelaic acid, metronidazole, doxycycline) to reduce inflammation and bacteria.\n",
211
+ "2. Brimonidine, a medication that helps reduce redness and inflammation.\n",
212
+ "3. Sulfacetamide or sulfur to help reduce acne-like lesions.\n",
213
+ "4. Salicylic acid or glycolic acid to exfoliate and improve skin texture.\n",
214
  "\n",
215
+ "In more severe cases, oral medications may be prescribed, such as:\n",
 
216
  "\n",
217
+ "1. Oral antibiotics (doxycycline, erythromycin, minocycline) to target bacteria and reduce inflammation.\n",
218
+ "2. Isotretinoin, a potent derivative of vitamin A, to treat moderate to severe rosacea.\n",
219
  "\n",
220
+ "In addition to medications, other strategies can help manage rosacea:\n",
 
 
 
 
221
  "\n",
222
+ "1. Warm compresses: Apply a warm, damp cloth to the affected area to reduce swelling and ease discomfort.\n",
223
+ "2. Avoid triggers: Identify and avoid triggers like the sun, extreme temperatures, and irritants.\n",
224
+ "3. Gently clean the skin: Use a gentle, fragrance-free cleanser and pat dry with a clean towel.\n",
225
+ "4. Moisturize: Use a non-comedogenic moisturizer to keep the skin hydrated and protected.\n",
226
+ "5. Makeup and scars: Camouflage redness and scars with green-tinted foundation or concealer.\n",
227
  "\n",
228
+ "It's essential to consult a dermatologist or healthcare provider for a proper diagnosis and personalized treatment plan. Based on your specific symptoms and severity of rosacea, your doctor may recommend a combination of medications, lifestyle changes, and other interventions.\n",
229
  "\n",
230
+ "Please consult with your healthcare provider or a dermatologist to discuss your symptoms and treatment options.\n"
231
  ]
232
  }
233
  ],
 
243
  },
244
  {
245
  "cell_type": "code",
246
+ "execution_count": 7,
247
  "metadata": {},
248
  "outputs": [
249
  {
 
264
  },
265
  {
266
  "cell_type": "code",
267
+ "execution_count": 8,
268
  "metadata": {},
269
  "outputs": [
270
  {
 
273
  "text": [
274
  "System: You are an medical expert on Rosacea. Your job is to provide sound medical advice.\n",
275
  "Human: Hi, my name is Daniel. I think I have rosacea. Can you explain the symptoms and best prescriptions to reduce them please.\n",
276
+ "AI: Hello Daniel! As a medical expert on Rosacea, I'd be happy to help you understand your symptoms and offer guidance on treatment options.\n",
277
+ "\n",
278
+ "Rosacea is a chronic skin condition characterized by frequent flushing, redness, and inflammatory lesions on the face. The exact cause is still unknown, but it's believed to be linked to factors such as:\n",
279
  "\n",
280
+ "1. Overactive immune response\n",
281
+ "2. Genetic predisposition\n",
282
+ "3. Environmental triggers (sun, wind, heat, humidity, stress)\n",
283
+ "4. Demodex mites (tiny insects that live in follicles)\n",
284
  "\n",
285
+ "Common symptoms of rosacea include:\n",
 
 
 
 
 
286
  "\n",
287
+ "1. Redness and flushing: Hot, itchy, or burning sensations on the face, often accompanied by a noticeable pink or red glow.\n",
288
+ "2. Acne-like lesions: Small, pus-filled bumps, papules, or pustules, particularly on the nose, cheeks, forehead, and chin.\n",
289
+ "3. Telangiectasias: Visible blood vessels or fine lines on the skin.\n",
290
+ "4. Eye problems: Burning, itching, or dryness of the eyes, eyelids, or surrounding skin.\n",
291
  "\n",
292
+ "For mild to moderate rosacea, topical creams and gels are often the first line of treatment. These may contain:\n",
 
 
 
 
293
  "\n",
294
+ "1. Antibiotics (azelaic acid, metronidazole, doxycycline) to reduce inflammation and bacteria.\n",
295
+ "2. Brimonidine, a medication that helps reduce redness and inflammation.\n",
296
+ "3. Sulfacetamide or sulfur to help reduce acne-like lesions.\n",
297
+ "4. Salicylic acid or glycolic acid to exfoliate and improve skin texture.\n",
298
  "\n",
299
+ "In more severe cases, oral medications may be prescribed, such as:\n",
 
 
 
 
 
300
  "\n",
301
+ "1. Oral antibiotics (doxycycline, erythromycin, minocycline) to target bacteria and reduce inflammation.\n",
302
+ "2. Isotretinoin, a potent derivative of vitamin A, to treat moderate to severe rosacea.\n",
303
  "\n",
304
+ "In addition to medications, other strategies can help manage rosacea:\n",
305
+ "\n",
306
+ "1. Warm compresses: Apply a warm, damp cloth to the affected area to reduce swelling and ease discomfort.\n",
307
+ "2. Avoid triggers: Identify and avoid triggers like the sun, extreme temperatures, and irritants.\n",
308
+ "3. Gently clean the skin: Use a gentle, fragrance-free cleanser and pat dry with a clean towel.\n",
309
+ "4. Moisturize: Use a non-comedogenic moisturizer to keep the skin hydrated and protected.\n",
310
+ "5. Makeup and scars: Camouflage redness and scars with green-tinted foundation or concealer.\n",
311
+ "\n",
312
+ "It's essential to consult a dermatologist or healthcare provider for a proper diagnosis and personalized treatment plan. Based on your specific symptoms and severity of rosacea, your doctor may recommend a combination of medications, lifestyle changes, and other interventions.\n",
313
+ "\n",
314
+ "Please consult with your healthcare provider or a dermatologist to discuss your symptoms and treatment options.\n",
315
  "Human: What is my name?\n",
316
  "AI: Your name is Daniel.\n"
317
  ]
 
323
  },
324
  {
325
  "cell_type": "code",
326
+ "execution_count": 9,
327
  "metadata": {},
328
  "outputs": [
329
  {
330
  "name": "stdout",
331
  "output_type": "stream",
332
  "text": [
333
+ "Soolantra is a great choice! Soolantra (;;\n",
334
+ "\n",
335
+ ") is the brand name for metronidazole 1% gel, a topical antibiotic cream that's commonly used to treat rosacea.\n",
336
+ "\n",
337
+ "Metronidazole targets the bacteria that can contribute to rosacea, such as Demodex mites, and helps reduce inflammation, redness, and acne-like lesions. It's often used to treat papules, pustules, and acne-like lesions on the face.\n",
338
  "\n",
339
+ "Soolantra can help in various ways:\n",
340
  "\n",
341
+ "1. Reduces inflammation: Metronidazole decreases inflammation by killing bacteria and reducing the immune response.\n",
342
+ "2. Improves skin clarity: By tackling bacteria and reducing inflammation, Soolantra can help improve the appearance of your skin, making it look clearer and smoother.\n",
343
+ "3. Reduces acne-like lesions: Soolantra can help reduce the number and severity of acne-like lesions, including papules and pustules.\n",
344
+ "4. Relieves itching and burning: Some people with rosacea experience itching or burning sensations on their skin, which may be alleviated with Soolantra.\n",
345
  "\n",
346
+ "It's essential to note that Soolantra is typically used for 4-6 weeks at a time, and your dermatologist or healthcare provider may recommend applying it twice daily. You may also need to use it for a longer period or in combination with other treatments to achieve optimal results.\n",
347
  "\n",
348
+ "If you're using Soolantra and you're not seeing the desired effects, your healthcare provider may adjust your treatment plan or combine it with other medications. Be sure to follow their guidance and follow up with regular check-ins to monitor your progress.\n",
 
 
349
  "\n",
350
+ "Keep in mind that Soolantra is not a cure for rosacea, but it can help manage symptoms and reduce the appearance of affected areas.\n"
351
  ]
352
  }
353
  ],
 
370
  },
371
  {
372
  "cell_type": "code",
373
+ "execution_count": 11,
374
  "metadata": {},
375
+ "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
 
376
  "source": [
377
  "# using prompt templates\n",
378
  "from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder\n",
 
385
  " ]\n",
386
  ")\n",
387
  "\n",
388
+ "# del store[\"s2\"] # reset conversation history\n",
389
  "\n",
390
  "chain = prompt | chat_model.bind(max_tokens=1000, temperature=1) # define a simple chain\n",
391
  "\n",
 
396
  },
397
  {
398
  "cell_type": "code",
399
+ "execution_count": 12,
400
  "metadata": {},
401
  "outputs": [
402
  {
403
  "name": "stdout",
404
  "output_type": "stream",
405
  "text": [
406
+ "Hello Daniel! Thank you for reaching out. It's great that you're taking the first step in understanding and addressing your concerns. As an expert in rosacea, I'd be happy to help you explore the possibilities.\n",
 
 
407
  "\n",
408
+ "Rosacea can occur at any age, but it typically starts between the ages of 30 and 50. However, it's not uncommon for younger individuals, like yourself, to experience symptoms early on.\n",
409
  "\n",
410
+ "There are several theories about how rosacea develops, but it's believed that a combination of factors contributes to its onset. Some of these factors include:\n",
 
 
 
 
 
 
411
  "\n",
412
+ "1. Genetic predisposition: If your parents or family members have rosacea, you may be more likely to develop it.\n",
413
+ "2. Vascular issues: Rosacea is often associated with abnormal blood vessel growth, which can lead to flushing and redness.\n",
414
+ "3. Demodex mites: These tiny mites live on the skin and can cause inflammation and irritation, which may contribute to rosacea.\n",
415
+ "4. Bacteria: Some research suggests that certain bacteria, such as Helicobacter pylori, may play a role in the development of rosacea.\n",
416
+ "5. Environmental factors: Exposure to sunlight, heat, and stress can trigger rosacea symptoms.\n",
417
+ "6. Hormonal changes: Hormonal fluctuations, such as those experienced during menopause or puberty, can also contribute to rosacea.\n",
418
+ "7. Skin products: Using heavy or harsh skin products, especially those containing fragrances, dyes, or alpha-hydroxy acids, can exacerbate rosacea.\n",
419
  "\n",
420
+ "Given your age, it's possible that hormonal changes or environmental factors may have contributed to the onset of your symptoms. It's also important to consider that rosacea can be triggered or exacerbated by various stimuli, so it's essential to identify and avoid potential triggers.\n",
421
  "\n",
422
+ "Can you tell me more about your symptoms? What kind of redness, flushing, or acne-like lesions have you been experiencing? Have you noticed any patterns or triggers that make your symptoms worse?\n"
423
  ]
424
  }
425
  ],
 
437
  },
438
  {
439
  "cell_type": "code",
440
+ "execution_count": 13,
441
  "metadata": {},
442
  "outputs": [
443
  {
444
  "name": "stdout",
445
  "output_type": "stream",
446
  "text": [
447
+ "You're 26 years old, Daniel, and you currently live in Solihull!\n"
448
  ]
449
  }
450
  ],
 
456
  },
457
  {
458
  "cell_type": "code",
459
+ "execution_count": 14,
460
  "metadata": {},
461
  "outputs": [
462
  {
 
464
  "output_type": "stream",
465
  "text": [
466
  "Human: Hi, my name is Daniel. I'm 26 years old and currently live in Solihull. I believe I have symptoms of rosacea, I've never had it before. How could it have come about?\n",
467
+ "AI: Hello Daniel! Thank you for reaching out. It's great that you're taking the first step in understanding and addressing your concerns. As an expert in rosacea, I'd be happy to help you explore the possibilities.\n",
468
  "\n",
469
+ "Rosacea can occur at any age, but it typically starts between the ages of 30 and 50. However, it's not uncommon for younger individuals, like yourself, to experience symptoms early on.\n",
470
  "\n",
471
+ "There are several theories about how rosacea develops, but it's believed that a combination of factors contributes to its onset. Some of these factors include:\n",
472
  "\n",
473
+ "1. Genetic predisposition: If your parents or family members have rosacea, you may be more likely to develop it.\n",
474
+ "2. Vascular issues: Rosacea is often associated with abnormal blood vessel growth, which can lead to flushing and redness.\n",
475
+ "3. Demodex mites: These tiny mites live on the skin and can cause inflammation and irritation, which may contribute to rosacea.\n",
476
+ "4. Bacteria: Some research suggests that certain bacteria, such as Helicobacter pylori, may play a role in the development of rosacea.\n",
477
+ "5. Environmental factors: Exposure to sunlight, heat, and stress can trigger rosacea symptoms.\n",
478
+ "6. Hormonal changes: Hormonal fluctuations, such as those experienced during menopause or puberty, can also contribute to rosacea.\n",
479
+ "7. Skin products: Using heavy or harsh skin products, especially those containing fragrances, dyes, or alpha-hydroxy acids, can exacerbate rosacea.\n",
480
  "\n",
481
+ "Given your age, it's possible that hormonal changes or environmental factors may have contributed to the onset of your symptoms. It's also important to consider that rosacea can be triggered or exacerbated by various stimuli, so it's essential to identify and avoid potential triggers.\n",
482
  "\n",
483
+ "Can you tell me more about your symptoms? What kind of redness, flushing, or acne-like lesions have you been experiencing? Have you noticed any patterns or triggers that make your symptoms worse?\n",
 
 
484
  "Human: How old am I and where do I currently live\n",
485
+ "AI: You're 26 years old, Daniel, and you currently live in Solihull!\n"
486
  ]
487
  }
488
  ],
 
499
  },
500
  {
501
  "cell_type": "code",
502
+ "execution_count": 16,
503
  "metadata": {},
504
  "outputs": [],
505
  "source": [
 
511
  " ]\n",
512
  ")\n",
513
  "\n",
514
+ "# del store[\"s3\"] # delete conversation history if needed\n",
515
  "\n",
516
  "chain = language_prompt | chat_model.bind(max_tokens=1000, temperature=1)\n",
517
  "\n",
 
520
  },
521
  {
522
  "cell_type": "code",
523
+ "execution_count": 17,
524
  "metadata": {},
525
  "outputs": [
526
  {
527
  "name": "stdout",
528
  "output_type": "stream",
529
  "text": [
530
+ "Hola Daniel, gracias por consultarme sobre tus síntomas. Es importante mencionar que el roaselga no es una condición contagiosa, por lo que no se transmite de persona a persona a través del contacto.\n",
 
 
531
  "\n",
532
+ "La causa exacta del roaselga no está completamente clara, pero se cree que se debe a una combinación de factores, incluyendo:\n",
 
 
 
 
533
  "\n",
534
+ "* La herencia: Si hay antecedentes de roaselga en tu familia, tienes un mayor riesgo de desarrollarla.\n",
535
+ "* El estrés: El estrés crónico puede aumentar la sensibilidad de la piel y contribuir al desarrollo de roaselga.\n",
536
+ "* La exposición al sol: La radiación ultravioleta (UV) del sol puede irritar la piel y desencadenar síntomas de roaselga.\n",
537
+ "* La humble de la piel: La carencia de sebohidroóxidos en la piel puede llevar a la inflamación y el enrojecimiento, características comunes del roaselga.\n",
538
+ "* El consumo de ciertos alimentos: Algunos alimentos y bebidas pueden desencadenar o exacerbaron tu roaselga. Ejemplos comunes incluyen el vino, el queso, los frutos secos y los alimentos enlatados que contienen conservantes.\n",
539
  "\n",
540
+ "Debido a que eres joven, es posible que estés experimentando con el roaselga debido a una combinación de estos factores. Es importante que consultes con un dermatólogo para obtener un diagnóstico preciso y recibir orientación personalizada sobre cómo manejar tus síntomas.\n",
541
  "\n",
542
+ "En el camino hacia un diagnóstico, puedo pedirte que me des más información sobre tus síntomas. ¿Cuál es el aspecto principal que te preocupa? ¿Te sientes que tu piel está enrojecida, inflamada, ha aumentado la sensibilidad u otros síntomas?\n"
543
  ]
544
  }
545
  ],
 
557
  },
558
  {
559
  "cell_type": "code",
560
+ "execution_count": 18,
561
  "metadata": {},
562
  "outputs": [
563
  {
564
  "name": "stdout",
565
  "output_type": "stream",
566
  "text": [
567
+ "Hola Daniel! Vivo en Solihull, Reino Unido, y tu nombre es Daniel. ¡Recuerdo perfectamente que nos hablamos anteriormente sobre tu posible diagnóstico de roaselga!\n"
568
  ]
569
  }
570
  ],
 
578
  },
579
  {
580
  "cell_type": "code",
581
+ "execution_count": 19,
582
  "metadata": {},
583
  "outputs": [
584
  {
 
586
  "output_type": "stream",
587
  "text": [
588
  "Human: Hi, my name is Daniel. I'm 26 years old and currently live in Solihull. I believe I have symptoms of rosacea, I've never had it before. How could it have come about?\n",
589
+ "AI: Hola Daniel, gracias por consultarme sobre tus síntomas. Es importante mencionar que el roaselga no es una condición contagiosa, por lo que no se transmite de persona a persona a través del contacto.\n",
590
  "\n",
591
+ "La causa exacta del roaselga no está completamente clara, pero se cree que se debe a una combinación de factores, incluyendo:\n",
592
  "\n",
593
+ "* La herencia: Si hay antecedentes de roaselga en tu familia, tienes un mayor riesgo de desarrollarla.\n",
594
+ "* El estrés: El estrés crónico puede aumentar la sensibilidad de la piel y contribuir al desarrollo de roaselga.\n",
595
+ "* La exposición al sol: La radiación ultravioleta (UV) del sol puede irritar la piel y desencadenar síntomas de roaselga.\n",
596
+ "* La humble de la piel: La carencia de sebohidroóxidos en la piel puede llevar a la inflamación y el enrojecimiento, características comunes del roaselga.\n",
597
+ "* El consumo de ciertos alimentos: Algunos alimentos y bebidas pueden desencadenar o exacerbaron tu roaselga. Ejemplos comunes incluyen el vino, el queso, los frutos secos y los alimentos enlatados que contienen conservantes.\n",
598
  "\n",
599
+ "Debido a que eres joven, es posible que estés experimentando con el roaselga debido a una combinación de estos factores. Es importante que consultes con un dermatólogo para obtener un diagnóstico preciso y recibir orientación personalizada sobre cómo manejar tus síntomas.\n",
600
  "\n",
601
+ "En el camino hacia un diagnóstico, puedo pedirte que me des más información sobre tus síntomas. ¿Cuál es el aspecto principal que te preocupa? ¿Te sientes que tu piel está enrojecida, inflamada, ha aumentado la sensibilidad u otros síntomas?\n",
 
 
602
  "Human: Hola AI, puedes contarme donde vivo yo? ¿Y que es mi nombre?\n",
603
+ "AI: Hola Daniel! Vivo en Solihull, Reino Unido, y tu nombre es Daniel. ¡Recuerdo perfectamente que nos hablamos anteriormente sobre tu posible diagnóstico de roaselga!\n"
604
  ]
605
  }
606
  ],
 
610
  },
611
  {
612
  "cell_type": "code",
613
+ "execution_count": 20,
614
  "metadata": {},
615
  "outputs": [
616
  {
617
  "data": {
618
  "text/plain": [
619
+ "[ChatPromptTemplate(input_variables=['language', 'messages'], input_types={'messages': list[typing.Annotated[typing.Union[typing.Annotated[langchain_core.messages.ai.AIMessage, Tag(tag='ai')], typing.Annotated[langchain_core.messages.human.HumanMessage, Tag(tag='human')], typing.Annotated[langchain_core.messages.chat.ChatMessage, Tag(tag='chat')], typing.Annotated[langchain_core.messages.system.SystemMessage, Tag(tag='system')], typing.Annotated[langchain_core.messages.function.FunctionMessage, Tag(tag='function')], typing.Annotated[langchain_core.messages.tool.ToolMessage, Tag(tag='tool')], typing.Annotated[langchain_core.messages.ai.AIMessageChunk, Tag(tag='AIMessageChunk')], typing.Annotated[langchain_core.messages.human.HumanMessageChunk, Tag(tag='HumanMessageChunk')], typing.Annotated[langchain_core.messages.chat.ChatMessageChunk, Tag(tag='ChatMessageChunk')], typing.Annotated[langchain_core.messages.system.SystemMessageChunk, Tag(tag='SystemMessageChunk')], typing.Annotated[langchain_core.messages.function.FunctionMessageChunk, Tag(tag='FunctionMessageChunk')], typing.Annotated[langchain_core.messages.tool.ToolMessageChunk, Tag(tag='ToolMessageChunk')]], FieldInfo(annotation=NoneType, required=True, discriminator=Discriminator(discriminator=<function _get_type at 0x10e637060>, custom_error_type=None, custom_error_message=None, custom_error_context=None))]]}, partial_variables={}, messages=[SystemMessagePromptTemplate(prompt=PromptTemplate(input_variables=['language'], input_types={}, partial_variables={}, template='You are an medical expert on Rosacea. Your job is to provide sound medical advice. Respond in {language}'), additional_kwargs={}), MessagesPlaceholder(variable_name='messages')])]"
620
  ]
621
  },
622
+ "execution_count": 20,
623
  "metadata": {},
624
  "output_type": "execute_result"
625
  }
 
655
  },
656
  {
657
  "cell_type": "code",
658
+ "execution_count": 21,
659
  "metadata": {},
660
  "outputs": [
661
  {
 
706
  },
707
  {
708
  "cell_type": "code",
709
+ "execution_count": 22,
710
  "metadata": {},
711
  "outputs": [],
712
  "source": [
 
721
  },
722
  {
723
  "cell_type": "code",
724
+ "execution_count": 23,
725
  "metadata": {},
726
  "outputs": [
727
  {
 
740
  },
741
  {
742
  "cell_type": "code",
743
+ "execution_count": 24,
744
  "metadata": {},
745
  "outputs": [
746
  {
 
749
  "{'source': 'example_documents/resume.pdf', 'page': 0, 'start_index': 813}"
750
  ]
751
  },
752
+ "execution_count": 24,
753
  "metadata": {},
754
  "output_type": "execute_result"
755
  }
 
769
  },
770
  {
771
  "cell_type": "code",
772
+ "execution_count": 25,
773
  "metadata": {},
774
  "outputs": [],
775
  "source": [
 
799
  },
800
  {
801
  "cell_type": "code",
802
+ "execution_count": 26,
803
  "metadata": {},
804
  "outputs": [
805
  {
 
869
  },
870
  {
871
  "cell_type": "code",
872
+ "execution_count": 27,
873
  "metadata": {},
874
  "outputs": [
875
  {
 
882
  "Login successful\n",
883
  " \n",
884
  "\n",
 
 
 
 
885
  "Answer: \n",
886
  "\n",
887
+ "Based on the CV, Daniel's strengths are: \n",
 
 
 
 
 
 
888
  "\n",
889
+ "1. **Data Science skills**: Daniel has a strong background in data science, with experience in machine learning, natural language processing, and data visualization. He has also worked on several projects, showcasing his ability to develop reproducible analytical pipelines and optimize feature retrieval and engineering.\n",
890
+ "2. **Leadership skills**: Daniel has demonstrated leadership skills, having led a team to explore the use of large language models within the Home Office and overseeing learning and development initiatives within the data science team.\n",
891
+ "3. **Communication skills**: Daniel has highlighted his ability to effectively communicate complex concepts to non-technical stakeholders, which is an essential skill for a data scientist.\n",
892
+ "4. **Adaptability and flexibility**: Daniel has shown flexibility in his teaching style as a private mathematics tutor, adapting to different learning preferences and students with learning disabilities.\n",
893
+ "5. **Academic achievements**: Daniel has a strong academic background, with a distinction and best student award for his MSc, and a 1st class degree in Mathematics with Finance and Economics.\n",
894
+ "6. **Project management**: Daniel has managed several projects, including developing a reproducible analytical pipeline and leading a team to explore the use of large language models.\n",
895
+ "7. **Language skills**: Daniel is fluent in Spanish and has a basic understanding of German, which could be beneficial in a globalized work environment. \n",
896
  "\n",
897
+ "Overall, Daniel's CV showcases a strong combination of technical skills, leadership abilities, and adaptability, making him a competitive candidate in the data science field.\n"
 
 
 
 
 
 
 
 
 
 
 
 
898
  ]
899
  }
900
  ],
 
933
  "\n",
934
  "print(rag_chain.invoke(\"What are Daniel's strengths in this CV?\"))\n"
935
  ]
 
 
 
 
 
 
 
936
  }
937
  ],
938
  "metadata": {
939
  "kernelspec": {
940
+ "display_name": "llm_env",
941
  "language": "python",
942
  "name": "python3"
943
  },
llm_handbook.ipynb CHANGED
@@ -9,7 +9,9 @@
9
  "source": [
10
  "# LLM handbook\n",
11
  "\n",
12
- "Following guidance from <a href='https://www.pinecone.io/learn/series/langchain/'> Pinecone's Langchain handbook.</a>"
 
 
13
  ]
14
  },
15
  {
 
9
  "source": [
10
  "# LLM handbook\n",
11
  "\n",
12
+ "Following guidance from <a href='https://www.pinecone.io/learn/series/langchain/'> Pinecone's Langchain handbook.</a>\n",
13
+ "\n",
14
+ "NOTE: this notebook was written for an older version of LangChain and many of the functionality used here has been deprecated."
15
  ]
16
  },
17
  {
rag_chatbot.ipynb CHANGED
@@ -16,7 +16,7 @@
16
  },
17
  {
18
  "cell_type": "code",
19
- "execution_count": 1,
20
  "metadata": {},
21
  "outputs": [
22
  {
@@ -72,7 +72,7 @@
72
  },
73
  {
74
  "cell_type": "code",
75
- "execution_count": 2,
76
  "metadata": {},
77
  "outputs": [],
78
  "source": [
@@ -93,7 +93,7 @@
93
  },
94
  {
95
  "cell_type": "code",
96
- "execution_count": 3,
97
  "metadata": {},
98
  "outputs": [],
99
  "source": [
@@ -123,7 +123,7 @@
123
  },
124
  {
125
  "cell_type": "code",
126
- "execution_count": 4,
127
  "metadata": {},
128
  "outputs": [],
129
  "source": [
@@ -139,7 +139,7 @@
139
  },
140
  {
141
  "cell_type": "code",
142
- "execution_count": 5,
143
  "metadata": {},
144
  "outputs": [
145
  {
@@ -185,7 +185,7 @@
185
  },
186
  {
187
  "cell_type": "code",
188
- "execution_count": 6,
189
  "metadata": {},
190
  "outputs": [],
191
  "source": [
@@ -223,7 +223,7 @@
223
  },
224
  {
225
  "cell_type": "code",
226
- "execution_count": 7,
227
  "metadata": {},
228
  "outputs": [
229
  {
@@ -234,7 +234,7 @@
234
  "\u001b[0m[inputs]\n",
235
  "\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] Entering Prompt run with input:\n",
236
  "\u001b[0m[inputs]\n",
237
- "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] [1ms] Exiting Prompt run with output:\n",
238
  "\u001b[0m[outputs]\n",
239
  "\u001b[32;1m\u001b[1;3m[llm/start]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatHuggingFace] Entering LLM run with input:\n",
240
  "\u001b[0m{\n",
@@ -242,12 +242,12 @@
242
  " \"System: Given a chat history and the latest user question which might reference context in the chat history, formulate a standalone question which can be understood without the chat history. Do NOT answer the question, just reformulate it if needed and otherwise return it as is.\\nHuman: Hello, my name is Daniel and I work as a data scientist.I'd really enjoyed the methodology section of this project document. Especially the part on single-stage models.\\nAI: Hello Daniel, nice to meet you. Sounds interesting.\\nHuman: What observation was made about single-stage models?\"\n",
243
  " ]\n",
244
  "}\n",
245
- "\u001b[36;1m\u001b[1;3m[llm/end]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatHuggingFace] [334ms] Exiting LLM run with output:\n",
246
  "\u001b[0m{\n",
247
  " \"generations\": [\n",
248
  " [\n",
249
  " {\n",
250
- " \"text\": \"What was the conclusion or insight drawn about single-stage models from the methodology section of the project document?\",\n",
251
  " \"generation_info\": {\n",
252
  " \"finish_reason\": \"stop\"\n",
253
  " },\n",
@@ -262,7 +262,7 @@
262
  " \"AIMessage\"\n",
263
  " ],\n",
264
  " \"kwargs\": {\n",
265
- " \"content\": \"What was the conclusion or insight drawn about single-stage models from the methodology section of the project document?\",\n",
266
  " \"response_metadata\": {\n",
267
  " \"token_usage\": {\n",
268
  " \"completion_tokens\": 21,\n",
@@ -273,7 +273,7 @@
273
  " \"finish_reason\": \"stop\"\n",
274
  " },\n",
275
  " \"type\": \"ai\",\n",
276
- " \"id\": \"run-e4edd572-e4e5-4c30-be80-3909713e7cde-0\",\n",
277
  " \"tool_calls\": [],\n",
278
  " \"invalid_tool_calls\": []\n",
279
  " }\n",
@@ -296,9 +296,9 @@
296
  "\u001b[0m[inputs]\n",
297
  "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > parser:StrOutputParser] [0ms] Exiting Parser run with output:\n",
298
  "\u001b[0m{\n",
299
- " \"output\": \"What was the conclusion or insight drawn about single-stage models from the methodology section of the project document?\"\n",
300
  "}\n",
301
- "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence] [618ms] Exiting Chain run with output:\n",
302
  "\u001b[0m[outputs]\n"
303
  ]
304
  }
@@ -326,19 +326,19 @@
326
  },
327
  {
328
  "cell_type": "code",
329
- "execution_count": 8,
330
  "metadata": {},
331
  "outputs": [
332
  {
333
  "data": {
334
  "text/plain": [
335
- "[Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 17, 'start_index': 77}, page_content='Page 17 of 69 3 Methodology 3.1 Methodological approach This project adopted a prototyping approach to developing the best model possible to meet the objectives set in section 1.3. The goal of prototyping is to evaluate an idea. After analysing the research presented in chapter 2, it was clear that the best approach to this problem involved removing unnecessary details from the imagery to make the CNN focus more on the features related to each SRM. Almost every paper in chapter 2 avoided single-stage models such as the Single Shot Detector (SSD) due to a lack of performance against two-stage models. Not only did this lead to the decision to create the two-stage models presented this project, but it highlighted the importance of the image pre-processing stage. However, at the time, several ideas for how to execute this objective existed. For this reason, prototyping began on the ROI detector. Prototyping was the necessary approach as it was important to create ROI detectors, each'),\n",
336
- " Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 60, 'start_index': 77}, page_content='Page 60 of 69 The majority of Stage 4 did not take place at all due to the total amount of delays which amounted during the project. Networks were adapted to the application as mentioned in 6.1 and AlexNet did produce competitive results without further modification. Stage 5 took 1 week longer than expected due to the iterative changes made to the model. Often, as soon as results were gathered, new ideas were implemented into the model which meant experiments had to be run again. For example, during the image segmentation problem shown in section 6.5.3, all CNNs had to be trained and analysed again. It took time to develop a routine for collecting data from models. It was paramount to keep the same conditions for each experiment. This meant occasionally restarting the computer to let it cool down after many sessions of CNN training. These sessions would cause performance of the computer to decrease, and it was then decided not to collect performance measurements for the model'),\n",
337
- " Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 58, 'start_index': 564}, page_content='6 10/07/2020 - 19/07/2020 27/07/2020 02/08/2020 Begin iterative process of improving performance of model Record iterative improvements Settle on final iteration Critically analyse performance and computational requirements 7 20/07/2020 - 31/07/2020 31/07/2020 14/08/2020 Produce first write-up draft 8 31/07/2020 - 14/08/2020 07/08/2020 14/08/2020 Final opportunity for technical ideas or modifications to proposed model • Consider feedback from supervisor to iteratively improve final project write-up As shown above, the planned project schedule was adhered to for stage 1. This involved searching for and selecting a suitable dataset which contained good quality imagery and ground truth data. Almost all of the first few literature papers at least partly used this dataset to conduct'),\n",
338
  " Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 60, 'start_index': 1671}, page_content='7.2.2.4. Stage 7 was delayed by over 1 week but only as a results of previous delays. However, it took 1 week longer than expected. This is because of how difficult it was to write the report in a flowing manner. Having a record of tasks completed along with dates prevented this stage from taking any longer. Since stage 7 overran by 1 week, final modifications and adjustments had to be made simultaneously with report writing. 8.2 Quality Management Since many models were tested during this project, it was important to create code scripts, CNN objects and datasets specifically for them. This required a clear naming procedure which is')]"
339
  ]
340
  },
341
- "execution_count": 8,
342
  "metadata": {},
343
  "output_type": "execute_result"
344
  }
@@ -361,7 +361,7 @@
361
  },
362
  {
363
  "cell_type": "code",
364
- "execution_count": 11,
365
  "metadata": {},
366
  "outputs": [],
367
  "source": [
@@ -397,7 +397,7 @@
397
  },
398
  {
399
  "cell_type": "code",
400
- "execution_count": 12,
401
  "metadata": {},
402
  "outputs": [
403
  {
@@ -408,20 +408,20 @@
408
  "\u001b[0m[inputs]\n",
409
  "\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] Entering Prompt run with input:\n",
410
  "\u001b[0m[inputs]\n",
411
- "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] [2ms] Exiting Prompt run with output:\n",
412
  "\u001b[0m[outputs]\n",
413
  "\u001b[32;1m\u001b[1;3m[llm/start]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatHuggingFace] Entering LLM run with input:\n",
414
  "\u001b[0m{\n",
415
  " \"prompts\": [\n",
416
- " \"System: You are an assistant for question-answering tasks. Use the following pieces of retrieved context to answer the question. If you don't know the answer, say that you don't know. Use three sentences maximum and keep the answer concise.\\n\\n[Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 17, 'start_index': 77}, page_content='Page 17 of 69 3 Methodology 3.1 Methodological approach This project adopted a prototyping approach to developing the best model possible to meet the objectives set in section 1.3. The goal of prototyping is to evaluate an idea. After analysing the research presented in chapter 2, it was clear that the best approach to this problem involved removing unnecessary details from the imagery to make the CNN focus more on the features related to each SRM. Almost every paper in chapter 2 avoided single-stage models such as the Single Shot Detector (SSD) due to a lack of performance against two-stage models. Not only did this lead to the decision to create the two-stage models presented this project, but it highlighted the importance of the image pre-processing stage. However, at the time, several ideas for how to execute this objective existed. For this reason, prototyping began on the ROI detector. Prototyping was the necessary approach as it was important to create ROI detectors, each'), Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 60, 'start_index': 77}, page_content='Page 60 of 69 The majority of Stage 4 did not take place at all due to the total amount of delays which amounted during the project. Networks were adapted to the application as mentioned in 6.1 and AlexNet did produce competitive results without further modification. Stage 5 took 1 week longer than expected due to the iterative changes made to the model. Often, as soon as results were gathered, new ideas were implemented into the model which meant experiments had to be run again. For example, during the image segmentation problem shown in section 6.5.3, all CNNs had to be trained and analysed again. It took time to develop a routine for collecting data from models. It was paramount to keep the same conditions for each experiment. This meant occasionally restarting the computer to let it cool down after many sessions of CNN training. These sessions would cause performance of the computer to decrease, and it was then decided not to collect performance measurements for the model'), Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 58, 'start_index': 564}, page_content='6 10/07/2020 - 19/07/2020 27/07/2020 02/08/2020 Begin iterative process of improving performance of model Record iterative improvements Settle on final iteration Critically analyse performance and computational requirements 7 20/07/2020 - 31/07/2020 31/07/2020 14/08/2020 Produce first write-up draft 8 31/07/2020 - 14/08/2020 07/08/2020 – 14/08/2020 • Final opportunity for technical ideas or modifications to proposed model • Consider feedback from supervisor to iteratively improve final project write-up As shown above, the planned project schedule was adhered to for stage 1. This involved searching for and selecting a suitable dataset which contained good quality imagery and ground truth data. Almost all of the first few literature papers at least partly used this dataset to conduct'), Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 60, 'start_index': 1671}, page_content='7.2.2.4. Stage 7 was delayed by over 1 week but only as a results of previous delays. However, it took 1 week longer than expected. This is because of how difficult it was to write the report in a flowing manner. Having a record of tasks completed along with dates prevented this stage from taking any longer. Since stage 7 overran by 1 week, final modifications and adjustments had to be made simultaneously with report writing. 8.2 Quality Management Since many models were tested during this project, it was important to create code scripts, CNN objects and datasets specifically for them. This required a clear naming procedure which is')]You are also given chat history below to help contextualise the question.[HumanMessage(content=\\\"Hello, my name is Daniel and I work as a data scientist.I'd really enjoyed the methodology section of this project document. Especially the part on single-stage models.\\\", additional_kwargs={}, response_metadata={}), AIMessage(content='Hello Daniel, nice to meet you. Sounds interesting.', additional_kwargs={}, response_metadata={})]Can you remind me of why that type of model was chosen for the project?\"\n",
417
  " ]\n",
418
  "}\n",
419
- "\u001b[36;1m\u001b[1;3m[llm/end]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatHuggingFace] [2.16s] Exiting LLM run with output:\n",
420
  "\u001b[0m{\n",
421
  " \"generations\": [\n",
422
  " [\n",
423
  " {\n",
424
- " \"text\": \"The reason for choosing two-stage models over single-stage models, such as the Single Shot Detector (SSD), was due to the lack of performance of single-stage models compared to two-stage models. Almost every paper analyzed in chapter 2 of the document avoided single-stage models and highlighted the importance of the image pre-processing stage, which led to the decision to create the two-stage models presented in this project.\",\n",
425
  " \"generation_info\": {\n",
426
  " \"finish_reason\": \"stop\"\n",
427
  " },\n",
@@ -436,18 +436,18 @@
436
  " \"AIMessage\"\n",
437
  " ],\n",
438
  " \"kwargs\": {\n",
439
- " \"content\": \"The reason for choosing two-stage models over single-stage models, such as the Single Shot Detector (SSD), was due to the lack of performance of single-stage models compared to two-stage models. Almost every paper analyzed in chapter 2 of the document avoided single-stage models and highlighted the importance of the image pre-processing stage, which led to the decision to create the two-stage models presented in this project.\",\n",
440
  " \"response_metadata\": {\n",
441
  " \"token_usage\": {\n",
442
- " \"completion_tokens\": 82,\n",
443
- " \"prompt_tokens\": 1021,\n",
444
- " \"total_tokens\": 1103\n",
445
  " },\n",
446
  " \"model\": \"\",\n",
447
  " \"finish_reason\": \"stop\"\n",
448
  " },\n",
449
  " \"type\": \"ai\",\n",
450
- " \"id\": \"run-f666ceef-4a4b-4089-a13d-48cdbccd3aa4-0\",\n",
451
  " \"tool_calls\": [],\n",
452
  " \"invalid_tool_calls\": []\n",
453
  " }\n",
@@ -457,9 +457,9 @@
457
  " ],\n",
458
  " \"llm_output\": {\n",
459
  " \"token_usage\": {\n",
460
- " \"completion_tokens\": 82,\n",
461
- " \"prompt_tokens\": 1021,\n",
462
- " \"total_tokens\": 1103\n",
463
  " },\n",
464
  " \"model\": \"\"\n",
465
  " },\n",
@@ -470,21 +470,21 @@
470
  "\u001b[0m[inputs]\n",
471
  "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > parser:StrOutputParser] [1ms] Exiting Parser run with output:\n",
472
  "\u001b[0m{\n",
473
- " \"output\": \"The reason for choosing two-stage models over single-stage models, such as the Single Shot Detector (SSD), was due to the lack of performance of single-stage models compared to two-stage models. Almost every paper analyzed in chapter 2 of the document avoided single-stage models and highlighted the importance of the image pre-processing stage, which led to the decision to create the two-stage models presented in this project.\"\n",
474
  "}\n",
475
- "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence] [2.17s] Exiting Chain run with output:\n",
476
  "\u001b[0m{\n",
477
- " \"output\": \"The reason for choosing two-stage models over single-stage models, such as the Single Shot Detector (SSD), was due to the lack of performance of single-stage models compared to two-stage models. Almost every paper analyzed in chapter 2 of the document avoided single-stage models and highlighted the importance of the image pre-processing stage, which led to the decision to create the two-stage models presented in this project.\"\n",
478
  "}\n"
479
  ]
480
  },
481
  {
482
  "data": {
483
  "text/plain": [
484
- "'The reason for choosing two-stage models over single-stage models, such as the Single Shot Detector (SSD), was due to the lack of performance of single-stage models compared to two-stage models. Almost every paper analyzed in chapter 2 of the document avoided single-stage models and highlighted the importance of the image pre-processing stage, which led to the decision to create the two-stage models presented in this project.'"
485
  ]
486
  },
487
- "execution_count": 12,
488
  "metadata": {},
489
  "output_type": "execute_result"
490
  }
@@ -504,7 +504,7 @@
504
  },
505
  {
506
  "cell_type": "code",
507
- "execution_count": 13,
508
  "metadata": {},
509
  "outputs": [],
510
  "source": [
@@ -518,7 +518,7 @@
518
  },
519
  {
520
  "cell_type": "code",
521
- "execution_count": 14,
522
  "metadata": {},
523
  "outputs": [
524
  {
@@ -533,11 +533,7 @@
533
  "\u001b[0m[inputs]\n",
534
  "\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence > prompt:ChatPromptTemplate] Entering Prompt run with input:\n",
535
  "\u001b[0m[inputs]\n",
536
- "\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnablePassthrough] Entering Chain run with input:\n",
537
- "\u001b[0m[inputs]\n",
538
- "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnablePassthrough] [1ms] Exiting Chain run with output:\n",
539
- "\u001b[0m[outputs]\n",
540
- "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence > prompt:ChatPromptTemplate] [11ms] Exiting Prompt run with output:\n",
541
  "\u001b[0m[outputs]\n",
542
  "\u001b[32;1m\u001b[1;3m[llm/start]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence > llm:ChatHuggingFace] Entering LLM run with input:\n",
543
  "\u001b[0m{\n",
@@ -549,12 +545,16 @@
549
  "\u001b[0m[inputs]\n",
550
  "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnablePassthrough] [0ms] Exiting Chain run with output:\n",
551
  "\u001b[0m[outputs]\n",
552
- "\u001b[36;1m\u001b[1;3m[llm/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence > llm:ChatHuggingFace] [879ms] Exiting LLM run with output:\n",
 
 
 
 
553
  "\u001b[0m{\n",
554
  " \"generations\": [\n",
555
  " [\n",
556
  " {\n",
557
- " \"text\": \"What motivated the choice of the single-stage model over other possible approaches in this project?\",\n",
558
  " \"generation_info\": {\n",
559
  " \"finish_reason\": \"stop\"\n",
560
  " },\n",
@@ -569,18 +569,18 @@
569
  " \"AIMessage\"\n",
570
  " ],\n",
571
  " \"kwargs\": {\n",
572
- " \"content\": \"What motivated the choice of the single-stage model over other possible approaches in this project?\",\n",
573
  " \"response_metadata\": {\n",
574
  " \"token_usage\": {\n",
575
- " \"completion_tokens\": 18,\n",
576
  " \"prompt_tokens\": 135,\n",
577
- " \"total_tokens\": 153\n",
578
  " },\n",
579
  " \"model\": \"\",\n",
580
  " \"finish_reason\": \"stop\"\n",
581
  " },\n",
582
  " \"type\": \"ai\",\n",
583
- " \"id\": \"run-4bc0e842-6461-46fd-a2a9-b2aaece618ce-0\",\n",
584
  " \"tool_calls\": [],\n",
585
  " \"invalid_tool_calls\": []\n",
586
  " }\n",
@@ -590,9 +590,9 @@
590
  " ],\n",
591
  " \"llm_output\": {\n",
592
  " \"token_usage\": {\n",
593
- " \"completion_tokens\": 18,\n",
594
  " \"prompt_tokens\": 135,\n",
595
- " \"total_tokens\": 153\n",
596
  " },\n",
597
  " \"model\": \"\"\n",
598
  " },\n",
@@ -603,28 +603,28 @@
603
  "\u001b[0m[inputs]\n",
604
  "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence > parser:StrOutputParser] [1ms] Exiting Parser run with output:\n",
605
  "\u001b[0m{\n",
606
- " \"output\": \"What motivated the choice of the single-stage model over other possible approaches in this project?\"\n",
607
  "}\n",
608
- "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence] [1.34s] Exiting Chain run with output:\n",
609
  "\u001b[0m[outputs]\n",
610
- "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input>] [1.35s] Exiting Chain run with output:\n",
611
  "\u001b[0m[outputs]\n",
612
  "\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] Entering Prompt run with input:\n",
613
  "\u001b[0m[inputs]\n",
614
- "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] [1ms] Exiting Prompt run with output:\n",
615
  "\u001b[0m[outputs]\n",
616
  "\u001b[32;1m\u001b[1;3m[llm/start]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatHuggingFace] Entering LLM run with input:\n",
617
  "\u001b[0m{\n",
618
  " \"prompts\": [\n",
619
- " \"System: You are an assistant for question-answering tasks. Use the following pieces of retrieved context to answer the question. If you don't know the answer, say that you don't know. Use three sentences maximum and keep the answer concise.\\n\\n[Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 17, 'start_index': 77}, page_content='Page 17 of 69 3 Methodology 3.1 Methodological approach This project adopted a prototyping approach to developing the best model possible to meet the objectives set in section 1.3. The goal of prototyping is to evaluate an idea. After analysing the research presented in chapter 2, it was clear that the best approach to this problem involved removing unnecessary details from the imagery to make the CNN focus more on the features related to each SRM. Almost every paper in chapter 2 avoided single-stage models such as the Single Shot Detector (SSD) due to a lack of performance against two-stage models. Not only did this lead to the decision to create the two-stage models presented this project, but it highlighted the importance of the image pre-processing stage. However, at the time, several ideas for how to execute this objective existed. For this reason, prototyping began on the ROI detector. Prototyping was the necessary approach as it was important to create ROI detectors, each'), Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 60, 'start_index': 77}, page_content='Page 60 of 69 The majority of Stage 4 did not take place at all due to the total amount of delays which amounted during the project. Networks were adapted to the application as mentioned in 6.1 and AlexNet did produce competitive results without further modification. Stage 5 took 1 week longer than expected due to the iterative changes made to the model. Often, as soon as results were gathered, new ideas were implemented into the model which meant experiments had to be run again. For example, during the image segmentation problem shown in section 6.5.3, all CNNs had to be trained and analysed again. It took time to develop a routine for collecting data from models. It was paramount to keep the same conditions for each experiment. This meant occasionally restarting the computer to let it cool down after many sessions of CNN training. These sessions would cause performance of the computer to decrease, and it was then decided not to collect performance measurements for the model'), Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 60, 'start_index': 870}, page_content='let it cool down after many sessions of CNN training. These sessions would cause performance of the computer to decrease, and it was then decided not to collect performance measurements for the model until the computer had cooled. Also, organising the data was more time consuming than expected. It was important not to confuse data between models and so extra time and precaution was given to storing data in safe locations. Screenshots were carefully handled and stored in a location referring to their respective models. Some of the new ideas and iterations mentioned in the above paragraph are part of stage 6. This is when most of the iterative improvements occurred. The biggest development during stage 6 was the creation of the second-generation ROI_RESIZED detector which was explained in 7.2.2.4. Stage 7 was delayed by over 1 week but only as a results of previous delays. However, it took 1 week longer than expected. This is because of how difficult it was to write the report in a'), Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 58, 'start_index': 564}, page_content='6 10/07/2020 - 19/07/2020 27/07/2020 02/08/2020 Begin iterative process of improving performance of model Record iterative improvements • Settle on final iteration • Critically analyse performance and computational requirements 7 20/07/2020 - 31/07/2020 31/07/2020 14/08/2020 • Produce first write-up draft 8 31/07/2020 - 14/08/2020 07/08/2020 14/08/2020 Final opportunity for technical ideas or modifications to proposed model • Consider feedback from supervisor to iteratively improve final project write-up As shown above, the planned project schedule was adhered to for stage 1. This involved searching for and selecting a suitable dataset which contained good quality imagery and ground truth data. Almost all of the first few literature papers at least partly used this dataset to conduct')]You are also given chat history below to help contextualise the question.{'chat_history': [HumanMessage(content=\\\"Hello, my name is Daniel and I work as a data scientist.I'd really enjoyed the methodology section of this project document. Especially the part on single-stage models.\\\", additional_kwargs={}, response_metadata={}), AIMessage(content='Hello Daniel, nice to meet you. Sounds interesting.', additional_kwargs={}, response_metadata={})], 'input': 'Can you remind me of why that type of model was chosen for the project?'}{'chat_history': [HumanMessage(content=\\\"Hello, my name is Daniel and I work as a data scientist.I'd really enjoyed the methodology section of this project document. Especially the part on single-stage models.\\\", additional_kwargs={}, response_metadata={}), AIMessage(content='Hello Daniel, nice to meet you. Sounds interesting.', additional_kwargs={}, response_metadata={})], 'input': 'Can you remind me of why that type of model was chosen for the project?'}\"\n",
620
  " ]\n",
621
  "}\n",
622
- "\u001b[36;1m\u001b[1;3m[llm/end]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatHuggingFace] [1.57s] Exiting LLM run with output:\n",
623
  "\u001b[0m{\n",
624
  " \"generations\": [\n",
625
  " [\n",
626
  " {\n",
627
- " \"text\": \"The project chose two-stage models instead of single-stage models like Single Shot Detector (SSD) because almost every paper analyzed in chapter 2 showed that two-stage models outperformed single-stage models.\",\n",
628
  " \"generation_info\": {\n",
629
  " \"finish_reason\": \"stop\"\n",
630
  " },\n",
@@ -639,18 +639,18 @@
639
  " \"AIMessage\"\n",
640
  " ],\n",
641
  " \"kwargs\": {\n",
642
- " \"content\": \"The project chose two-stage models instead of single-stage models like Single Shot Detector (SSD) because almost every paper analyzed in chapter 2 showed that two-stage models outperformed single-stage models.\",\n",
643
  " \"response_metadata\": {\n",
644
  " \"token_usage\": {\n",
645
- " \"completion_tokens\": 41,\n",
646
- " \"prompt_tokens\": 1186,\n",
647
- " \"total_tokens\": 1227\n",
648
  " },\n",
649
  " \"model\": \"\",\n",
650
  " \"finish_reason\": \"stop\"\n",
651
  " },\n",
652
  " \"type\": \"ai\",\n",
653
- " \"id\": \"run-8c3ce7a8-f3b9-4cf5-ac7e-37b81ff3876b-0\",\n",
654
  " \"tool_calls\": [],\n",
655
  " \"invalid_tool_calls\": []\n",
656
  " }\n",
@@ -660,9 +660,9 @@
660
  " ],\n",
661
  " \"llm_output\": {\n",
662
  " \"token_usage\": {\n",
663
- " \"completion_tokens\": 41,\n",
664
- " \"prompt_tokens\": 1186,\n",
665
- " \"total_tokens\": 1227\n",
666
  " },\n",
667
  " \"model\": \"\"\n",
668
  " },\n",
@@ -673,11 +673,11 @@
673
  "\u001b[0m[inputs]\n",
674
  "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > parser:StrOutputParser] [0ms] Exiting Parser run with output:\n",
675
  "\u001b[0m{\n",
676
- " \"output\": \"The project chose two-stage models instead of single-stage models like Single Shot Detector (SSD) because almost every paper analyzed in chapter 2 showed that two-stage models outperformed single-stage models.\"\n",
677
  "}\n",
678
- "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence] [2.93s] Exiting Chain run with output:\n",
679
  "\u001b[0m{\n",
680
- " \"output\": \"The project chose two-stage models instead of single-stage models like Single Shot Detector (SSD) because almost every paper analyzed in chapter 2 showed that two-stage models outperformed single-stage models.\"\n",
681
  "}\n"
682
  ]
683
  }
@@ -689,16 +689,16 @@
689
  },
690
  {
691
  "cell_type": "code",
692
- "execution_count": 16,
693
  "metadata": {},
694
  "outputs": [
695
  {
696
  "data": {
697
  "text/plain": [
698
- "'The project chose two-stage models instead of single-stage models like Single Shot Detector (SSD) because almost every paper analyzed in chapter 2 showed that two-stage models outperformed single-stage models.'"
699
  ]
700
  },
701
- "execution_count": 16,
702
  "metadata": {},
703
  "output_type": "execute_result"
704
  }
@@ -716,7 +716,7 @@
716
  },
717
  {
718
  "cell_type": "code",
719
- "execution_count": 17,
720
  "metadata": {},
721
  "outputs": [],
722
  "source": [
@@ -725,7 +725,7 @@
725
  },
726
  {
727
  "cell_type": "code",
728
- "execution_count": 18,
729
  "metadata": {},
730
  "outputs": [
731
  {
@@ -734,10 +734,10 @@
734
  "[HumanMessage(content=\"Hello, my name is Daniel and I work as a data scientist.I'd really enjoyed the methodology section of this project document. Especially the part on single-stage models.\", additional_kwargs={}, response_metadata={}),\n",
735
  " AIMessage(content='Hello Daniel, nice to meet you. Sounds interesting.', additional_kwargs={}, response_metadata={}),\n",
736
  " HumanMessage(content='Can you remind me of why that type of model was chosen for the project?', additional_kwargs={}, response_metadata={}),\n",
737
- " AIMessage(content='The project chose two-stage models instead of single-stage models like Single Shot Detector (SSD) because almost every paper analyzed in chapter 2 showed that two-stage models outperformed single-stage models.', additional_kwargs={}, response_metadata={})]"
738
  ]
739
  },
740
- "execution_count": 18,
741
  "metadata": {},
742
  "output_type": "execute_result"
743
  }
@@ -748,7 +748,7 @@
748
  },
749
  {
750
  "cell_type": "code",
751
- "execution_count": 20,
752
  "metadata": {},
753
  "outputs": [
754
  {
@@ -763,28 +763,28 @@
763
  "\u001b[0m[inputs]\n",
764
  "\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence > prompt:ChatPromptTemplate] Entering Prompt run with input:\n",
765
  "\u001b[0m[inputs]\n",
766
- "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence > prompt:ChatPromptTemplate] [2ms] Exiting Prompt run with output:\n",
767
- "\u001b[0m[outputs]\n",
768
- "\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnablePassthrough] Entering Chain run with input:\n",
769
- "\u001b[0m[inputs]\n",
770
- "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnablePassthrough] [0ms] Exiting Chain run with output:\n",
771
  "\u001b[0m[outputs]\n",
772
  "\u001b[32;1m\u001b[1;3m[llm/start]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence > llm:ChatHuggingFace] Entering LLM run with input:\n",
773
  "\u001b[0m{\n",
774
  " \"prompts\": [\n",
775
- " \"System: Given a chat history and the latest user question which might reference context in the chat history, formulate a standalone question which can be understood without the chat history. Do NOT answer the question, just reformulate it if needed and otherwise return it as is.\\nHuman: Hello, my name is Daniel and I work as a data scientist.I'd really enjoyed the methodology section of this project document. Especially the part on single-stage models.\\nAI: Hello Daniel, nice to meet you. Sounds interesting.\\nHuman: Can you remind me of why that type of model was chosen for the project?\\nAI: The project chose two-stage models instead of single-stage models like Single Shot Detector (SSD) because almost every paper analyzed in chapter 2 showed that two-stage models outperformed single-stage models.\\nHuman: And was anything said about the other type of model?\"\n",
776
  " ]\n",
777
  "}\n",
778
  "\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnablePassthrough] Entering Chain run with input:\n",
779
  "\u001b[0m[inputs]\n",
 
 
 
 
780
  "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnablePassthrough] [0ms] Exiting Chain run with output:\n",
781
  "\u001b[0m[outputs]\n",
782
- "\u001b[36;1m\u001b[1;3m[llm/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence > llm:ChatHuggingFace] [662ms] Exiting LLM run with output:\n",
783
  "\u001b[0m{\n",
784
  " \"generations\": [\n",
785
  " [\n",
786
  " {\n",
787
- " \"text\": \"Can you remind me what you're referring to by \\\"the other type of model\\\"?\",\n",
788
  " \"generation_info\": {\n",
789
  " \"finish_reason\": \"stop\"\n",
790
  " },\n",
@@ -799,18 +799,18 @@
799
  " \"AIMessage\"\n",
800
  " ],\n",
801
  " \"kwargs\": {\n",
802
- " \"content\": \"Can you remind me what you're referring to by \\\"the other type of model\\\"?\",\n",
803
  " \"response_metadata\": {\n",
804
  " \"token_usage\": {\n",
805
- " \"completion_tokens\": 18,\n",
806
- " \"prompt_tokens\": 196,\n",
807
- " \"total_tokens\": 214\n",
808
  " },\n",
809
  " \"model\": \"\",\n",
810
  " \"finish_reason\": \"stop\"\n",
811
  " },\n",
812
  " \"type\": \"ai\",\n",
813
- " \"id\": \"run-3342bd41-ffb2-4dca-a5ec-46fa2a86e8da-0\",\n",
814
  " \"tool_calls\": [],\n",
815
  " \"invalid_tool_calls\": []\n",
816
  " }\n",
@@ -820,9 +820,9 @@
820
  " ],\n",
821
  " \"llm_output\": {\n",
822
  " \"token_usage\": {\n",
823
- " \"completion_tokens\": 18,\n",
824
- " \"prompt_tokens\": 196,\n",
825
- " \"total_tokens\": 214\n",
826
  " },\n",
827
  " \"model\": \"\"\n",
828
  " },\n",
@@ -833,11 +833,11 @@
833
  "\u001b[0m[inputs]\n",
834
  "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence > parser:StrOutputParser] [0ms] Exiting Parser run with output:\n",
835
  "\u001b[0m{\n",
836
- " \"output\": \"Can you remind me what you're referring to by \\\"the other type of model\\\"?\"\n",
837
  "}\n",
838
- "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence] [1.02s] Exiting Chain run with output:\n",
839
  "\u001b[0m[outputs]\n",
840
- "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input>] [1.02s] Exiting Chain run with output:\n",
841
  "\u001b[0m[outputs]\n",
842
  "\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] Entering Prompt run with input:\n",
843
  "\u001b[0m[inputs]\n",
@@ -846,15 +846,15 @@
846
  "\u001b[32;1m\u001b[1;3m[llm/start]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatHuggingFace] Entering LLM run with input:\n",
847
  "\u001b[0m{\n",
848
  " \"prompts\": [\n",
849
- " \"System: You are an assistant for question-answering tasks. Use the following pieces of retrieved context to answer the question. If you don't know the answer, say that you don't know. Use three sentences maximum and keep the answer concise.\\n\\n[Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 50, 'start_index': 870}, page_content='which makes this example a prime one to investigate the differences between the models. As shown in the classification matrix, this misclassification only occurs happens three times between these two classes. By observing the scores in the bottom left image of Figure 42, the CNN was most confident about leftturn followed by 40 and finally 35.'), Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 17, 'start_index': 77}, page_content='Page 17 of 69 3 Methodology 3.1 Methodological approach This project adopted a prototyping approach to developing the best model possible to meet the objectives set in section 1.3. The goal of prototyping is to evaluate an idea. After analysing the research presented in chapter 2, it was clear that the best approach to this problem involved removing unnecessary details from the imagery to make the CNN focus more on the features related to each SRM. Almost every paper in chapter 2 avoided single-stage models such as the Single Shot Detector (SSD) due to a lack of performance against two-stage models. Not only did this lead to the decision to create the two-stage models presented this project, but it highlighted the importance of the image pre-processing stage. However, at the time, several ideas for how to execute this objective existed. For this reason, prototyping began on the ROI detector. Prototyping was the necessary approach as it was important to create ROI detectors, each'), Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 45, 'start_index': 77}, page_content='Page 45 of 69 Table 4 - Model results 7.2.1 Comparison with literature The results shown above show a mixture of over and underachievement compared with results obtained by other research shown in section 2. Before comparing results, it is important to note that the most comparable piece of literature to this project is that of Touqeer Ahmad et al. (2017). This is because this work was based entirely on the same dataset. In fact, just like this project, only the top 10 most represented classes were tested with. This means that this results in this project are directly comparable to those from Touqeer Ahmad et al.. On the other hand, as mentioned in the literature review, Toan Ming Hoang et al. (2019a) combined several datasets including the one used in this project. Also, this paper went further ROI detector + Colour CNN_SqueezeNet 63.33 28.03 ROI_RESIZED detector + Colour CNN_GoogleNet 69.9 24.41 Traffic Light Detection (TLD) detector + Rttld (Zhenchao Ouyang et al., 2020) 99.7'), Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 60, 'start_index': 870}, page_content='let it cool down after many sessions of CNN training. These sessions would cause performance of the computer to decrease, and it was then decided not to collect performance measurements for the model until the computer had cooled. Also, organising the data was more time consuming than expected. It was important not to confuse data between models and so extra time and precaution was given to storing data in safe locations. Screenshots were carefully handled and stored in a location referring to their respective models. Some of the new ideas and iterations mentioned in the above paragraph are part of stage 6. This is when most of the iterative improvements occurred. The biggest development during stage 6 was the creation of the second-generation ROI_RESIZED detector which was explained in 7.2.2.4. Stage 7 was delayed by over 1 week but only as a results of previous delays. However, it took 1 week longer than expected. This is because of how difficult it was to write the report in a')]You are also given chat history below to help contextualise the question.{'chat_history': [HumanMessage(content=\\\"Hello, my name is Daniel and I work as a data scientist.I'd really enjoyed the methodology section of this project document. Especially the part on single-stage models.\\\", additional_kwargs={}, response_metadata={}), AIMessage(content='Hello Daniel, nice to meet you. Sounds interesting.', additional_kwargs={}, response_metadata={}), HumanMessage(content='Can you remind me of why that type of model was chosen for the project?', additional_kwargs={}, response_metadata={}), AIMessage(content='The project chose two-stage models instead of single-stage models like Single Shot Detector (SSD) because almost every paper analyzed in chapter 2 showed that two-stage models outperformed single-stage models.', additional_kwargs={}, response_metadata={})], 'input': 'And was anything said about the other type of model?'}{'chat_history': [HumanMessage(content=\\\"Hello, my name is Daniel and I work as a data scientist.I'd really enjoyed the methodology section of this project document. Especially the part on single-stage models.\\\", additional_kwargs={}, response_metadata={}), AIMessage(content='Hello Daniel, nice to meet you. Sounds interesting.', additional_kwargs={}, response_metadata={}), HumanMessage(content='Can you remind me of why that type of model was chosen for the project?', additional_kwargs={}, response_metadata={}), AIMessage(content='The project chose two-stage models instead of single-stage models like Single Shot Detector (SSD) because almost every paper analyzed in chapter 2 showed that two-stage models outperformed single-stage models.', additional_kwargs={}, response_metadata={})], 'input': 'And was anything said about the other type of model?'}\"\n",
850
  " ]\n",
851
  "}\n",
852
- "\u001b[36;1m\u001b[1;3m[llm/end]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatHuggingFace] [1.28s] Exiting LLM run with output:\n",
853
  "\u001b[0m{\n",
854
  " \"generations\": [\n",
855
  " [\n",
856
  " {\n",
857
- " \"text\": \"The document mentions the Single Shot Detector (SSD) model as an example of a single-stage model that was avoided due to a lack of performance against two-stage models.\",\n",
858
  " \"generation_info\": {\n",
859
  " \"finish_reason\": \"stop\"\n",
860
  " },\n",
@@ -869,18 +869,18 @@
869
  " \"AIMessage\"\n",
870
  " ],\n",
871
  " \"kwargs\": {\n",
872
- " \"content\": \"The document mentions the Single Shot Detector (SSD) model as an example of a single-stage model that was avoided due to a lack of performance against two-stage models.\",\n",
873
  " \"response_metadata\": {\n",
874
  " \"token_usage\": {\n",
875
- " \"completion_tokens\": 35,\n",
876
- " \"prompt_tokens\": 1238,\n",
877
- " \"total_tokens\": 1273\n",
878
  " },\n",
879
  " \"model\": \"\",\n",
880
  " \"finish_reason\": \"stop\"\n",
881
  " },\n",
882
  " \"type\": \"ai\",\n",
883
- " \"id\": \"run-6aea1d58-56b0-40e2-98c4-30298a40f612-0\",\n",
884
  " \"tool_calls\": [],\n",
885
  " \"invalid_tool_calls\": []\n",
886
  " }\n",
@@ -890,9 +890,9 @@
890
  " ],\n",
891
  " \"llm_output\": {\n",
892
  " \"token_usage\": {\n",
893
- " \"completion_tokens\": 35,\n",
894
- " \"prompt_tokens\": 1238,\n",
895
- " \"total_tokens\": 1273\n",
896
  " },\n",
897
  " \"model\": \"\"\n",
898
  " },\n",
@@ -903,11 +903,11 @@
903
  "\u001b[0m[inputs]\n",
904
  "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > parser:StrOutputParser] [0ms] Exiting Parser run with output:\n",
905
  "\u001b[0m{\n",
906
- " \"output\": \"The document mentions the Single Shot Detector (SSD) model as an example of a single-stage model that was avoided due to a lack of performance against two-stage models.\"\n",
907
  "}\n",
908
- "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence] [2.31s] Exiting Chain run with output:\n",
909
  "\u001b[0m{\n",
910
- " \"output\": \"The document mentions the Single Shot Detector (SSD) model as an example of a single-stage model that was avoided due to a lack of performance against two-stage models.\"\n",
911
  "}\n"
912
  ]
913
  }
@@ -919,27 +919,6 @@
919
  " config={'callbacks': [ConsoleCallbackHandler()]})"
920
  ]
921
  },
922
- {
923
- "cell_type": "code",
924
- "execution_count": 26,
925
- "metadata": {},
926
- "outputs": [
927
- {
928
- "ename": "TypeError",
929
- "evalue": "'HumanMessage' object is not subscriptable",
930
- "output_type": "error",
931
- "traceback": [
932
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
933
- "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
934
- "Cell \u001b[0;32mIn[26], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mchat_history\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43muser\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\n",
935
- "\u001b[0;31mTypeError\u001b[0m: 'HumanMessage' object is not subscriptable"
936
- ]
937
- }
938
- ],
939
- "source": [
940
- "chat_history[0]"
941
- ]
942
- },
943
  {
944
  "cell_type": "code",
945
  "execution_count": null,
 
16
  },
17
  {
18
  "cell_type": "code",
19
+ "execution_count": 27,
20
  "metadata": {},
21
  "outputs": [
22
  {
 
72
  },
73
  {
74
  "cell_type": "code",
75
+ "execution_count": 28,
76
  "metadata": {},
77
  "outputs": [],
78
  "source": [
 
93
  },
94
  {
95
  "cell_type": "code",
96
+ "execution_count": 29,
97
  "metadata": {},
98
  "outputs": [],
99
  "source": [
 
123
  },
124
  {
125
  "cell_type": "code",
126
+ "execution_count": 30,
127
  "metadata": {},
128
  "outputs": [],
129
  "source": [
 
139
  },
140
  {
141
  "cell_type": "code",
142
+ "execution_count": 31,
143
  "metadata": {},
144
  "outputs": [
145
  {
 
185
  },
186
  {
187
  "cell_type": "code",
188
+ "execution_count": 32,
189
  "metadata": {},
190
  "outputs": [],
191
  "source": [
 
223
  },
224
  {
225
  "cell_type": "code",
226
+ "execution_count": 33,
227
  "metadata": {},
228
  "outputs": [
229
  {
 
234
  "\u001b[0m[inputs]\n",
235
  "\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] Entering Prompt run with input:\n",
236
  "\u001b[0m[inputs]\n",
237
+ "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] [2ms] Exiting Prompt run with output:\n",
238
  "\u001b[0m[outputs]\n",
239
  "\u001b[32;1m\u001b[1;3m[llm/start]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatHuggingFace] Entering LLM run with input:\n",
240
  "\u001b[0m{\n",
 
242
  " \"System: Given a chat history and the latest user question which might reference context in the chat history, formulate a standalone question which can be understood without the chat history. Do NOT answer the question, just reformulate it if needed and otherwise return it as is.\\nHuman: Hello, my name is Daniel and I work as a data scientist.I'd really enjoyed the methodology section of this project document. Especially the part on single-stage models.\\nAI: Hello Daniel, nice to meet you. Sounds interesting.\\nHuman: What observation was made about single-stage models?\"\n",
243
  " ]\n",
244
  "}\n",
245
+ "\u001b[36;1m\u001b[1;3m[llm/end]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatHuggingFace] [745ms] Exiting LLM run with output:\n",
246
  "\u001b[0m{\n",
247
  " \"generations\": [\n",
248
  " [\n",
249
  " {\n",
250
+ " \"text\": \"What are the key findings or insights from the single-stage models section of the project document you liked?\",\n",
251
  " \"generation_info\": {\n",
252
  " \"finish_reason\": \"stop\"\n",
253
  " },\n",
 
262
  " \"AIMessage\"\n",
263
  " ],\n",
264
  " \"kwargs\": {\n",
265
+ " \"content\": \"What are the key findings or insights from the single-stage models section of the project document you liked?\",\n",
266
  " \"response_metadata\": {\n",
267
  " \"token_usage\": {\n",
268
  " \"completion_tokens\": 21,\n",
 
273
  " \"finish_reason\": \"stop\"\n",
274
  " },\n",
275
  " \"type\": \"ai\",\n",
276
+ " \"id\": \"run-de5abc15-b0d2-4729-9be1-991117446ed7-0\",\n",
277
  " \"tool_calls\": [],\n",
278
  " \"invalid_tool_calls\": []\n",
279
  " }\n",
 
296
  "\u001b[0m[inputs]\n",
297
  "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > parser:StrOutputParser] [0ms] Exiting Parser run with output:\n",
298
  "\u001b[0m{\n",
299
+ " \"output\": \"What are the key findings or insights from the single-stage models section of the project document you liked?\"\n",
300
  "}\n",
301
+ "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence] [1.04s] Exiting Chain run with output:\n",
302
  "\u001b[0m[outputs]\n"
303
  ]
304
  }
 
326
  },
327
  {
328
  "cell_type": "code",
329
+ "execution_count": 34,
330
  "metadata": {},
331
  "outputs": [
332
  {
333
  "data": {
334
  "text/plain": [
335
+ "[Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 58, 'start_index': 564}, page_content='6 10/07/2020 - 19/07/2020 27/07/2020 02/08/2020 Begin iterative process of improving performance of model Record iterative improvements Settle on final iteration Critically analyse performance and computational requirements 7 20/07/2020 - 31/07/2020 31/07/2020 14/08/2020 Produce first write-up draft 8 31/07/2020 - 14/08/2020 07/08/2020 14/08/2020 Final opportunity for technical ideas or modifications to proposed model • Consider feedback from supervisor to iteratively improve final project write-up As shown above, the planned project schedule was adhered to for stage 1. This involved searching for and selecting a suitable dataset which contained good quality imagery and ground truth data. Almost all of the first few literature papers at least partly used this dataset to conduct'),\n",
336
+ " Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 17, 'start_index': 77}, page_content='Page 17 of 69 3 Methodology 3.1 Methodological approach This project adopted a prototyping approach to developing the best model possible to meet the objectives set in section 1.3. The goal of prototyping is to evaluate an idea. After analysing the research presented in chapter 2, it was clear that the best approach to this problem involved removing unnecessary details from the imagery to make the CNN focus more on the features related to each SRM. Almost every paper in chapter 2 avoided single-stage models such as the Single Shot Detector (SSD) due to a lack of performance against two-stage models. Not only did this lead to the decision to create the two-stage models presented this project, but it highlighted the importance of the image pre-processing stage. However, at the time, several ideas for how to execute this objective existed. For this reason, prototyping began on the ROI detector. Prototyping was the necessary approach as it was important to create ROI detectors, each'),\n",
337
+ " Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 64, 'start_index': 77}, page_content='Page 64 of 69 11 Student Reflections [ A reflective and critical appraisal of your personal performance, problems encountered and how they were resolved, lessons learnt, what could have been done better or differently, etc. ] This project is the largest piece of work I have completed during my academic studies. As such, it was difficult to predict a realistic timeline at the beginning. On the other hand, almost all of the planned deliverables were delivered; only bounding boxes, data augmentation and CNN modification were not delivered. However, as mentioned, bounding boxes could not be implemented due to issues with the dataset. In my opinion, the project was kept thoroughly organised. As mentioned in section 8.2, all scripts, datasets and MATLAB objects were stored safely and in organised folders. On the other hand, more could have been done to record daily progress. This is the weakest area of performance in the project. Although issues, successes, solutions and evidence were'),\n",
338
  " Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 60, 'start_index': 1671}, page_content='7.2.2.4. Stage 7 was delayed by over 1 week but only as a results of previous delays. However, it took 1 week longer than expected. This is because of how difficult it was to write the report in a flowing manner. Having a record of tasks completed along with dates prevented this stage from taking any longer. Since stage 7 overran by 1 week, final modifications and adjustments had to be made simultaneously with report writing. 8.2 Quality Management Since many models were tested during this project, it was important to create code scripts, CNN objects and datasets specifically for them. This required a clear naming procedure which is')]"
339
  ]
340
  },
341
+ "execution_count": 34,
342
  "metadata": {},
343
  "output_type": "execute_result"
344
  }
 
361
  },
362
  {
363
  "cell_type": "code",
364
+ "execution_count": 35,
365
  "metadata": {},
366
  "outputs": [],
367
  "source": [
 
397
  },
398
  {
399
  "cell_type": "code",
400
+ "execution_count": 36,
401
  "metadata": {},
402
  "outputs": [
403
  {
 
408
  "\u001b[0m[inputs]\n",
409
  "\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] Entering Prompt run with input:\n",
410
  "\u001b[0m[inputs]\n",
411
+ "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] [0ms] Exiting Prompt run with output:\n",
412
  "\u001b[0m[outputs]\n",
413
  "\u001b[32;1m\u001b[1;3m[llm/start]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatHuggingFace] Entering LLM run with input:\n",
414
  "\u001b[0m{\n",
415
  " \"prompts\": [\n",
416
+ " \"System: You are an assistant for question-answering tasks. Use the following pieces of retrieved context to answer the question. If you don't know the answer, say that you don't know. Use three sentences maximum and keep the answer concise.\\n\\n[Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 58, 'start_index': 564}, page_content='6 10/07/2020 - 19/07/2020 27/07/2020 – 02/08/2020 • Begin iterative process of improving performance of model • Record iterative improvements • Settle on final iteration • Critically analyse performance and computational requirements 7 20/07/2020 - 31/07/2020 31/07/2020 – 14/08/2020 • Produce first write-up draft 8 31/07/2020 - 14/08/2020 07/08/2020 – 14/08/2020 • Final opportunity for technical ideas or modifications to proposed model • Consider feedback from supervisor to iteratively improve final project write-up As shown above, the planned project schedule was adhered to for stage 1. This involved searching for and selecting a suitable dataset which contained good quality imagery and ground truth data. Almost all of the first few literature papers at least partly used this dataset to conduct'), Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 17, 'start_index': 77}, page_content='Page 17 of 69 3 Methodology 3.1 Methodological approach This project adopted a prototyping approach to developing the best model possible to meet the objectives set in section 1.3. The goal of prototyping is to evaluate an idea. After analysing the research presented in chapter 2, it was clear that the best approach to this problem involved removing unnecessary details from the imagery to make the CNN focus more on the features related to each SRM. Almost every paper in chapter 2 avoided single-stage models such as the Single Shot Detector (SSD) due to a lack of performance against two-stage models. Not only did this lead to the decision to create the two-stage models presented this project, but it highlighted the importance of the image pre-processing stage. However, at the time, several ideas for how to execute this objective existed. For this reason, prototyping began on the ROI detector. Prototyping was the necessary approach as it was important to create ROI detectors, each'), Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 64, 'start_index': 77}, page_content='Page 64 of 69 11 Student Reflections [ A reflective and critical appraisal of your personal performance, problems encountered and how they were resolved, lessons learnt, what could have been done better or differently, etc. ] This project is the largest piece of work I have completed during my academic studies. As such, it was difficult to predict a realistic timeline at the beginning. On the other hand, almost all of the planned deliverables were delivered; only bounding boxes, data augmentation and CNN modification were not delivered. However, as mentioned, bounding boxes could not be implemented due to issues with the dataset. In my opinion, the project was kept thoroughly organised. As mentioned in section 8.2, all scripts, datasets and MATLAB objects were stored safely and in organised folders. On the other hand, more could have been done to record daily progress. This is the weakest area of performance in the project. Although issues, successes, solutions and evidence were'), Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 60, 'start_index': 1671}, page_content='7.2.2.4. Stage 7 was delayed by over 1 week but only as a results of previous delays. However, it took 1 week longer than expected. This is because of how difficult it was to write the report in a flowing manner. Having a record of tasks completed along with dates prevented this stage from taking any longer. Since stage 7 overran by 1 week, final modifications and adjustments had to be made simultaneously with report writing. 8.2 Quality Management Since many models were tested during this project, it was important to create code scripts, CNN objects and datasets specifically for them. This required a clear naming procedure which is')]You are also given chat history below to help contextualise the question.[HumanMessage(content=\\\"Hello, my name is Daniel and I work as a data scientist.I'd really enjoyed the methodology section of this project document. Especially the part on single-stage models.\\\", additional_kwargs={}, response_metadata={}), AIMessage(content='Hello Daniel, nice to meet you. Sounds interesting.', additional_kwargs={}, response_metadata={})]Can you remind me of why that type of model was chosen for the project?\"\n",
417
  " ]\n",
418
  "}\n",
419
+ "\u001b[36;1m\u001b[1;3m[llm/end]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatHuggingFace] [3.65s] Exiting LLM run with output:\n",
420
  "\u001b[0m{\n",
421
  " \"generations\": [\n",
422
  " [\n",
423
  " {\n",
424
+ " \"text\": \"According to page 17 of the document, the decision to create two-stage models was made after analyzing the research presented in chapter 2, which showed that two-stage models outperformed single-stage models such as the Single Shot Detector (SSD).\",\n",
425
  " \"generation_info\": {\n",
426
  " \"finish_reason\": \"stop\"\n",
427
  " },\n",
 
436
  " \"AIMessage\"\n",
437
  " ],\n",
438
  " \"kwargs\": {\n",
439
+ " \"content\": \"According to page 17 of the document, the decision to create two-stage models was made after analyzing the research presented in chapter 2, which showed that two-stage models outperformed single-stage models such as the Single Shot Detector (SSD).\",\n",
440
  " \"response_metadata\": {\n",
441
  " \"token_usage\": {\n",
442
+ " \"completion_tokens\": 51,\n",
443
+ " \"prompt_tokens\": 1019,\n",
444
+ " \"total_tokens\": 1070\n",
445
  " },\n",
446
  " \"model\": \"\",\n",
447
  " \"finish_reason\": \"stop\"\n",
448
  " },\n",
449
  " \"type\": \"ai\",\n",
450
+ " \"id\": \"run-a32b4dbe-0e04-49ba-bfa6-3ac92bdfbe15-0\",\n",
451
  " \"tool_calls\": [],\n",
452
  " \"invalid_tool_calls\": []\n",
453
  " }\n",
 
457
  " ],\n",
458
  " \"llm_output\": {\n",
459
  " \"token_usage\": {\n",
460
+ " \"completion_tokens\": 51,\n",
461
+ " \"prompt_tokens\": 1019,\n",
462
+ " \"total_tokens\": 1070\n",
463
  " },\n",
464
  " \"model\": \"\"\n",
465
  " },\n",
 
470
  "\u001b[0m[inputs]\n",
471
  "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > parser:StrOutputParser] [1ms] Exiting Parser run with output:\n",
472
  "\u001b[0m{\n",
473
+ " \"output\": \"According to page 17 of the document, the decision to create two-stage models was made after analyzing the research presented in chapter 2, which showed that two-stage models outperformed single-stage models such as the Single Shot Detector (SSD).\"\n",
474
  "}\n",
475
+ "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence] [3.65s] Exiting Chain run with output:\n",
476
  "\u001b[0m{\n",
477
+ " \"output\": \"According to page 17 of the document, the decision to create two-stage models was made after analyzing the research presented in chapter 2, which showed that two-stage models outperformed single-stage models such as the Single Shot Detector (SSD).\"\n",
478
  "}\n"
479
  ]
480
  },
481
  {
482
  "data": {
483
  "text/plain": [
484
+ "'According to page 17 of the document, the decision to create two-stage models was made after analyzing the research presented in chapter 2, which showed that two-stage models outperformed single-stage models such as the Single Shot Detector (SSD).'"
485
  ]
486
  },
487
+ "execution_count": 36,
488
  "metadata": {},
489
  "output_type": "execute_result"
490
  }
 
504
  },
505
  {
506
  "cell_type": "code",
507
+ "execution_count": 37,
508
  "metadata": {},
509
  "outputs": [],
510
  "source": [
 
518
  },
519
  {
520
  "cell_type": "code",
521
+ "execution_count": 38,
522
  "metadata": {},
523
  "outputs": [
524
  {
 
533
  "\u001b[0m[inputs]\n",
534
  "\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence > prompt:ChatPromptTemplate] Entering Prompt run with input:\n",
535
  "\u001b[0m[inputs]\n",
536
+ "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence > prompt:ChatPromptTemplate] [1ms] Exiting Prompt run with output:\n",
 
 
 
 
537
  "\u001b[0m[outputs]\n",
538
  "\u001b[32;1m\u001b[1;3m[llm/start]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence > llm:ChatHuggingFace] Entering LLM run with input:\n",
539
  "\u001b[0m{\n",
 
545
  "\u001b[0m[inputs]\n",
546
  "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnablePassthrough] [0ms] Exiting Chain run with output:\n",
547
  "\u001b[0m[outputs]\n",
548
+ "\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnablePassthrough] Entering Chain run with input:\n",
549
+ "\u001b[0m[inputs]\n",
550
+ "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnablePassthrough] [0ms] Exiting Chain run with output:\n",
551
+ "\u001b[0m[outputs]\n",
552
+ "\u001b[36;1m\u001b[1;3m[llm/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence > llm:ChatHuggingFace] [628ms] Exiting LLM run with output:\n",
553
  "\u001b[0m{\n",
554
  " \"generations\": [\n",
555
  " [\n",
556
  " {\n",
557
+ " \"text\": \"What motivated the team to use a single-stage model in this project?\",\n",
558
  " \"generation_info\": {\n",
559
  " \"finish_reason\": \"stop\"\n",
560
  " },\n",
 
569
  " \"AIMessage\"\n",
570
  " ],\n",
571
  " \"kwargs\": {\n",
572
+ " \"content\": \"What motivated the team to use a single-stage model in this project?\",\n",
573
  " \"response_metadata\": {\n",
574
  " \"token_usage\": {\n",
575
+ " \"completion_tokens\": 15,\n",
576
  " \"prompt_tokens\": 135,\n",
577
+ " \"total_tokens\": 150\n",
578
  " },\n",
579
  " \"model\": \"\",\n",
580
  " \"finish_reason\": \"stop\"\n",
581
  " },\n",
582
  " \"type\": \"ai\",\n",
583
+ " \"id\": \"run-de54947e-535c-4425-ba1a-6c3ddd069c0a-0\",\n",
584
  " \"tool_calls\": [],\n",
585
  " \"invalid_tool_calls\": []\n",
586
  " }\n",
 
590
  " ],\n",
591
  " \"llm_output\": {\n",
592
  " \"token_usage\": {\n",
593
+ " \"completion_tokens\": 15,\n",
594
  " \"prompt_tokens\": 135,\n",
595
+ " \"total_tokens\": 150\n",
596
  " },\n",
597
  " \"model\": \"\"\n",
598
  " },\n",
 
603
  "\u001b[0m[inputs]\n",
604
  "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence > parser:StrOutputParser] [1ms] Exiting Parser run with output:\n",
605
  "\u001b[0m{\n",
606
+ " \"output\": \"What motivated the team to use a single-stage model in this project?\"\n",
607
  "}\n",
608
+ "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence] [927ms] Exiting Chain run with output:\n",
609
  "\u001b[0m[outputs]\n",
610
+ "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input>] [929ms] Exiting Chain run with output:\n",
611
  "\u001b[0m[outputs]\n",
612
  "\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] Entering Prompt run with input:\n",
613
  "\u001b[0m[inputs]\n",
614
+ "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] [0ms] Exiting Prompt run with output:\n",
615
  "\u001b[0m[outputs]\n",
616
  "\u001b[32;1m\u001b[1;3m[llm/start]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatHuggingFace] Entering LLM run with input:\n",
617
  "\u001b[0m{\n",
618
  " \"prompts\": [\n",
619
+ " \"System: You are an assistant for question-answering tasks. Use the following pieces of retrieved context to answer the question. If you don't know the answer, say that you don't know. Use three sentences maximum and keep the answer concise.\\n\\n[Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 17, 'start_index': 77}, page_content='Page 17 of 69 3 Methodology 3.1 Methodological approach This project adopted a prototyping approach to developing the best model possible to meet the objectives set in section 1.3. The goal of prototyping is to evaluate an idea. After analysing the research presented in chapter 2, it was clear that the best approach to this problem involved removing unnecessary details from the imagery to make the CNN focus more on the features related to each SRM. Almost every paper in chapter 2 avoided single-stage models such as the Single Shot Detector (SSD) due to a lack of performance against two-stage models. Not only did this lead to the decision to create the two-stage models presented this project, but it highlighted the importance of the image pre-processing stage. However, at the time, several ideas for how to execute this objective existed. For this reason, prototyping began on the ROI detector. Prototyping was the necessary approach as it was important to create ROI detectors, each'), Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 60, 'start_index': 77}, page_content='Page 60 of 69 The majority of Stage 4 did not take place at all due to the total amount of delays which amounted during the project. Networks were adapted to the application as mentioned in 6.1 and AlexNet did produce competitive results without further modification. Stage 5 took 1 week longer than expected due to the iterative changes made to the model. Often, as soon as results were gathered, new ideas were implemented into the model which meant experiments had to be run again. For example, during the image segmentation problem shown in section 6.5.3, all CNNs had to be trained and analysed again. It took time to develop a routine for collecting data from models. It was paramount to keep the same conditions for each experiment. This meant occasionally restarting the computer to let it cool down after many sessions of CNN training. These sessions would cause performance of the computer to decrease, and it was then decided not to collect performance measurements for the model'), Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 58, 'start_index': 564}, page_content='6 10/07/2020 - 19/07/2020 27/07/2020 02/08/2020 Begin iterative process of improving performance of model Record iterative improvements Settle on final iteration Critically analyse performance and computational requirements 7 20/07/2020 - 31/07/2020 31/07/2020 14/08/2020 Produce first write-up draft 8 31/07/2020 - 14/08/2020 07/08/2020 14/08/2020 Final opportunity for technical ideas or modifications to proposed model • Consider feedback from supervisor to iteratively improve final project write-up As shown above, the planned project schedule was adhered to for stage 1. This involved searching for and selecting a suitable dataset which contained good quality imagery and ground truth data. Almost all of the first few literature papers at least partly used this dataset to conduct'), Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 60, 'start_index': 1671}, page_content='7.2.2.4. Stage 7 was delayed by over 1 week but only as a results of previous delays. However, it took 1 week longer than expected. This is because of how difficult it was to write the report in a flowing manner. Having a record of tasks completed along with dates prevented this stage from taking any longer. Since stage 7 overran by 1 week, final modifications and adjustments had to be made simultaneously with report writing. 8.2 Quality Management Since many models were tested during this project, it was important to create code scripts, CNN objects and datasets specifically for them. This required a clear naming procedure which is')]You are also given chat history below to help contextualise the question.{'chat_history': [HumanMessage(content=\\\"Hello, my name is Daniel and I work as a data scientist.I'd really enjoyed the methodology section of this project document. Especially the part on single-stage models.\\\", additional_kwargs={}, response_metadata={}), AIMessage(content='Hello Daniel, nice to meet you. Sounds interesting.', additional_kwargs={}, response_metadata={})], 'input': 'Can you remind me of why that type of model was chosen for the project?'}{'chat_history': [HumanMessage(content=\\\"Hello, my name is Daniel and I work as a data scientist.I'd really enjoyed the methodology section of this project document. Especially the part on single-stage models.\\\", additional_kwargs={}, response_metadata={}), AIMessage(content='Hello Daniel, nice to meet you. Sounds interesting.', additional_kwargs={}, response_metadata={})], 'input': 'Can you remind me of why that type of model was chosen for the project?'}\"\n",
620
  " ]\n",
621
  "}\n",
622
+ "\u001b[36;1m\u001b[1;3m[llm/end]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatHuggingFace] [1.50s] Exiting LLM run with output:\n",
623
  "\u001b[0m{\n",
624
  " \"generations\": [\n",
625
  " [\n",
626
  " {\n",
627
+ " \"text\": \"The project chose two-stage models instead of single-stage models like SSD due to a lack of performance against two-stage models, as analyzed in chapter 2. This led to the decision to create the two-stage models presented in the project.\",\n",
628
  " \"generation_info\": {\n",
629
  " \"finish_reason\": \"stop\"\n",
630
  " },\n",
 
639
  " \"AIMessage\"\n",
640
  " ],\n",
641
  " \"kwargs\": {\n",
642
+ " \"content\": \"The project chose two-stage models instead of single-stage models like SSD due to a lack of performance against two-stage models, as analyzed in chapter 2. This led to the decision to create the two-stage models presented in the project.\",\n",
643
  " \"response_metadata\": {\n",
644
  " \"token_usage\": {\n",
645
+ " \"completion_tokens\": 48,\n",
646
+ " \"prompt_tokens\": 1124,\n",
647
+ " \"total_tokens\": 1172\n",
648
  " },\n",
649
  " \"model\": \"\",\n",
650
  " \"finish_reason\": \"stop\"\n",
651
  " },\n",
652
  " \"type\": \"ai\",\n",
653
+ " \"id\": \"run-ccbb3930-f155-4dbf-9678-76a5f9bdbde5-0\",\n",
654
  " \"tool_calls\": [],\n",
655
  " \"invalid_tool_calls\": []\n",
656
  " }\n",
 
660
  " ],\n",
661
  " \"llm_output\": {\n",
662
  " \"token_usage\": {\n",
663
+ " \"completion_tokens\": 48,\n",
664
+ " \"prompt_tokens\": 1124,\n",
665
+ " \"total_tokens\": 1172\n",
666
  " },\n",
667
  " \"model\": \"\"\n",
668
  " },\n",
 
673
  "\u001b[0m[inputs]\n",
674
  "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > parser:StrOutputParser] [0ms] Exiting Parser run with output:\n",
675
  "\u001b[0m{\n",
676
+ " \"output\": \"The project chose two-stage models instead of single-stage models like SSD due to a lack of performance against two-stage models, as analyzed in chapter 2. This led to the decision to create the two-stage models presented in the project.\"\n",
677
  "}\n",
678
+ "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence] [2.43s] Exiting Chain run with output:\n",
679
  "\u001b[0m{\n",
680
+ " \"output\": \"The project chose two-stage models instead of single-stage models like SSD due to a lack of performance against two-stage models, as analyzed in chapter 2. This led to the decision to create the two-stage models presented in the project.\"\n",
681
  "}\n"
682
  ]
683
  }
 
689
  },
690
  {
691
  "cell_type": "code",
692
+ "execution_count": 39,
693
  "metadata": {},
694
  "outputs": [
695
  {
696
  "data": {
697
  "text/plain": [
698
+ "'The project chose two-stage models instead of single-stage models like SSD due to a lack of performance against two-stage models, as analyzed in chapter 2. This led to the decision to create the two-stage models presented in the project.'"
699
  ]
700
  },
701
+ "execution_count": 39,
702
  "metadata": {},
703
  "output_type": "execute_result"
704
  }
 
716
  },
717
  {
718
  "cell_type": "code",
719
+ "execution_count": 40,
720
  "metadata": {},
721
  "outputs": [],
722
  "source": [
 
725
  },
726
  {
727
  "cell_type": "code",
728
+ "execution_count": 41,
729
  "metadata": {},
730
  "outputs": [
731
  {
 
734
  "[HumanMessage(content=\"Hello, my name is Daniel and I work as a data scientist.I'd really enjoyed the methodology section of this project document. Especially the part on single-stage models.\", additional_kwargs={}, response_metadata={}),\n",
735
  " AIMessage(content='Hello Daniel, nice to meet you. Sounds interesting.', additional_kwargs={}, response_metadata={}),\n",
736
  " HumanMessage(content='Can you remind me of why that type of model was chosen for the project?', additional_kwargs={}, response_metadata={}),\n",
737
+ " AIMessage(content='The project chose two-stage models instead of single-stage models like SSD due to a lack of performance against two-stage models, as analyzed in chapter 2. This led to the decision to create the two-stage models presented in the project.', additional_kwargs={}, response_metadata={})]"
738
  ]
739
  },
740
+ "execution_count": 41,
741
  "metadata": {},
742
  "output_type": "execute_result"
743
  }
 
748
  },
749
  {
750
  "cell_type": "code",
751
+ "execution_count": 42,
752
  "metadata": {},
753
  "outputs": [
754
  {
 
763
  "\u001b[0m[inputs]\n",
764
  "\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence > prompt:ChatPromptTemplate] Entering Prompt run with input:\n",
765
  "\u001b[0m[inputs]\n",
766
+ "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence > prompt:ChatPromptTemplate] [0ms] Exiting Prompt run with output:\n",
 
 
 
 
767
  "\u001b[0m[outputs]\n",
768
  "\u001b[32;1m\u001b[1;3m[llm/start]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence > llm:ChatHuggingFace] Entering LLM run with input:\n",
769
  "\u001b[0m{\n",
770
  " \"prompts\": [\n",
771
+ " \"System: Given a chat history and the latest user question which might reference context in the chat history, formulate a standalone question which can be understood without the chat history. Do NOT answer the question, just reformulate it if needed and otherwise return it as is.\\nHuman: Hello, my name is Daniel and I work as a data scientist.I'd really enjoyed the methodology section of this project document. Especially the part on single-stage models.\\nAI: Hello Daniel, nice to meet you. Sounds interesting.\\nHuman: Can you remind me of why that type of model was chosen for the project?\\nAI: The project chose two-stage models instead of single-stage models like SSD due to a lack of performance against two-stage models, as analyzed in chapter 2. This led to the decision to create the two-stage models presented in the project.\\nHuman: And was anything said about the other type of model?\"\n",
772
  " ]\n",
773
  "}\n",
774
  "\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnablePassthrough] Entering Chain run with input:\n",
775
  "\u001b[0m[inputs]\n",
776
+ "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnablePassthrough] [1ms] Exiting Chain run with output:\n",
777
+ "\u001b[0m[outputs]\n",
778
+ "\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnablePassthrough] Entering Chain run with input:\n",
779
+ "\u001b[0m[inputs]\n",
780
  "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnablePassthrough] [0ms] Exiting Chain run with output:\n",
781
  "\u001b[0m[outputs]\n",
782
+ "\u001b[36;1m\u001b[1;3m[llm/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence > llm:ChatHuggingFace] [421ms] Exiting LLM run with output:\n",
783
  "\u001b[0m{\n",
784
  " \"generations\": [\n",
785
  " [\n",
786
  " {\n",
787
+ " \"text\": \"What do you mean by \\\"other type of model\\\"?\",\n",
788
  " \"generation_info\": {\n",
789
  " \"finish_reason\": \"stop\"\n",
790
  " },\n",
 
799
  " \"AIMessage\"\n",
800
  " ],\n",
801
  " \"kwargs\": {\n",
802
+ " \"content\": \"What do you mean by \\\"other type of model\\\"?\",\n",
803
  " \"response_metadata\": {\n",
804
  " \"token_usage\": {\n",
805
+ " \"completion_tokens\": 12,\n",
806
+ " \"prompt_tokens\": 203,\n",
807
+ " \"total_tokens\": 215\n",
808
  " },\n",
809
  " \"model\": \"\",\n",
810
  " \"finish_reason\": \"stop\"\n",
811
  " },\n",
812
  " \"type\": \"ai\",\n",
813
+ " \"id\": \"run-90e9ccf6-5343-4e33-b21b-5bbb45235c34-0\",\n",
814
  " \"tool_calls\": [],\n",
815
  " \"invalid_tool_calls\": []\n",
816
  " }\n",
 
820
  " ],\n",
821
  " \"llm_output\": {\n",
822
  " \"token_usage\": {\n",
823
+ " \"completion_tokens\": 12,\n",
824
+ " \"prompt_tokens\": 203,\n",
825
+ " \"total_tokens\": 215\n",
826
  " },\n",
827
  " \"model\": \"\"\n",
828
  " },\n",
 
833
  "\u001b[0m[inputs]\n",
834
  "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence > parser:StrOutputParser] [0ms] Exiting Parser run with output:\n",
835
  "\u001b[0m{\n",
836
+ " \"output\": \"What do you mean by \\\"other type of model\\\"?\"\n",
837
  "}\n",
838
+ "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input> > chain:RunnableSequence] [729ms] Exiting Chain run with output:\n",
839
  "\u001b[0m[outputs]\n",
840
+ "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > chain:RunnableParallel<context,chat_history,input>] [730ms] Exiting Chain run with output:\n",
841
  "\u001b[0m[outputs]\n",
842
  "\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] Entering Prompt run with input:\n",
843
  "\u001b[0m[inputs]\n",
 
846
  "\u001b[32;1m\u001b[1;3m[llm/start]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatHuggingFace] Entering LLM run with input:\n",
847
  "\u001b[0m{\n",
848
  " \"prompts\": [\n",
849
+ " \"System: You are an assistant for question-answering tasks. Use the following pieces of retrieved context to answer the question. If you don't know the answer, say that you don't know. Use three sentences maximum and keep the answer concise.\\n\\n[Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 17, 'start_index': 77}, page_content='Page 17 of 69 3 Methodology 3.1 Methodological approach This project adopted a prototyping approach to developing the best model possible to meet the objectives set in section 1.3. The goal of prototyping is to evaluate an idea. After analysing the research presented in chapter 2, it was clear that the best approach to this problem involved removing unnecessary details from the imagery to make the CNN focus more on the features related to each SRM. Almost every paper in chapter 2 avoided single-stage models such as the Single Shot Detector (SSD) due to a lack of performance against two-stage models. Not only did this lead to the decision to create the two-stage models presented this project, but it highlighted the importance of the image pre-processing stage. However, at the time, several ideas for how to execute this objective existed. For this reason, prototyping began on the ROI detector. Prototyping was the necessary approach as it was important to create ROI detectors, each'), Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 50, 'start_index': 870}, page_content='which makes this example a prime one to investigate the differences between the models. As shown in the classification matrix, this misclassification only occurs happens three times between these two classes. By observing the scores in the bottom left image of Figure 42, the CNN was most confident about leftturn followed by 40 and finally 35.'), Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 9, 'start_index': 77}, page_content='Page 9 of 69 2 Literature Review Previous research in this application of detecting or classifying SRMs involve methods which can be split into two main categories: (1) explicitly specifying features such as colour, edges and using machine learning to extract those features in images. And (2), using deep learning to detect more abstract and complex features. Deep learning methods can be further split into two categories: two-stage such as R-CNN (R. Girshick et al., 2014), Fast R-CNN (R. Girshick, 2015), Faster R-CNN (R. Girshick et al., 2017), Feature Pyramid Networks (FPN) (T.-Y. Lin et al., 2017) and mask R-CNN (K. He et al., 2017) and single-stage models such as the Single Shot Detector (SSD) (W. Liu et al., 2016) and You Only Look Once (YOLO) (J. Redmon and A. Farhadi, 2018). Two-stage models consist of a region proposal unit which pre-processes images in preparation for deep learning architectures. Not knowing what features a deep learning model has learned is what makes deep'), Document(metadata={'source': 'example_documents/deep_learning.pdf', 'page': 9, 'start_index': 880}, page_content='models consist of a region proposal unit which pre-processes images in preparation for deep learning architectures. Not knowing what features a deep learning model has learned is what makes deep learning, especially deep CNNs, a ‘black box’ type of technology. The latest research in the classification and detection of SRMs has begun to involve more and more deep learning. In relative terms, a much lower amount of research has been conducted in total when compared with research into detecting pedestrians, vehicles, lane markings and traffic lights (Touqeer Ahmad et al., 2017). This is mainly due to the lack of ground truth data available for SRMs. Only after new datasets have emerged such as: Cambridge (Cambridge-Driving Labeled Video Database (CamVid), Oct. 2018), Daimler (Daimler Urban Segmentation Dataset, Jan. 2019), Malaga (The Málaga Stereo and Laser Urban Data Set—MRPT, Oct. 2018), KITTI (A. Geiger et al., 2013) and others, more time been dedicated into this specific')]You are also given chat history below to help contextualise the question.{'chat_history': [HumanMessage(content=\\\"Hello, my name is Daniel and I work as a data scientist.I'd really enjoyed the methodology section of this project document. Especially the part on single-stage models.\\\", additional_kwargs={}, response_metadata={}), AIMessage(content='Hello Daniel, nice to meet you. Sounds interesting.', additional_kwargs={}, response_metadata={}), HumanMessage(content='Can you remind me of why that type of model was chosen for the project?', additional_kwargs={}, response_metadata={}), AIMessage(content='The project chose two-stage models instead of single-stage models like SSD due to a lack of performance against two-stage models, as analyzed in chapter 2. This led to the decision to create the two-stage models presented in the project.', additional_kwargs={}, response_metadata={})], 'input': 'And was anything said about the other type of model?'}{'chat_history': [HumanMessage(content=\\\"Hello, my name is Daniel and I work as a data scientist.I'd really enjoyed the methodology section of this project document. Especially the part on single-stage models.\\\", additional_kwargs={}, response_metadata={}), AIMessage(content='Hello Daniel, nice to meet you. Sounds interesting.', additional_kwargs={}, response_metadata={}), HumanMessage(content='Can you remind me of why that type of model was chosen for the project?', additional_kwargs={}, response_metadata={}), AIMessage(content='The project chose two-stage models instead of single-stage models like SSD due to a lack of performance against two-stage models, as analyzed in chapter 2. This led to the decision to create the two-stage models presented in the project.', additional_kwargs={}, response_metadata={})], 'input': 'And was anything said about the other type of model?'}\"\n",
850
  " ]\n",
851
  "}\n",
852
+ "\u001b[36;1m\u001b[1;3m[llm/end]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatHuggingFace] [1.56s] Exiting LLM run with output:\n",
853
  "\u001b[0m{\n",
854
  " \"generations\": [\n",
855
  " [\n",
856
  " {\n",
857
+ " \"text\": \"The document mentions Single Shot Detector (SSD) as a single-stage model, and explains why it was not chosen for the project. However, it does not provide any further information about SSD or other single-stage models beyond that.\",\n",
858
  " \"generation_info\": {\n",
859
  " \"finish_reason\": \"stop\"\n",
860
  " },\n",
 
869
  " \"AIMessage\"\n",
870
  " ],\n",
871
  " \"kwargs\": {\n",
872
+ " \"content\": \"The document mentions Single Shot Detector (SSD) as a single-stage model, and explains why it was not chosen for the project. However, it does not provide any further information about SSD or other single-stage models beyond that.\",\n",
873
  " \"response_metadata\": {\n",
874
  " \"token_usage\": {\n",
875
+ " \"completion_tokens\": 47,\n",
876
+ " \"prompt_tokens\": 1290,\n",
877
+ " \"total_tokens\": 1337\n",
878
  " },\n",
879
  " \"model\": \"\",\n",
880
  " \"finish_reason\": \"stop\"\n",
881
  " },\n",
882
  " \"type\": \"ai\",\n",
883
+ " \"id\": \"run-f6e26267-2dbb-44a7-b4c3-314540be13d9-0\",\n",
884
  " \"tool_calls\": [],\n",
885
  " \"invalid_tool_calls\": []\n",
886
  " }\n",
 
890
  " ],\n",
891
  " \"llm_output\": {\n",
892
  " \"token_usage\": {\n",
893
+ " \"completion_tokens\": 47,\n",
894
+ " \"prompt_tokens\": 1290,\n",
895
+ " \"total_tokens\": 1337\n",
896
  " },\n",
897
  " \"model\": \"\"\n",
898
  " },\n",
 
903
  "\u001b[0m[inputs]\n",
904
  "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > parser:StrOutputParser] [0ms] Exiting Parser run with output:\n",
905
  "\u001b[0m{\n",
906
+ " \"output\": \"The document mentions Single Shot Detector (SSD) as a single-stage model, and explains why it was not chosen for the project. However, it does not provide any further information about SSD or other single-stage models beyond that.\"\n",
907
  "}\n",
908
+ "\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence] [2.30s] Exiting Chain run with output:\n",
909
  "\u001b[0m{\n",
910
+ " \"output\": \"The document mentions Single Shot Detector (SSD) as a single-stage model, and explains why it was not chosen for the project. However, it does not provide any further information about SSD or other single-stage models beyond that.\"\n",
911
  "}\n"
912
  ]
913
  }
 
919
  " config={'callbacks': [ConsoleCallbackHandler()]})"
920
  ]
921
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
922
  {
923
  "cell_type": "code",
924
  "execution_count": null,