Repository: informagi/REL (language: python)

Issue:
Documentation update
Hi all, there is quite nice documentation already in the tutorials section, but it is somewhat difficult to navigate. As discussed with @KDercksen , I will implement a documentation system so that the the docs are easier to work with. This issue tracks the progress.

- [ ] Re-organize docs so that they can be built using [mkdocs](https://www.mkdocs.org/)
- [ ] Host docs on [readthedocs.io](http://readthedocs.io/)


Discussion / hints:

Fix patch:
diff --git a/.readthedocs.yaml b/.readthedocs.yaml
new file mode 100644
index 0000000..0c1ef3d
--- /dev/null
+++ b/.readthedocs.yaml
@@ -0,0 +1,24 @@
+# .readthedocs.yaml
+# Read the Docs configuration file
+# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
+
+# Required
+version: 2
+
+# Set the version of Python and other tools you might need
+build:
+  os: ubuntu-20.04
+  tools:
+    python: "3.7"
+
+# Build documentation in the docs/ directory with Sphinx
+mkdocs:
+  configuration: mkdocs.yml
+
+# Optionally declare the Python requirements required to build your docs
+python:
+   install:
+   - method: pip
+     path: .
+     extra_requirements:
+      - docs
diff --git a/README.md b/README.md
index 790268a..2c193eb 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
 # REL: Radboud Entity Linker
 
-![API status](https://img.shields.io/endpoint?label=status&url=https%3A%2F%2Frel.cs.ru.nl%2Fapi)
-![build](https://github.com/informagi/REL/workflows/build/badge.svg)
+[![API status](https://img.shields.io/endpoint?label=status&url=https%3A%2F%2Frel.cs.ru.nl%2Fapi)](https://rel.cs.ru.nl/api)
+[![build](https://github.com/informagi/REL/workflows/build/badge.svg)](https://github.com/informagi/REL/actions/workflows/build.yaml)
 
 REL is a modular Entity Linking package that is provided as a Python package as well as a web API. REL has various meanings -  one might first notice that it stands for relation, which is a suiting name for the problems that can be tackled with this package. Additionally, in Dutch a 'rel' means a disturbance of the public order, which is exactly what we aim to achieve with the release of this package.
 
@@ -9,7 +9,7 @@ REL utilizes *English* Wikipedia as a knowledge base and can be used for the fol
 - **Entity linking (EL)**: Given a text, the system outputs a list of mention-entity pairs, where each mention is a n-gram from text and each entity is an entity in the knowledge base.
 - **Entity Disambiguation (ED)**: Given a text and a list of mentions, the system assigns an entity (or NIL) to each mention.
 
-# REL variants
+## REL variants
 
 REL comes in two variants for identifying entity mentions:
 
@@ -28,10 +28,10 @@ Below is a comparison of these two models on [CoNLL-2003 NER](https://www.clips.
 | `ner-fast-with-lowercase`  |  lower-cased | 89.73 |
 | `ner-fast-with-lowercase`  |  random | 89.66 |
 
-See [Notes on using custom models](https://github.com/informagi/REL/tree/master/tutorials/07_custom_models.md) for further information on switiching between these variants.
+See [Notes on using custom models](https://rel.readthedocs.io/en/latest/tutorials/custom_models/) for further information on switiching between these variants.
 
 
-# Calling our API
+## Calling our API
 
 Users may access our API by using the example script below. 
 For EL, the `spans` field needs to be set to an empty list. For ED, however, the `spans` field should consist of a list of tuples, where each tuple refers to the start position and length of a mention.
@@ -55,23 +55,28 @@ ed_result = requests.post(API_URL, json={
 }).json()
 ```
 
-# Setup package
+## Setup package
+
 This section describes how to deploy REL on a local machine and setup the API. If you want to do anything more than simply running our API locally, you can skip the Docker steps and continue with installation from source.
 
-## Option 1: Installation using Docker
+### Option 1: Installation using Docker
+
 First, download the necessary data; you need the generic files and a Wikipedia version (2014 or 2019) (see [Download](#download)). Extract them anywhere, we will bind the directories to the Docker container as volumes.
 
 ```bash
 ./scripts/download_data.sh ./data generic wiki_2019
 ```
 
-### Prebuilt images
+#### Prebuilt images
+
 To use our prebuilt default image, run:
+
 ```bash
 docker pull informagi/rel
 ```
 
 To run the API locally:
+
 ```bash
 # Map container port 5555 to local port 5555, and use Wikipedia 2019
 # Also map the generic and wiki_2019 folders to directories in Docker container
@@ -85,8 +90,10 @@ docker run \
 Now you can make requests to `http://localhost:5555` (or another port if you
 use a different mapping) in the format described in the example above.
 
-### Build your own Docker image
+#### Build your own Docker image
+
 To build the Docker image yourself, run:
+
 ```bash
 # Clone the repository
 git clone https://github.com/informagi/REL && cd REL
@@ -96,14 +103,17 @@ docker build . -t informagi/rel
 
 To run the API locally, use the same commands as mentioned in the previous section.
 
-##  Option 2: Installation from source code
+### Option 2: Installation from source code
+
 Run the following command in a terminal to install REL:
-```
+
+```bash
 pip install git+https://github.com/informagi/REL
 ```
 You will also need to manually download the files described in the next section.
 
-## Download
+### Download data
+
 The files used for this project can be divided into three categories. The first is a generic set of documents and embeddings that was used throughout the project. This folder includes the GloVe embeddings and the unprocessed datasets that were used to train the ED model. The second and third category are Wikipedia corpus related files, which in our case either originate from a 2014 or 2019 corpus. Alternatively, users may use their own corpus, for which we refer to the tutorials.
 
 * [Download generic files](http://gem.cs.ru.nl/generic.tar.gz)
@@ -112,25 +122,25 @@ The files used for this project can be divided into three categories. The first
 * [Download Wikipedia corpus (2019)](http://gem.cs.ru.nl/wiki_2019.tar.gz)
 * [Download ED model 2019](http://gem.cs.ru.nl/ed-wiki-2019.tar.gz)
 
-## Tutorials
-To promote usage of this package we developed various tutorials. If you simply want to use our API, then 
-we refer to the section above. If you feel one is missing or unclear, then please create an issue, which is much appreciated :)! The first two tutorials are
+### Tutorials
+
+To promote usage of this package we developed various [tutorials](https://rel.readthedocs.io/en/latest/tutorials/). If you simply want to use our API, then 
+we refer to the section above. If you feel one is missing or unclear, then please create an [issue](https://github.com/informagi/REL/issues), which is much appreciated :)! 
+
+The first two tutorials are
 for users who simply want to use our package for EL/ED and will be using the data files that we provide. 
 The remainder of the tutorials are optional and for users who wish to e.g. train their own Embeddings.
 
-1. [How to get started (project folder and structure).](https://github.com/informagi/REL/tree/master/tutorials/01_How_to_get_started.md)
-2. [End-to-End Entity Linking.](https://github.com/informagi/REL/tree/master/tutorials/02_E2E_Entity_Linking.md)
-3. [Evaluate on GERBIL.](https://github.com/informagi/REL/tree/master/tutorials/03_Evaluate_Gerbil.md)
-4. [Deploy REL for a new Wikipedia corpus](https://github.com/informagi/REL/tree/master/tutorials/deploy_REL_new_Wiki/04_deploy_REL_new_wiki.md):
-    1. [Extracting a new Wikipedia corpus and creating a p(e|m) index.](https://github.com/informagi/REL/tree/master/tutorials/deploy_REL_new_Wiki/04_01_Extracting_a_new_Wikipedia_corpus.md)
-    2. [Training your own Embeddings.](https://github.com/informagi/REL/tree/master/tutorials/deploy_REL_new_Wiki/04_02_training_your_own_embeddings.md)
-    3. [Generating training, validation and test files.](https://github.com/informagi/REL/tree/master/tutorials/deploy_REL_new_Wiki/04_03_generating_training_test_files.md)
-    4. [Training your own Entity Disambiguation model.](https://github.com/informagi/REL/tree/master/tutorials/deploy_REL_new_Wiki/04_04_training_your_own_ED_model.md)
-5. [Reproducing our results](https://github.com/informagi/REL/tree/master/tutorials/05_reproducing_our_results.md)
-6. [REL as systemd service](https://github.com/informagi/REL/tree/master/tutorials/06_systemd_instructions.md)
-7. [Notes on using custom models](https://github.com/informagi/REL/tree/master/tutorials/07_custom_models.md)
-
-# Efficiency of REL
+1. [How to get started (project folder and structure).](https://rel.readthedocs.io/en/latest/tutorials/how_to_get_started/)
+2. [End-to-End Entity Linking.](https://rel.readthedocs.io/en/latest/tutorials/e2e_entity_linking/)
+3. [Evaluate on GERBIL.](https://rel.readthedocs.io/en/latest/tutorials/evaluate_gerbil/)
+4. [Deploy REL for a new Wikipedia corpus](https://rel.readthedocs.io/en/latest/tutorials/deploy_REL_new_wiki/):
+5. [Reproducing our results](https://rel.readthedocs.io/en/latest/tutorials/reproducing_our_results/)
+6. [REL as systemd service](https://rel.readthedocs.io/en/latest/tutorials/systemd_instructions/)
+7. [Notes on using custom models](https://rel.readthedocs.io/en/latest/tutorials/custom_models/)
+
+## Efficiency of REL
+
 We measured the efficiency of REL on a per-document basis. We ran our API with 50 documents from AIDA-B with > 200 words, which is 323 (± 105) words and 42 (± 19) mentions per document. The results are added to the table below.
 
 | Model  | Time MD | Time ED |
@@ -140,10 +150,11 @@ We measured the efficiency of REL on a per-document basis. We ran our API with 5
 
 As our package has changed overtime, we refer to one of our [earlier commits](https://github.com/informagi/REL/tree/a0a93487ecc640a72f33ffe015a7a34dff8f054f) for reproducing the results in the table above. To reproduce the results above, perform the following steps:
 1. Start the server. As can be seen in `server.py`, we added [checkpoints in our server calls](https://github.com/informagi/REL/blob/a0a93487ecc640a72f33ffe015a7a34dff8f054f/REL/server.py#L82) to measure time taken per call.
-3. Once the server is started, run the [efficiency test](https://github.com/informagi/REL/blob/a0a93487ecc640a72f33ffe015a7a34dff8f054f/scripts/efficiency_test.py). Do not forget to update the `base_url` to specify where the data is located in the filesystem. This directory refers to where all project-related data is stored (see our [tutorial on how to get started](https://github.com/informagi/REL/blob/master/tutorials/01_How_to_get_started.md)
+3. Once the server is started, run the [efficiency test](https://github.com/informagi/REL/blob/a0a93487ecc640a72f33ffe015a7a34dff8f054f/scripts/efficiency_test.py). Do not forget to update the `base_url` to specify where the data is located in the filesystem. This directory refers to where all project-related data is stored (see our [tutorial on how to get started](https://rel.readthedocs.io/en/latest/tutorials/how_to_get_started/)
 4. Finally, process the [efficiency results](https://github.com/informagi/REL/blob/a0a93487ecc640a72f33ffe015a7a34dff8f054f/scripts/efficiency_results.py).
 
-# Cite
+## Cite
+
 If you are using REL, please cite the following paper:
 
 ```bibtex
@@ -157,8 +168,10 @@ If you are using REL, please cite the following paper:
 }
 ```
 
-# Contact
+## Contact
+
 If you find any bugs or experience difficulties when using REL, please create a issue on this Github page. If you have any specific questions with respect to our research with REL, please email [Mick van Hulst](mailto:mick.vanhulst@gmail.com).
 
-# Acknowledgements
+## Acknowledgements
+
 Our thanks go out to the authors that open-sourced their code, enabling us to create this package that can hopefully be of service to many.
diff --git a/REL/entity_disambiguation.py b/REL/entity_disambiguation.py
index 70a43ee..eec44a4 100644
--- a/REL/entity_disambiguation.py
+++ b/REL/entity_disambiguation.py
@@ -23,15 +23,15 @@
 from REL.training_datasets import TrainingEvaluationDatasets
 from REL.vocabulary import Vocabulary
 
-"""
-Parent Entity Disambiguation class that directs the various subclasses used
-for the ED step.
-"""
 
 wiki_prefix = "en.wikipedia.org/wiki/"
 
 
 class EntityDisambiguation:
+    """
+    Parent Entity Disambiguation class that directs the various subclasses used
+    for the ED step.
+    """
     def __init__(self, base_url, wiki_version, user_config, reset_embeddings=False):
         self.base_url = base_url
         self.wiki_version = wiki_version
diff --git a/REL/mention_detection.py b/REL/mention_detection.py
index 89c184b..fc552ed 100644
--- a/REL/mention_detection.py
+++ b/REL/mention_detection.py
@@ -4,12 +4,12 @@
 
 from REL.mention_detection_base import MentionDetectionBase
 
-"""
-Class responsible for mention detection.
-"""
 
 
 class MentionDetection(MentionDetectionBase):
+    """
+    Class responsible for mention detection.
+    """
     def __init__(self, base_url, wiki_version):
         self.cnt_exact = 0
         self.cnt_partial = 0
diff --git a/REL/mulrel_ranker.py b/REL/mulrel_ranker.py
index 9166ad3..56aa71f 100644
--- a/REL/mulrel_ranker.py
+++ b/REL/mulrel_ranker.py
@@ -3,13 +3,13 @@
 import torch.nn.functional as F
 from torch.autograd import Variable
 
-"""
-PreRank class is used for preranking entities for a given mention by multiplying entity vectors with
-word vectors
-"""
 
 
 class PreRank(torch.nn.Module):
+    """
+    PreRank class is used for preranking entities for a given mention by multiplying entity vectors with
+    word vectors
+    """
     def __init__(self, config, embeddings=None):
         super(PreRank, self).__init__()
         self.config = config
diff --git a/REL/server.py b/REL/server.py
index d7e42c4..d26d6a9 100644
--- a/REL/server.py
+++ b/REL/server.py
@@ -8,12 +8,12 @@
 
 API_DOC = "API_DOC"
 
-"""
-Class/function combination that is used to setup an API that can be used for e.g. GERBIL evaluation.
-"""
 
 
 def make_handler(base_url, wiki_version, model, tagger_ner):
+    """
+    Class/function combination that is used to setup an API that can be used for e.g. GERBIL evaluation.
+    """
     class GetHandler(BaseHTTPRequestHandler):
         def __init__(self, *args, **kwargs):
             self.model = model
diff --git a/REL/training_datasets.py b/REL/training_datasets.py
index 6ffb97a..f12abac 100644
--- a/REL/training_datasets.py
+++ b/REL/training_datasets.py
@@ -1,14 +1,12 @@
 import os
 import pickle
 
-"""
-Class responsible for loading training/evaluation datasets for local ED.
-"""
-
 
 class TrainingEvaluationDatasets:
     """
-    reading dataset from CoNLL dataset, extracted by https://github.com/dalab/deep-ed/
+    Class responsible for loading training/evaluation datasets for local ED.
+    
+    Reading dataset from CoNLL dataset, extracted by https://github.com/dalab/deep-ed/
     """
 
     def __init__(self, base_url, wiki_version):
diff --git a/REL/vocabulary.py b/REL/vocabulary.py
index e7482df..e70d293 100644
--- a/REL/vocabulary.py
+++ b/REL/vocabulary.py
@@ -13,12 +13,12 @@
     "-RSB-": "]",
 }
 
-"""
-Class that creates a Vocabulary object that is used to store references to Embeddings.
-"""
 
 
 class Vocabulary:
+    """
+    Class that creates a Vocabulary object that is used to store references to Embeddings.
+    """
     unk_token = UNK_TOKEN
 
     def __init__(self):
diff --git a/REL/wikipedia.py b/REL/wikipedia.py
index 0a562c7..0c607ef 100644
--- a/REL/wikipedia.py
+++ b/REL/wikipedia.py
@@ -3,12 +3,12 @@
 
 from REL.utils import first_letter_to_uppercase, trim1
 
-"""
-Class responsible for loading Wikipedia files. Required when filling sqlite3 database with e.g. p(e|m) index.
-"""
 
 
 class Wikipedia:
+    """
+    Class responsible for loading Wikipedia files. Required when filling sqlite3 database with e.g. p(e|m) index.
+    """
     def __init__(self, base_url, wiki_version):
         self.base_url = base_url + wiki_version
         # if include_wiki_id_name:
diff --git a/REL/wikipedia_yago_freq.py b/REL/wikipedia_yago_freq.py
index 8c95456..003c0f5 100644
--- a/REL/wikipedia_yago_freq.py
+++ b/REL/wikipedia_yago_freq.py
@@ -7,13 +7,13 @@
 from REL.db.generic import GenericLookup
 from REL.utils import first_letter_to_uppercase, trim1, unicode2ascii
 
-"""
-Class responsible for processing Wikipedia dumps. Performs computations to obtain the p(e|m) index and counts 
-overall occurrences of mentions.
-"""
 
 
 class WikipediaYagoFreq:
+    """
+    Class responsible for processing Wikipedia dumps. Performs computations to obtain the p(e|m) index and counts 
+    overall occurrences of mentions.
+    """
     def __init__(self, base_url, wiki_version, wikipedia):
         self.base_url = base_url
         self.wiki_version = wiki_version
diff --git a/docs/api/entity_disambiguation.md b/docs/api/entity_disambiguation.md
new file mode 100644
index 0000000..65064d8
--- /dev/null
+++ b/docs/api/entity_disambiguation.md
@@ -0,0 +1,2 @@
+::: REL.entity_disambiguation
+
diff --git a/docs/api/mention_detection.md b/docs/api/mention_detection.md
new file mode 100644
index 0000000..1a7e5b8
--- /dev/null
+++ b/docs/api/mention_detection.md
@@ -0,0 +1,1 @@
+::: REL.mention_detection
diff --git a/docs/api/mulrel_ranker.md b/docs/api/mulrel_ranker.md
new file mode 100644
index 0000000..6ad0d1b
--- /dev/null
+++ b/docs/api/mulrel_ranker.md
@@ -0,0 +1,1 @@
+::: REL.mulrel_ranker
diff --git a/docs/api/server.md b/docs/api/server.md
new file mode 100644
index 0000000..3f0b88b
--- /dev/null
+++ b/docs/api/server.md
@@ -0,0 +1,1 @@
+::: REL.server
diff --git a/docs/api/training_datasets.md b/docs/api/training_datasets.md
new file mode 100644
index 0000000..8a9299b
--- /dev/null
+++ b/docs/api/training_datasets.md
@@ -0,0 +1,1 @@
+::: REL.training_datasets
diff --git a/docs/api/utils.md b/docs/api/utils.md
new file mode 100644
index 0000000..2a946b2
--- /dev/null
+++ b/docs/api/utils.md
@@ -0,0 +1,1 @@
+::: REL.utils
diff --git a/docs/api/vocabulary.md b/docs/api/vocabulary.md
new file mode 100644
index 0000000..ae1ef38
--- /dev/null
+++ b/docs/api/vocabulary.md
@@ -0,0 +1,1 @@
+::: REL.vocabulary
diff --git a/docs/api/wikipedia.md b/docs/api/wikipedia.md
new file mode 100644
index 0000000..ac19b8c
--- /dev/null
+++ b/docs/api/wikipedia.md
@@ -0,0 +1,1 @@
+::: REL.wikipedia
diff --git a/docs/api/wikipedia_yago_freq.md b/docs/api/wikipedia_yago_freq.md
new file mode 100644
index 0000000..00781b4
--- /dev/null
+++ b/docs/api/wikipedia_yago_freq.md
@@ -0,0 +1,1 @@
+::: REL.wikipedia_yago_freq
diff --git a/docs/contributing.md b/docs/contributing.md
new file mode 100644
index 0000000..19be3a4
--- /dev/null
+++ b/docs/contributing.md
@@ -0,0 +1,51 @@
+# Getting started with development
+
+## Setup
+
+*REL* is compatible with Python 3.7 or higher.
+
+Clone the repository:
+
+```console
+git clone https://github.com/informagi/REL.git
+```
+
+Install using `virtualenv`:
+
+```console
+cd REL
+python -m venv env
+source env/bin/activate
+python -m pip install -e .[develop]
+```
+
+Alternatively, install using Conda:
+
+```console
+cd REL
+conda create -n REL python=3.8
+conda activate REL
+pip install -e .[develop]
+```
+
+## Running tests
+
+REL uses [pytest](https://docs.pytest.org/) to run the tests. You can run the tests for yourself using:
+
+```console
+pytest
+```
+
+## Updating/Building the documentation
+
+The documentation is written in [markdown](https://www.markdownguide.org/basic-syntax/), and uses [mkdocs](https://www.mkdocs.org/) to generate the pages.
+
+To build the documentation for yourself:
+
+```console
+pip install -e .[docs]
+mkdocs serve
+```
+
+You can find the documentation source in the [docs](https://github.com/informagi/REL/tree/main/docs) directory. 
+If you are adding new pages, make sure to update the listing in the [`mkdocs.yml`](https://github.com/informagi/REL/blob/mkdocs/mkdocs.yml) under the `nav` entry.
diff --git a/docs/index.md b/docs/index.md
new file mode 100644
index 0000000..7d211af
--- /dev/null
+++ b/docs/index.md
@@ -0,0 +1,1 @@
+{!../README.md!}
diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css
new file mode 100644
index 0000000..e391cf9
--- /dev/null
+++ b/docs/stylesheets/extra.css
@@ -0,0 +1,6 @@
+/* Indentation. */
+div.doc-contents:not(.first) {
+  padding-left: 25px;
+  border-left: .05rem solid var(--md-default-fg-color--lightest);
+  margin-bottom: 80px;
+}
diff --git a/tutorials/07_custom_models.md b/docs/tutorials/custom_models.md
similarity index 95%
rename from tutorials/07_custom_models.md
rename to docs/tutorials/custom_models.md
index 290a1c5..5dca8c2 100644
--- a/tutorials/07_custom_models.md
+++ b/docs/tutorials/custom_models.md
@@ -1,4 +1,5 @@
 # Notes on using custom models with REL
+
 It is easy to swap out parts of REL's pipeline with different models. REL
 contains infrastructure to easily download and use models provided by us, but
 you can also define your own models. In this tutorial, we outline some possible
@@ -15,10 +16,11 @@ model, you can only use a local filepath.
     - [Local or remote archives](#local-or-remote-archives)
 - [Under the hood](#under-the-hood)
 
-# Loading semantics
+## Loading semantics
+
 NER and ED models that we provide as part of REL can be loaded easily using
 aliases.  Available models are listed
-[here](https://github.com/informagi/REL/tree/master/REL/models/models.json).
+[on the REL repository](https://github.com/informagi/REL/tree/master/REL/models/models.json).
 All models that need to be downloaded from the web are cached for subsequent
 use.
 
@@ -27,7 +29,8 @@ use.
 Additionally, fields that accept aliases also take URLs and regular file paths
 as values.
 
-## Examples
+### Examples
+
 Loading Flair NER models:
 ```python
 from REL.ner import load_flair_ner
@@ -57,7 +60,7 @@ the model, you can supply either a local filepath without extension, or a
 URL/filepath to a tarfile containing the two files. Examples of the required
 directory structure are shown below.
 
-### Aliases
+#### Aliases
 Loading an ED model using a REL alias is simple. Pass the alias string to the
 `model_path` key in the configuration, e.g.:
 ```python
@@ -72,7 +75,7 @@ config = {
 ed_model = EntityDisambiguation(base_url, wiki_version, config)
 ```
 
-### Local filepath
+#### Local filepath
 Required directory structure:
 ```
 model_folder
@@ -97,7 +100,7 @@ config = {
 ed_model = EntityDisambiguation(base_url, wiki_version, config)
 ```
 
-### Local or remote archives
+#### Local or remote archives
 Required archive structure:
 ```
 Filename: model_folder.tar
@@ -140,7 +143,7 @@ config = {
 ed_model = EntityDisambiguation(base_url, wiki_version, config)
 ```
 
-# Under the hood
+## Under the hood
 All the remote model loading functionality is built on `REL.utils.fetch_model`.
 This function tries to get a URL from `models.json` if applicable, and then
 downloads and caches the model checkpoint. You can use this function yourself
diff --git a/docs/tutorials/deploy_REL_new_wiki.md b/docs/tutorials/deploy_REL_new_wiki.md
new file mode 100644
index 0000000..bbde38e
--- /dev/null
+++ b/docs/tutorials/deploy_REL_new_wiki.md
@@ -0,0 +1,191 @@
+# Deploy REL for a new Wikipedia corpus
+
+Although we will do our best to continuously provide the community with recent corpuses, it may be the case that a user wants to, for example, use
+an older corpus for a specific evaluation. For this reason we provide the user with the option to do so. We must, however,
+note that some steps are outside the scope of the REL package, which makes support for some of these steps a difficult task.
+
+This tutorial is divided in four parts. The first part deals with [extracting a Wikipedia corpus and creating a p(e|m) index](#extracting-a-wikipedia-dump).
+After extracting the aforementioned index and thus obtaining a sqlite3 database, we are also in need of Embeddings. We obtain new embeddings by [training a Wikipedia2Vec model](#training-wikipedia2vec-embeddings).
+To train our own Entity Disambiguation model, we need to [generate training, validation and test files](#generate-training-validation-and-test-files).
+These aforementioned p(e|m) index,  can be used to [train your own Entity Disambiguation model](#training-your-own-entity-disambiguation-model). 
+After obtaining this model, a user may choose to [evaluate the obtained model on Gerbil](../evaluate_gerbil/) or for [E2E Entity Linking](../e2e_entity_linking/).
+
+## Creating a folder structure
+
+Previously we have defined our `base_url`, but now we need to create a new sub folder in our directory to obtain 
+the following folder structure:
+
+```
+.
+├── generic
+└─── wiki_2014
+|   ├── basic_data
+|      └── anchor_files
+|   └── generated
+└─── wiki_2019
+|   ├── basic_data
+|      └── anchor_files
+|   └── generated
+└─── your_corpus_name
+|   ├── basic_data
+|      └── anchor_files
+|   └── generated
+```
+
+### Extracting a Wikipedia dump
+
+There are several platforms that host [Wikipedia dumps](https://dumps.wikimedia.org/). These platforms provide `xml` files that need processing. 
+A tool that does this is called [WikiExtractor](https://github.com/attardi/wikiextractor). This tool takes as an input a
+Wikipedia dump and spits out files that are required for our package. We, however, had to alter it slightly such that it 
+stored some additional files that are required for this package. As such, we have added this edited edition to our scripts
+folder. To process a Wikipedia dump run the command below in a terminal. We define the file size (`bytes`) as one GB, but it can
+be changed based on the user's wishes. We advice users to run the script in the `basic_data` folder. After the script is
+done, the user only needs to copy the respective wikipedia dump (this excludes the wiki id/name mapping, disambiguation pages
+and redirects) into the `anchor_files` folder. 
+
+```
+python WikiExtractor.py ./wiki_corpus.xml --links --filter_disambig_pages --processes 1 --bytes 1G
+```
+
+### Generate p(e\|m) index
+
+Now that we have extracted the necessary data from our Wikipedia corpus, we may create the p(e|m) index. This index
+is automatically stored in the same database as the embeddings that can be found in the `generated` folder. The first
+thing we need to do is define define a variable where we store our database. Secondly, we instantiate a `Wikipedia` class
+that loads the wikipedia id/name mapping, disambiguation file and redirect file. 
+
+```python
+wiki_version = "your_corpus_name"
+wikipedia = Wikipedia(base_url, wiki_version)
+```
+
+Now all that is left is to instantiate our `WikipediaYagoFreq` class that is responsible for parsing the Wikipedia and
+YAGO articles. Here we note that the function `compute_custom()` by default computes the p(e|m) probabilities of
+YAGO, but that it can be replaced by any Knowledge Base of your choosing. To replace YAGO, make sure that the input dictionary
+to the aforementioned function is of the following format: 
+`{mention_0: {entity_0: cnt_0, entity_n: cnt_n}, ... mention_n: {entity_0: cnt_0, entity_n: cnt_n}}`
+
+```python
+wiki_yago_freq = WikipediaYagoFreq(base_url, wiki_version, wikipedia)
+wiki_yago_freq.compute_wiki()
+wiki_yago_freq.compute_custom()
+wiki_yago_freq.store()
+```
+
+## Embeddings
+
+### Training Wikipedia2Vec embeddings
+Training new embeddings is based on the [Wikipedia2Vec](http://wikipedia2vec.github.io/) package. For extra information
+about this package we refer to their website. We did, however, feel obligated to provide users with the same scripts that
+we used to train our embeddings. These two shell scripts first install Wikipedia2vec and then asks you where
+your Wikipedia dump is stored. Please make sure that the dump is still zipped and thus has the extensions `.xml.bz2`.
+The two scripts are located in `scripts/w2v`, where you first run `preprocess.sh` which requires you to enter the
+location of your Wikipedia dump. After this is done, you can run `train.sh` which will train a Wikipedia2Vec model and
+store it in the required word2vec format.
+
+### Storing Embeddings in DB
+
+Now that the Embeddings are trained and stored you might notice that the file is huge. This is exactly the reason
+why we choose for a database approach, because it was simply infeasible to load all the embeddings into memory. After 
+the package is installed, all we have to do is run the code below. Please make sure to not not change the variables `save_dir`
+and `db_name`. The variable `embedding_file` needs to point to the trained Wikipedia2vec file.
+
+```python
+from REL.db.generic import GenericLookup
+
+save_dir = "{}/{}/generated/".format(base_url, wiki_version)
+db_name = "entity_word_embedding"
+embedding_file = "./enwiki_w2v_model"
+
+# Embedding load.
+emb = GenericLookup(db_name, save_dir=save_dir, table_name='embeddings')
+emb.load_word2emb(embedding_file, batch_size=5000, reset=True)
+```
+
+## Generating training, validation and test files
+
+To train your own Entity Disambiguation model, training, validation and test files are required. To obtain these
+files we first define our `wiki_version` and instantiate a `Wikipedia` class that are required.
+
+```python
+from REL.wikipedia import Wikipedia
+from REL.generate_train_test import GenTrainingTest
+
+wiki_version = "wiki_2019/"
+wikipedia = Wikipedia(base_url, wiki_version)
+```
+Secondly, we instantiate the class `GenTrainingTest` that parses the raw training and test files that can be found in our
+`generic` folder. The user may choose to only retrieve one of the listed datasets below by simply changing the name
+in the function `process_wned` or `process_aida`. The reason for separating these functions was due to the way they were
+provided and had to be parsed.
+
+```python
+data_handler = GenTrainingTest(base_url, wiki_version, wikipedia)
+for ds in ["aquaint", "msnbc", "ace2004", "wikipedia", "clueweb"]:
+    data_handler.process_wned(ds)
+
+for ds in ["train", "test"]:
+    data_handler.process_aida(ds)
+```
+
+## Training your own Entity Disambiguation model
+
+For our final tutorial we will train our own Entity Disambiguation model. The first step, as always, is to import
+the necessary packages and to define the `wiki_version`.
+
+```python
+from REL.training_datasets import TrainingEvaluationDatasets
+from REL.entity_disambiguation import EntityDisambiguation
+
+wiki_version = "wiki_2019"
+```
+
+Our second step is loading our training and evaluation datasets that can be found in our `generated` folder. These
+datasets are provided by us, but can also be generated by the user in previous steps.
+
+```python
+datasets = TrainingEvaluationDatasets(base_url, wiki_version).load()
+```
+
+
+Our third step consists of defining the config dictionary that serves as an input to the model. If the mode is set 
+to `eval` then the model will evaluate the given datasets given that the model exists (else it will throw an error). The 
+mode should be set to `train` if the user wishes to train a new model and save it in the given `model_path`.
+
+```python
+config = {
+    "mode": "train",
+    "model_path": "{}/{}/generated/model".format(
+        base_url, wiki_version
+    ),
+}
+model = EntityDisambiguation(base_url, wiki_version, config)
+```
+
+Our fourth step consists of training or evaluating the model. This is dependent on the `mode` that was chosen previously,
+
+```python
+# 3. Train or evaluate model
+if config["mode"] == "train":
+    model.train(
+        datasets["aida_train"], {k: v for k, v in datasets.items() if k != "aida_train"}
+    )
+else:
+    model.evaluate({k: v for k, v in datasets.items() if "train" not in k})
+```
+
+Now that we have obtained our model, we want to express how confident we are in our prediction.
+By default this is not integrated in our model, but we implemented an additional step, where we use Logistic Regression
+to obtain confidence scores. However, to obtain such scores, we first need to train the model. This can be done by
+running the code below.
+
+```python
+# 3. Train and predict using LR
+
+model_path_lr = "{}/{}/generated/".format(base_url, wiki_version)
+
+model.train_LR(
+    datasets,
+    model_path_lr
+)
+```
\ No newline at end of file
diff --git a/tutorials/03_Evaluate_Gerbil.md b/docs/tutorials/evaluate_gerbil.md
similarity index 76%
rename from tutorials/03_Evaluate_Gerbil.md
rename to docs/tutorials/evaluate_gerbil.md
index ff58f9b..2d6322b 100644
--- a/tutorials/03_Evaluate_Gerbil.md
+++ b/docs/tutorials/evaluate_gerbil.md
@@ -1,17 +1,22 @@
-# Evaluate on GERBIL
-For evaluation we used [GERBIL](https://github.com/dice-group/gerbil/). GERBIL requires middleware software, which we have provided in our scripts
-folder. The first thing that needs to be done is forwarding a port that GERBIL
-can refer to. This port should refer to the port 1235, which we use for our middleware code. Alternatively, one could choose to download the local GERBIL platform, but we could not get that to
-work properly.
-
-After opening the `gerbil_middleware` folder, the user can run the following command to start the middleware:
-```
-mvn clean -Dmaven.tomcat.port=1235 tomcat:run
-```
-Secondly, we need to [start the API]((https://github.com/informagi/REL/tree/master/tutorials/02_E2E_Entity_Linking.md)) as described in the previous tutorials. Make sure
-to change the port to '5555'.
-
-Finally, the user may open the [GERBIL platform](http://gerbil.aksw.org/gerbil/config) and configure and run an experiment. Where the URI field
-should be filled with:
-
- `http://{YOUR_IP_ADD}:1235/gerbil-spotWrapNifWS4Test/myalgorithm`
\ No newline at end of file
+# Evaluate on GERBIL
+
+For evaluation we used [GERBIL](https://github.com/dice-group/gerbil/). GERBIL requires middleware software, which we have provided in our scripts
+folder. The first thing that needs to be done is forwarding a port that GERBIL
+can refer to. This port should refer to the port 1235, which we use for our middleware code. Alternatively, one could choose to download the local GERBIL platform, but we could not get that to
+work properly.
+
+After opening the `gerbil_middleware` folder, the user can run the following command to start the middleware:
+
+```bash
+mvn clean -Dmaven.tomcat.port=1235 tomcat:run
+```
+
+Secondly, we need to [start the API](../e2e_entity_linking/#setting-up-your-own-api) as described in the previous tutorials. Make sure
+to change the port to '5555'.
+
+Finally, the user may open the [GERBIL platform](http://gerbil.aksw.org/gerbil/config) and configure and run an experiment. Where the URI field
+should be filled with:
+
+```
+http://{YOUR_IP_ADD}:1235/gerbil-spotWrapNifWS4Test/myalgorithm
+```
\ No newline at end of file
diff --git a/tutorials/01_How_to_get_started.md b/docs/tutorials/how_to_get_started.md
similarity index 97%
rename from tutorials/01_How_to_get_started.md
rename to docs/tutorials/how_to_get_started.md
index 331ddcd..a2d6f44 100644
--- a/tutorials/01_How_to_get_started.md
+++ b/docs/tutorials/how_to_get_started.md
@@ -1,25 +1,26 @@
-# How to get started
-Throughout the project we will constantly use a variable, which we called `base_url`. This variable refers to your data
-folder and will be used to store the folders that need to be downloaded from our main Github page, but will also be used to 
-store e.g. generated training and test files.
-
-```python
-base_url = "/home/user/project_folder"
-```
-
-The files that are provided on our main Github page can be copied and downloaded into this folder, thus obtaining
-the folder structure below. Throughout this set of tutorials the `generic` folder will always be required, but the user
-may choose to work with either the 2014, 2019 or their own Wikipedia corpus.
-
-```
-.
-├── generic
-└─── wiki_2014
-|   ├── basic_data
-|      └── anchor_files
-|   └── generated
-└─── wiki_2019
-|   ├── basic_data
-|      └── anchor_files
-|   └── generated
+# How to get started
+
+Throughout the project we will constantly use a variable, which we called `base_url`. This variable refers to your data
+folder and will be used to store the folders that need to be downloaded from our main Github page, but will also be used to 
+store e.g. generated training and test files.
+
+```python
+base_url = "/home/user/project_folder"
+```
+
+The files that are provided on our main Github page can be copied and downloaded into this folder, thus obtaining
+the folder structure below. Throughout this set of tutorials the `generic` folder will always be required, but the user
+may choose to work with either the 2014, 2019 or their own Wikipedia corpus.
+
+```
+.
+├── generic
+└─── wiki_2014
+|   ├── basic_data
+|      └── anchor_files
+|   └── generated
+└─── wiki_2019
+|   ├── basic_data
+|      └── anchor_files
+|   └── generated
 ```
\ No newline at end of file
diff --git a/docs/tutorials/index.md b/docs/tutorials/index.md
new file mode 100644
index 0000000..c96d1bd
--- /dev/null
+++ b/docs/tutorials/index.md
@@ -0,0 +1,16 @@
+# Tutorials
+
+Welcome to the tutorials for REL.
+
+The first two tutorials for users who simply want to use our package for Entity Linking and Entity Disambiguation using
+the data we files that we provide. 
+
+The remainder of the tutorials are optional and for users who wish to e.g. train their own Embeddings.
+
+1. [How to get started (project folder and structure).](how_to_get_started/)
+2. [End-to-End Entity Linking.](e2e_entity_linking/)
+3. [Evaluate on GERBIL.](evaluate_gerbil/)
+4. [Deploy REL for a new Wikipedia corpus](deploy_REL_new_wiki/):
+5. [Reproducing our results](reproducing_our_results/)
+6. [REL as systemd service](systemd_instructions/)
+7. [Notes on using custom models](custom_models/)
diff --git a/tutorials/05_reproducing_our_results.md b/docs/tutorials/reproducing_our_results.md
similarity index 67%
rename from tutorials/05_reproducing_our_results.md
rename to docs/tutorials/reproducing_our_results.md
index 993f976..38e8231 100644
--- a/tutorials/05_reproducing_our_results.md
+++ b/docs/tutorials/reproducing_our_results.md
@@ -1,12 +1,15 @@
 # Reproducing our results
+
 To reproduce our results there are various steps that need to be taken. The first step is making sure that the user
 has downloaded the respective download folders on our main Github folder. Here we politely refer the user to our tutorial on 
-[how to get started](https://github.com/informagi/REL/tree/master/tutorials/01_How_to_get_started.md). Now that we have obtained
-the required folder structure, which includes the necessary training, validation and test files, we need [to train our Entity Disambiguation model](https://github.com/informagi/REL/tree/master/tutorials/deploy_REL_new_Wiki/04_04_training_your_own_ED_model.md). 
+[how to get started](../how_to_get_started/). Now that we have obtained
+the required folder structure, which includes the necessary training, validation and test files, we need [to train our Entity Disambiguation model](../deploy_rel_new_wiki/#training-your-own-entity-disambiguation-model). 
 
 To train a ED model for Wikipedia 2014, no extra changes are required. To obtain results for Wikipedia 2019, we note that the parameter `"dev_f1_change_lr"` needs to 
 be changed to `0.88`. After following these steps, the user now has access to a Entity Disambiguation model. In our paper we divide our results into three tables, which
-can be reproduced by following the [linked tutorial](https://github.com/informagi/REL/tree/master/tutorials/03_Evaluate_Gerbil.md) and by making sure to use the
+can be reproduced by following the [linked tutorial](../evaluate_gerbil/) and by making sure to use the
 corresponding settings:
+
  1. Configure the GERBIL platform to perform either the Entity Linking or Disambiguation step.
- 2. Configure the server to use the correct model path for Wiki 2014 or 2019.
\ No newline at end of file
+ 2. Configure the server to use the correct model path for Wiki 2014 or 2019.
+ 
diff --git a/tutorials/06_systemd_instructions.md b/docs/tutorials/systemd_instructions.md
similarity index 97%
rename from tutorials/06_systemd_instructions.md
rename to docs/tutorials/systemd_instructions.md
index 5f0a1e1..3613e36 100644
--- a/tutorials/06_systemd_instructions.md
+++ b/docs/tutorials/systemd_instructions.md
@@ -1,9 +1,11 @@
 # Running REL as a systemd service
+
 In this tutorial we provide some instructions on how to run REL as a systemd
 service. This is a fairly simple setup, and allows for e.g. automatic restarts
 after crashes or machine reboots.
 
-## rel.service
+## Create `rel.service`
+
 For a basic systemd service file for REL, put the following content into
 `/etc/systemd/system/rel.service`:
 
@@ -29,6 +31,7 @@ instructions, see e.g. [here](https://wiki.debian.org/systemd/Services) or `man
 5 systemd.service`.
 
 ## Enable the service
+
 In order to enable the service, run the following commands in your shell:
 
 ```bash
diff --git a/mkdocs.yml b/mkdocs.yml
new file mode 100644
index 0000000..63aa102
--- /dev/null
+++ b/mkdocs.yml
@@ -0,0 +1,89 @@
+site_name: "REL: Radboud Entity Linker"
+
+nav:
+  - Home: index.md
+  - Tutorials:
+    - tutorials/how_to_get_started.md
+    - tutorials/e2e_entity_linking.md
+    - tutorials/evaluate_gerbil.md
+    - tutorials/deploy_REL_new_wiki.md
+    - tutorials/reproducing_our_results.md
+    - tutorials/systemd_instructions.md
+    - tutorials/custom_models.md
+  - Python API reference:
+    - api/entity_disambiguation.md
+    - api/generate_train_test.md
+    - api/mention_detection.md
+    - api/mulrel_ranker.md
+    - api/server.md
+    - api/training_datasets.md
+    - api/utils.md
+    - api/vocabulary.md
+    - api/wikipedia.md
+    - api/wikipedia_yago_freq.md
+  - Development: contributing.md
+  - 🔗 Source code: https://github.com/informagi/REL
+  - 🔗 Issues: https://github.com/informagi/REL/issues
+
+
+theme:
+  name: material
+  palette:
+    - media: "(prefers-color-scheme: light)"
+      primary: blue
+      accent: red
+      scheme: default
+      toggle:
+        name: Switch to dark mode
+        icon: material/lightbulb
+    - media: "(prefers-color-scheme: dark)"
+      primary: blue
+      accent: red
+      scheme: slate
+      toggle:
+        name: Switch to light mode
+        icon: material/lightbulb-outline
+
+extra_css:
+  - stylesheets/extra.css
+
+markdown_extensions:
+  - admonition
+  - attr_list
+  - markdown_include.include:
+      base_path: docs
+  - pymdownx.extra
+  - pymdownx.arithmatex:
+      generic: true
+
+extra_javascript:
+  - https://polyfill.io/v3/polyfill.min.js?features=es6
+  - https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
+
+plugins:
+- search
+- mkdocstrings:
+    # https://mkdocstrings.github.io/usage/
+    handlers:
+      python:
+        import:
+        - https://docs.python.org/3/objects.inv
+        - https://numpy.org/doc/stable/objects.inv
+        - https://docs.scipy.org/doc/scipy/objects.inv
+        - https://pandas.pydata.org/docs/objects.inv
+        selection:
+          docstring_style: sphinx
+          docstring_options:
+            ignore_init_summary: yes
+        rendering:
+          show_submodules: no
+          show_source: true
+          docstring_section_style: list
+          members_order: alphabetical
+          show_category_heading: no
+          merge_init_into_class: yes
+
+watch:
+  - REL/
+  - docs/
+  - README.md
diff --git a/setup.py b/setup.py
index c5e8126..c6a3342 100644
--- a/setup.py
+++ b/setup.py
@@ -23,6 +23,17 @@
         "Operating System :: OS Independent",
     ],
     install_requires=required,
+    extras_require={
+        'develop': [
+            'pytest',
+        ],
+        'docs': [
+          'markdown-include',
+          'mkdocs',
+          'mkdocs-material',
+          'mkdocstrings[python]',
+        ]
+    },
     include_package_data=True,
     python_requires=">=3.6",
 )
diff --git a/tutorials/__init__.py b/tutorials/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/tutorials/deploy_REL_new_Wiki/04_01_Extracting_a_new_Wikipedia_corpus.md b/tutorials/deploy_REL_new_Wiki/04_01_Extracting_a_new_Wikipedia_corpus.md
deleted file mode 100644
index e7ca1e3..0000000
--- a/tutorials/deploy_REL_new_Wiki/04_01_Extracting_a_new_Wikipedia_corpus.md
+++ /dev/null
@@ -1,57 +0,0 @@
-# Creating a folder structure
-Previously we have defined our `base_url`, but now we need to create a new sub folder in our directory to obtain 
-the following folder structure:
-
-```
-.
-├── generic
-└─── wiki_2014
-|   ├── basic_data
-|      └── anchor_files
-|   └── generated
-└─── wiki_2019
-|   ├── basic_data
-|      └── anchor_files
-|   └── generated
-└─── your_corpus_name
-|   ├── basic_data
-|      └── anchor_files
-|   └── generated
-```
-# Extracting a Wikipedia dump
-There are several platforms that host [Wikipedia dumps](https://dumps.wikimedia.org/). These platforms provide `xml` files that need processing. 
-A tool that does this is called [WikiExtractor](https://github.com/attardi/wikiextractor). This tool takes as an input a
-Wikipedia dump and spits out files that are required for our package. We, however, had to alter it slightly such that it 
-stored some additional files that are required for this package. As such, we have added this edited edition to our scripts
-folder. To process a Wikipedia dump run the command below in a terminal. We define the file size (`bytes`) as one GB, but it can
-be changed based on the user's wishes. We advice users to run the script in the `basic_data` folder. After the script is
-done, the user only needs to copy the respective wikipedia dump (this excludes the wiki id/name mapping, disambiguation pages
-and redirects) into the `anchor_files` folder. 
-
-```
-python WikiExtractor.py ./wiki_corpus.xml --links --filter_disambig_pages --processes 1 --bytes 1G
-```
-
-# Generate p(e|m) index
-Now that we have extracted the necessary data from our Wikipedia corpus, we may create the p(e|m) index. This index
-is automatically stored in the same database as the embeddings that can be found in the `generated` folder. The first
-thing we need to do is define define a variable where we store our database. Secondly, we instantiate a `Wikipedia` class
-that loads the wikipedia id/name mapping, disambiguation file and redirect file. 
-
-```python
-wiki_version = "your_corpus_name"
-wikipedia = Wikipedia(base_url, wiki_version)
-```
-
-Now all that is left is to instantiate our `WikipediaYagoFreq` class that is responsible for parsing the Wikipedia and
-YAGO articles. Here we note that the function `compute_custom()` by default computes the p(e|m) probabilities of
-YAGO, but that it can be replaced by any Knowledge Base of your choosing. To replace YAGO, make sure that the input dictionary
-to the aforementioned function is of the following format: 
-`{mention_0: {entity_0: cnt_0, entity_n: cnt_n}, ... mention_n: {entity_0: cnt_0, entity_n: cnt_n}}`
-
-```python
-wiki_yago_freq = WikipediaYagoFreq(base_url, wiki_version, wikipedia)
-wiki_yago_freq.compute_wiki()
-wiki_yago_freq.compute_custom()
-wiki_yago_freq.store()
-```
diff --git a/tutorials/deploy_REL_new_Wiki/04_02_training_your_own_embeddings.md b/tutorials/deploy_REL_new_Wiki/04_02_training_your_own_embeddings.md
deleted file mode 100644
index 684cb35..0000000
--- a/tutorials/deploy_REL_new_Wiki/04_02_training_your_own_embeddings.md
+++ /dev/null
@@ -1,27 +0,0 @@
-# Embeddings
-## Training Wikipedia2Vec embeddings
-Training new embeddings is based on the [Wikipedia2Vec](http://wikipedia2vec.github.io/) package. For extra information
-about this package we refer to their website. We did, however, feel obligated to provide users with the same scripts that
-we used to train our embeddings. These two shell scripts first install Wikipedia2vec and then asks you where
-your Wikipedia dump is stored. Please make sure that the dump is still zipped and thus has the extensions `.xml.bz2`.
-The two scripts are located in `scripts/w2v`, where you first run `preprocess.sh` which requires you to enter the
-location of your Wikipedia dump. After this is done, you can run `train.sh` which will train a Wikipedia2Vec model and
-store it in the required word2vec format.
-
-## Storing Embeddings in DB
-Now that the Embeddings are trained and stored you might notice that the file is huge. This is exactly the reason
-why we choose for a database approach, because it was simply infeasible to load all the embeddings into memory. After 
-the package is installed, all we have to do is run the code below. Please make sure to not not change the variables `save_dir`
-and `db_name`. The variable `embedding_file` needs to point to the trained Wikipedia2vec file.
-
-```python
-from REL.db.generic import GenericLookup
-
-save_dir = "{}/{}/generated/".format(base_url, wiki_version)
-db_name = "entity_word_embedding"
-embedding_file = "./enwiki_w2v_model"
-
-# Embedding load.
-emb = GenericLookup(db_name, save_dir=save_dir, table_name='embeddings')
-emb.load_word2emb(embedding_file, batch_size=5000, reset=True)
-```
\ No newline at end of file
diff --git a/tutorials/deploy_REL_new_Wiki/04_04_training_your_own_ED_model.md b/tutorials/deploy_REL_new_Wiki/04_04_training_your_own_ED_model.md
deleted file mode 100644
index 7213644..0000000
--- a/tutorials/deploy_REL_new_Wiki/04_04_training_your_own_ED_model.md
+++ /dev/null
@@ -1,60 +0,0 @@
-# Training your own Entity Disambiguation model
-For our final tutorial we will train our own Entity Disambiguation model. The first step, as always, is to import
-the necessary packages and to define the `wiki_version`.
-
-```python
-from REL.training_datasets import TrainingEvaluationDatasets
-from REL.entity_disambiguation import EntityDisambiguation
-
-wiki_version = "wiki_2019"
-```
-
-Our second step is loading our training and evaluation datasets that can be found in our `generated` folder. These
-datasets are provided by us, but can also be generated by the user in previous steps.
-
-```python
-datasets = TrainingEvaluationDatasets(base_url, wiki_version).load()
-```
-
-
-Our third step consists of defining the config dictionary that serves as an input to the model. If the mode is set 
-to `eval` then the model will evaluate the given datasets given that the model exists (else it will throw an error). The 
-mode should be set to `train` if the user wishes to train a new model and save it in the given `model_path`.
-
-```python
-config = {
-    "mode": "train",
-    "model_path": "{}/{}/generated/model".format(
-        base_url, wiki_version
-    ),
-}
-model = EntityDisambiguation(base_url, wiki_version, config)
-```
-
-Our fourth step consists of training or evaluating the model. This is dependent on the `mode` that was chosen previously,
-
-```python
-# 3. Train or evaluate model
-if config["mode"] == "train":
-    model.train(
-        datasets["aida_train"], {k: v for k, v in datasets.items() if k != "aida_train"}
-    )
-else:
-    model.evaluate({k: v for k, v in datasets.items() if "train" not in k})
-```
-
-Now that we have obtained our model, we want to express how confident we are in our prediction.
-By default this is not integrated in our model, but we implemented an additional step, where we use Logistic Regression
-to obtain confidence scores. However, to obtain such scores, we first need to train the model. This can be done by
-running the code below.
-
-```python
-# 3. Train and predict using LR
-
-model_path_lr = "{}/{}/generated/".format(base_url, wiki_version)
-
-model.train_LR(
-    datasets,
-    model_path_lr
-)
-```
\ No newline at end of file
diff --git a/tutorials/deploy_REL_new_Wiki/04_deploy_REL_new_wiki.md b/tutorials/deploy_REL_new_Wiki/04_deploy_REL_new_wiki.md
deleted file mode 100644
index 747b980..0000000
--- a/tutorials/deploy_REL_new_Wiki/04_deploy_REL_new_wiki.md
+++ /dev/null
@@ -1,10 +0,0 @@
-# Deploy REL for a new Wikipedia corpus
-Although we will do our best to continuously provide the community with recent corpuses, it may be the case that a user wants to, for example, use
-an older corpus for a specific evaluation. For this reason we provide the user with the option to do so. We must, however,
-note that some steps are outside the scope of the REL package, which makes support for some of these steps a difficult task.
-
-This tutorial is divided in four parts. The first part deals with [Extracting a Wikipedia corpus and creating a p(e|m) index](https://github.com/informagi/REL/tree/master/tutorials/deploy_REL_new_Wiki/04_01_Extracting_a_new_Wikipedia_corpus.md).
-After extracting the aforementioned index and thus obtaining a sqlite3 database, we are also in need of Embeddings. We obtain new embeddings by [training a Wikipedia2Vec model](https://github.com/informagi/REL/tree/master/tutorials/deploy_REL_new_Wiki/04_02_training_your_own_embeddings.md).
-To train our own Entity Disambiguation model, we need to [generate training, validation and test files](https://github.com/informagi/REL/tree/master/tutorials/deploy_REL_new_Wiki/04_03_generating_training_test_files.md).
-These aforementioned p(e|m) index,  can be used to [train your own Entity Disambiguation model](https://github.com/informagi/REL/tree/master/tutorials/deploy_REL_new_Wiki/04_04_training_your_own_ED_model.md). 
-After obtaining this model, a user may choose to [evaluate the obtained model on Gerbil](https://github.com/informagi/REL/tree/master/tutorials/03_Evaluate_Gerbil.md) or for [E2E Entity Linking](https://github.com/informagi/REL/tree/master/tutorials/02_E2E_Entity_Linking.md).
\ No newline at end of file


Test patch:
diff --git a/REL/generate_train_test.py b/REL/generate_train_test.py
index 46ce8c5..6616330 100644
--- a/REL/generate_train_test.py
+++ b/REL/generate_train_test.py
@@ -6,13 +6,13 @@
 from REL.mention_detection_base import MentionDetectionBase
 from REL.utils import modify_uppercase_phrase, split_in_words_mention
 
-"""
-Class responsible for formatting WNED and AIDA datasets that are required for ED local evaluation and training.
-Inherits overlapping functions from the Mention Detection class.
-"""
 
 
 class GenTrainingTest(MentionDetectionBase):
+    """
+    Class responsible for formatting WNED and AIDA datasets that are required for ED local evaluation and training.
+    Inherits overlapping functions from the Mention Detection class.
+    """
     def __init__(self, base_url, wiki_version, wikipedia):
         self.wned_path = os.path.join(base_url, "generic/test_datasets/wned-datasets/")
         self.aida_path = os.path.join(base_url, "generic/test_datasets/AIDA/")
diff --git a/docs/api/generate_train_test.md b/docs/api/generate_train_test.md
new file mode 100644
index 0000000..4589c5d
--- /dev/null
+++ b/docs/api/generate_train_test.md
@@ -0,0 +1,1 @@
+::: REL.generate_train_test
diff --git a/tutorials/02_E2E_Entity_Linking.md b/docs/tutorials/e2e_entity_linking.md
similarity index 99%
rename from tutorials/02_E2E_Entity_Linking.md
rename to docs/tutorials/e2e_entity_linking.md
index ebbced5..4174f82 100644
--- a/tutorials/02_E2E_Entity_Linking.md
+++ b/docs/tutorials/e2e_entity_linking.md
@@ -1,9 +1,11 @@
 # End-to-End Entity Linking
+
 In this tutorial we will guide you through the process of using our Entity Linking system. Please take note that we assume
 that the tutorials are followed in a sequential order, meaning that the variable `base_url` is defined and that you have
 amended the required project structure.
 
 ## Setting up  your own API
+
 Previously we defined our `base_url`. We also need the project to know which specific
 Wikipedia corpus we would like to use. We do this by creating a variable that in this case refers to the folder containing
 the necessary files for our Wikipedia 2014 folder. Additionally, we import the required packages.
@@ -91,6 +93,7 @@ API_result = requests.post("{}:{}".format(IP_ADDRESS, PORT), json=document).json
 ```
 
 ## Pipeline integration
+
 Alternatively, one may choose to integrate the package into an existing pipeline. This grants the user a bit more freedom
 with inputting multiple documents at the same time. This can especially be useful when batch loading multiple documents
 using their own or our Mention Detection system. To do this we once more import the required packages and define the folder name that contains our Wikipedia corpus files.
@@ -152,6 +155,7 @@ result = process_results(mentions_dataset, predictions, input_text)
 ```
 
 ## Replacing the Mention Detection module
+
 With this project we attempt to advocate a modular approach to development, making it easy
 for a user to replace certain components. One of such components is the Mention Detection module. After experimenting with
 various approaches, we came to the conclusion that the NER-system provided by Flair worked best and was easiest to integrate
diff --git a/tutorials/deploy_REL_new_Wiki/04_03_generating_training_test_files.md b/tutorials/deploy_REL_new_Wiki/04_03_generating_training_test_files.md
deleted file mode 100644
index d3ba579..0000000
--- a/tutorials/deploy_REL_new_Wiki/04_03_generating_training_test_files.md
+++ /dev/null
@@ -1,23 +0,0 @@
-# Generating training, validation and test files
-To train your own Entity Disambiguation model, training, validation and test files are required. To obtain these
-files we first define our `wiki_version` and instantiate a `Wikipedia` class that are required.
-```python
-from REL.wikipedia import Wikipedia
-from REL.generate_train_test import GenTrainingTest
-
-wiki_version = "wiki_2019/"
-wikipedia = Wikipedia(base_url, wiki_version)
-```
-Secondly, we instantiate the class `GenTrainingTest` that parses the raw training and test files that can be found in our
-`generic` folder. The user may choose to only retrieve one of the listed datasets below by simply changing the name
-in the function `process_wned` or `process_aida`. The reason for separating these functions was due to the way they were
-provided and had to be parsed.
-
-```python
-data_handler = GenTrainingTest(base_url, wiki_version, wikipedia)
-for ds in ["aquaint", "msnbc", "ace2004", "wikipedia", "clueweb"]:
-    data_handler.process_wned(ds)
-
-for ds in ["train", "test"]:
-    data_handler.process_aida(ds)
-```
\ No newline at end of file