Author: Abhishek Sakhuja / Hector Lopez Perez
Organisation: NTT Data
Date: 12 to 14th March 2024
Location: BE
The solution presented here shows a proof of concept of how to use the high capacity of LLMs to convert (unstructured) medical texts into structured data, increasing the usefulness of this data for further research and management tasks. To accomplish this, two Retrieval-Augmented Generation (RAG) pipelines have been implemented, the first one aiming to extract key fields from the text document, saving each patient's record in MongoDB. Once this has been achieved, the second pipeline is in charge of feeding this information to a chat in which a doctor can consult the patient's information by simply using natural language.
This repository contains the necessary code as well as other dependencies to run the EaseMed application. In this guide we will detail the different considerations and steps necessary to reproduce the final environment of the application.
For this development, python version 3.10 was used.
python -m venv <environment name>
.\<environment name>\Scripts\activate (windows)
.\<environment name>\bin\activate (linux)
pip install -r requirements.txt
brew tap mongodb/brew
brew update
brew install [email protected]
brew install --cask mongodb-compass
brew services start [email protected]
brew services stop [email protected]
mongod --config /opt/homebrew/etc/mongod.conf --fork
uvicorn nosql.app.app.main:app
Download MongoDB Community Edition from MongoDB Community.
Due to the need to carry out a purely local deployment of the solution, Chroma DB on-premises was the choice of vector data base. To load the SNOMED-CT data into this database, from the root directory of this project we will have to execute the following command (bash/cmd):
python ./src/data_cleaning.py
For demo purposes only a subset of records/terms are processed and their embeddings stored.
For testing purposes, also OpenAI (gpt3.5 turbo) and AzureOpenAI LLM support is implemented. To use this option, the corresponding API Key (only the key) has to be placed in a .secrets/azureopenapikey or .secrets/openapikey
For dynamic control of the environment, configuration variables that modify parts of the architecture are found in the configuration file in pipeline_meta/prompt_meta.yaml. From this file we can specify the LLM to be used in the application, the options being:
If support for another model wants to be implemented, this option must be added in the load_llm function, which is located in src/services/rag_loader.py
Download mistral 7B model or other model: mistral-7b-instruct-v0.1.Q4_K_M.gguf
Change the model_file parameter in src/services/rag_loader.py to the model
streamlit run frontend/ui_feed_db.py
streamlit run frontend/ui_chat_db.py
Author: Abhishek Sakhuja / Hector Lopez Perez
Organisation: NTT Data
Date: 12 to 14th March 2024
Location: BE
The solution presented here shows a proof of concept of how to use the high capacity of LLMs to convert (unstructured) medical texts into structured data, increasing the usefulness of this data for further research and management tasks. To accomplish this, two Retrieval-Augmented Generation (RAG) pipelines have been implemented, the first one aiming to extract key fields from the text document, saving each patient's record in MongoDB. Once this has been achieved, the second pipeline is in charge of feeding this information to a chat in which a doctor can consult the patient's information by simply using natural language.
This repository contains the necessary code as well as other dependencies to run the EaseMed application. In this guide we will detail the different considerations and steps necessary to reproduce the final environment of the application.
For this development, python version 3.10 was used.
python -m venv <environment name>
.\<environment name>\Scripts\activate (windows)
.\<environment name>\bin\activate (linux)
pip install -r requirements.txt
brew tap mongodb/brew
brew update
brew install [email protected]
brew install --cask mongodb-compass
brew services start [email protected]
brew services stop [email protected]
mongod --config /opt/homebrew/etc/mongod.conf --fork
uvicorn nosql.app.app.main:app
Download MongoDB Community Edition from MongoDB Community.
Due to the need to carry out a purely local deployment of the solution, Chroma DB on-premises was the choice of vector data base. To load the SNOMED-CT data into this database, from the root directory of this project we will have to execute the following command (bash/cmd):
python ./src/data_cleaning.py
For demo purposes only a subset of records/terms are processed and their embeddings stored.
For testing purposes, also OpenAI (gpt3.5 turbo) and AzureOpenAI LLM support is implemented. To use this option, the corresponding API Key (only the key) has to be placed in a .secrets/azureopenapikey or .secrets/openapikey
For dynamic control of the environment, configuration variables that modify parts of the architecture are found in the configuration file in pipeline_meta/prompt_meta.yaml. From this file we can specify the LLM to be used in the application, the options being:
If support for another model wants to be implemented, this option must be added in the load_llm function, which is located in src/services/rag_loader.py
Download mistral 7B model or other model: mistral-7b-instruct-v0.1.Q4_K_M.gguf
Change the model_file parameter in src/services/rag_loader.py to the model
streamlit run frontend/ui_feed_db.py
streamlit run frontend/ui_chat_db.py