cogstacksystems/medcat-trainer-nginxMedCATTrainer is an interface for building, improving and customising a given Named Entity Recognition and Linking (NER+L) model (MedCAT) for biomedical domain text.
MedCATTrainer was presented at EMNLP/IJCNLP 2019 :tada: here
MedCATtrainer is a docker-compose packaged Django application.
Quick-install script, downloads the docker-compose file, default env var and runs them. 1.
$ git clone [***] $ cd MedCATtrainer $ docker-compose up
If you have MedCAT v0.x models, and want to use the trainer please use the following docker-compose file: This refences the latest built image for the trainer that is still compatible with MedCAT v0.x. and under.
$ docker-compose -f docker-compose-mc0x.yml up
If the build fails with an error code 137, the virtual machine running the docker daemon does not have enough memory. Increase the allocated memory to containers in the docker daemon settings CLI or associated docker GUI.
On MAC: [***]
On Windows: [***]
2. MedCATTrainer is now running:
Upon initial install, an example administrator user, example dataset, concept database, vocab and project are setup. The next section provides further details.
3. (Optional), Environment variables are used to configure the app:
| Parameter | Description |
|---|---|
| MEDCAT_CONFIG_FILE | MedCAT config file as described here |
| BEHIND_RP | If you're running MedCATtrainer, use 1, otherwise this defaults to 0 i.e. False |
| MCTRAINER_PORT | The port to run the trainer app on |
Set these and re-run the docker-compose file.
You'll need to docker stop the running containers if you have already run the install.
1. The container runs a vanilla django app, that upon initially loaded will create a defaulted administrator user with details:
username: admin
password: admin
2. We strongly recommend creating a new admin user before using the trainer in 'production' and storing sensitive clinical documents on the trainer. To add a new user navigate to select http://localhost:8001/admin/ and select 'Users'.
3. Select 'Add User' and complete the form with a new username / password.
4. Once created, select the new user, and tick the 'Staff Status' or 'Superuser Status' to allow the user to access the admin app.
5. Remove the default admin user by navigating to step 2, select the user and the action
For demonstration purposes and general testing of a current model a stripped back version of the annotator is provided via the 'Demo' tab of the main screen.
This presents a similar looking annotation screen as a real project, described in detail here, but does not force usage of a particular dataset, setup of filters, and other project settings. This view does not allow for 'annotating' identified concepts (or adding new concepts) but allows for users to get a feel for what an existing MedCAT model is capable of annotating in via an interactive model
1. A form to:
2. Example clinical text is displayed here, with text spans highlighted in blue. Click any annotation to show linked concept DB details in 3.
3. Linked concept details from selected concepts from the 2.
Using the admin page, a configured superuser can create, edit and delete annotation projects.
Annotation projects are used to inspect, validate and improve concepts recognised by MedCAT.
1. Navigate to http://localhost:8001/admin/ and select 'Project annotate entities'.
!Main Menu list
2. 'Add Project Annotate Entities'
!Add Project Annotate Entities button
3. Complete the new annotation project form. The table below provides details the purpose of each field:
| Parameter | Description |
|---|---|
| Name | # Name of the project that appears on the landing page |
| Description | Example projects', # Description as it appears on the landing page |
| Members | list of users that have access to this project, select the '+' to create new users |
| Dataset | The set of documents to be annotated. The dataset tabular schema is described below. |
| Validated Documents | Ignore this list. Use of this list is described in the forthcoming advanced administrator user guide |
| Cuis | (Optional) A list of comma separated Concept Unique Identifiers (CUIs). Use this to only show precise concepts in this project |
| CUI File | (Optional) A JSON formatted list of CUIs. Can be useful if the project should be setup to annotate large CUI lists extracted gathered from introspection of a CDB. Will be merged with the above 'Cuis' list |
| Concept DB | A MedCAT Concept Database. This should be the resulting file from a call to the function medcat.cdb.CDB.save_dict('name_of_cdb.dat'). Clicking the '+' icon here opens a dialog to upload a CDB file. |
| vocab | A MedCAT Vocabulary. This should be the resulting file from a call to the function medcat.cdb.utils.Vocab.save_dict('name_of_vocab.dat'). Clicking the '+' icon here opens a dialog to upload a vocab file. |
| cdb_search_filter | list of CDB IDs that are used to lookup concepts during addition of annotations to a document |
| Require Entity Validation | (Default: True) With this option ticked, annotations in the interface, that are made by MedCAT will appear 'grey' indicating they have not been validated. Document submission is dependent upon all 'grey' annotations to be marked by a user. Unticked ensures all annotations are marked 'valid' by default |
| Train Model On Submit | (Default: True) With this option ticked, each document submission trains the configured MedCAT instance with the marked, and added if any, annotations from this document. Unticked, ensures the MedCAT model does not train between submissions. |
| Add New Entities | (Default: False) With this option ticked, allows users to add entirely new concepts to the existing MedCAT CDB. False ensures this option is not available to users. |
| Restrict Concept Lookup | (Default: False) With this option ticked, restricts the concept lookup (add annotation / alternative concept) to only include those CUIs listed in the above filters (either from CUI / TUI list or uploade 'CUI File' list |
| Terminate Available | (Default: True) With this option ticked, the option to terminate an annotated concept will appear |
| Irrelevant Available | (Default: False) With this option ticked, the option to mark an annotated concept as 'irrlevant' will appear |
| Tasks | Select from the list 'Meta Annotation' tasks that will appear once a given annotation has been marked correct. |
Datasets can be uploaded in CSV or XLSX format. Example:
| name | text |
|---|---|
| Doc 1 | Example document text |
| Doc 2 | More example text |
The name column is optional, and will be auto-generated for each document if not supplied in the upload. Example datasets are supplied under docs/example_data/*.csv
4. Click 'Save' to store the new project.
5. Navigate to the home screen (http://localhost:8001/admin/), login with your username and password setup previously.
6. select your new project to begin annotating documents
NB. Example Concept and Vocab databses are freely available on MedCAT github. Note. UMLS and SNOMED-CT are licensed products so only these smaller trained concept / vocab databases are made available currently.
More documentation on the creation of UMLS / SNOMED-CT CDBs from respective source data will be released soon.
NNB. Tasks allow for the creation of meta-annotations and their associated set of values an annotator can use. An example 'meta-annotation' could be 'Temporality'. Values could then be 'Past', 'Present', 'Future'.
NB Please NOTE Firefox and IE are currently not supported. Please use Chrome or Safari.
The annotation interface can be split initially into 5 sections.
A list of documents to be completed in this project. Currently selected documents are highlighted in blue left border. Submitted documents are marked with a !tick_mark.
The selected documents text, highlighted with each concept recognised by the configured MedCAT model. Highlighted spans of text indicate status of the annotation:
MedCAT may miss text spans that are acronyms, abbreviations or misspellings of concepts. Missing annotations can be added to the text by directly highlighting the text span, right clicking, selecting 'Add Term', searching for concept (via ID, or name), and selecting Add Term:
-> ->
Select:
Navigating between the list of concepts as they appear in the document:
A concept can be marked with only one status. Status is recorded but only sent to MedCAT for training on submit of the document and if the projects configured with "Train Model On Submit" is ticked.
Submit is disabled until all concepts have been reviewed and marked with a status. Clicking submit will produce
a submission confirmation dialog with an annotation summary. Confirming submission will send all new annotations
to MedCATTrainer middle tier, and re-train the MedCAT model. The following document will be selected and annotated
by the newly trained MedCAT model
Lists the current name of the document under review and the number of remaining documents to annotate in this project action buttons for:
Lists the current selected concepts details.
| Concept Detail | Description |
|---|---|
| Annotated Text | The text span linked to the concept |
| Name | The linked concept name from within the MedCAT CDB |
| Term ID | The higher level group of concepts that this concept sits under. This may be 'N/A' depending if you CDB is complete with TUIs. |
| Concept ID | The unique identifier for this linked concept from the MedCAT CDB. |
| Accuracy | The MedCAT found accuracy of the linked concept for this span. Text spans will have an accuracy 1.0, if they are uniquely identified by that name in the CDB |
| Description | The MedCAT associated description of the concept. SNOMED-CT does not provide descriptions of concepts, only alternative names whereas UMLS does provide descriptions |
MedCAT is also able to learn project & context specific annotations that overlay on top of the base layer of concept annotations.
Example use cases of these annotations could be to train models to predict if:
MedCATTrainer is configurable (via the administrator app), to allow for the collection of these meta annotations. We currently have not integrated the active learning components of the concept recognition.
To create a new Meta Annotation Task and attach to an existing project:
1. Enter your project configuration settings via the admin page (http://localhost:8001/admin/)
2. At the bottom of the form, select the + icon to bring up the new Meta Annotation Task Form.
3. Complete the form and add additional meta task values if required for your task via the '+' icon and the 'values' input. Values are enumerated options for your specific task. These can be re-used across projects or be project specific. Ensure the default is one of the corresponding values available. Descriptions appear alongside the tasks in interface and in full in the help dialog.
4. Select desired Meta Annotation tasks for the project by holding down (ctrl / cmd) and clicking the meta tasks, then select 'Save' to save the project changes.
5. Meta Annotations now appear in the interface for that project under the concept summary. Meta-annotations only appear for concepts that are correct.
The concept picker is used to:
The available list of concepts is populated via a MedCAT CDB and indexed to enable fast type-ahead style search.
SNOMED-CT / UMLS built databases can contain thousands if not millions of concepts so this process is executed in asynchronous task to ensure the admin page and app are still available for use.
This process should only be done once for each concept universe (i.e. SNOMED-CT, UMLS are 2 distinct concept universes) per deployment or if the underlying MedCAT CDB changes Concepts will be indexed by there CUI, so importing different CDB instances that reference the same concept universe will only import the concepts that are in the set difference.
To make these concepts available to a (or any project):
1. Open the admin app. (http://localhost:8001/admin/)
2. Select 'Concept Dbs'
3. Select the Concept DB entry, and choose the action 'Import Concept', then press the 'Go' button.
Project annotations can be downloaded with or without the source text, especially important if the source text is particularly sensitive and should be not be shared.
1. Open the admin app. (http://localhost:8001/admin/)
2. Select 'Project annotate entities', !Main Menu list
3. Select the project(s) to download the annotations for and select the appropriate action for w/ or w/o source text, then press the 'Go' button. This will download all annotations, the meta-annotations (if any) for all projects selected. Annotations
4. An example jupyter notebook is provided under docs/Processing_Annotations.ipynb.
Cloning Projects is a easy & fast method to create copies of configured projects. This includes the dataset, CDB / vocab reference, meta annotation settings etc. Annotations themselves will not be copied across.
1. Open the admin app. (http://localhost:8001/admin/), and select 'Project annotate entities' (same as above for downloading)
2. Select the project(s) to clone, select the 'Clone projects', then press the 'Go' button.
NB: Cloning projects will use the same CDB instance. If you're double annotating datasets to then calculate agreement scores (IIA, Cohen's Kappa etc.) then uncheck "Train Model On Submit" for each of the projects to ensure the model is not trained by each annotator. If you do want 'online training' of the model, use separate instances of the same model. You can directly upload multiple instances of the same CDB file appropriately named to achieve this.
Use with caution. Resetting projects deletes all annotations and resets a project to its state upon initial creation.
1. Open the admin app. (http://localhost:8001/admin/), and select 'Project annotate entities' (same as above for downloading)
2. Select the project(s) to reset, then press the 'Go' button.
We strongly suggest models are not saved within MedCATtrainer then directly used. Instead, we suggest you use the collected annotations from projects to train and test a new MedCAT model.
However, to save the current state of the model you can use:
An API call - <deployment>:<port>/save-models/
Alternatively, login with an 'admin', (i.e. staff or superuser) account and hit the save model button associated with the project.
1. Open the admin app. (http://localhost:8001/admin/), and select 'Concept dbs'.
2. Click the CDB item you would like to download.
4. Click the CDB file, you will be prompted to save down the new CDB file. This file will be of the same format you
have used previously, i.e. you've called medcat.cdb.save_dict('
The saved MedCAT models can be used in any instance a regular MedCAT model may be used. I.e. in a jupyter notebook, part of a web service, or further fine-tuning in another MedCATTrainer instance.
The Trainer currently does not support inspection / training / storage of the meta annotation models. These will be integrated in a forthcoming release.
5. To load the new dictionary use medcat.cdb.load_dict('
Annotation guidelines can assist guiding annotators when annotating texts for a MedCATTrainer project.
Once an initial guideline has been defined, a pilot project in MedCATTrainer can be used to further refine the guideline.
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
在 Linux 系统配置镜像服务
在 Docker Desktop 配置镜像
Docker Compose 项目配置
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
MacOS OrbStack 容器配置
在宝塔面板一键配置镜像
Synology 群晖 NAS 配置
飞牛 fnOS 系统配置镜像
极空间 NAS 系统配置服务
爱快 iKuai 路由系统配置
绿联 NAS 系统配置镜像
QNAP 威联通 NAS 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
无需登录使用专属域名
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
免费版仅支持 Docker Hub 访问,不承诺可用性和速度;专业版支持更多镜像源,保证可用性和稳定速度,提供优先客服响应。
专业版支持 docker.io、gcr.io、ghcr.io、registry.k8s.io、nvcr.io、quay.io、mcr.microsoft.com、docker.elastic.co 等;免费版仅支持 docker.io。
当返回 402 Payment Required 错误时,表示流量已耗尽,需要充值流量包以恢复服务。
通常由 Docker 版本过低导致,需要升级到 20.x 或更高版本以支持 V2 协议。
先检查 Docker 版本,版本过低则升级;版本正常则验证镜像信息是否正确。
使用 docker tag 命令为镜像打上新标签,去掉域名前缀,使镜像名称更简洁。
来自真实用户的反馈,见证轩辕镜像的优质服务