
KnowledgeGPTは、インターネットやローカルデータを含むさまざまなソースから情報を収集するように設計されており、プロンプトを作成するために使用できます。これらのプロンプトは、OpenaiのGPT-3モデルによって利用され、その後、将来の参照のためにデータベースに保存される回答を生成できます。
これを達成するために、テキストは最初にオープンソースまたはOpenaIモデルのいずれかを使用して固定サイズのベクトルに変換されます。クエリが送信されると、テキストはベクトルに変換され、保存された知識の埋め込みと比較されます。その後、最も関連性の高い情報が選択され、迅速なコンテキストを生成するために使用されます。
KnowledgeGPTは、Webサイト、PDF、PowerPointファイル(PPTX)、ドキュメント(Docs)などのさまざまな情報ソースをサポートしています。さらに、YouTube字幕とオーディオ(音声からテキストテクノロジーを使用)からテキストを抽出し、情報源として使用できます。これにより、さまざまな範囲の情報を収集し、プロンプトと回答を生成するために使用できます。
Pypiインストール、ターミナルで実行: pip install knowledgegpt
または、リポジトリの最新バージョンを使用することもできます。PIP pip install -r requirements.txt 、次にpip install .
解析に必要な言語モデルをダウンロード: python3 -m spacy download en_core_web_sm
uvicorn server:app --reload
# 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 build -t knowledgegptimage .
docker run -p 8888:8888 knowledgegptimage(拡張される...)
(より良い画像で更新される)