
Use LLMs for document ranking
使用 LLM 进行文档排名。
AI 的力量在于,你可以“把问题扔给它”,然后得到一些结果,甚至不需要完全定义问题。例如,给它一堆代码差异(code diffs)和一份安全公告,然后问:“这些差异中哪一个最有可能修复这个安全漏洞?”然而,事情并不总是那么容易:
我们构建了 raink 来规避这些问题,并解决那些对 LLM 来说难以处理的通用排序问题。请参阅我们的博客文章 raink:使用 LLM 进行文档排名 了解该技术的更多背景,并观看我们的演讲 Patch Perfect:与 LLM 配合发现安全漏洞 了解我们如何将 raink 应用于进攻性安全问题。
git clone https://github.com/bishopfox/raink
cd raink
go install
设置你的 OPENAI_API_KEY 环境变量。
raink -h
Usage of raink:
-f string
Input file
-p string
Initial prompt
-r int
Number of runs (default 10)
-s int
Batch size (default 10)
不到 2 分钟即可比较 100 个句子。
raink \
-f testdata/sentences.txt \
-r 10 \
-s 10 \
-p 'Rank each of these items according to their relevancy to the concept of "time".' |
jq -r '.[:10] | map(.value)[]' |
nl
1 The train arrived exactly on time.
2 The old clock chimed twelve times.
3 The clock ticked steadily on the wall.
4 The bell rang, signaling the end of class.
5 The rooster crowed at the break of dawn.
6 She climbed to the top of the hill to watch the sunset.
7 He watched as the leaves fell one by one.
8 The stars twinkled brightly in the clear night sky.
9 He spotted a shooting star while stargazing.
10 She opened the curtains to let in the morning light.
本项目采用 MIT 许可证 授权。