Git Product home page Git Product logo

neo4j-generative-ai-azure's Introduction

neo4j-generative-ai-azure

This is a sample notebook and web application which shows how Azure OpenAI can be used with Neo4j. We will explore how to leverage Azure OpenAI LLMs to build and consume a knowledge graph in Neo4j.

This notebook parses data from a public corpus of Medical Case Sheet using Azure OpenAI's gpt-4-32k model. The model is prompted to recognise and extract entities and relationships.

We then use the gpt-4-32k model and prompt it to convert questions in English to Cypher - Neo4j's query language for data retrieval.

Setup

To get started, create a managed notebook in Azure ML. Once that has started, open the notebook and a terminal window within that. Clone this repo with the command:

git clone https://github.com/neo4j-partners/neo4j-generative-ai-azure.git

Notebook

The notebook at ingestion/ingestion.ipynb walks through prompts and tuning a model. You will need to run that before the UI.

UI

The UI application is based on Streamlit.

Let's install python & pip first:

apt install -y python
apt install -y pip

Now, let's create a Virtual Environment to isolate our Python environment and activate it

apt-get install -y python3-venv
python3 -m venv /app/venv/genai
source /app/venv/genai/bin/activate

To install Streamlit and other dependencies:

cd ui
pip install -r requirements.txt

Check if streamlit command is accessible from PATH by running this command:

streamlit --version

If not, you need to add the streamlit binary to PATH variable like below:

export PATH="/app/venv/genai/bin:$PATH"

Next up you'll need to create a secrets file for the app to use. Open the file and edit it:

cd streamlit
cd .streamlit
cp secrets.toml.example secrets.toml
vi secrets.toml

You will now need to edit that file to reflect your Azure OpenAI and Neo4j credentials. The file has the following variables:

OPENAI_API_KEY = "" #OPENAI KEY
OPENAI_API_TYPE = "azure"
OPENAI_API_VERSION = "2023-03-15-preview"
OPENAI_API_BASE = ""
OPENAI_MODEL_NAME = "gpt-4-32k"
OPENAI_DEPLOYMENT_NAME = "gpt-4-32k"
NEO4J_URI = "neo4j+s://xxxxx.databases.neo4j.io" # Neo4j URL. Include port if applicable
NEO4J_USER = "neo4j" # Neo4j User Name
NEO4J_PASSWORD = "Foo12345678" #Neo4j Password

Now we can run the app with the commands:

streamlit run Home.py --server.port=80

Sample Questions to ask:

  1. Which patient has the most number of symptoms?
  2. Which disease affect most of my patients?
  3. How many of my patients suffer from both cough and weight loss?
  4. When someone has cough and nausea, do they also lose weight?
  5. Which body part got affected in most of my patients?
  6. Which age group has the most number of heart diseases?

neo4j-generative-ai-azure's People

Contributors

ezhilvendhan avatar benofben avatar

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.