Code Monkey home page Code Monkey logo

document-question-answering-system's Introduction

Document-Question-Answering-System

Apply LLM to Your Documents for Question-Answering

This repository utlizes LLM, or OpenAI ChatGPT API to create an app for question-answering for the contents in documents.

Setup Environment

Download python libraries:

pip install -r requirements.txt

Preprocess Documents for Similarity Search

To vectorize documents for the question-answering system, use sentence transformers with example instructions here. Convert each section of the document into a single vector, and save to vectors.pkl. The original document can be saved as document.pkl with same order as their corresponding vectors.

from sentence_transformers import SentenceTransformer
model = SentenceTransformer("all-MiniLM-L6-v2")

# document sections to encode
sections = [
    "Chapter 1 Lorem ipsum dolor sit amet, consectetur adipiscing elit...",
    "Chapter 2 Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...z",
    "Chapter 3 Ut enim ad minim veniam, quis nostrud exercitation..."
]

# Sentences are encoded by calling model.encode()
embeddings = model.encode(sections)

Run App with OpenAI API

In terminal or cmd run:

flask run

Question-Answering Application should open up in browser http://127.0.0.1:5000:

User Interface

Run App with Local LLM

The local_llm_app.py script is compatible with Mistral-7B-Instruct-v0.1-GGUF. Download gguf model and set filepath in environment variable MODEL_PATH.

flask run local_llm_app

document-question-answering-system's People

Contributors

albertkao227 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.