Giter Site home page Giter Site logo

document-qna-chatbot's Introduction

document-qna-chatbot

Chatbot for asking questions about documents using open-source tools. Uses Langchain with RAG.

Background

Many tutorials on LangChain chatbots rely on using paid tokens from 3rd party providers. Our aim is to construct a simple document question answering bot using open-source tools.

The model architecture is based on a ConversationalRetrievalChain with memory.

We tested with the following data:

  • csv - health record data available from Kaggle
    Where the source column of text is 'Transcription'
  • pdf Several academic papers on using machine learning for automatic code generation.

How to run

  1. Codebase uses pipenv as environment manager. Install pipenv
    pip install pipenv

  2. Navigate to the project directory.

  3. Run command
    pipenv install --ignore-pipfile

You can also of course install the required packages with your preferred environment manager. The package list is found in Pipfile.

  1. Make sure you have a directory with the target documents that you want to ask questions about. At present, pdf and csv formats supported.

  2. Download an open-source language model. In this code, we used GPT4All.
    If you use other models,
    you must change the llm and embeddings imports to the appropriate one:
    from langchain.llms import GPT4All
    from langchain.embeddings import GPT4AllEmbeddings

Refer here for available LLMs.

  1. Create a local_config.py file with a MODEL_PATH variable pointing to your model.

  2. Navigate to your src directory and run:
    python main.py --directory '<document_path>' --file_type 'csv'

Improvements

Here are some ideas for improvements. We list them in order of priority:

  1. Performance improvement. Currently, a relatively involved question takes around 10 minutes.
    Yes, totally impractical but this is a first attempt on open-source data running on consumer-grade hardware.

  2. Document reference improvement. In the case of CSVs, the output includes the source rows of the answer,
    but there appears to be a bug with row duplication. Need to test how this works
    for multiple csv documents.

  3. More advanced pdf processing. It is practical to be able to handle PDFs with charts and tables.

document-qna-chatbot's People

Contributors

matsuobasho avatar

Watchers

 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.