Giter Site home page Giter Site logo

llm-chain-entity-extraction's Introduction

Using AI Chains for SNOMED CT entity extraction from free text clinical notes

LLM Chains allow us to divide a complex task into a Chain of smaller tasks, where the output of one prompt becomes the input of the next.

This is not significantly slower, despite requiring a greater number of calls/requests to the LLM, because short outputs take a proportionally shorter time to generate. Although the input prompt tokens also need to be processed each time, they are less time-expensive than output generated tokens in the case of LLaMA 2.

Chain design

image

How to run the Entity Extractor

The entity_extractor.py script extracts clinical entities from free text using LLMs. It uses the FHIR API to retrieve clinical data and the OpenAI, BARD, or Llama API to extract entities from the text.

Prerequisites

To run the entity_extractor.py script, you will need:

Usage

To use the entity_extractor.py script, follow these steps:

  • Clone the repository to your local machine.
  • Open the project in your preferred code editor.
  • Install any necessary dependencies by running pip install -r requirements.txt in your terminal.
  • If you need to use OpenAI models, save your OpenAI API key in a file named "openai.key".
  • Run the script by typing python entity_extractor.py -a --model in your terminal, where is the name of the LLM API you want to use (openai, bard, or llama) and is the name of the model you want to run for OpenAI or path to the model in the case of Llama-2.
  • View the output in the terminal or in the output pane of your code editor.

Examples:

python3.10 entity_extractor.py --api llama --model /my-drive/models/llama2/llama-2-13b-chat/ggml-model-q4_0.bin --sentences=example_cases/clinical_text.txt

python3 entity_extractor.py --api openai --model gpt-4o  --sentences=example_cases/clinical_text.txt

References

llm-chain-entity-extraction's People

Contributors

alopezo avatar ageneric avatar kaicode avatar stacksharebot avatar liquid36 avatar dependabot[bot] avatar

Stargazers

 avatar Sophie avatar Sathianphong Phongsathian avatar  avatar HengJay avatar Akarshi Mathur avatar  avatar Dee-Anne B avatar Shaishav Jain avatar MITAI avatar Thomas Corcoran avatar  avatar  avatar

Watchers

Rory Davidson avatar  avatar  avatar Peter G. Williams avatar Michael Chu avatar Jim avatar Steve Archbold avatar Juergen Baier avatar  avatar  avatar  avatar  avatar  avatar

llm-chain-entity-extraction's Issues

Missing requirements.txt file

Hi @kaicode, I want to try this repo and test some SNOMED-CT entity experiments with entity_extractor.py

but I didn't find the requirements.txt so that I can install the related package.

Where can I find that? ๐Ÿง Thanks a lot~

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.