KnowledgeGPT--本地部署--从各种信息源中提取知识并生成答案
KnowledgeGPT是什么?
KnowledgeGPT是用于从各种信息源中提取知识并使用OpenAI的GPT-3模型生成答案的工具。
支持从互联网、本地数据、YouTube字幕和音频等各种信息源中提取文本。可以使用RESTful API或Python库进行调用。
项目GitHub地址: https://github.com/geeks-of-data/knowledge-gpt
知识gpt
knowledgegpt旨在从各种来源收集信息,包括互联网和本地数据,这些信息可用于创建提示。然后,OpenAI 的 GPT-3 模型可以利用这些提示来生成答案,然后将其存储在数据库中以供将来参考。
为了实现这一目标,首先使用开源或 OpenAI 模型将文本转换为固定大小的向量。提交查询时,文本也会转换为向量并与存储的知识嵌入进行比较。然后选择最相关的信息并用于生成提示上下文。
knowledgegpt支持各种信息源,包括网站、PDF、PowerPoint 文件 (PPTX) 和文档 (Docs)。此外,它还可以从 YouTube 字幕和音频中提取文本(使用语音转文本技术)并将其用作信息源。这允许收集各种信息并用于生成提示和答案。
Pypi链接地址: https: //pypi.org/project/knowledgegpt/
安装
PyPI安装,在终端中运行:
pip install knowledgegpt
或者您可以使用存储库中的最新版本:
pip install -r requirements.txt
然后pip install .
下载解析所需的语言模型:
python3 -m spacy download en_core_web_sm
如何使用
API
uvicorn server:app --reload
设置您的 API 密钥
创建新密钥并复制
如何使用图书馆
# Import the library from knowledgegpt.extractors.web_scrape_extractor import WebScrapeExtractor # Import OpenAI and Set the API Key import openai from example_config import SECRET_KEY openai.api_key = SECRET_KEY # Define target website url = "https://en.wikipedia.org/wiki/Bombard_(weapon)" # Initialize the WebScrapeExtractor scrape_website = WebScrapeExtractor( url=url, embedding_extractor="hf", model_lang="en") # Prompt the OpenAI Model answer, prompt, messages = scrape_website.extract(query="What is a bombard?",max_tokens=300, to_save=True, mongo_client=db) # See the answer print(answer) # Output: 'A bombard is a type of large cannon used during the 14th to 15th centuries.'
其他示例可以在示例文件夹中找到。但为了更好地了解如何使用该库,这里有一个简单的示例:
# Basic Usage basic_extractor = BaseExtractor(df) answer, prompt, messages = basic_extractor.extract("What is the title of this PDF?", max_tokens=300)
# PDF Extraction pdf_extractor = PDFExtractor( pdf_file_path, extraction_type="page", embedding_extractor="hf", model_lang="en") answer, prompt, messages = pdf_extractor.extract(query, max_tokens=1500)
# PPTX Extraction ppt_extractor = PowerpointExtractor(file_path=ppt_file_path, embedding_extractor="hf", model_lang="en") answer, prompt, messages = ppt_extractor.extract( query,max_tokens=500)
# DOCX Extraction docs_extractor = DocsExtractor(file_path="../example.docx", embedding_extractor="hf", model_lang="en", is_turbo=False) answer, prompt, messages = \ docs_extractor.extract( query="What is an object detection system?", max_tokens=300)
# Extraction from Youtube video (audio) scrape_yt_audio = YoutubeAudioExtractor(video_id=url, model_lang='tr', embedding_extractor='hf') answer, prompt, messages = scrape_yt_audio.extract( query=query, max_tokens=1200) # Extraction from Youtube video (transcript) scrape_yt_subs = YTSubsExtractor(video_id=url, embedding_extractor='hf', model_lang='en') answer, prompt, messages = scrape_yt_subs.extract( query=query, max_tokens=1200)
Docker 的使用
docker build -t knowledgegptimage . docker run -p 8888:8888 knowledgegptimage
如何贡献
打开一个问题
分叉仓库
创建一个新分支
做出你的改变
创建拉取请求
特征
从互联网(即维基百科)中提取知识
从本地数据源提取知识 - PDF
从本地数据源提取知识 - DOCX
从本地数据源提取知识 - PPTX
从 YouTube 音频中提取知识(当字幕不可用时)
从 YouTube 成绩单中提取知识
从整个 YouTube 播放列表中提取知识
去做
FAISS 支持
添加矢量数据库(Pinecone、Milvus、Qdrant 等)
添加耳语模型
添加 Whisper 本地支持(不通过 openai API)
为超过 25MB 的音频添加 Whisper
添加网络界面
迁移到 Promptify 以生成提示
添加 ChatGPT 支持
通过更好的基础设施和规划添加 ChatGPT 支持
增加提示数量
增加支持的知识源数量
增加支持的语言数量
增加开源模型的数量
高级网页抓取
提示答案存储(很可能这将在单独的项目中完成)
添加更好的文档
添加更好的日志系统
添加更好的错误处理系统
添加更好的测试系统
添加更好的 CI/CD 系统
将项目 Docker 化
添加搜索引擎支持,如Google、Bing等。
添加对开源 OpenAI 替代方案的支持(用于生成答案)
评估依赖关系并删除不必要的依赖关系
为任何型号的使用提供迅速的灵活性