警告
该软件包是实验性的,处于开发早期。在生产中使用它时要小心。
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,这个项目就不可能实现!