Apache License 2.0

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

h2oai/h2ogpt:私密本地GPT的深层技术分析

项目背景与痛点

核心问题

在数据分析和人工智能领域,用户往往需要处理大量的文档、图片甚至视频数据。这些数据在本地部署时,如何保证处理的安全性和高效性成为了一个关键问题。同时,随着生成式AI模型的广泛应用,保证数据的隐私性和模型的可靠性也成为很多企业的迫切需求。

为什么需要 h2ogpt?

h2oai/h2ogpt 是一个基于 GPT(Generative Pre-trained Transformer)模型的私密聊天工具,旨在为用户提供一个完全私密的数据处理环境。通过在本地部署,它可以确保用户的文档、图片和视频等数据不离开本地机器,从而避免数据泄露的风险。

核心技术揭秘

技术架构

h2ogpt 支持多种流行的大模型框架,如 oLLaMa、Mixtral 和 llama.cpp,提供强大的文本生成和处理功能。其架构设计允许数据处理完全在本地进行,确保数据不离开用户的设备,提高了隐私保护水平。

graph TD A[用户请求] --> B{"参数校验"} B -->|"通过"| C[文档处理] B -->|"失败"| D[返回错误] C --> E[文本生成] E --> F[返回结果]

数据流与实现原理

在 h2ogpt 中,数据处理的核心流程包含以下几个步骤:

  1. 参数校验:用户输入后,系统首先对请求的参数进行验证,确保用户请求的有效性。
  2. 文档处理:通过内部的数据处理模块,将文档、图片、视频等数据转化为模型可理解的格式。
  3. 文本生成:使用选定的 GPT 模型框架(如 oLLaMa 或 Mixtral),进行文本生成或处理。
  4. 结果返回:将生成的文本或其他处理结果返回给用户。

功能亮点与差异

独特设计

h2ogpt 的关键优势在于其完全私密的数据处理环境。通过在本地部署,用户的数据不会暴露在任何网络环境中,从根本上避免了数据泄露的风险。另一方面,支持多种流行的大模型框架,使得 h2ogpt 能够适应不同的业务场景,满足多样化的处理需求。

对比竞品

与其他云服务或远程部署的生成式 AI 工具相比,h2ogpt 的主要优势在于数据隐私保护。远程部署方案可能会将用户的数据传输至云端,存在数据泄露的风险。而 h2ogpt 的本地部署模式,则完美解决了这一痛点。

应用场景与落地建议

生产环境使用注意事项

在实际生产环境中部署 h2ogpt,需要注意以下几个方面:

  1. 硬件资源:确保本地机器有充足的计算资源,尤其是 GPU 资源,以支持大模型的运行。
  2. 模型选择:根据实际业务需求,选择合适的 GPT 模型框架和版本,确保性能和效果的最佳平衡。
  3. 数据格式:正确处理各种输入数据的格式,确保文档、图片、视频等数据能够顺利转换为模型所需的格式。

适合的业务场景

h2ogpt 适用于任何需要处理敏感数据的企业或个人开发者,特别是需要严格保护数据隐私的环境,如金融、医疗和科研机构。

综合评价

优点

  1. 数据隐私保护:数据全程在本地处理,极大地增强了数据安全性。
  2. 多模型支持:支持多种 GPT 模型和框架,适应不同应用场景。
  3. 高效文本生成:强大的文本生成能力和本地处理效率,提供了高效的数据处理能力。

缺点

  1. 资源需求高:本地部署需要较高的硬件资源支持,尤其在处理大规模数据时更为明显。
  2. 定制开发:相较于其他云服务,h2ogpt 的定制和部署可能更具挑战。

通过深入的技术分析和功能解读,h2oai/h2ogpt 展现了其在私密数据处理和本地部署上的独特优势,是一款值得开发者深挖的优质项目。

关于

GitHub 原始描述(英文)

Private chat with local GPT with document, images, video, etc. 100% private, Apache 2.0. Supports oLLaMa, Mixtral, llama.cpp, and more. Demo: https://gpt.h2o.ai/ https://gpt-docs.h2o.ai/

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
14532
价值分
7529
活跃状态
归档

语言占比

Dockerfile
Groovy
HTML
Jupyter Notebook
Makefile
Python
Shell
Smarty
TeX

Release

README

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.

Check out a long CoT Open-o1 open 🍓strawberry🍓 project: https://github.com/pseudotensor/open-strawberry

Try Enterprise Version for Free

Enterprise h2oGPTe

Video Demo

https://github.com/h2oai/h2ogpt/assets/2249614/2f805035-2c85-42fb-807f-fd0bca79abc6

img-small.png YouTube 4K Video

Features

  • Private offline database of any documents (PDFs, Excel, Word, Images, Video Frames, YouTube, Audio, 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)
    • Parallel summarization and extraction, reaching an output of 80 tokens per second with the 13B LLaMa2 model
    • HYDE (Hypothetical Document Embeddings) for enhanced retrieval based upon LLM responses
    • Semantic Chunking for better document splitting (requires GPU)
  • Variety of models supported (LLaMa2, Mistral, Falcon, Vicuna, WizardLM. With AutoGPTQ, 4-bit/8-bit, LORA, etc.)
    • GPU support from HF and LLaMa.cpp GGML models, and CPU support using HF, LLaMa.cpp, and GPT4ALL models
    • Attention Sinks for arbitrarily long generation (LLaMa-2, Mistral, MPT, Pythia, Falcon, etc.)
  • Gradio UI or CLI with streaming of all models
    • Upload and View documents through the UI (control multiple collaborative or personal collections)
    • Vision Models LLaVa, Claude-3, Gemini-Pro-Vision, GPT-4-Vision
    • Image Generation Stable Diffusion (sdxl-turbo, sdxl, SD3), PlaygroundAI (playv2), and Flux
    • Voice STT using Whisper with streaming audio conversion
    • Voice TTS using MIT-Licensed Microsoft Speech T5 with multiple voices and Streaming audio conversion
    • Voice TTS using MPL2-Licensed TTS including Voice Cloning and Streaming audio conversion
    • AI Assistant Voice Control Mode for hands-free control of h2oGPT chat
    • Bake-off UI mode against many models at the same time
    • Easy Download of model artifacts and control over models like LLaMa.cpp through the UI
    • Authentication in the UI by user/password via Native or Google OAuth
    • State Preservation in the UI by user/password
  • Open Web UI with h2oGPT as backend via OpenAI Proxy
    • See Start-up Docs.
    • Chat completion with streaming
    • Document Q/A using h2oGPT ingestion with advanced OCR from DocTR
    • Vision models
    • Audio Transcription (STT)
    • Audio Generation (TTS)
    • Image generation
    • Authentication
    • State preservation
  • Linux, Docker, macOS, and Windows support
  • Inference Servers support for oLLaMa, HF TGI server, vLLM, Gradio, ExLLaMa, Replicate, Together.ai, OpenAI, Azure OpenAI, Anthropic, MistralAI, Google, and Groq
  • OpenAI compliant
    • Server Proxy API (h2oGPT acts as drop-in-replacement to OpenAI server)
    • Chat and Text Completions (streaming and non-streaming)
    • Audio Transcription (STT)
    • Audio Generation (TTS)
    • Image Generation
    • Embedding
    • Function tool calling w/auto tool selection
    • AutoGen Code Execution Agent
  • JSON Mode
    • Strict schema control for vLLM via its use of outlines
    • Strict schema control for OpenAI, Anthropic, Google Gemini, MistralAI models
    • JSON mode for some older OpenAI or Gemini models with schema control if model is smart enough (e.g. gemini 1.5 flash)
    • Any model via code block extraction
  • Web-Search integration with Chat and Document Q/A
  • Agents for Search, Document Q/A, Python Code, CSV frames
    • High quality Agents via OpenAI proxy server on separate port
    • Code-first agent that generates plots, researches, evaluates images via vision model, etc. (client code openai_server/openai_client.py).
    • No UI for this, just API
  • Evaluate performance using reward models
  • Quality maintained with over 1000 unit and integration tests taking over 24 GPU-hours

Get Started

GitHub license Linux macOS Windows Docker

Install h2oGPT

Docker is recommended for Linux, Windows, and MAC for full capabilities. Linux Script also has full capability, while Windows and MAC scripts have less capabilities than using Docker.


Collab Demos

Resources

Docs Guide

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 run h2oGPT tests:
    pip install requirements-parser pytest-instafail pytest-random-order playsound==1.3.0
    conda install -c conda-forge gst-python -y
    sudo apt-get install gstreamer-1.0
    pip install pygame
    GPT_H2O_AI=0 CONCURRENCY_COUNT=1 pytest --instafail -s -v tests
    # for openai server test on already-running local server
    pytest -s -v -n 4 openai_server/test_openai_server.py::test_openai_client
    
    or tweak/run tests/test4gpus.sh to run tests in parallel.

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

评论

暂无评论