Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AIの弱点、やっぱりプログラミングは人間が(も)勉強しよう / YAPC AI and Pro...

AIの弱点、やっぱりプログラミングは人間が(も)勉強しよう / YAPC AI and Programming

2025-11-14に開催されたYAPC::Fukuoka 2025での登壇資料です

Avatar for Naoki Kishida

Naoki Kishida

November 14, 2025
Tweet

More Decks by Naoki Kishida

Other Decks in Programming

Transcript

  1. 2 Agenda • AIについて • AIの仕組み • AIの弱点 • プログラミング言語

    • プログラミングに必要なこと • プログラミング言語機能の概要 • プログラムの最適化 • まとめたい
  2. Transformer • 2017にGoogleが発表 • Attention is All You Need •

    アテンション • 文章中の単語がどの単語を注目しているか • O(n^2)
  3. MoE(Mixture of Experts) (GPT-4) • FFNは知識をうけもつ • すべての知識を同時に使うことはない • 多数の専門家モデルを持っておいて、

    推論時に必要なモデルだけを呼び出 すことでリソースを節約 • GPT-oss 120B • エキスパート数 128 • アクティブパラメータ数5.1B
  4. Function Calling • LLMから外部関数を呼び出す • OpenAI、Google、Hugging HaceはFunction Calling • Anthropic、AWSはTool

    Use • AIが幅広い機能をもつようになった • MCP • JSON-RPCを使ってリモートでFunction Calling • MCPサーバーは状態を持つので、JSON-RPCによる分散オブジェクト
  5. AIの計算 • 226-68=? • LLMだと(Llama3-8B) • 3桁までの数字は1トークンで扱う • 24層の12439番目のニューロンは引き算が150~180のときに発火 •

    30層の1582番目のニューロンは引き算が8で終わるときに発火 • どんどん出現比率をあげて、 最終的に158の確率が高まる • ヒューリスティックを積み上げて 答えの確率を高めていく Arithmetic Without Algorithms: Language Models Solve Math with a Bag of Heuristics https://arxiv.org/abs/2410.21272
  6. キャッシュ • 変数による値の使いまわし • hashmapによるキャッシュ func(list) { print("合計": list.sum()); print("平均":

    list.sum() / list.count()); } func(list) { var sum = list.sum(); print("合計": sum); print("平均": sum / list.count()); }
  7. スコープ最小化 • 関数引数やループ変数に依存しない処理を外に出す func() { for (int i = 0;

    i < 10; ++i) { var n = init(); proc(n, i); } } func() { var n = init(); for (int i = 0; i < 10; ++i) { proc(n, i); } }
  8. 多態を活用する • 部分型による多態を活用 • テンプレートメソッド abstract class Base { abstract

    void before(); abstract void after(); void proc() { before(); println("はろー"); after(); } } class School extends Base { @Override void before() { println("起立"); } @Override void after() { println("着席"); } }
  9. 関数による実装 • 高階関数だとすっきり書けることも多い void proc(Runnable before, Runnable after) { before.run();

    println("はろー"); after.run(); } proc(() -> println("起立"), () -> println("着席"));
  10. 依存の適正化 • 使ってない変数が見えないようにする foo(int a, int b) { for(int i

    = 0; i < a; ++i) { ..割と長い処理 } for(int i = 0; i < b; ++i) { ..割と長い処理 } } fooa(int a) { for(int i = 0; i < a; ++i) [ ..割と長い処理 } } foob(int b) { for(int i = 0; i < b; ++i) { ..割と長い処理 } } foo(int a, int b) { fooa(a); foob(b); }