Skip to content

Latest commit

 

History

History
151 lines (100 loc) · 7.16 KB

README.md

File metadata and controls

151 lines (100 loc) · 7.16 KB

InterSystems IRIS Vector Search

This year, we're adding a powerful Vector Search capability to the InterSystems IRIS Data Platform, to help you innovate faster and build intelligent applications powered by Generative AI. At the center of the new capability is a new VECTOR native datatype for IRIS SQL, along with similarity functions that leverage optimized chipset instructions (SIMD).

This repository offers code samples to get you started with the new features, and we'll continue to add more, but encourage you to let us know about your own experiments on the InterSystems Developer Community. At the bottom of this page, you'll find links to a few demo repositories we liked a lot!

InterSystems IRIS Vector Search Quickstart

  1. Clone the repo
    git clone https://github.com/intersystems-community/hackmit-2024.git

Using a Jupyter container

If you prefer just running the demos from your local Python environment, skip to Using your local Python environment.

  1. For langchain_demo.ipynb and llama_demo.ipynb, you need an OpenAI API Key. Update the corresponding entry in docker-compose.yml:

      OPENAI_API_KEY: xxxxxxxxx
    
  2. Change your directory to hackmit-2024

    cd hackmit-2024
  3. Start the Docker containers (one for IRIS, one for Jupyter):

    docker-compose up
  4. Once loaded, navigate to http://localhost:8888/lab to access the notebook. To view the container information, run in a new terminal:

    docker-compose ps

Using your local Python environment

Note: if you used the previous method (Jupyter container), you will need to stop the previous docker container before running the following steps, as they will try to use the same port (Alternatively, use a different port)

  1. Install IRIS Community Edtion in a container:

    docker run -d --name iris-comm -p 1972:1972 -p 52773:52773 -e IRIS_PASSWORD=demo -e IRIS_USERNAME=demo intersystemsdc/iris-community:latest

    ℹ️ After running the above command, you can access the System Management Portal via http://localhost:52773/csp/sys/UtilHome.csp. Please note you may need to configure your web server separately when using another product edition.

  2. Create a Python environment and activate it (conda, venv or however you wish) For example:

    conda:

    conda create --name iris-vector-search python=3.10
    conda activate

    or

    venv (Windows):

    python -m venv iris-vector-search
    .\iris-vector-search\Scripts\Activate

    or

    venv (Unix):

    python -m venv iris-vector-search
    source ./iris-vector-search/bin/activate
  3. Install packages for all demos:

    pip install -r requirements.txt
  4. For langchain_demo.ipynb and llama_demo.ipynb, you need an OpenAI API Key. Create a .env file in this repo to store the key:

    OPENAI_API_KEY=xxxxxxxxx
    
  5. The demos in this repository are formatted as Jupyter notebooks. To run them, just start Jupyter and navigate to the /demo/ folder:

    jupyter lab

Using the Management Portal

  1. Navigate to http://localhost:52773/csp/sys/UtilHome.csp, login with username: demo, password: demo (or whatever you configured)
  2. Change the namespace (on the top left) from %SYS to USER
  3. On the left navigation pane, click 'System Explorer'
  4. Click 'SQL' -> 'Go'
  5. Here, you can execute SQL queries. You can also view the tables by clicking the relevant table on the left, under 'Tables', and then clicking 'Open Table' (above the SQL query box)

Basic Demos

IRIS SQL now supports vector search (with other columns)! In this demo, we're searching a whiskey dataset for whiskeys that are priced < $100 and have a taste description similar to "earthy and creamy taste".

IRIS now has a langchain integration as a VectorDB! In this demo, we use the langchain framework with IRIS to ingest and search through a document.

IRIS now has a llama_index integration as a VectorDB! In this demo, we use the llama_index framework with IRIS to ingest and search through a document.

If you are more comfortable with traditional forms of connection to a relational database like pyodbc, this and the next notebook will allow you to use the DB-API connection to IRIS db. This notebook covers the basic CRUD operations.

Building on IRISDatabaseOperations.ipynb, this notebook presents an example of semantic search leveraging the vector search capabilities in IRIS (using the pyodbc style DB-API connection).

Quick Start App

This allows you to quickly get started with a full stack app that uses a flask backend connected to an IRIS db. The frontend is basic HTML,javacript and css served from flask. This app uses the DB-API connectors, so this starter app along with demo notebooks : IRISDatabaseOperations.ipynb and SemanticSearch.ipynb can be used to make a more advanced app that leverages the vector search capabilities of IRIS

Which to use?

If you need to use search with filters, use IRIS SQL. This is the most flexible way to build RAG.

If you're building a genAI app that uses a variety of tools (agents, chained reasoning, api calls), go for langchain.

If you're building a RAG app, go for llama_index.

The fastest and easiest way to contact any InterSystems Mentor is via Slack or Discord - feel free to ask any questions about our technology, or about your project in general!

More Demos / References:

Uses langchain-iris to search Youtube Audio transcriptions

Original IRIS langhain demo, that runs the containerized IRIS in the notebook

Original IRIS llama_index demo, that runs the containerized IRIS in the notebook

Official page for InterSystems Documentation