ドキュメントのランキングにLLMを使用します。
AIには、問題を完全に定義せずに「問題を投げる」だけで何らかの結果を得られるという力があります。例えば、コード差分を大量に与えてセキュリティアドバイザリを添え、「これらの差分のうち、どれがセキュリティバグを修正する可能性が最も高そうですか?」と尋ねることができます。しかし、常にそれほど簡単なわけではありません。
私たちは、こうした問題を回避し、LLMが処理するのが難しい一般的なランキング問題を解決するためにrainkを構築しました。このテクニックの背景についてはブログ記事 raink: Use LLMs for Document Ranking を、また、rainkを攻撃的セキュリティ問題に応用した方法については講演 Patch Perfect: Harmonizing with LLMs to Find Security Vulns をご覧ください。
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)
100の文を2分以内で比較します。
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ライセンスの下でライセンスされています。