---
title: "Function calling (LLM) — ファンクションコーリング"
source: "https://systems-analysis.info/int/Function_calling_(LLM)_%E2%80%94_%E3%83%95%E3%82%A1%E3%83%B3%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%AA%E3%83%B3%E3%82%B0"
wiki: "systems-analysis.info/int"
article: "Function_calling_(LLM)_—_ファンクションコーリング"
language: "ja"
categories:
  - "Category:Japanese"
  - "Category:Large language models"
  - "Category:Machine learning"
  - "Category:Prompt engineering"
revision_id: 2344
wiki_created_at: 2026-09-06T23:02:28Z
wiki_modified_at: 2026-09-06T23:02:28Z
downloaded_at: 2026-09-07T22:50:36Z
---

# Function calling (LLM) — ファンクションコーリング

**Function Calling** (**関数呼び出し**) — は、大規模言語モデル (LLM)において、モデルが外部のツールやAPIと対話し、直接的なテキスト応答の代わりに構造化データ（通常はJSON）を生成して関数を呼び出すことを可能にするメカニズムです<sup>[\[1\]](https://systems-analysis.info/int/Function_calling_(LLM)_%E2%80%94_%E3%83%95%E3%82%A1%E3%83%B3%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%AA%E3%83%B3%E3%82%B0#cite_note-hopsworks_whatis-1)</sup>。

言い換えれば、モデルはユーザーのプロンプトに基づいて、提案された関数セットの中からどの関数をどのパラメータで呼び出すべきかを判断します。このメカニズムはLLMの応用範囲を広げ、自然言語と実用的なアクションとの間のインターフェースとして機能させることを可能にします。これにより、AIを外部システムと統合する道が開かれます。モデルは最新のデータを要求したり、操作を実行したり、サービスを利用したりすることができるため、インテリジェントアシスタントや自律エージェントの構築において特に価値があります。また、外部ツールを使用することで、信頼できる情報源にアクセスするため、ハルシネーション（幻覚、事実に基づかない情報の生成）のリスクを低減できます<sup>[\[2\]](https://systems-analysis.info/int/Function_calling_(LLM)_%E2%80%94_%E3%83%95%E3%82%A1%E3%83%B3%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%AA%E3%83%B3%E3%82%B0#cite_note-dark_side_paper-2)</sup>。

## 歴史と実装アプローチ

### 初期のアプローチ（プロンプティングとToolformer）

言語モデルに関数を呼び出す方法を教えるというアイデアは、2022年から2023年にかけて形成されました。初期のアプローチは、複雑なプロンプティング技術に基づいていました。例えば、2022年には**ReAct**の仕組みが提案され、モデルは対話の中で推論とアクション（ツールの呼び出し）を一つのテキストに符号化して交互に実行しました。

重要な一歩となったのは、2023年初頭にMetaの研究者によって発表された**Toolformer**モデルの登場です。Toolformerは、LLMがテキストのヒントに基づいて外部ツール（電卓、検索エンジン、カレンダー）を自律的に呼び出すように特別にファインチューニングできることを実証しました。生成されるテキストに特別なAPI呼び出しトークンを挿入することでこれを実現します<sup>[\[3\]](https://systems-analysis.info/int/Function_calling_(LLM)_%E2%80%94_%E3%83%95%E3%82%A1%E3%83%B3%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%AA%E3%83%B3%E3%82%B0#cite_note-toolformer_paper-3)</sup>。

### 公式サポートと発展

特筆すべきマイルストーンとして、OpenAIが2023年6月にGPT-3.5およびGPT-4モデル用のAPIにFunction Callingのサポートを公式に導入したことが挙げられます<sup>[\[4\]](https://systems-analysis.info/int/Function_calling_(LLM)_%E2%80%94_%E3%83%95%E3%82%A1%E3%83%B3%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%AA%E3%83%B3%E3%82%B0#cite_note-openai_fc_announcement-4)</sup>。新しいバージョンのモデルは、ユーザーのクエリが外部関数の呼び出しを意図している状況を認識し、引数を含む正確に構造化されたJSONオブジェクトを生成するようにファインチューニングされました。OpenAIはこの機能を「GPTを外部ツールやAPIと確実につなぐ新しい方法」と称しました。

### オープンな取り組み

商用実装に続き、正しい関数呼び出しを生成するためにファインチューニングされたオープンモデルが登場しました。

- **Gorilla**: カリフォルニア大学バークレー校のプロジェクトで、ファインチューニングされたLLaMAのバージョンです。数千の異なるAPIへの呼び出しを形成することができます。このようなモデルを評価するために、Berkeley Function-Calling Leaderboardというベンチマークが作成されました<sup>[\[5\]](https://systems-analysis.info/int/Function_calling_(LLM)_%E2%80%94_%E3%83%95%E3%82%A1%E3%83%B3%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%AA%E3%83%B3%E3%82%B0#cite_note-gorilla_site-5)</sup>。
- **ToolAlpaca**、**ToolLLaMA**、**Hermes**: より強力なモデルによって生成されることが多い、関数呼び出しの合成データセットでファインチューニングされた一連のオープンモデルです。

## 動作の仕組み

Function Callingの利用プロセスは、通常、いくつかのステップで構成されます。

1.  **関数の定義**。開発者は、モデルが利用できる関数（外部APIなど）のセットをあらかじめ定義し、そのシグネチャと目的を通常JSON Schema形式で記述します。
2.  **リクエストの分析**。対話中、モデルはユーザーの意図を分析し、応答するために定義された関数のいずれかを呼び出すべきかどうかを自律的に判断します。
3.  **呼び出しの生成**。アクションが必要な場合、LLMは通常のテキストの代わりに、特別な構造化された出力（関数名と引数を含むJSONなど）を生成します。呼び出しが不要な場合は、通常のテキスト応答を返します。
4.  **関数の実行**。外部プログラム（チャットボットのラッパーやエージェント）がJSONを受け取り、指定された関数を提案されたパラメータで実際に呼び出し、その結果をモデルに返します。
5.  **最終応答の生成**。モデルは受け取ったデータを使用して、ユーザーへの最終的な応答を生成します<sup>[\[4\]](https://systems-analysis.info/int/Function_calling_(LLM)_%E2%80%94_%E3%83%95%E3%82%A1%E3%83%B3%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%AA%E3%83%B3%E3%82%B0#cite_note-openai_fc_announcement-4)</sup>。

この多段階プロセスを管理するために、モデルのトレーニングでは特別な対話形式が使用されます。例えば、OpenAIのChatMLマークアップでは、「user」と「assistant」の役割に加えて、呼び出し結果を渡すための「function」という役割が導入されています。

## 応用と利点

関数を呼び出す機能は、LLMで解決できるタスクの範囲を大幅に拡大します。

- **外部APIとの連携**。モデルは、最新情報を必要とするクエリに応答するために外部サービスを呼び出すことができます（例：天気、為替レート、ニュースの取得）。
- **ユーザーアクションの自動化**。LLMは、電子メールの送信、カレンダーへのイベント作成、オンラインストアでの注文など、日常的なタスクを実行できます。
- **データベースと分析へのアクセス**。自然言語でのクエリを、内部APIの呼び出しやSQLクエリに変換して、データを抽出・分析することができます。
- **構造化情報の抽出**。LLMは、長いテキストから事実（名前、日付、住所など）を抽出し、その後のプログラム処理に便利な構造化されたJSON配列として返すことができます。

## セキュリティの問題

Function Callingはモデルの能力を拡大する一方で、新たなリスクももたらします。

- **未検証の出力**。モデルと外部ツールとの対話は、慎重に保護する必要があります。モデルがAPIから悪意のある、または誤った値を受け取ると、それを応答に含めたり、それに基づいて別の関数を呼び出したりする可能性があり、予測不能な結果を招くことがあります。
- **関数引数を介した攻撃**。研究者たちは、Function Callingモードに特有の脆弱性を発見しました。2025年には「Function Callingのダークサイド」と名付けられた攻撃が実証されました。その本質は、引数内に禁止された指示（*ジェイルブレイク・ペイロード*）が隠された特別な「関数」をモデルに提案することにあります。モデルは関数呼び出しの原則に従い、ルールに違反するコンテンツを含む引数を生成することで、モデレーションフィルターを回避します。この攻撃は、GPT-4やClaudeを含む6つの最新モデルで**90%**以上の成功率を示しました<sup>[\[2\]](https://systems-analysis.info/int/Function_calling_(LLM)_%E2%80%94_%E3%83%95%E3%82%A1%E3%83%B3%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%AA%E3%83%B3%E3%82%B0#cite_note-dark_side_paper-2)</sup>。

このようなインシデントを防ぐためには、モデルに信頼できるツールのみを提供し、重要なアクションを実行する前にユーザーの確認を実装し、さらに特別な「防御的」プロンプトを使用し、引数に危険なコンテンツが含まれていないか厳密に検証することが推奨されます。

## 外部リンク

- <a href="https://openai.com/index/function-calling-and-other-api-updates/" class="external text" rel="nofollow">OpenAIによるFunction Callingの公式発表</a>
- <a href="https://gorilla.cs.berkeley.edu/" class="external text" rel="nofollow">Gorilla LLMプロジェクトページ</a>
- Apideck (2024). *An Introduction to Function Calling and Tool Use*. <a href="https://www.apideck.com/blog/llm-tool-use-and-function-calling" class="external text" rel="nofollow">Apideck Blog</a>.
- LangChain (2025). *Tool Calling (Documentation)*. <a href="https://python.langchain.com/docs/concepts/tool_calling/" class="external text" rel="nofollow">LangChain Docs</a>.
- Mistral AI (2025). *Function Calling – Documentation*. <a href="https://docs.mistral.ai/capabilities/function_calling/" class="external text" rel="nofollow">Mistral Docs</a>.
- Hopsworks (2024). *What is Function Calling with LLMs?*. <a href="https://www.hopsworks.ai/dictionary/function-calling-with-llms" class="external text" rel="nofollow">Hopsworks Dictionary</a>.
- Hopsworks (2024). *Unlocking the Power of Function Calling with LLMs*. <a href="https://www.hopsworks.ai/post/unlocking-the-power-of-function-calling-with-llms" class="external text" rel="nofollow">Hopsworks Blog</a>.
- University of California, Berkeley (2025). *Berkeley Function Calling Leaderboard V3*. <a href="https://gorilla.cs.berkeley.edu/leaderboard.html" class="external text" rel="nofollow">Online Resource</a>.

## 参考文献

- Wu, Z. et al. (2025). *The Dark Side of Function Calling: Pathways to Jailbreaking Large Language Models*. <a href="https://aclanthology.org/2025.coling-main.39.pdf" class="external text" rel="nofollow">ACL 2025</a>.
- OpenAI (2023). *Function Calling and Other API Updates*. <a href="https://openai.com/index/function-calling-and-other-api-updates/" class="external text" rel="nofollow">OpenAI Blog</a>.
- Schick, T. et al. (2023). *Toolformer: Language Models Can Teach Themselves to Use Tools*. <a href="https://arxiv.org/abs/2302.04761" class="external text" rel="nofollow">arXiv:2302.04761</a>.
- Patil, S. G. et al. (2023). *Gorilla: Large Language Model Connected with Massive APIs*. <a href="https://arxiv.org/abs/2305.15334" class="external text" rel="nofollow">arXiv:2305.15334</a>.
- Liu, W. et al. (2024). *ToolACE: Winning the Points of LLM Function Calling*. <a href="https://arxiv.org/abs/2409.00920" class="external text" rel="nofollow">arXiv:2409.00920</a>.
- Yao, S. et al. (2022). *ReAct: Synergizing Reasoning and Acting in Language Models*. <a href="https://arxiv.org/abs/2210.03629" class="external text" rel="nofollow">arXiv:2210.03629</a>.

## 脚注

1.  <span id="cite_note-hopsworks_whatis-1">[↑](https://systems-analysis.info/int/Function_calling_(LLM)_%E2%80%94_%E3%83%95%E3%82%A1%E3%83%B3%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%AA%E3%83%B3%E3%82%B0#cite_ref-hopsworks_whatis_1-0) «What is Function Calling with LLMs?». *Hopsworks*. <a href="https://www.hopsworks.ai/dictionary/function-calling-with-llms" class="external autonumber" rel="nofollow">[1]</a></span>
2.  <span id="cite_note-dark_side_paper-2">↑ <sup>[2.0](https://systems-analysis.info/int/Function_calling_(LLM)_%E2%80%94_%E3%83%95%E3%82%A1%E3%83%B3%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%AA%E3%83%B3%E3%82%B0#cite_ref-dark_side_paper_2-0)</sup> <sup>[2.1](https://systems-analysis.info/int/Function_calling_(LLM)_%E2%80%94_%E3%83%95%E3%82%A1%E3%83%B3%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%AA%E3%83%B3%E3%82%B0#cite_ref-dark_side_paper_2-1)</sup> Wu, Z. et al. «The Dark Side of Function Calling: Pathways to Jailbreaking Large Language Models». *Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing*, 2025. <a href="https://aclanthology.org/2025.coling-main.39.pdf" class="external autonumber" rel="nofollow">[2]</a></span>
3.  <span id="cite_note-toolformer_paper-3">[↑](https://systems-analysis.info/int/Function_calling_(LLM)_%E2%80%94_%E3%83%95%E3%82%A1%E3%83%B3%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%AA%E3%83%B3%E3%82%B0#cite_ref-toolformer_paper_3-0) Schick, T. et al. «Toolformer: Language Models Can Teach Themselves to Use Tools». *arXiv:2302.04761*, 2023. <a href="https://arxiv.org/abs/2302.04761" class="external autonumber" rel="nofollow">[3]</a></span>
4.  <span id="cite_note-openai_fc_announcement-4">↑ <sup>[4.0](https://systems-analysis.info/int/Function_calling_(LLM)_%E2%80%94_%E3%83%95%E3%82%A1%E3%83%B3%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%AA%E3%83%B3%E3%82%B0#cite_ref-openai_fc_announcement_4-0)</sup> <sup>[4.1](https://systems-analysis.info/int/Function_calling_(LLM)_%E2%80%94_%E3%83%95%E3%82%A1%E3%83%B3%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%AA%E3%83%B3%E3%82%B0#cite_ref-openai_fc_announcement_4-1)</sup> «Function calling and other API updates». *OpenAI*, 2023. <a href="https://openai.com/index/function-calling-and-other-api-updates/" class="external autonumber" rel="nofollow">[4]</a></span>
5.  <span id="cite_note-gorilla_site-5">[↑](https://systems-analysis.info/int/Function_calling_(LLM)_%E2%80%94_%E3%83%95%E3%82%A1%E3%83%B3%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%AA%E3%83%B3%E3%82%B0#cite_ref-gorilla_site_5-0) «Gorilla: Large Language Model Connected to Massive APIs». *University of California, Berkeley*. <a href="https://gorilla.cs.berkeley.edu/" class="external autonumber" rel="nofollow">[5]</a></span>
