About AI chat assistant
About
the customerOur customer was a US-based legal startup looking for a way to access the information stored within their internal database in a contextual, appropriate way using an LLM. They wanted to develop a specialized AI chat assistant tailored to the unique challenges of the legal industry, including high-fidelity responses and industry-compliant interactions.
About the projectThe main objective was to create an AI chat assistant to engage in intelligent conversations with legal documents stored in a database. The goal was to streamline document analysis and enhance legal discourse efficiency.
The challengeAfter the initial analysis and proof-of-concept phase, we identified a couple of challenges. First, the customer stored their documents in multiple formats in cloud storage services, so there was no single point of truth. Secondly, the documents in the internal database were confidential so data privacy and anonymity were a high priority. Lastly, we were dealing with cutting-edge technology in the field of law so we had to deliver a 100% stable and safe environment for the AI chat assistant users.
The solutionWe started with a thorough analysis of the documents and stored information. The first step was to unify disparate documents into a singular vector database from various cloud drives. Consolidating all legal records into a dedicated AWS S3 Bucket, we seamlessly chopped those big files and other documents into chunks and embedded them in vector format using the OpenAI text-embedding-ada002 model. We then leveraged Qdrant's vector database, empowering our AI chat assistant with semantic search capabilities.With the database transformed, we implemented RAG (Retrieval-Augmented Generation) which combines pre-trained AI language models like GPT-4 with information retrieved from an external knowledge base (like the legal document stored by the customer). It significantly improves conversational AI responses by retrieving information relevant to a specific context of questions asked by end-users. It was a great tool for our proof of concept but was ill-suited for the production phase as RAG has not yet reached the production-ready status. That’s when we switched to the OpenAI library. To facilitate effective search functionalities within legal documents, we incorporated the Qdrant vector database, designed to bolster semantic search and guarantee accurate and contextually aware information retrieval. For secure storage and management of user interactions and conversation history, we opted for PostgreSQL as our database.
For embedding legal documents we utilized the text-embedding-ada002 model provided by OpenAI. Additionally, we integrated the GPT-3.5 and GPT-4 models as our primary Language Models (LLM) to generate responses and engage in discourse. In upholding a secure and compliant setting, our team deployed OpenAI's moderation endpoint to guarantee adherence to OpenAI's policies. Prioritizing data privacy and anonymization, we employed AWS cloud services to protect user information and interactions.
As a result, we designed and implemented a custom AI chat assistant able to answer legal questions in a contextual, fast, and secure manner.