Skip to content

doc(ai): sync hugegraph-ml with main - #482

Merged
imbajin merged 1 commit into
apache:masterfrom
bitflicker64:doc-sync/ai-hugegraph-ml
Sep 6, 2026
Merged

doc(ai): sync hugegraph-ml with main#482
imbajin merged 1 commit into
apache:masterfrom
bitflicker64:doc-sync/ai-hugegraph-ml

Conversation

@bitflicker64

Copy link
Copy Markdown
Contributor

Syncs the HugeGraph-ML quick start (en and cn) with apache/hugegraph-ai@main at version 1.7.0. Every change below traces to a file on main.

Page Wrong Changed to Source
en + cn Intro listed only node embedding, node classification, graph classification Added link prediction and fraud detection hugegraph-ml/src/hugegraph_ml/tasks/link_prediction_seal.py:32, .../fraud_detector_caregnn.py:27
en + cn No statement of how the module reaches the server Reads use the Gremlin endpoint via pyhugegraph; importers use schema and batch APIs in batches of 500 hugegraph-ml/src/hugegraph_ml/data/hugegraph2dgl.py:41,54, .../utils/dgl2hugegraph_utils.py:45
en + cn No torch / dgl / ogb versions anywhere on the page Added pin table: torch==2.2.0, dgl~=2.1.0, ogb~=1.3.6, torchdata~=0.7.0, catboost~=1.2.3, category-encoders~=2.6.3, numpy~=1.24.4, pandas~=2.2.3 pyproject.toml:109,110,136-140,143
en + cn No mention of CPU vs GPU Pins install CPU builds; every task takes gpu defaulting to -1 hugegraph-ml/src/hugegraph_ml/tasks/node_embed.py:49, .../node_classify.py:61
en + cn Models table grouped names by purpose, framed as "the current README lists these models" Per-module table of model, module file, entry class, purpose and paper link, derived from the source tree hugegraph-ml/src/hugegraph_ml/models/agnn.py:33, appnp.py:32, arma.py:122, bgnn.py:60, bgrl.py:93, care_gnn.py:127, cluster_gcn.py:34, correct_and_smooth.py:160, dagnn.py:100, deepergcn.py:38, dgi.py:35, diffpool.py:36, gatne.py:66, grace.py:36, grand.py:35, jknet.py:33, pgnn.py:79, seal.py:175
en + cn BGNN listed under "Fraud detection" BGNN is gradient boosting combined with a GNN over node features; the bundled example runs task="regression" hugegraph-ml/src/hugegraph_ml/examples/bgnn_example.py:40
en + cn GIN and MLPClassifier only mentioned in a trailing prose note Promoted to first-class rows in the models table hugegraph-ml/src/hugegraph_ml/models/gin_global_pool.py:26, .../mlp.py:22
en + cn Nothing said about how to import models models/__init__.py re-exports nothing; import from the module file hugegraph-ml/src/hugegraph_ml/models/__init__.py:1
en + cn Missing: GIN pooling options sum (default), mean, max, global_attention, set2set hugegraph-ml/src/hugegraph_ml/models/gin_global_pool.py:41
en + cn Missing section: the conversion API. Only convert_graph appeared, inside an example New "Reading Graph Data" section with the constructor and all seven public methods with their defaults hugegraph-ml/src/hugegraph_ml/data/hugegraph2dgl.py:33,44,60,114,148,158,177,185
en + cn Missing: which ndata keys each task requires NodeEmbed needs feat; the three node classification tasks need feat, label, train_mask, val_mask, test_mask hugegraph-ml/src/hugegraph_ml/tasks/node_embed.py:36, .../node_classify.py:38
en + cn Missing section: dataset importers. Only import_graph_from_dgl("cora") appeared New "Importing Sample Datasets" section: nine importers, the dataset names each accepts, and the labels each creates hugegraph-ml/src/hugegraph_ml/utils/dgl2hugegraph_utils.py:59,130,211,295,366,424,513,613,749
en + cn Missing: clear_all_data and the test fixture flow Drops all vertices and edges; the fixture calls it, loads CORA, MUTAG, ACM, then calls it again hugegraph-ml/src/hugegraph_ml/utils/dgl2hugegraph_utils.py:48, hugegraph-ml/src/tests/conftest.py:29
en + cn Missing: AMAZONGATNE and AVAZU are not auto-downloaded Added a note pointing at the archive URLs in the source comments hugegraph-ml/src/hugegraph_ml/utils/dgl2hugegraph_utils.py:303,757
en + cn Missing section: task classes. Only NodeEmbed and NodeClassify appeared in examples New "Tasks" section covering all nine task classes with entry points and defaults, including the GraphClassify 70/20/10 split, NodeClassifyWithSample being CPU only, LinkPredictionSeal calling data_prepare() in its constructor, and DetectorCaregnn reading ndata["feature"] hugegraph-ml/src/hugegraph_ml/tasks/node_embed.py:42, node_classify.py:54, node_classify_with_edge.py:58, node_classify_with_sample.py:65, graph_classify.py:59,73, fraud_detector_caregnn.py:81, hetero_sample_embed_gatne.py:40, link_prediction_pgnn.py:36, link_prediction_seal.py:43
en + cn Missing: EarlyStopping behaviour patience defaults to float("inf"), monitors loss or accuracy, restores best weights hugegraph-ml/src/hugegraph_ml/utils/early_stopping.py:42
en + cn Missing section: the example scripts. Only two were named, in prose New "Runnable Examples" section with the run command from hugegraph-ml/src and a 19-row table of script, model, task and graph labels read hugegraph-ml/src/hugegraph_ml/examples/agnn_example.py:23, bgnn_example.py:32, care_gnn_example.py:27, cluster_gcn_example.py:25, deepergcn_example.py:25, diffpool_example.py:25, gatne_example.py:26, gin_example.py:25, pgnn_example.py:26, seal_example.py:28
en + cn DGI example did not show what evaluate() returns Added the metrics dict and a sample value hugegraph-ml/src/hugegraph_ml/tasks/node_classify.py:44, hugegraph-ml/README.md:137
en + cn import_graph_from_dgl("cora") gave no hint why the labels are CORA_* The name is upper-cased before use hugegraph-ml/src/hugegraph_ml/utils/dgl2hugegraph_utils.py:67
en + cn GRAND example did not explain its non-standard output GRAND returns a list of logits per augmentation and NodeClassify masks each element hugegraph-ml/src/hugegraph_ml/tasks/node_classify.py:87
en + cn Troubleshooting had no entry for the missing-attribute failure Added ValueError: Graph is missing required node attribute ... with the fix hugegraph-ml/src/hugegraph_ml/tasks/node_classify.py:41
en + cn Troubleshooting had no entry for unsupported dataset names Added ValueError: dataset not supported, and that import_graph_from_ogb matches ogbl-collab without upper-casing hugegraph-ml/src/hugegraph_ml/utils/dgl2hugegraph_utils.py:75,521
en + cn No warning that bgrl_example.py fails on import It imports MLP_Predictor, but the class is MLPPredictor hugegraph-ml/src/hugegraph_ml/examples/bgrl_example.py:19, .../models/bgrl.py:43
en + cn No warning that care_gnn_example.py has no matching importer It reads AMAZON_user_v and three AMAZON_net_*_e labels that no bundled importer creates hugegraph-ml/src/hugegraph_ml/examples/care_gnn_example.py:28, .../utils/dgl2hugegraph_utils.py:306

Upstream defects found while reading the code

Not fixed here, they belong in apache/hugegraph-ai:

  • hugegraph-ml/README.md:35 says "python 3.9+", but hugegraph-ml/pyproject.toml:32 sets requires-python = ">=3.10".
  • Root README.md:105,107 advertises DeepWalk, Node2Vec, GAT, GCN and GraphSAGE. models/ contains no DeepWalk, Node2Vec or GAT; GraphSAGE exists only as SAGE inside cluster_gcn.py:34, and GCN only as encoder classes inside bgrl.py:71, grace.py:196 and seal.py:51.
  • hugegraph-ml/src/hugegraph_ml/examples/bgrl_example.py:19 imports MLP_Predictor, which does not exist; models/bgrl.py:43 defines MLPPredictor. src/tests/test_examples/test_examples.py:24 imports this example, so the whole example test module fails to collect.

Rebuild the Implemented Models table from src/hugegraph_ml/models/ so it
lists every module, its entry class and its paper, including GIN and
MLPClassifier. Correct the BGNN row: the bundled example runs regression
over tabular node features, not fraud detection.

Add sections for the HugeGraph2DGL conversion methods, the dataset
importers and the datasets each accepts, the task classes and their
entry points, and the runnable example scripts. Record the ML dependency
pins from the root constraint-dependencies block, and add troubleshooting
entries for the missing node attributes error, the unsupported dataset
error, the bgrl_example MLP_Predictor import mismatch and the missing
CARE-GNN dataset importer.

@imbajin imbajin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking: yes. Summary: The page adds useful coverage but currently contains several user-facing contracts that contradict the pinned HugeGraph-AI implementation, including server-version, task-device, attribute, importer, and destructive-clear behavior. Evidence: exact-head source cross-checks against apache/hugegraph-ai@5ee21cc and the HugeGraph GraphsAPI; exact-head site CI is green.

- HugeGraph Server 1.0 or later; 1.5 or later is recommended
- `uv` 0.7 or later

All server access goes through `hugegraph-python-client` (the `pyhugegraph` package) from the same repository. `HugeGraph2DGL` pulls vertices and edges over the Gremlin endpoint with `g.V().hasLabel(...)` and `g.E().hasLabel(...)`, and the dataset importers write through the schema and batch vertex/edge APIs in batches of 500.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ The requirements above still allow HugeGraph Server 1.0, but this newly documented dependency resolves to hugegraph-python-client 1.7.0, whose HGraphConfig raises RuntimeError below 1.5.0 (apache/hugegraph-ai@5ee21cc, hugegraph-python-client/src/pyhugegraph/utils/huge_config.py:66-71). Please change the requirement to 1.5.0+ and mirror it in CN; otherwise this page tells users to run an unsupported combination.

| `numpy` | `~=1.24.4` |
| `pandas` | `~=2.2.3` |

Those pins install CPU builds. Every task accepts a `gpu` argument that defaults to `-1`, meaning CPU; pass a device index only after installing CUDA builds of `torch` and `dgl` yourself.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This blanket statement is contradicted by the task table below: NodeClassifyWithSample.train has no gpu parameter and its implementation fixes CPU (apache/hugegraph-ai@5ee21cc, hugegraph-ml/src/hugegraph_ml/tasks/node_classify_with_sample.py:32-72). Please scope "Every task" to tasks that expose gpu, or explicitly exempt this task in both translations; as written, following the sentence leads to a TypeError.

| `convert_graph_ogb(vertex_label, edge_label, split_label)` | `(dgl.DGLGraph, split_edge)` | Used by SEAL |
| `convert_hetero_graph_bgnn(vertex_labels, edge_labels, feat_key="feat", label_key="class", cat_key="cat_features", mask_keys=None)` | DGL heterograph | Used by BGNN |

Node features land in `ndata["feat"]`, labels in `ndata["label"]` and each mask in `ndata[<mask key>]`. `NodeEmbed` requires `feat` only; `NodeClassify`, `NodeClassifyWithEdge` and `NodeClassifyWithSample` require `feat`, `label`, `train_mask`, `val_mask` and `test_mask` and raise `ValueError` when one is missing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ The listed node attributes are not the complete contract for NodeClassifyWithEdge. Its _check_graph also requires graph.edata["feat"] (apache/hugegraph-ai@5ee21cc, hugegraph-ml/src/hugegraph_ml/tasks/node_classify_with_edge.py:39-46), while convert_graph_with_edge_feat supplies that edge attribute. Please include this requirement so users do not hit ValueError after satisfying the documented list.

| `import_graph_from_ogb` | `ogbl-collab`, matched without upper-casing | `<NAME>_vertex`, `<NAME>_edge` |
| `import_split_edge_from_ogb` | `ogbl-collab`, matched without upper-casing | `<NAME>_split_edge` |

Any other name raises `ValueError("dataset not supported")`. `import_split_edge_from_ogb` additionally requires the `idx_to_vertex_id` mapping and a `max_nodes` cap returned by the vertex import.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ import_split_edge_from_ogb does not receive a mapping or max_nodes "returned by the vertex import": import_graph_from_ogb keeps idx_to_vertex_id and max_nodes local and invokes split import itself; the standalone function requires callers to provide them (apache/hugegraph-ai@5ee21cc, hugegraph-ml/src/hugegraph_ml/utils/dgl2hugegraph_utils.py:544-610, 613-629). Please document that the caller must build those values, or describe the automatic path only.


Any other name raises `ValueError("dataset not supported")`. `import_split_edge_from_ogb` additionally requires the `idx_to_vertex_id` mapping and a `max_nodes` cap returned by the vertex import.

`clear_all_data()` drops every vertex and edge in the target graph. The test fixture calls it, loads `CORA`, `MUTAG` and `ACM`, and calls it again on teardown.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ clear_all_data() delegates to clear_graph_all_data(), whose HugeGraph clear endpoint removes schema, vertices, edges, and indexes (the repository's Graphs REST API documentation and GraphsAPI.truncateBackend). Saying it drops only vertices and edges understates the destructive scope; please mention schema/index deletion and warn users.

| `NodeClassifyWithEdge` | `node_classify_with_edge.py` | Same shape, for models that also read `edata["feat"]` |
| `NodeClassifyWithSample` | `node_classify_with_sample.py` | Cluster-GCN style training on `ClusterGCNSampler` partitions; runs on CPU and takes no `gpu` argument |
| `GraphClassify` | `graph_classify.py` | `train(batch_size=20, lr, weight_decay, n_epochs, patience, early_stopping_monitor, clip=2.0, gpu)` over a `HugeGraphDataset`, split 70/20/10 |
| `DetectorCaregnn` | `fraud_detector_caregnn.py` | CARE-GNN training; `evaluate()` reports recall and ROC AUC and reads `ndata["feature"]` rather than `ndata["feat"]` |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ DetectorCaregnn directly reads ndata["feature"], but convert_hetero_graph stores the configured vertex feature under ndata["feat"] (apache/hugegraph-ai@5ee21cc, hugegraph-ml/src/hugegraph_ml/data/hugegraph2dgl.py:81-85 and tasks/fraud_detector_caregnn.py:43-45). Following this page's converter + task flow therefore raises KeyError unless the user manually renames the field; please add that preparation step or document the mismatch.

```

The source also includes `GIN` for graph classification and `MLPClassifier` for downstream classification. The model count changes between versions; use `src/hugegraph_ml/models/` as the authoritative list.
Each script also exposes a function of the same name, so it can be imported and called with a smaller epoch count.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 bgnn_example is the only listed example function without an epoch parameter—it hard-codes num_epochs=100 (apache/hugegraph-ai@5ee21cc, hugegraph-ml/src/hugegraph_ml/examples/bgnn_example.py:30,49-58). Calling each example with a smaller epoch count as this sentence suggests raises TypeError; qualify the sentence or update that example's signature.

@imbajin imbajin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

中文段落已完成一致性复核(GPU/示例边界说明)并已修订,当前可合并。评分 9.1/10

@imbajin
imbajin merged commit f845164 into apache:master Sep 6, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants