Giter VIP home page Giter VIP logo

h2ogpt's Introduction

h2oGPT

Turn โ˜… into โญ (top-right corner) if you like the project!

Query and summarize your documents or just chat with local private GPT LLMs using h2oGPT, an Apache V2 open-source project.

  • Private offline database of any documents (PDFs, Excel, Word, Images, Code, Text, MarkDown, etc.)
  • Persistent database (Chroma, Weaviate, or in-memory FAISS) using accurate embeddings (instructor-large, all-MiniLM-L6-v2, etc.)
  • Efficient use of context using instruct-tuned LLMs (no need for LangChain's few-shot approach)
  • Upload and View documents via UI (collaborative space or scratch space)
  • UI or CLI with streaming of all models
  • Bake-off UI mode against many models at same time
  • Variety of models supported (Falcon, Vicuna, WizardLM including AutoGPTQ, 4-bit/8-bit, LORA)
  • GPU support from HF models, and CPU support using LLaMa cpp and GPT4ALL
  • Linux, Docker, MAC, and Windows support
  • Inference Servers support (HF TGI server, vLLM, Gradio, OpenAI)
  • OpenAI-compliant Python client API for client-server control
  • Evaluate performance using reward models

Live Demos

Resources:

Video Demo:

demo2.mp4

YouTube 4K version: https://www.youtube.com/watch?v=_iktbj4obAI

Guide:

Supported OS and Hardware

GitHub license Linux macOS Windows Docker

GPU mode requires CUDA support via torch and transformers. A 6.9B (or 12GB) model in 8-bit uses 8GB (or 13GB) of GPU memory. 8-bit precision, 4-bit precision, and AutoGPTQ can further reduce memory requirements down no more than about 6.5GB when asking a question about your documents (see low-memory mode).

CPU mode uses GPT4ALL and LLaMa.cpp, e.g. gpt4all-j, requiring about 14GB of system RAM in typical use.

GPU and CPU mode tested on variety of NVIDIA GPUs in Ubuntu 18-22, but any modern Linux variant should work. MACOS support tested on Macbook Pro running Monterey v12.3.1 using CPU mode, as well as MAC M1 using MPS.

Roadmap

  • Integration of code and resulting LLMs with downstream applications and low/no-code platforms
  • Complement h2oGPT chatbot with search and other APIs
  • High-performance distributed training of larger models on trillion tokens
  • Enhance the model's code completion, reasoning, and mathematical capabilities, ensure factual correctness, minimize hallucinations, and avoid repetitive output
  • Add other tools like search
  • Add agents for SQL and CSV question/answer

Getting Started

First one needs a Python 3.10 environment. For help installing a Python 3.10 environment, see Install Python 3.10 Environment. On newer Ubuntu systems and environment may be installed by just doing:

sudo apt-get install -y build-essential gcc python3.10-dev
virtualenv -p python3 h2ogpt
source h2ogpt/bin/activate

or use conda:

conda create -n h2ogpt -y
conda activate h2ogpt
conda install python=3.10 -c conda-forge -y

Check your installation by doing:

python --version # should say 3.10.xx
pip --version  # should say pip 23.x.y ... (python 3.10)

On some systems, pip still refers back to the system one, then one can use python -m pip or pip3 instead of pip or try python3 instead of python.

TLDR

For MACOS and Windows 10/11 please follow their instructions.

On Ubuntu, after Python 3.10 environment installed do:

git clone https://github.com/h2oai/h2ogpt.git
cd h2ogpt
# fix any bad env
pip uninstall -y pandoc pypandoc pypandoc-binary
# broad support, but no training-time or data creation dependencies

# CPU only:
pip install -r requirements.txt --extra-index https://download.pytorch.org/whl/cpu

# GPU only:
pip install -r requirements.txt --extra-index https://download.pytorch.org/whl/cu118

Then run:

# Required for Doc Q/A: LangChain:
pip install -r reqs_optional/requirements_optional_langchain.txt
# Required for CPU: LLaMa/GPT4All:
pip install -r reqs_optional/requirements_optional_gpt4all.txt
# Optional: PyMuPDF/ArXiv:
pip install -r reqs_optional/requirements_optional_langchain.gpllike.txt
# Optional: Selenium/PlayWright:
pip install -r reqs_optional/requirements_optional_langchain.urls.txt
# Optional: support docx, pptx, ArXiv, etc. required by some python packages
sudo apt-get install -y libmagic-dev poppler-utils tesseract-ocr libreoffice
# Optional: for supporting unstructured package
python -m nltk.downloader all
# Optional: For AutoGPTQ support on x86_64 linux
pip uninstall -y auto-gptq ; CUDA_HOME=/usr/local/cuda-11.8  GITHUB_ACTIONS=true pip install auto-gptq --no-cache-dir

See AutoGPTQ for more details for AutoGPTQ and other GPU installation aspects.

Place all documents in user_path or upload in UI (Help with UI).

UI using GPU with at least 24GB with streaming:

python generate.py --base_model=h2oai/h2ogpt-oasst1-512-12b --load_8bit=True  --score_model=None --langchain_mode='UserData' --user_path=user_path

UI using LLaMa.cpp model:

wget https://huggingface.co/TheBloke/WizardLM-7B-uncensored-GGML/resolve/main/WizardLM-7B-uncensored.ggmlv3.q8_0.bin
python generate.py --base_model='llama' --prompt_type=wizard2 --score_model=None --langchain_mode='UserData' --user_path=user_path

which works on CPU or GPU (assuming llama cpp python package compiled against CUDA or Metal).

If using OpenAI for the LLM is ok, but you want documents to be parsed and embedded locally, then do:

python generate.py  --inference_server=openai_chat --base_model=gpt-3.5-turbo --score_model=None

and perhaps you want better image caption performance and focus local GPU on that, then do:

python generate.py  --inference_server=openai_chat --base_model=gpt-3.5-turbo --score_model=None --captions_model=Salesforce/blip2-flan-t5-xl

Add --share=True to make gradio server visible via sharable URL. If you see an error about protobuf, try:

pip install protobuf==3.20.0

Once all files are downloaded, the CLI and UI can be run in offline mode, see offline mode.

Development

  • To create a development environment for training and generation, follow the installation instructions.
  • To fine-tune any LLM models on your data, follow the fine-tuning instructions.
  • To create a container for deployment, follow the Docker instructions.
  • To run h2oGPT tests, run pip install requirements-parser ; pytest -s -v tests client/tests

Help

Acknowledgements

Why H2O.ai?

Our Makers at H2O.ai have built several world-class Machine Learning, Deep Learning and AI platforms:

We also built platforms for deployment and monitoring, and for data wrangling and governance:

  • H2O MLOps to deploy and monitor models at scale
  • H2O Feature Store in collaboration with AT&T
  • Open-source Low-Code AI App Development Frameworks Wave and Nitro
  • Open-source Python datatable (the engine for H2O Driverless AI feature engineering)

Many of our customers are creating models and deploying them enterprise-wide and at scale in the H2O AI Cloud:

We are proud to have over 25 (of the world's 280) Kaggle Grandmasters call H2O home, including three Kaggle Grandmasters who have made it to world #1.

Disclaimer

Please read this disclaimer carefully before using the large language model provided in this repository. Your use of the model signifies your agreement to the following terms and conditions.

  • Biases and Offensiveness: The large language model is trained on a diverse range of internet text data, which may contain biased, racist, offensive, or otherwise inappropriate content. By using this model, you acknowledge and accept that the generated content may sometimes exhibit biases or produce content that is offensive or inappropriate. The developers of this repository do not endorse, support, or promote any such content or viewpoints.
  • Limitations: The large language model is an AI-based tool and not a human. It may produce incorrect, nonsensical, or irrelevant responses. It is the user's responsibility to critically evaluate the generated content and use it at their discretion.
  • Use at Your Own Risk: Users of this large language model must assume full responsibility for any consequences that may arise from their use of the tool. The developers and contributors of this repository shall not be held liable for any damages, losses, or harm resulting from the use or misuse of the provided model.
  • Ethical Considerations: Users are encouraged to use the large language model responsibly and ethically. By using this model, you agree not to use it for purposes that promote hate speech, discrimination, harassment, or any form of illegal or harmful activities.
  • Reporting Issues: If you encounter any biased, offensive, or otherwise inappropriate content generated by the large language model, please report it to the repository maintainers through the provided channels. Your feedback will help improve the model and mitigate potential issues.
  • Changes to this Disclaimer: The developers of this repository reserve the right to modify or update this disclaimer at any time without prior notice. It is the user's responsibility to periodically review the disclaimer to stay informed about any changes.

By using the large language model provided in this repository, you agree to accept and comply with the terms and conditions outlined in this disclaimer. If you do not agree with any part of this disclaimer, you should refrain from using the model and any content generated by it.

Star History

Star History Chart

h2ogpt's People

Contributors

pseudotensor avatar arnocandel avatar tloen avatar achraf-mer avatar hsm207 avatar chathurindaranasinghe avatar fazpu avatar mathanraj-sharma avatar this avatar zainhaq-h2o avatar eltociear avatar jefffohl avatar kohakublueleaf avatar 3x0dv5 avatar pascal-pfeiffer avatar srisatish avatar orellavie1212 avatar jllllll avatar lo5 avatar bofenghuang avatar oceanplexian avatar captain320 avatar wienke avatar rthaweewat avatar cimadure avatar 0xraks avatar maralski avatar cpatrickalves avatar parkeraddison avatar thisserand 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.