Code Monkey home page Code Monkey logo

nlp-llm-medicalbot's Introduction

NLP-LLM-MedicalBot

A quantined llama 2 based medical bot using a medical book pdf for vector database and chainlit for ui

Demo Video

Alt Text

Features

  • The medicalbot uses the pdf file 71763-gale-encyclopedia-of-medicine.-vol.-1.-2nd-ed.pdf is used to generate a vector database and this vector database is used as a reference when answering user questions.
  • The vector database is generated from the pdf file using the script ingest.py
    • HuggingFaceEmbeddings from langchain utilizes the model sentence-transformers/all-MiniLM-L6-v2 to generate the vector database
  • The main python script for the chainlit chatbot is model.py
    • The chatbot LLM model used is TheBloke/Llama-2-7B-Chat-GGML, a quantized version of Llama 2 7B Chat. As such this quantized model takes up less resources.
    • The chatbot responds by displaying both the user-query answer and the source of info. from the pdf file.

Environment

Python version: 3.10

Instructions

  1. Install dependencies using pip install -r requirements.txt (creating a separate virtual environment is recommended)
  2. Run the script python ingest.py to create a vector database
  3. Run the chainlit-langchain script chainlit run model.py -w to run the chatbot powered by quantized Llama 2 7B Chat.
    • Note: Since this code utilizes the CPU, the reponse from the bot takes some time to generate.

Reference

nlp-llm-medicalbot's People

Contributors

rukshar69 avatar

Watchers

 avatar

Forkers

stophobia

nlp-llm-medicalbot's Issues

1 validation error for StuffDocumentsChain __root__ document_variable_name context was not found in llm_chain input_variables: [''] (type=value_error)

(llama) E:\LLAMA>chainlit run model.py -w
2024-02-28 16:40:08 - Your app is available at http://localhost:8000
2024-02-28 16:40:11 - Translation file for en-IN not found. Using default translation en-US.
2024-02-28 16:40:15 - Load pretrained SentenceTransformer: sentence-transformers/all-MiniLM-L6-v2
2024-02-28 16:40:19 - Loading faiss with AVX2 support.
2024-02-28 16:40:19 - Could not load library with AVX2 support due to:
ModuleNotFoundError("No module named 'faiss.swigfaiss_avx2'")
2024-02-28 16:40:19 - Loading faiss.
2024-02-28 16:40:19 - Successfully loaded faiss.
2024-02-28 16:40:43 - 1 validation error for StuffDocumentsChain
root
document_variable_name context was not found in llm_chain input_variables: [''] (type=value_error)
Traceback (most recent call last):
File "E:\LLAMA\llama\lib\site-packages\chainlit\utils.py", line 39, in wrapper
return await user_function(**params_values)
File "E:\LLAMA\model.py", line 63, in start
chain = qa_bot()
File "E:\LLAMA\model.py", line 55, in qa_bot
qa = retrieval_qa_chain(llm, qa_prompt, db)
File "E:\LLAMA\model.py", line 39, in retrieval_qa_chain
qa_chain = RetrievalQA.from_chain_type(
File "E:\LLAMA\llama\lib\site-packages\langchain\chains\retrieval_qa\base.py", line 105, in from_chain_type
combine_documents_chain = load_qa_chain(
File "E:\LLAMA\llama\lib\site-packages\langchain\chains\question_answering_init_.py", line 249, in load_qa_chain
return loader_mapping[chain_type](
File "E:\LLAMA\llama\lib\site-packages\langchain\chains\question_answering_init_.py", line 81, in _load_stuff_chain
return StuffDocumentsChain(
File "E:\LLAMA\llama\lib\site-packages\langchain_core\load\serializable.py", line 120, in init
super().init(**kwargs)
File "E:\LLAMA\llama\lib\site-packages\pydantic\v1\main.py", line 341, in init
raise validation_error
pydantic.v1.error_wrappers.ValidationError: 1 validation error for StuffDocumentsChain
root
document_variable_name context was not found in llm_chain input_variables: [''] (type=value_error)

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.