0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Ollamaでtoolsを使う。Request受付まで

Posted at

Ollamaでtoolsが使えるようになったというニュースがありました。

それで気になって調べてみた結果がこれです。Lhama3.1です。途中までです。普通のチャットだと、role的に答えられないために途中までです。

ChatGPTのAssistant機能とか値段が、高かったので放置してたため、知識として欠落してました。

ようするに Toolを使うと、LLMが質問に質問を返すようになる。

https://ollama.com/blog/tool-support
toolとは、こちらで定義した関数を元に、向うから、最終的に、こちらのチャットに答えるために、質問してくる仕組み。(自動でそれに答える仕組みを用意しないといけない)
roleをtoolで答えたら、それを元に最終返答が返ってくるみたいです。

本来は、お天気の例みたいに、自分で関数を定義しないといけませんが、
Web browsing/検索(brave_search),数値計算(wolfram_alpha) コード実行(Code interpreter)は定義しなくても、用意されているみたいです。(モデルによるだろうけど)

image.png
引用元 https://llama.meta.com/docs/model-cards-and-prompt-formats/llama3_1/

ただ、公開アプリとかで、この機能実装すると、インターネット検索やpython実行など、セキュリティーホールになりそうな感じは強いよね。

 ただ、質問に答えるために、どのtool(関数)を使えばいいのか、判断するみたいなので、チャットだけで、面白いことはできそうですね。

入力と出力

System

Environment: ipython Tools: brave_search Today Date: 27 Jul 2024

Input

明日の東京の天気 use brave_search

Output

<|python_tag|>brave_search.call(query="tomorrow's weather in Tokyo")<|eom_id|>

SystemのEnvironment: ipythonや、Inputのuse brave_search入れた方が、python_tag形式で返す確率が上がります。(tool_choiceで制御するべきなのですが、未サポート)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?