LangChain and Redis collaborate to develop tools to improve the accuracy of financial document analysis.

2023-12-21

The emergence of advanced AI models has completely transformed the field of natural language processing, enabling machines to analyze, interpret, and respond to human language with increasing accuracy and complexity. However, even after significant advancements in these models, AI-driven assistants such as ChatGPT still face challenges in accurately answering complex questions extracted from documents filed with the U.S. Securities and Exchange Commission. Researchers at Patronus AI found that even the best-performing AI model configuration, OpenAI's GPT-4-Turbo, could only provide correct answers to 79% of the questions in Patronus AI's new test. In collaboration with LangChain, Redis has developed the Redis RAG template, optimized for creating conversation applications based on large language models (LLMs) with factual consistency. By leveraging Redis as a vector database, this template ensures fast context retrieval and prompt prompt construction, providing developers with essential tools to create chat applications that offer responsive and accurate AI responses. The Redis RAG template is a REST API that allows developers to interact with public financial documents, such as Nike's 10k filing. This application uses FastAPI and Uvicorn for HTTP service client requests. It also utilizes the UnstructuredFileLoader to parse PDF documents into raw text, the RecursiveCharacterTextSplitter to split the text into smaller chunks, and HuggingFace's 'all-MiniLM-L6-v2' sentence transformer to embed the text chunks into vectors. Additionally, it utilizes Redis as a vector database for real-time context retrieval and employs OpenAI's 'gpt-3.5-turbo-16k' LLM to generate answers to user queries. In a recent interaction with AIM, Redis CTO Yiftach Shoolman said, "Your data is everywhere, whether it's on your laptop, in organized repositories, on AWS S3, or in Google Cloud Storage. You need a platform to bring the data into vector databases like Redis and segment it based on relevant knowledge." Critiquing ChatGPT, he added, "ChatGPT doesn't know anything because it wasn't trained on your data," and emphasized that users need to look for data relevant to their requests in the knowledge base they just created. The RAG template provides a deployable reference architecture that combines efficiency with adaptability, offering developers a comprehensive set of options to create factually consistent chat applications with responsive and accurate AI responses based on LLMs. LangChain's deployable architecture hub also includes specific toolchains, LLM chains, and specific technology chains that reduce the difficulty of deploying APIs. LangServe plays a central role in deploying these templates, converting LLM-based chains or proxies into actionable REST APIs using FastAPI, improving accessibility, and ensuring production readiness.