Google Cloud Solution Graph Ml

google/skills/skills/cloud/google-cloud-solution-graph-ml

作者 google751b947a5749b27eb3d2b8bcd1aa4bdb6fa0f426无许可证25K 个星标收录于 2026年12月5日更新于 2026年12月5日仓库今天更新

Orchestrates end-to-end Graph Machine Learning (GNN) solutions on Google Cloud, integrating Knowledge Catalog discovery (Dataplex, Collibra), BigQuery and Spanner Property Graph staging and readiness auditing, Distributed Graph Flow (dgf) pipeline synthesis, and Colab Enterprise training. Use when evaluating graph vs. tabular ML, staging enterprise sources (Drive, SharePoint, Salesforce, CSVs) into graphs, mapping ontologies and auditing foreign-key joins, super-hubs, or feature leakage, designing temporal splits and DGF GNN models, running multi-hop sampling on Dataflow or high-memory VMs, generating Colab Enterprise notebooks, or diagnosing GNN lift and Vizier tuning. Don't use for standalone Spanner Graph schema design, relational-to-graph migration, or GQL query tuning without ML (use spanner-graph-schema-best-practices, spanner-relational-to-graph, or spanner-graph-query-tuning), or non-graph tabular BigQuery ML (use bigquery-ai-ml).

AI 生成的概览

指导在 Google Cloud 上端到端构建图机器学习(GNN)方案,涵盖领域适配、图就绪审计、DGF 流水线与 Colab 训练。

功能
该技能引导智能体按七个步骤构建 Google Cloud 图机器学习方案:业务与领域对齐、将数据暂存到 BigQuery、Spanner 或 GCS、本体与属性图映射、五支柱图就绪审计、GNN 架构与标签设计、Distributed Graph Flow 流水线合成,以及训练与调优诊断。它会产出领域对齐简报、就绪评分卡、流水线交接规范和可运行的 Colab Enterprise 笔记本,并在图结构无增益时建议改用表格机器学习。
适用场景
适用于判断关系型数据是否适合 GNN 消息传递而非表格机器学习、将企业数据源暂存为属性图、审计外键连接、超级枢纽或特征泄漏,以及设计和运行 DGF GNN 训练与调优。不适用于独立的 Spanner Graph 模式设计、关系型到图迁移、GQL 查询调优或非图的 BigQuery ML。
运行要求
需要 Google Cloud SDK(gcloud、bq)、通过 gcloud 登录或应用默认凭据完成认证、已启用计费和相关 API 的项目,以及相应的 IAM 角色。需在用户批准后安装 dgf 包(分布式 Dataflow ETL 可选 dgf-nightly 与 apache-beam[gcp])。附带 BigQuery 就绪审计 SQL 脚本和 Colab 笔记本生成脚本。

AI 概览如何生成和校验

Graph machine learning (GNN) on Google Cloud

Usage Attribution

MUST READ: Before executing any gcloud, REST API, or MCP command, you MUST read and follow the instructions in Usage Attribution [blocked].


Google Cloud Prerequisites, IAM, Region & Cost Hygiene

Before provisioning resources or querying data, verify environment setup and obtain human authorization for billable actions:

1. Prerequisites Checklist

  • Google Cloud SDK (gcloud): Ensure gcloud and bq CLI tools are installed (Cloud SDK Installation). If missing locally, provide copy-ready commands for the user to run. Never install software packages on the host machine without explicit approval, because unsolicited host changes can conflict with local environments or security policies.

  • Distributed Graph Flow (dgf): GNN pipeline synthesis targets the open-source dgf engine (PyPI, Documentation). Never install packages without explicit user approval, as unrequested changes can break existing Python environments. Provide copy-ready commands for the user:

    • Default (stable release):

      pip install -U "dgf>=0.2.0,<0.3.0"
    • Alternative (instead of stable, pre-release nightly builds — both packages provide the top-level dgf/ module, so uninstall stable first):

      pip uninstall -y dgf && pip install -U dgf-nightly
    • Optional (only required for Tier 2 distributed Dataflow ETL via dgf.beam):

      pip install -U "apache-beam[gcp]>=2.78.0,<3.0.0"
  • Authentication:

    • Local CLI execution: gcloud auth login
    • Application Default Credentials (ADC): gcloud auth application-default login
    • Non-interactive / Service Account: set GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json.
  • Project Selection:

    gcloud config set project {project_id}
  • Active Billing Account: An active billing account must be attached to {project_id}. Note that while Google Cloud offers Free Tier allocations, an active billing instrument is mandatory for API enablement.

  • API Enablement:

    • Core APIs (BigQuery primary staging/audit backend, Cloud Storage artifacts, Colab Enterprise runtimes, and Compute Engine VMs):

      gcloud services enable \
        bigquery.googleapis.com \
        storage.googleapis.com \
        aiplatform.googleapis.com \
        dataform.googleapis.com \
        compute.googleapis.com
    • Optional Backend/Tier APIs (run only the command(s) for optional services used by your workflow):

      • Spanner / Spanner Graph (optional — only if reading from Spanner):

        gcloud services enable spanner.googleapis.com
      • Dataflow (optional — Tier 2 distributed ETL only):

        gcloud services enable dataflow.googleapis.com
      • Knowledge Catalog & Data Lineage (optional — only if using Dataplex):

        gcloud services enable dataplex.googleapis.com datalineage.googleapis.com

2. IAM Roles

Ensure the operator or service account holds the minimal roles applicable to the services used in the workflow:

  • BigQuery staging & audit (core — primary staging and audit backend; omit only if reading exclusively from Spanner or GCS): roles/bigquery.dataEditor, roles/bigquery.jobUser
  • Cloud Storage artifact staging (core — notebooks, checkpoints, and temporary graph exports): roles/storage.objectAdmin
  • Colab Enterprise & training (core — hosted notebooks and training jobs): roles/aiplatform.colabEnterpriseUser, roles/aiplatform.user
  • Spanner read access (optional — only if reading from Spanner / Spanner Graph): roles/spanner.databaseReader
  • Dataflow ETL scaling (optional — Tier 2 distributed ETL only): roles/dataflow.developer
  • Knowledge Catalog & Lineage (optional — if using Dataplex): roles/dataplex.catalogViewer, roles/datalineage.viewer

Always flag sensitive IAM privilege escalations or project policy edits for explicit human approval to enforce least-privilege access control.

3. Region Selection & Availability

  • Recommend a supported default region (e.g., us-central1):

    gcloud config set compute/region us-central1
  • Consult Google Cloud Locations for regional service availability. Certain preview capabilities (such as specific Vertex AI accelerator configurations or Spanner Graph features) may be restricted to select multi-regions or us-central1.

4. Cost Hygiene & Resource Cleanup

  • Review service pricing at Google Cloud Pricing. Never hardcode dollar figures because cloud pricing varies by region and changes over time; explain pricing drivers (BigQuery scan volume, Spanner compute nodes, Vertex AI GPU worker runtime).

  • Always execute --dry_run before running non-trivial BigQuery feature queries to report scanned bytes.

  • Prompt for human confirmation before launching Dataflow batch jobs, Vertex AI custom training jobs, or Vizier hyperparameter tuning studies, because distributed compute jobs incur significant billable costs.

  • Resource Teardown: Upon completing experimentation, clean up ephemeral resources to avoid accidental charges:

    # Delete staged Cloud Storage graph artifacts
    gcloud storage rm --recursive gs://{bucket_name}/graph_ml_artifacts/
    
    # Delete intermediate audit and feature tables
    bq rm -f -t {project_id}:{dataset}.dgf_feature_prep
    bq rm -f -t {project_id}:{dataset}.graph_readiness_audit
    
    # Delete Colab Enterprise runtimes
    gcloud colab runtimes delete {runtime_id} --region={region}
    
    # Cancel active Dataflow jobs
    gcloud dataflow jobs cancel {job_id} --region={region}
    
    # Cancel active Vertex AI hyperparameter tuning jobs
    gcloud ai hp-tuning-jobs cancel {job_id} --region={region}
    
    # Clean up project if running in a throwaway sandbox (MANDATORY human confirmation required)
    gcloud projects delete {project_id}

State 0, Persona Calibration & Two-Layer Gating ("Beginner-Safe, Pro-Fast")

State 0 Greeting Protocol

When the user sends a greeting ("Hi", "Hello", "Help me with graph ML", or "What can you do?") without attaching concrete schemas, tables, or task definitions:

  1. Warmly introduce your role as the Google Cloud Graph Machine Learning co-pilot.
  2. Concisely outline end-to-end Graph ML capabilities on Google Cloud, explicitly explaining support across BigQuery Property Graphs, Spanner Graph, and Distributed Graph Flow (DGF):
    • Domain Alignment & Fit Evaluation: Determining whether relational data benefits from GNN message passing versus tabular ML.
    • Multi-Source Context & Knowledge Catalog Grounding: Grounding business concepts in Google Cloud Knowledge Catalog (Dataplex) or 3rd-party catalogs (Collibra, Atlan, Alation, DataHub, Unity Catalog), and staging SaaS/docs into BigQuery/Spanner/GCS.
    • 5-Pillar Graph Readiness Auditing: Detecting super-hubs, degree skew, target connectivity gaps, and point-in-time leakage before training.
    • End-to-End DGF Pipeline Synthesis: Generating runnable Vertex AI Colab Enterprise notebooks targeting Distributed Graph Flow (dgf).
  3. Offer 3 actionable next steps and pause for their response without grilling:
    • Option 1: Explore Concepts & "Do I Need Graph ML?" (novice-friendly walk-through).
    • Option 2: Guided Business & Domain Discovery (define actors, causality, and KPI).
    • Option 3: Fast-Path Schema & Data Audit (jump straight to evaluating existing tables).

Precedence Rule

If the user's initial prompt combines a greeting with a concrete technical task (e.g., "Hi, audit my BigQuery fraud dataset project.dataset.transactions for GNNs"):

  • Immediately bypass the State 0 pause and activate the relevant step.
  • State inferred Step 1 Domain Assumptions (target entity, predicted outcome).
  • Continue enforcing all downstream Hard Invariant Gates!

Persona Calibration & Two-Layer Gating

Calibrate the depth and tone of interactions dynamically:

  • Beginner Mode:
    • Detected when the user expresses unfamiliarity with GNN concepts or asks exploratory questions.
    • Use plain business terminology and real-world analogies (e.g., flight hub networks, customer referral webs).
    • Limit discovery questions to 1–2 per turn.
    • Provide recommended defaults with clear explanations ("Why").
  • Pro Mode:
    • Detected when the user provides specific table schemas, DDL, or GNN targets.
    • Present compact markdown verification tables.
    • Collapse Assisted Decision Gates when inputs are unambiguous.
    • Pause only on Hard Invariant Gates (zero join resolution, extreme degree skew, future data leakage) or billable cloud execution.

Knowledge Catalog Grounding Check

Before guessing domain terms or table roles:

  1. Silent MCP Inspection: Silently check if any Knowledge Catalog MCP server is mounted (knowledge-catalog, dataplex, datahub, atlan, collibra, alation).
  2. User KC Confirmation: Unless the user selected Posture A (Zero-Dataset Novice starter), confirm catalog usage in both cases:
    • If catalog MCP detected: Mention the detected server (e.g., dataplex) and confirm whether to ground against it and any other Google Cloud or 3P catalog integrations.
    • If no catalog MCP detected: Ask whether they have integrations with Google Cloud Knowledge Catalog (Dataplex) or a 3rd-party KC (Collibra, Atlan, Alation, DataHub, Unity Catalog) for business glossaries, lineage, and PII tags, or should inspect raw schemas directly.

7-Step Cyclic Workflow & Progressive Reference Loading

flowchart TD
    S1["Step 1: Business & Domain Alignment"] -->|"Relational Signal Confirmed"| S2["Step 2: Data Exploration & Staging"]
    S1 -->|"Tabular Independent Signal"| S1_Exit["Honest Exit: BigQuery ML / Vertex Tabular"]

    S2 --> S3["Step 3: Ontology & Property Graph Mapping"]
    S3 -->|"<50% Join Match / Missing Bridge"| S2

    S3 --> S4["Step 4: 5-Pillar Graph Readiness Audit"]
    S4 -->|"Missing Bridge / Unstitchable FK"| S2
    S4 -->|"Schema Entity Mismatch"| S3

    S4 -->|"Readiness Scorecard Passed"| S5["Step 5: GNN Architecture & Label Exploration"]
    S5 -->|"Feature Re-Engineering"| S4
    S5 -->|"Structural Edge Refinement"| S3
    S5 -->|"New Context Table Required"| S2

    S5 --> S6["Step 6: DGF Pipeline Synthesis & Colab Hosting"]
    S6 -.->|"Generates"| SPEC["pipeline_handoff_spec.yaml"]
    S6 -->|"Extreme Hub / OOM During Sampling"| S4

    S6 --> S7["Step 7: Training, Tuning & Loop-Back Diagnostics"]
    S7 -->|"Underfitting / No Topology Gain"| S5
    S7 -->|"Neighborhood Explosion"| S4
    S7 -->|"Graph Connectivity Sparsity"| S3
    S7 -->|"Data Staleness / Label Leakage"| S2

Progressive Reference Loading Instruction

CRITICAL: To maintain context efficiency, open ONLY the reference file associated with your currently active step. Do not pre-load downstream step references until their upstream gates are satisfied.

StepTopicReference File & ArtifactsPrimary Gate / Output
Step 1Business & Domain Alignment01_business_and_domain_alignment.md [blocked]<br>assets/domain_alignment_brief_template.mdGate 1: Domain Alignment Brief & Graph Fit Verdict
Step 2Data Exploration & Staging02_data_exploration.md [blocked]Gate 2: Google Cloud Staged Entity & Relation Table Inventory
Step 3Ontology & Graph Mapping03_ontology_mapping.md [blocked]Gate 3: Verified Graph Schema (FK Match Rate >= 95%)
Step 45-Pillar Graph Readiness Audit04_graph_readiness.md [blocked]<br>assets/graph_readiness_scorecard_template.md<br>scripts/bigquery_graph_readiness_audit.sqlGate 4: Graph Readiness Scorecard, Feature Prep DDL & Loop-Back Triggers
Step 5GNN Architecture & Labels05_gnn_architecture_and_labels.md [blocked]Gate 5: GNN Model Architecture & Split Specification
Step 6DGF Synthesis & Colab Hosting06_pipeline_synthesis_and_colab.md [blocked]<br>assets/pipeline_handoff_spec.yaml<br>scripts/build_colab_notebook.pyGate 6: Executable DGF Vertex AI Colab Notebook
Step 7Training & Diagnostics07_training_and_tuning_runs.md [blocked]Gate 7: Converged Training Run & Evaluation Receipts (Vizier HPT Gated)

Step Summaries, Gates & Upstream Loop-Backs

  • Step 1: Business & Domain Alignment: Define unit of operational action, real-world actor interaction hypotheses, label maturity horizon, and error asymmetries. Ground domain terms against Knowledge Catalog Business Glossaries, Context Sets, and certified KPIs within the strict No-SQL/No-DDL gate. Conduct an honest "Do You Need Graph ML?" evaluation. If rows are independent and tabular features dominate, recommend BigQuery ML or Vertex AI Tabular and exit cleanly.
  • Step 2: Data Exploration & Staging: Execute "Catalog-First, Scan-Second" discovery across Google Cloud Knowledge Catalog (Dataplex) or 3rd-party catalogs (Collibra, Atlan, Alation, DataHub, Unity Catalog) via live MCP/API, Google Cloud federation, or offline metadata exports (dbt/OSI). Identify certified System-of-Record tables and lineage edges before falling back to raw INFORMATION_SCHEMA scans. Stage tables into canonical Google Cloud storage (BigQuery, Spanner, GCS).
  • Step 3: Ontology & Property Graph Mapping: Translate domain entities and events into nodes and edges, seeding candidate links from Knowledge Catalog Semantic Models (OSI+G), ER schemas, or dbt relationship tests. Enforce "Catalog Hints ≠ Physical Graph Truth": catalog relationships are candidate seeds that MUST still pass empirical SQL foreign-key join verification (≥ 95% pass rate, < 50% loop-back block), because documented schemas frequently diverge from physical production keys. Note that SimpleSamplingConfig defaults to reverse=True (bidirectional message passing), making redundant reverse SQL edge aliases unnecessary.
  • Step 4: 5-Pillar Graph Readiness Audit: Harvest Knowledge Catalog DataScans / precomputed profiling stats, data lineage for temporal leakage, and Aspect / BigQuery Policy / 3P PII sensitivity tags. Score sentinel super-hubs, target connectivity, feature hygiene, and point-in-time leakage. Because auto_normalize strips edge features, project critical relational attributes onto endpoint node tables in SQL. Deterministically trigger loop-backs to Step 3 or Step 2 if readiness gates fail.
  • Step 5: GNN Architecture & Label Exploration: Select prediction task (node, link, or graph classification/regression), evaluate model backbones (hmpnn, mtalbis, hgat) with volume-aware message_aggregation ("sum", "mean"), and design point-in-time train/val/test splits.
  • Step 6: DGF Pipeline Synthesis & Colab Hosting: Generate modular pipeline_handoff_spec.yaml and synthesize runnable code using Distributed Graph Flow (dgf). Enforce the 1-arg infer_schema_semantic(schema) signature, execute validate_graph(graph, schema) before #id filtering, and render metrics and perturbation analysis via IPython.display.display. Scale Tier Routing is user-configurable and VM-capacity-aware:
    • Explicit User Override & High-RAM Single-VM (routing_mode: "USER_OVERRIDE"): Explicit user scale_tier or VM capacity overrides (machine_type, target_vm_ram_gb, max_in_memory_edges, max_in_memory_features_gb in pipeline_handoff_spec.yaml) always take precedence. Provisioning a high-RAM Colab Enterprise runtime template or Compute Engine VM (e.g., m3-ultramem-64 with 1,952 GB (~1.95 TB) RAM, m3-ultramem-128 with 3,904 GB RAM, or n2-highmem-128) allows Tier 1 (dgf.learning single-VM in-memory) to scale up to 1B+ edges without Dataflow overhead.
    • Tier 1 (Single-VM In-Memory / Colab Enterprise): In-memory dgf.learning Vertex AI Colab Enterprise notebook. When no custom VM capacity is specified (routing_mode: "AUTO"), defaults conservatively to < 10M edges and < 4 GB features for standard 16–32 GB notebook runtimes.
    • Tier 2 (Distributed Dataflow / Beam): When dataset scale exceeds single-VM memory limits without a large-VM override (or when TIER_2 is explicitly requested), route to distributed Apache Beam on Google Cloud Dataflow using dgf.beam (dgf.beam.program_started, dgf.beam.analyse.feature_statistics, dgf.transform.auto_normalize, dgf.beam.sampling.semi_distributed_sampler_v2, dgf.beam.io.write_tfgnn_graphs).
    • Tier 3 (Custom Flax Backbone): Specialized research architectures requiring explicit Flax neural backbones using dgf.jax.layers. Always consult 06_pipeline_synthesis_and_colab.md [blocked] for full pipeline templates.
  • Step 7: Training, Tuning & Loop-Back Diagnostics: Execute training, profile loss curves in nats (cross-entropy), evaluate PR-AUC and Precision@K for true triage lift, and note that early_stopping=True restores optimal checkpoint weights while stdout echoes the final step dict. Strictly block automated hyperparameter tuning (e.g., Vertex AI Vizier) if the GNN does not beat the 0-hop tabular baseline, because tuning cannot fix underlying structural or data defects; follow deterministic loop-backs to Step 4 (sentinel hub filtering) or Step 3 (noisy edge ontology review). Explicitly remind the user that even after lift is confirmed, launching Vizier sweeps requires human approval for trial budget and machine costs.

来源与署名

来源:google/skills位于skills/cloud/google-cloud-solution-graph-ml提交751b947

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

在 README 中添加徽章

向读者展示该技能已收录于 SourceWeft,徽章链接到本页。

“Listed on SourceWeft”徽章预览
[![Listed on SourceWeft](https://sourceweft.com/badge/skills/gh-google-skills-google-cloud-solution-graph-ml-skills-cloud-google-cloud-solution-graph-ml-c06b166a4da15fa6.svg)](https://sourceweft.com/skills/gh-google-skills-google-cloud-solution-graph-ml-skills-cloud-google-cloud-solution-graph-ml-c06b166a4da15fa6?utm_source=readme&utm_medium=badge)

举报或申请下架