警告
該軟體包是實驗性的,處於開發早期。在生產中使用它時要小心。
Spehulak.jl 是一個 GenAI 可觀察性套件 - 幫助您了解 GenAI 模型內部發生的情況。它提供了一組用於檢查和評估透過 PromptingTools.jl 保存的追蹤的工具。
只需使用以下命令將其添加到您的環境中:
using Pkg
Pkg . activate ( " . " )
Pkg . add ( " Spehulak " )
然後,啟動應用程式
using Spehulak
launch () # starts an asynchronous server on 9001
開啟瀏覽器並導航至http://localhost:9001
。
Spehuak 可以載入透過 PromptingTools.jl(即 JSON 檔案)保存的任何序列化的 LLM 對話或 RAG 結果。
有兩種選擇:
例如,在此儲存庫中載入檔案log/conversation...
有兩個頁面:1) 對話瀏覽器和 2) RAG 檢視器。您可以透過點擊左側的圖示在它們之間進行更改。
對話瀏覽器顯示垂直堆疊的所有已載入對話,因此您可以快速瀏覽追蹤並注意到奇怪的行為。
RAG 檢視器始終僅顯示單一RAGResult
,但會顯示大量詳細資訊(例如,使用者對話、底層 LLM 鏈、來源、上下文、排名/嵌入候選者等)。
為了幫助您進行導航,您可以使用右上角的箭頭:「<」轉到上一個,「>」轉到下一個,以及用於隨機選擇的骰子圖示。您可以將這些導航工具用於對話瀏覽器和 RAG 檢視器。
對於對話瀏覽器,您還可以過濾特定關鍵字(它在幕後利用occursin
)。只需輸入一些關鍵字並按 ENTER 鍵即可。它將僅保留包含該關鍵字的對話。
提示
過濾對話時,首先使用 Spehulak 進行過濾以減少顯示的對話數量,然後使用瀏覽器搜尋工具突出顯示所需關鍵字的所有出現位置。
它能做什麼?瀏覽任何序列化的 LLM 對話。如果您使用追蹤訊息,我們也會顯示所有相關元資料(模型、範本、範本版本等)。
如何自動儲存/記錄我的 LLM 對話?請參閱 PromptingTools.jl 文檔
或生成一些玩具範例
using PromptingTools
using PromptingTools : TracerSchema, SaverSchema, OpenAISchema, pprint
schema = OpenAISchema () |> TracerSchema |> SaverSchema
# Let's create a multi-turn conversation
conversation = aigenerate (schema, :JuliaExpertAsk ; ask = " Write a function to convert vector of strings into pig latin " , model = " gpt4o " , return_all = true )
pprint (conversation)
# Let's create one more turn -- notice that we provide the past conversation as a kwarg
conversation = aigenerate (schema, " That's too complicated. Please simplify it. Think step by step first " ; conversation, model = " gpt4o " , return_all = true )
pprint (conversation)
您應該會看到在資料夾log/
中創建了一些檔案 - 嘗試使用 Spehuak 打開它們!
如何保存我的 RAG 結果?
保存RAGResult
以供將來分析就像JSON3.write(path, result)
一樣簡單
完整範例:
using PromptingTools
using PromptingTools : pprint
using PromptingTools . Experimental . RAGTools
# to access unexported functionality
const RT = PromptingTools . Experimental . RAGTools
sentences = [
" Search for the latest advancements in quantum computing using Julia language. " ,
" How to implement machine learning algorithms in Julia with examples. " ,
" Looking for performance comparison between Julia, Python, and R for data analysis. " ,
" Find Julia language tutorials focusing on high-performance scientific computing. " ,
" Search for the top Julia language packages for data visualization and their documentation. " ,
" How to set up a Julia development environment on Windows 10. " ,
" Discover the best practices for parallel computing in Julia. " ,
" Search for case studies of large-scale data processing using Julia. " ,
" Find comprehensive resources for mastering metaprogramming in Julia. " ,
" Looking for articles on the advantages of using Julia for statistical modeling. " ,
" How to contribute to the Julia open-source community: A step-by-step guide. " ,
" Find the comparison of numerical accuracy between Julia and MATLAB. " ,
" Looking for the latest Julia language updates and their impact on AI research. " ,
" How to efficiently handle big data with Julia: Techniques and libraries. " ,
" Discover how Julia integrates with other programming languages and tools. " ,
" Search for Julia-based frameworks for developing web applications. " ,
" Find tutorials on creating interactive dashboards with Julia. " ,
" How to use Julia for natural language processing and text analysis. " ,
" Discover the role of Julia in the future of computational finance and econometrics. "
]
sources = map (i -> " Doc $i " , 1 : length (sentences))
# # Build the index
index = RT . build_index (sentences; chunker_kwargs = (; sources))
# # Generate an answer
question = " What are the best practices for parallel computing in Julia? "
result = airag (index; question, return_all = true )
# You can preview the RAGResult with pretty-printing
pprint (result)
# Save the RAGResult
mkpath ( " log " )
JSON3 . write ( " log/rag_result_20240615.json " , result)
現在,您可以使用 Spehulak 檢查其詳細資訊!
斯佩胡拉克是什麼?
「Špehulak」(發音為“shpeh-hoo-lahk”)融合了“間諜”和“雪人”,即興發揮了捷克語“špeh”(間諜)和“sněhulák”(雪人)的意思。對於可觀察性平台來說,這是一個有趣的名字,因為它就像間諜一樣保持警惕,而雪人部分則在你篩選大量數據時在壓力下保持冷靜,而且是隱形的/在後台,而不是在現實中。它非常適合深入了解 LLM 應用程式的內部運作!
MultiCandidateChunks
) 如果沒有來自 Genie.jl 系列的令人驚嘆的 Stipple.jl,這個項目就不可能實現!