DocsScraper.jl
v0.1.0
DocsScraper 是一個軟體包,旨在從 Julia 語言的線上文件網站建立「知識包」。
它會抓取並解析 URL,並在 PromptingTools.jl 的幫助下建立可在 RAG 應用程式中使用的區塊及其嵌入的索引。它與 AIHelpMe.jl 和 PromptingTools.jl 集成,提供高效且相關的查詢檢索,確保系統生成的回應特定於所創建資料庫中的內容。
若要安裝 DocsScraper,請使用 Julia 套件管理員和套件名稱(尚未註冊):
using Pkg
Pkg . add (url = " https://github.com/JuliaGenAI/DocsScraper.jl " )
先決條件:
using DocsScraper
crawlable_urls = [ " https://juliagenai.github.io/DocsScraper.jl/dev " ]
index_path = make_knowledge_packs (crawlable_urls;
index_name = " docsscraper " , embedding_dimension = 1024 , embedding_bool = true , target_path = " knowledge_packs " )
[ Info : robots . txt unavailable for https : // juliagenai . github . io : / DocsScraper . jl / dev / home /
[ Info : Scraping link : https : // juliagenai . github . io : / DocsScraper . jl / dev / home /
[ Info : robots . txt unavailable for https : // juliagenai . github . io : / DocsScraper . jl / dev
[ Info : Scraping link : https : // juliagenai . github . io : / DocsScraper . jl / dev
. . .
[ Info : Processing https : // juliagenai . github . io : / DocsScraper . jl / dev ...
[ Info : Parsing URL : https : // juliagenai . github . io : / DocsScraper . jl / dev
[ Info : Scraping done : 44 chunks
[ Info : Removed 0 short chunks
[ Info : Removed 1 duplicate chunks
[ Info : Created embeddings for docsscraper. Cost : $ 0. 001
a docsscraper__v20240823__textembedding3large - 1024 - Bool__v1. 0. hdf5
[ Info : ARTIFACT : docsscraper__v20240823__textembedding3large - 1024 - Bool__v1. 0. tar . gz
┌ Info : sha256 :
└ sha = " 977c2b9d9fe30bebea3b6db124b733d29b7762a8f82c9bd642751f37ad27ee2e "
┌ Info : git - tree - sha1 :
└ git_tree_sha = " eca409c0a32ed506fbd8125887b96987e9fb91d2 "
[ Info : Saving source URLS in Julia knowledge_packs docsscraper docsscraper_URL_mapping . csv
" Julia \ knowledge_packs \ docsscraper \ Index \ docsscraper__v20240823__textembedding3large-1024-Bool__v1.0.hdf5 "
make_knowledge_packs
是包包的入口點。此函數接收要解析的 URL 並傳回索引。此索引可以傳遞到 AIHelpMe.jl 以回答對建置的知識包的查詢。
預設make_knowledge_packs
參數:
embedding_bool = true
。embedding_dimension = custom_dimension
3072。max_chunk_size = custom_max_size
區塊大小為 384,最小min_chunk_size = custom_min_size
大小為 40。注意:對於日常使用,嵌入大小 = 1024 且嵌入類型 = Bool 就足夠了。這與 AIHelpMe 的:bronze
和:silver
管道 ( update_pipeline(:bronze)
) 相容。為了獲得更好的結果,請使用嵌入大小 = 3072 和嵌入類型 = Float32。這需要使用:gold
管道(請參閱更多?RAG_CONFIGURATIONS
)
using AIHelpMe
using AIHelpMe : pprint, load_index!
# set it as the "default" index, then it will be automatically used for every question
load_index! (index_path)
aihelp ( " what is DocsScraper.jl? " ) |> pprint
[ Info : Updated RAG pipeline to ` :bronze ` (Configuration key : " textembedding3large-1024-Bool " ) .
[ Info : Loaded index from packs : julia into MAIN_INDEX
[ Info : Loading index from Julia DocsScraper . jl docsscraper Index docsscraper__v20240823__textembedding3large - 1024 - Bool__v1. 0. hdf5
[ Info : Loaded index a file Julia DocsScraper . jl docsscraper Index docsscraper__v20240823__textembedding3large - 1024 - Bool__v1. 0. hdf5 into MAIN_INDEX
[ Info : Done with RAG. Total cost : $ 0. 009
--------------------
AI Message
--------------------
DocsScraper . jl is a Julia package designed to create a vector database from input URLs. It scrapes and parses the URLs and, with the assistance of
PromptingTools . jl, creates a vector store that can be utilized in RAG (Retrieval - Augmented Generation) applications. DocsScraper . jl integrates with
AIHelpMe . jl and PromptingTools . jl to provide efficient and relevant query retrieval, ensuring that the responses generated by the system are specific to the content in the created database.
提示:使用pprint
可以獲得更好的來源輸出,使用last_result
獲得更詳細的輸出(來源)。
using AIHelpMe : last_result
# last_result() returns the last result from the RAG pipeline, ie, same as running aihelp(; return_all=true)
print ( last_result ())
make_knowledge_packs
建立以下檔案:
index_name
│
├── Index
│ ├── index_name__artifact__info.txt
│ ├── index_name__vDate__model_embedding_size-embedding_type__v1.0.hdf5
│ └── index_name__vDate__model_embedding_size-embedding_type__v1.0.tar.gz
│
├── Scraped_files
│ ├── scraped_hostname-chunks-max-chunk_size-min-min_chunk_size.jls
│ ├── scraped_hostname-sources-max-chunk_size-min-min_chunk_size.jls
│ └── . . .
│
└── index_name_URL_mapping.csv
該專案是作為 Google Summer of Code (GSoC) 計劃的一部分開發的。 GSoC 是一項全球計劃,為學生開發人員提供津貼,幫助他們為開源專案編寫程式碼。我們感謝 Google 和開源社群透過這項措施提供的支持和機會。