Inspiration
Legal AI is a revolutionary web app that allows you to easily understand legal documents by interacting with them in a natural way. With our advanced AI technology, as soon as you upload a document, a summary is provided of the complete document, after which you can ask follow-up questions. You can basically "talk" to the document and ask any question you have, receiving clear and concise answers. Our user-friendly platform also enables you to ask any legal-related questions, even if they are not mentioned in the document, making it easy to navigate the complexities of legal language. Whether you are a lawyer, business owner, or just someone who needs to understand a legal contract, Legal AI is here to help you understand legal documents with ease.
We also manage the edge case such as our platform won't answer questions unrelated to the legal document, no matter how much generic the question is.
What it does
Legal AI solves the problem of understanding complex legal documents. Legal language can be difficult for laymen to comprehend, and the process of reviewing and understanding legal documents can be time-consuming and confusing.
It addresses this problem by providing an easy-to-use platform that uses advanced AI technology to summarize and explain legal documents in a clear and concise way. By allowing users to interact with documents and ask follow-up questions, Legal AI makes it easy for anyone to understand the contents of legal documents, regardless of their level of legal knowledge. This can save time, reduce confusion and increase understanding of legal agreements and contracts.
How we built it
We built the front end using NextJS. We used Firebase to store the uploaded documents. For the backend we used NodeJS to retrieve the documents Additionally, the main backend pipeline and processing were done in Flask. We handled the requests and processed the docs in Flask only. We used OpenAI's text-davinci model to summarize the uploaded document. To create the question answering related to the document, we used OpenAI's embeddings and langchain.
Challenges we ran into
Developing the main feature of the application i.e, you can basically talk to the document and ask anything about it, was the most difficult part to develop. We had to make sure that the 'PDF' document which was uploaded by the user is correctly processed and the text is extracted which is then further passed to our Open AI's embedding model where it is embedded into vectors and then the user can ask queries against that.
This was challenging as we had to make sure that the model should answer everything related to the document covering all the edge cases and not answer questions that are unrelated to the document and don't fall in the legal/law domain. Also, the GPT model shouldn't hallucinate either i.e it should not respond with made-up answers.
Also, we ran into errors regarding integrating our complete pipeline of the application. The user uploads the document via the NextJS frontend which then gets stored in firebase, we were unable to retrieve it using Flask therefore we had to introduce a NodeJS backend to retrieve files from Firebase and send them to our Flask backend where they can be processed further. So creating this complete pipeline was quite cumbersome and filled with errors which were solved eventually.
There were many irritating errors along the way that ate up a lot of our time. For instance, the one which kept us up all night: We kept getting a byte string instead of a JSON response upon a POST request. We had to solve it by decoding the byte string and then eventually stripping characters off of the string to obtain the required result.
Accomplishments that we're proud of
We are proud to have successfully built a pipeline to develop a fully functional web application using a variety of technologies. Also, super happy to have implemented everything in a given time frame
What we learned
We learned about OpenAI's embeddings, and a lot about leveraging LLMs to make a valuable product. We learned how to integrate the backend and front end seamlessly while ensuring that there is minimal latency.
What's next for LegalAI
Make it a one-stop solution for all your Legal and Law related needs by adding features to provide you with ready-to-go templates for different types of legal docs.
Built With
- firebase
- flask
- gpt-3
- next.js
- node.js
- openai
- python
- typescript
Log in or sign up for Devpost to join the conversation.