Google AI Platform
AI・機械学習プラットフォーム
Google AI Platform (Vertex AI)
概要
Google AI Platform(現在のVertex AI)は、Googleが提供する統合された AI・機械学習プラットフォームです。機械学習モデルの開発から本番環境でのデプロイメントまで、MLライフサイクル全体をカバーする包括的なサービスセットを提供します。2025年現在、Gemini 2.5モデルファミリーやModel Garden、充実したAutoML機能を含む、エンタープライズレベルのAI開発基盤として急速に成長しています。
詳細
Google AI Platform(Vertex AI)は、Google Cloudの中核的なAI・機械学習サービスとして、以下の主要コンポーネントで構成されています:
コアサービス
- Vertex AI Workbench: 統合されたJupyterLab環境でのデータ分析・モデル開発
- AutoML: コードを書かずに高品質なカスタムモデルを構築
- Model Garden: Google、サードパーティ、オープンソースモデルへの統一アクセス
- Vertex AI Pipelines: MLワークフローの自動化・管理
- Feature Store: 機械学習特徴量の中央管理・再利用
2025年の主要アップデート
- Gemini 2.5 Pro: 複雑な推論タスクに対応する最新のマルチモーダルモデル
- Gemini 2.0 Flash: 画像生成機能付きの高速モデル(プレビュー版)
- 拡張されたModel Garden: Anthropic Claude、Llama 4、Qwen3、Gemma 3などの新モデル
- Gen AI Evaluation Service: 生成AIモデルの評価サービスがGA(一般提供)
- Private Service Connect: MLパイプライン実行での強化されたプライベート接続
技術的特徴
- 統合プラットフォーム: データ準備からモデルデプロイまでの一元管理
- スケーラブル: Google Cloud基盤上での自動スケーリング
- エンタープライズ対応: セキュリティ、コンプライアンス、ガバナンス機能
- マルチクラウド対応: Anthos経由での他クラウドプロバイダー連携
メリット・デメリット
メリット
- 包括的なMLプラットフォーム: データ前処理から本番運用まで一貫したワークフロー
- 豊富な事前訓練済みモデル: Gemini、Imagen、Chirpなど最先端のGoogleモデル
- AutoML機能: 機械学習専門知識がなくても高品質なモデル構築が可能
- Google Cloud統合: BigQuery、Cloud Storage、GKEなどとのシームレス連携
- 強力なMLOps: バージョン管理、実験追跡、モデル監視の自動化
- グローバルエンドポイント: 世界規模での低レイテンシサービス提供
デメリット
- 学習コストの高さ: 多機能ゆえの複雑性、初期習得に時間が必要
- 料金の複雑性: 使用量ベースの料金体系で予算管理が困難
- ベンダーロックイン: Google Cloud固有の機能により他プラットフォームへの移行が困難
- AutoML制限: 2024年9月以降、一部のAutoML機能がGeminiプロンプト調整に移行
- プライベート接続の制約: エンタープライズ環境での細かな接続制御が必要
参考ページ
- Google Cloud Vertex AI公式サイト
- Vertex AI ドキュメント
- Generative AI on Vertex AI
- Model Garden概要
- Vertex AI リリースノート
- Vertex AI料金
書き方の例
1. 基本的なセットアップと認証
# 必要なライブラリのインストール
%pip install --upgrade --quiet google-cloud-aiplatform
# Vertex AI SDKの初期化
import vertexai
from google.cloud import aiplatform
# プロジェクト設定
PROJECT_ID = "your-project-id"
LOCATION = "us-central1"
STAGING_BUCKET = "gs://your-staging-bucket"
# Vertex AIの初期化
vertexai.init(project=PROJECT_ID, location=LOCATION)
aiplatform.init(
project=PROJECT_ID,
location=LOCATION,
staging_bucket=STAGING_BUCKET,
experiment='my-ml-experiment'
)
print(f"Vertex AI initialized for project: {PROJECT_ID}")
2. AutoMLとカスタムモデルトレーニング
# タブラーデータセットの作成とAutoMLトレーニング
from google.cloud import aiplatform
# データセットの読み込み
dataset = aiplatform.TabularDataset.create(
display_name="customer-churn-dataset",
gcs_source=["gs://your-bucket/customer_data.csv"],
sync=True
)
# AutoMLトレーニングジョブの設定
automl_job = aiplatform.AutoMLTabularTrainingJob(
display_name="churn-prediction-automl",
optimization_prediction_type="classification",
optimization_objective="maximize-au-prc",
column_specs={
"customer_id": "auto",
"churn": "auto",
}
)
# モデルトレーニングの実行
model = automl_job.run(
dataset=dataset,
target_column="churn",
training_fraction_split=0.8,
validation_fraction_split=0.1,
test_fraction_split=0.1,
budget_milli_node_hours=1000,
model_display_name="churn-prediction-model",
disable_early_stopping=False,
)
print(f"AutoML training completed. Model: {model.display_name}")
3. モデルデプロイメントと予測
# モデルのエンドポイントデプロイ
from google.cloud import aiplatform
# 既存モデルの取得
model = aiplatform.Model('projects/my-project/locations/us-central1/models/{MODEL_ID}')
# エンドポイントの作成とデプロイ
endpoint = model.deploy(
display_name="churn-prediction-endpoint",
machine_type="n1-standard-2",
min_replica_count=1,
max_replica_count=5,
traffic_percentage=100,
sync=True
)
# オンライン予測の実行
prediction_data = [
[25, 50000, 2, 1, 0], # 年齢, 年収, 利用年数, サポート問い合わせ数, プレミアム会員
[45, 85000, 5, 0, 1]
]
predictions = endpoint.predict(instances=prediction_data)
print(f"Churn predictions: {predictions.predictions}")
# バッチ予測ジョブの実行
batch_job = model.batch_predict(
job_display_name="batch-churn-prediction",
gcs_source=["gs://your-bucket/batch_prediction_data.csv"],
gcs_destination_prefix="gs://your-bucket/predictions/",
instances_format="csv",
predictions_format="jsonl",
machine_type="n1-standard-4",
sync=False
)
print(f"Batch prediction job started: {batch_job.display_name}")
4. バッチ処理とパイプライン管理
# Vertex AI Pipelinesを使用したMLパイプライン
from google.cloud.aiplatform import PipelineJob
import google.cloud.aiplatform as aip
# パイプライン定義の作成
@aip.pipeline(name="ml-training-pipeline")
def training_pipeline(
project_id: str,
dataset_path: str,
model_name: str
):
from google.cloud.aiplatform.v1.types import InputDataConfig
# データ前処理コンポーネント
preprocess_task = aip.preprocessing_component(
input_data_path=dataset_path,
output_data_path="gs://your-bucket/processed/",
)
# モデルトレーニングコンポーネント
training_task = aip.training_component(
input_data=preprocess_task.outputs["processed_data"],
model_output_path="gs://your-bucket/models/",
hyperparameters={"learning_rate": 0.01, "epochs": 100}
)
# モデル評価コンポーネント
evaluation_task = aip.evaluation_component(
model=training_task.outputs["model"],
test_data=preprocess_task.outputs["test_data"]
)
return evaluation_task.outputs
# パイプラインのコンパイルと実行
pipeline_job = PipelineJob(
display_name="automated-ml-pipeline",
template_path="pipeline.json",
parameter_values={
"project_id": PROJECT_ID,
"dataset_path": "gs://your-bucket/raw_data.csv",
"model_name": "automated-model"
},
pipeline_root="gs://your-bucket/pipeline-root/"
)
# パイプラインの実行
pipeline_job.run(
service_account="[email protected]",
sync=True
)
print(f"Pipeline execution completed: {pipeline_job.display_name}")
5. Feature Storeとデータ管理
# Vertex AI Feature Storeの利用
from google.cloud.aiplatform import Featurestore, EntityType, Feature
# Feature Storeの作成
featurestore = Featurestore.create(
featurestore_id="customer-features",
location=LOCATION,
sync=True
)
# エンティティタイプの作成
entity_type = EntityType.create(
entity_type_id="customer",
featurestore_name=featurestore.resource_name,
sync=True
)
# 特徴量の定義
age_feature = Feature.create(
feature_id="age",
entity_type_name=entity_type.resource_name,
value_type="INT64",
sync=True
)
income_feature = Feature.create(
feature_id="annual_income",
entity_type_name=entity_type.resource_name,
value_type="DOUBLE",
sync=True
)
# 特徴量データの取り込み
from google.cloud.aiplatform_v1 import FeaturestoreServiceClient
import pandas as pd
# サンプルデータの準備
feature_data = pd.DataFrame({
"customer_id": ["cust_001", "cust_002", "cust_003"],
"age": [25, 45, 35],
"annual_income": [50000.0, 85000.0, 70000.0],
"event_time": pd.to_datetime(["2025-01-01", "2025-01-01", "2025-01-01"])
})
# バッチ取り込みジョブの実行
import_job = entity_type.batch_create_features(
feature_specs=[
{"id": "age", "value_type": "INT64"},
{"id": "annual_income", "value_type": "DOUBLE"}
],
sync=True
)
print(f"Feature Store setup completed: {featurestore.resource_name}")
6. MLOpsとモデル監視
# モデル監視とメトリクス追跡
from google.cloud.aiplatform import Model, ModelMonitoringJob
from google.cloud.aiplatform.v1.types import ModelMonitoringSchema
# デプロイ済みモデルの監視設定
model = aiplatform.Model('projects/my-project/locations/us-central1/models/{MODEL_ID}')
# モデル監視アラートの設定
monitoring_config = {
"skew_detection": {
"data_skew_threshold": 0.8,
"attribution_score_threshold": 0.7
},
"drift_detection": {
"drift_threshold": 0.8,
"attribution_score_threshold": 0.7
},
"explanation_config": {
"enable_feature_attributes": True
}
}
# 監視ジョブの作成
monitoring_job = ModelMonitoringJob.create(
display_name="model-performance-monitoring",
model_name=model.resource_name,
target_dataset="projects/{PROJECT_ID}/datasets/monitoring_dataset",
notification_channels=["projects/{PROJECT_ID}/notificationChannels/{CHANNEL_ID}"],
monitoring_config=monitoring_config,
sync=True
)
# モデルバージョンの管理と実験追跡
from google.cloud import aiplatform
import vertexai.preview.vertex_ai_tracking as tracking
# 実験トラッキングの開始
with tracking.init_experiment("model-optimization-experiment"):
# パラメータのログ
tracking.log_params({
"learning_rate": 0.01,
"batch_size": 32,
"optimizer": "adam"
})
# メトリクスのログ
tracking.log_metrics({
"accuracy": 0.95,
"precision": 0.93,
"recall": 0.96,
"f1_score": 0.94
})
# モデルアーティファクトのログ
tracking.log_model(
model=model,
artifact_path="model-artifacts",
model_name="optimized-churn-model"
)
# A/Bテスト用のトラフィック分割
endpoint.update_traffic_split({
"model_v1": 70, # 70%のトラフィック
"model_v2": 30 # 30%のトラフィック
})
print("MLOps monitoring and experimentation setup completed")