Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Azure App Service on Linux の Sidecar に Phi-3 を配...
Search
TonyTonyKun
October 03, 2024
Technology
1.6k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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 Durable Functions で作った NL2SQL Agent の精度向上に取り組んだ話/aidevday2026
thara0402
0
470
Azure Static Web Apps の自動ビルドがタイムアウトしやすくなった状況に対応した件/global-azure2026
thara0402
0
880
Azure Durable Functions で作った NL2SQL Agent の精度向上に取り組んだ話/jat08
thara0402
0
450
これでバッチリ!Azure マルチテナントアーキテクチャ設計のコツ/jat06
thara0402
0
800
Azure Load Testing を使って Azure Functions Flex Consumption の HTTP Trigger のパフォーマンスとコストを最適化してみよう/global-azure2025
thara0402
0
390
Prompty を使って生成 AI アプリケーション開発のプロンプトを管理する/jat03
thara0402
0
100
Azure OpenAI Service で意図せず PTU モデルをデプロイして高額請求されてしまった件/jat04
thara0402
0
120
「Durable Task Scheduler」をチョイ見せ!/jat05
thara0402
0
80
サイクルガードサービス AlterLock の問い合わせ対応業務に Azure OpenAI Service を活用した話/jazug46
thara0402
0
1.1k
Other Decks in Technology
See All in Technology
DevelopersIO 2026 知識の地図を描く ─ オントロジーとは何か?
ishikawa_satoru
1
110
全社共通データ基盤をつくる。ソニーのDatabricks活用とデータガバナンス設計の裏側
sony
0
430
子育てエンジニアの可処分時間が減っても成長を諦めない戦い方
sudoakiy
1
1.5k
SDDの運用にめげずに向き合った話
sansantech
PRO
1
130
ファミコンでPHPを動かす / PHP on the Famicom side b
tomzoh
0
140
契約書画像からの情報抽出に特化した視覚接地モデルを育てる話
sansantech
PRO
1
150
Kernel testing frameworks
ennael
PRO
0
110
ミイダス株式会社 テックチームのご紹介 / MIIDAS Tech Team
miidas
0
160
Claude Code本は、どのように執筆チームで書かれたか
oikon48
0
270
並行性の問題を防げ!実践トランザクション入門
occhi
0
280
BedrockとLambdaで作る リアルタイム進行型推理ゲーム
kawametho
0
190
カンファレンスに参加した後の浮遊感とセルフケア
pauli
0
310
Featured
See All Featured
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
450
YesSQL, Process and Tooling at Scale
rocio
174
15k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
270
Building an army of robots
kneath
307
47k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
42k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
510
Claude Code のすすめ
schroneko
67
230k
KATA
mclloyd
PRO
35
16k
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
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.