Tool Call
LLM 要使用 tool 時,底層會透過特殊的 Token 進行輸出(通常在訓練後進行 fine-tuned 做處理),以 <|tool_call|>, <|end_tool_call|> 當作範例,實際上這個 Token 不代表任何的文字:
<|tool_call|>
{
"name": "get_current_weather",
"arguments": {
"location": "Austin, TX, USA"
}
}
<|end_tool_call|>
意思為要使用 get_current_weather 的這個 tool。
Harness 系統看到這 Token 的時候,瞭解到需要暫停 LLM 的執行,然後去執行這個 tool。
執行結束後,Harness 會以另一個標記,以<|tool_result|>, <|end_tool_result|> 告訴 LLM 執行的結果:
<|tool_result|>
{
"location": "Austin, TX, USA",
"temperature": 93,
"unit": "fahrenheit",
"conditions": "sunny"
}
<|end_tool_result|>
這些特殊 token 無法由人類輸入產生,所以模型會知道哪些是 tool 執行的結果。