· May 15 4m read

Vector search + GenAI + InterSystems technologies with Banksia Global


Hi all! Here I would like to share how we use vector search and GenAI with InterSystems technology. As an example, I'll describe BG-AppealAI project, which our company submitted to the InterSystems Vector Search, GenAI and ML Contest. BG-AppealAI application can write an appeal if you upload an insurance contract and the insurance company’s letter with a refusal to pay medical expenses. Of course, we are aware that at the moment AI has not reached such a level as to create ready-made legal documents. However, it's already possible to create tools to serve as assistants for specialists or ordinary users. Likewise, our application is an AI assistant that answers the question: "Is an appeal possible?" and creates a draft letter of appeal, if possible. 

Explore our application in action by following this link:

We've also created a video showcasing our app:

How BG-AppealAI works

Insurance contracts and rejection letters vectorization: to be able to better assist with appeals, AI needs a context of the denial. One of the possible ways we can provide a context is by citing relevant parts of insurance contracts. Upon receiving an insurance contract, BG-AppealAI breaks it down into parts, converting each part into a multi-dimensional vector. These vectors are stored in an InterSystems IRIS database, allowing fast and accurate retrieval when needed. 

Vector Search:  when you upload a rejection letter to the app, BG-AppealAI converts it to the vector, this is called the vectorization process.  BG-AppealAI then uses IRIS vector search functionality to compare vectors extracted from the rejection letter with vectors extracted from the relevant insurance contract.

AI-Powered Appeal Generation: having identified potential context for appeal, BG-AppealAI sends a request to the generative AI service to assess the possibility of drafting an appeal. If it is deemed appropriate, AppealAI sends a new request in order to create a draft letter of appeal.


What's under the hood of the BG-AppealAI

Traditionally, our application consists of backend and frontend parts, where the frontend is developed on Angular framework and the backend on InterSystems IRIS. The video about our application has already shown the work of the frontend part of the application and a brief overview of the product, here I want to focus on the implementation of Interoperability Production. This is where we can clearly see the application of vector search and generative AI. 

So, there are the following elements in our system:
1) ConversionToVector - process that converts document text into vectors using LangChain, and invokes process GetText and operations SaveVector, SaveDocument for the corresponding actions.


2) GetText - process that parses data from a file into a stream, for further text processing and analysis. Here there is opportunity to work with 2 types of extensions: docx and pdf, as the most common ones for documents. 


3) VectorSearch - process that performs a vector search and looks for matches between documents. Also, it is in this business process that methods are called to write promts to the AI and analyze rejection letters. 


Note, that here we used a language model developed by OpenAI and the LangChain framework. All business processes are implemented using embedded python as it provides easy access to utilization to use LangChain and write promts to OpenAI.
4) AppealIn - service that receives the rejection file and sends it for analysis.
5) DocumentIn - service that receives the insurance contract file and sends it for vectorization.
6) OpenAiOut - operation that makes a request to a generative AI - OpenAI, receives promt, returns a response from GenAI.
7) SaveDocument - operation that stores the document file in the database.
8) SaveVector - operation that stores vectors in the database.
9) SaveAppeal - operation that gets the text of the appeal and stores it in the database.

The interaction of all the above elements is well shown by the visual trace. Visual trace of taking an insurance contract, dividing it into vectors, and storing the vectors in a database:


Visual trace of receiving a rejection letter, sending requests to OpenAI, and saving the appeal letter if an appeal is possible:


This is an example of a rejection letter:


This is an example of an appeal written by BG-AppealAI:


We hope that our open source project will be useful to this community and help you implement innovative technologies in your projects. Our team would like to thank InterSystems for the opportunity to work with cutting-edge technologies. We're eager to engage with your thoughts and questions in the comments below. Let's continue pushing the boundaries of what's possible with technology together! Stay tuned for more updates and insights from our team.

If you enjoyed getting to know BG-AppealAI and its features and would like to support us, please take a moment to vote for our app here Thank you!

Discussion (1)4
Log in or sign up to continue

Hi Maria,

Your video is available on InterSystems Developers YouTube:

⏯️ AppealAIMovie
[This is an embedded link, but you cannot view embedded content directly on the site because you have declined the cookies necessary to access it. To view embedded content, you would need to accept all cookies in your Cookies Settings]