Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Azure App Service on Linux の Sidecar に Phi-3 を配...
Search
TonyTonyKun
October 03, 2024
Technology
1.5k
0
Share
Azure App Service on Linux の Sidecar に Phi-3 を配置してインテリジェントなアプリケーションを作ってみよう/jazug-anniv14
Japan Azure User Group 14周年イベントのセッション資料です。
TonyTonyKun
October 03, 2024
More Decks by TonyTonyKun
See All by TonyTonyKun
Azure Static Web Apps の自動ビルドがタイムアウトしやすくなった状況に対応した件/global-azure2026
thara0402
0
740
Azure Durable Functions で作った NL2SQL Agent の精度向上に取り組んだ話/jat08
thara0402
0
380
これでバッチリ!Azure マルチテナントアーキテクチャ設計のコツ/jat06
thara0402
0
720
Azure Load Testing を使って Azure Functions Flex Consumption の HTTP Trigger のパフォーマンスとコストを最適化してみよう/global-azure2025
thara0402
0
320
Prompty を使って生成 AI アプリケーション開発のプロンプトを管理する/jat03
thara0402
0
86
Azure OpenAI Service で意図せず PTU モデルをデプロイして高額請求されてしまった件/jat04
thara0402
0
93
「Durable Task Scheduler」をチョイ見せ!/jat05
thara0402
0
69
サイクルガードサービス AlterLock の問い合わせ対応業務に Azure OpenAI Service を活用した話/jazug46
thara0402
0
1k
Microsoft Ignite 2023 現地参加レポート/ignite2023
thara0402
0
340
Other Decks in Technology
See All in Technology
Ruby::Boxでできること、Refinementsでできること
joker1007
3
380
ルールやカスタム機能、どう使う?理想の出力を引き出すために今知りたいIBM Bob 5つの機能
muehara
1
320
地元にいないローカルオーガナイザーの立ち回り
uvb_76
1
460
速さだけじゃない! VoidZero ツールが移行先に選ばれる理由
mizdra
PRO
6
740
oracle-to-databricks-migration-with-llm-and-dbt
casek
1
430
Strands Agents超入門
kintotechdev
1
160
APIテストとは?
nagix
0
180
OCI Oracle AI Database Services新機能アップデート(2026/03-2026/05)
oracle4engineer
PRO
0
190
新規ゲーム開発におけるAI駆動開発のリアル
202409e2
0
2.3k
ITエンジニアを取り巻く環境とキャリアパス / A career path for Japanese IT engineers
takatama
4
1.8k
Claude code Orchestra
ozakiomumkj
3
930
Oracle Cloud Infrastructure IaaS 新機能アップデート 2026/3 - 2026/5
oracle4engineer
PRO
1
170
Featured
See All Featured
Context Engineering - Making Every Token Count
addyosmani
9
930
Accessibility Awareness
sabderemane
1
130
How to Ace a Technical Interview
jacobian
281
24k
Making Projects Easy
brettharned
120
6.7k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
310
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.7k
The browser strikes back
jonoalderson
0
1.1k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.2k
The Limits of Empathy - UXLibs8
cassininazir
1
350
Building AI with AI
inesmontani
PRO
1
1k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
410
Transcript
Azure App Service on Linux の Sidecar に Phi-3 を配置して
インテリジェントなアプリケーションを 作ってみよう 2024.10.5 Japan Azure User Group 14周年イベント
自己紹介 名前 原 敏之 個人 X (Twitter) : @TonyTonyKun ROMANCE
DAWN for the new world • https://gooner.hateblo.jp/ Microsoft MVP for Microsoft Azure 2017 〜 2023 Microsoft MVP for AI Platform 2024 〜 仕事 株式会社ネクストスケープ Copyright© 2024, JAZUG All Rights Reserved. 2
アジェンダ Sidecar Pattern とは SLM(Phi-3)を Sidecar として活用する Sidecar Pattern with
App Service の使いどころを考える まとめ 3 Copyright© 2024, JAZUG All Rights Reserved.
Sidecar Pattern Sidecar パターンとは 4 Copyright© 2024, JAZUG All Rights
Reserved.
Sidecar パターンとは 5 Copyright© 2024, JAZUG All Rights Reserved. マイクロサービスの非機能要件をアプリケーションから切り離し、
疎結合に実装するデザインパターン メインアプリケーションの実装に依存せずに、非機能要件を組み込める 一方で、通信処理によるオーバーヘッドがトレードオフとなる モニタリング&ロギング 分散トレーシング ネットワークプロキシ リモートサービス呼び出しのリトライ サーキットブレーカー セキュリティ 通信暗号化 シークレット管理
Sidecar パターンのソリューション① 6 Copyright© 2024, JAZUG All Rights Reserved. コンテナーのグループ化(Kubernetes
の Pod) Kubernetes 上に構築するサービスメッシュ(Istio など) Envoy コンテナーをインジェクションして、サービス間の通信を統一的な仕組みで管理する
Sidecar パターンのソリューション② 7 Copyright© 2024, JAZUG All Rights Reserved. コンテナーのグループ化(Kubernetes
の Pod) Kubernetes 上に構築する Dapr( Distributed Application Runtime )
Sidecar パターンのソリューション③ 8 Copyright© 2024, JAZUG All Rights Reserved. Sidecar
Pattern with Azure App Service on Linux App Service on Linux に Sidecar パターンでコンテナーを追加できる 機能が追加されました。
Sidecar Pattern with App Service on Linux 9 Copyright© 2024,
JAZUG All Rights Reserved. App Service 作成時、Sidecar Support を有効化する 現時点の制約(Public Preview) • Docker Container のみ(Windows Container は未対応) • Sidecar を構成できるのは新規作成のみ、既存リソースに追加不可 • Sidecar を構成できるリージョンは限定(West Europe など)
Sidecar Pattern with App Service on Linux 10 Copyright© 2024,
JAZUG All Rights Reserved. App Service に対して、Sidecar の Container Registry を追加する
Phi-3 SLM with Linux App Service SLM(Phi-3)を Sidecar パターンで活用する 11
Copyright© 2024, JAZUG All Rights Reserved.
モチベーション 12 Copyright© 2024, JAZUG All Rights Reserved. なぜ、SLM を
Sidecar で使うユースケースが良いと感じたのか? AOAI で LLM を使うだけがシステムの生成 AI 活用ではない • 期待値が高すぎる、大きく構えずにライトな活用も検討してもいいのでは? SLM のセルフホストで十分なユースケースもありそう • リアルタイム応答、機密データの取り扱い、コスト削減を実現しやすい • LLM と比較すると、ファインチューニングの敷居もそれほど高くない SLM を動かせるデバイスに実行環境を作るのはそれなりに大変そう • 2024年5月から Copilot+PC が発売されているが・・・ PaaS で提供される Sidecar に SLM をセルフホストするアーキテクチャ https://azure.github.io/AppService/2024/08/05/Using-SLM-with-Sidecar.html
手順① SLM の Sidecar を作る 13 Copyright© 2024, JAZUG All
Rights Reserved. Phi-3 モデルの呼び出しをサポートするツールに Ollama を使い、 REST API で対話できる I/F をもったコンテナーを作成する Phi-3 • Microsoft によって開発された Small Language Models(SLM) Ollama(https://ollama.com/) • ローカル環境で LLM や SLM のモデルを動かすことができるツール • Phi-3 以外にも、Llama 3.1 や Google Gemma 2 などのモデルをサポート ※ SLM の呼び出しをサポートできれば、 ONNX Runtime generate API などを活用してもいい
手順① SLM の Sidecar を作る 14 Copyright© 2024, JAZUG All
Rights Reserved. Ollama の Docker Image をベースに Dockerfile を定義する
手順② メインのアプリケーションを作る 15 Copyright© 2024, JAZUG All Rights Reserved. ASP.NET
Core で Sidecar を呼び出す Web API を作成する
手順② メインのアプリケーションを作る 16 Copyright© 2024, JAZUG All Rights Reserved. Ollama
のモデルを実行するための REST API エンドポイント Generate a completion Generate a chat completion など https://github.com/ollama/ollama/blob/main/docs/api.md
デモ 17 Copyright© 2024, JAZUG All Rights Reserved. VS Code
拡張の REST Client で Web API を呼び出す
事例:.NET Smart Components 18 Copyright© 2024, JAZUG All Rights Reserved.
AI を活用した機能を .NET アプリに組み込めるコンポーネント コンポーネントに含まれている機能 • Smart Paste • Smart TextArea • Smart ComboBox AI バックエンド • Azure OpenAI Service • OpenAI • セルフホスト • Ollama など OpenAI API スキーマと互換性のあるエンドポイント https://github.com/dotnet/smartcomponents/blob/main/docs/configure-openai-backend.md このようなコンポーネントであれば、SLM のセルフホストでいいのでは?
What are the use cases for Sidecar Pattern with App
Service? Sidecar Pattern with App Service の使いどころを考える 19 Copyright© 2024, JAZUG All Rights Reserved.
モニタリング&ロギング 20 Copyright© 2024, JAZUG All Rights Reserved. Datadog などの監視ツールにログやメトリクスを送信する
メインアプリケーションに改修を行うことなく、Sidecar を配置する だけで監視ツールとシームレスに統合できる https://azure.github.io/AppService/2024/07/26/Using-Datadog-with-Sidecar.html https://azure.github.io/AppService/2024/07/26/Using-Dynatrace-with-Sidecar.html
キャッシュ 21 Copyright© 2024, JAZUG All Rights Reserved. Sidecar にキャッシュのデータストア(Redis)を配置する
Sidecar をオンメモリキャッシュとして使いたい気持ちはわかる • 通信処理のオーバヘッドが小さいため、高速にキャッシュをリードライトできる ただし、アーキテクチャ上の注意事項あり • リクエストがルーティングされるインスタンスによってはキャッシュが使えない • メインアプリケーションと Sidecar が同一ライフサイクルなので • 素直に Azure Cache for Redis を使った方が良さそう • 個人的には Sidecar パターンの特性には合っていない気がする https://azure.github.io/AppService/2024/07/19/Using-Redis-with-Sidecar.html
定期的なバックグラウンド処理 22 Copyright© 2024, JAZUG All Rights Reserved. Sidecar ではなく、App
Service の WebJobs を使ったほうがいい WebJobs で出来ること • 継続的なジョブで定期タスクを自動化 • CRON によるトリガーでタスクを実行 スクリプトファイル、バッチファイルをそのままデプロイ ちょっとした定期タスク向き • Linux や Container 版は Preview 版だが、Windows 版は GA 済み メインアプリケーションと分離したい場合は、Azure Functions を使う
マルチコンテナーの後継機能 23 Copyright© 2024, JAZUG All Rights Reserved. App Service
では、以前から複数コンテナーをサポートしている 2つの形式 • Docker Compose • Kubernetes Deployment YAML 公式ドキュメントで紹介されているユースケース • WordPress(Web Server と MySQL)をデプロイする Sidecar パターンの登場により、オワコンとなる可能性を示唆 Frontend と Backend をまとめて1つのホストに配置するユースケース が Sidecar として本当に適切かどうかはしっかりと検討したい
Conclusion まとめ 24 Copyright© 2024, JAZUG All Rights Reserved.
まとめ Sidecar パターンは、SLM のセルフホストと相性が良さそう リアルタイム応答、機密データの取り扱い、コスト削減を実現しやすい LLM と比較すると、ファインチューニングの敷居もそれほど高くない このアーキテクチャでのインテリジェントアプリ開発が流行るかも Sidecar パターンの使いどころ
非機能要件の疎結合化 • 王道はロギングやモニタリング • あくまでメインアプリケーションを補助的にサポートするコンテナー • 少なからず、オーバヘッドが発生するので許容できるかどうか メインアプリケーションと同一ライフサイクルであることがポイント 25 Copyright© 2024, JAZUG All Rights Reserved.
参考リンク 個人ブログ Azure App Service の Sidecar に Phi-3 をデプロイして
Web アプリケーションの機能を拡張する • https://gooner.hateblo.jp/entry/2024/08/14/173326 Azure App Service Team Blog Phi-3 • https://azure.github.io/AppService/2024/08/05/Using-SLM-with-Sidecar.html • https://azure.github.io/AppService/2024/09/03/Phi3-vector.html • https://azure.github.io/AppService/2024/08/19/Phi-3-ONNX.html Datadog • https://azure.github.io/AppService/2024/07/26/Using-Datadog-with-Sidecar.html Dynatrace • https://azure.github.io/AppService/2024/07/26/Using-Dynatrace-with-Sidecar.html Redis • https://azure.github.io/AppService/2024/07/19/Using-Redis-with-Sidecar.html .NET Smart Components https://github.com/dotnet/smartcomponents/ 26 Copyright© 2024, JAZUG All Rights Reserved.