
KnowledgeGPT 는 인터넷 및 로컬 데이터를 포함한 다양한 소스의 정보를 수집하도록 설계되었으며, 이는 프롬프트를 만들 수 있습니다. 그런 다음 이러한 프롬프트는 OpenAI의 GPT-3 모델에 의해 활용하여 향후 참조를 위해 데이터베이스에 저장된 답변을 생성 할 수 있습니다.
이를 달성하기 위해 텍스트는 먼저 오픈 소스 또는 OpenAI 모델을 사용하여 고정 크기 벡터로 변환됩니다. 쿼리가 제출되면 텍스트도 벡터로 변환되어 저장된 지식 임베딩과 비교됩니다. 그런 다음 가장 관련성이 높은 정보를 선택하고 즉각적인 컨텍스트를 생성하는 데 사용됩니다.
KnowledgeGPT는 웹 사이트, PDF, PPTX (PowerPoint Files) 및 문서 (DOCS)를 포함한 다양한 정보 소스를 지원합니다. 또한 YouTube 자막 및 오디오 (음성 텍스트 기술 사용)에서 텍스트를 추출하여 정보 소스로 사용할 수 있습니다. 이를 통해 다양한 정보를 수집하여 프롬프트 및 답변을 생성하는 데 사용할 수 있습니다.
PYPI 설치, 터미널에서 실행 : pip install knowledgegpt
또는 리포지토리에서 최신 버전을 사용할 수 있습니다 : 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(확장 될 ...)
(더 나은 이미지로 업데이트하려면)