{"success":true,"data":{"author":"Open Graph Benchmark team (Hu et al., Stanford)","bucketAccessType":"public","bucketName":"OGB/ogbg-code2","bucketPrefix":"","category":"Machine Learning & AI","cloudProvider":"huggingface","createdAt":"2026-11-14T14:15:20.480Z","description":"ogbg-code2 from the Open Graph Benchmark (OGB). It is a collection of abstract syntax trees (ASTs) of about 450,000 Python method definitions from 13,587 popular GitHub repositories in the CodeSearchNet corpus, with AST nodes, AST edges and the tokenised method name extracted for each. The task is to predict the sub-tokens of the method name from the body, a code summarisation problem framed as graph-to-sequence prediction. This Hugging Face copy stores the graphs as JSON Lines (train.jsonl about 3.3 GB, valid.jsonl about 0.19 GB, test.jsonl about 0.17 GB, measured 2026-11-14), and the card shows conversion to PyTorch Geometric. Uses include benchmarking graph neural networks on large sparse trees, program representation learning and comparing graph and sequence models of source code. Load with Hugging Face datasets or pandas and build graphs with PyTorch Geometric or DGL; the official ogb package also downloads it. OGB lists the ogbg-code2 licence as MIT; cite Hu et al., Open Graph Benchmark (NeurIPS 2020).","displayTitle":"OGB ogbg-code2: Code Summarization as Graph Prediction (Open Graph Benchmark)","id":"7b317fa5-bb4a-56ae-a6c2-3602e809ac13","license":"MIT","licenseEvidenceUrl":"https://ogb.stanford.edu/docs/graphprop/","objectCountEstimate":5,"probeStatus":"ok","referenceUrl":"https://arxiv.org/abs/2005.00687","region":"us","schemaCard":{"accessHints":[{"language":"python-datasets","snippet":"from datasets import load_dataset\nds = load_dataset(\"OGB/ogbg-code2\")"},{"language":"python-hub","snippet":"from huggingface_hub import snapshot_download\nsnapshot_download(repo_id=\"OGB/ogbg-code2\", repo_type=\"dataset\")"}],"caveats":["HuggingFace metadata: author=OGB, license:mit, size_categories:100K<n<1M, format:json, downloads=1973"],"format":"mixed","generatedAt":"2026-11-14T14:15:26.038Z","layout":{"example":"test.jsonl","pattern":"{repoId}/{filename}"},"mountPath":"/mnt/archive","sampleHeaders":[{"bytes":"{\"edge_index\": [[0, 1, 1, 1, 2, 4, 6, 7, 7, 7, 7, 7, 7, 7, 9, 9, 9, 10, 12, 15, 15, 15, 16, 18, 21, 21, 21, 22, 24, 27, 27, 27, 28, 30, 33, 33, 33, 34, 36, 39, 39, 39, 40, 42, 42, 42, 43, 45], [1, 2, 4, 6, 3, 5, 7, 8, 9, 15, 21, 27, 33, 39, 10, 12, 14, 11, 13, 16, 18, 20, 17, 19, 22, 24, 26, 23, 25, 28, 30, 32, 29, 31, 34, 36, 38, 35, 37, 40, 42, 48, 41, 43, 45, 47, 44, 46]], \"node_feat\": [[59, 10028], [35, 1461], [93, 10028], [92, 9437], [30, 10028], [79, 10029], [73, 10028], [15, 10028], [68, 10028], [18,","encoding":"utf8","key":"test.jsonl","truncatedAt":512}],"sampleObjects":["test.jsonl","train.jsonl","valid.jsonl"],"sidecars":[{"bytes":"---\nlicense: mit\ntask_categories:\n- graph-ml\n---\n\n# Dataset Card for ogbg-code2\n\n## Table of Contents\n- [Table of Contents](#table-of-contents)\n- [Dataset Description](#dataset-description)\n  - [Dataset Summary](#dataset-summary)\n  - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)\n- [External Use](#external-use)\n  - [PyGeometric](#pygeometric)\n- [Dataset Structure](#dataset-structure)\n  - [Data Properties](#data-properties)\n  - [Data Fields](#data-fields)\n  - [Data Splits](#data-splits)\n- [Additional Information](#additional-information)\n  - [Licensing Information](#licensing-information)\n  - [Citation Information](#citation-information)\n  - [Contributions](#contributions)\n\n## Dataset Description\n\n- **[Homepage](https://ogb.stanford.edu/docs/graphprop/#ogbg-code2)**\n- **[Repository](https://github.com/snap-stanford/ogb):**: \n- **Paper:**: Open Graph Benchmark: Datasets for Machine Learning on Graphs (see citation) \n- **Leaderboard:**: [OGB leaderboard](https://ogb.stanford.edu/docs/leader_graphprop/#ogbg-code2) and [Papers with code leaderboard](https://paperswithcode.com/sota/graph-property-prediction-on-ogbg-code2)\n\n### Dataset Summary\n\nThe `ogbg-code2` dataset contains Abstract Syntax Trees (ASTs) obtained from 450 thousands Python method definitions, from GitHub CodeSearchNet. \"Methods are extracted from a total of 13,587 different repositories across the most popular projects on GitHub.\", by teams at Stanford, to be a part of the Open Graph Benchmark. See their website or paper for dataset postprocessing.\n\n### Supported Tasks and Leaderboards\n\n\"The task is to predict the sub-tokens forming the method name, given the Python method body represented by AST and its node features. This task is often referred to as “code summarization”, because the model is trained to find succinct and precise description for a complete logical unit.\" \n\nThe score is the F1 score of sub-token prediction. \n\n## External Use\n### PyGeometric\nTo load in PyGeometric, do the following:\n\n```python\nfrom datasets import load_dataset\n\nfrom torch_geometric.data import Data\nfrom torch_geometric.loader import DataLoader\n\ngraphs_dataset = load_dataset(\"graphs-datasets/ogbg-code2)\n# For the train set (replace by valid or test as needed)\ngraphs_list = [Data(graph) for graph in graphs_dataset[\"train\"]]\ngraphs_pygeometric = DataLoader(graph_list)\n\n```\n\n\n## Dataset Structure\n\n### Data Properties\n\n| property | value |\n|---|---|\n| scale | medium |\n| #graphs | 452,741 |\n| average #nodes | 125.2 |\n| average #edges | 124.2 |\n| average node degree | 2.0 | \n| average cluster coefficient | 0.0 | \n| MaxSCC ratio | 1.000 |\n| graph diameter | 13.5 |\n\n### Data Fields\n\nEach row of a given file is a graph, with: \n- `edge_index` (list: 2 x #edges): pairs of nodes constituting edges\n- `edge_feat` (list: #edges x #edge-features): features of edges\n- `node_feat` (list: #nodes x #node-features): the nodes features, embedded\n- `node_feat_expanded` (list: #nodes x #node-features): the nodes features, as code\n- `node_is_attributed` (list: 1 x #nodes): ?\n- `node_dfs_order` (list: #nodes x #1): the nodes order in the abstract tree, if parsed using a depth first search\n- `node_depth` (list: #nodes x #1): the nodes depth in the abstract tree\n- `y` (list: 1 x #tokens): contains the tokens to predict as method name\n- `num_nodes` (int): number of nodes of the graph\n- `ptr` (list: 2): index of first and last node of the graph\n- `batch` (list: 1 x #nodes): ?\n\n### Data Splits\n\nThis data comes from the PyGeometric version of the dataset provided by OGB, and follows the provided data splits.\nThis information can be found back using\n```python\nfrom ogb.graphproppred import PygGraphPropPredDataset\n\ndataset = PygGraphPropPredDataset(name = 'ogbg-code2')\n\nsplit_idx = dataset.get_idx_split() \ntrain = dataset[split_idx['train']] # valid, test\n```\n\nMore information (`node_feat_expanded`) has been added through the typeidx2type and attridx2attr csv files of the repo.\n\n## Additional Information\n\n### Licensing Information\nThe dataset has been released under MIT license license.","encoding":"utf8","key":"README.md","name":"README.md","size":5123,"truncated":true}],"sourceObjectKey":"test.jsonl","starterCell":"from datasets import load_dataset\nds = load_dataset(\"OGB/ogbg-code2\")\nprint(ds)","starterSamplePath":"test.jsonl","totalObjects":5},"summary":"ogbg-code2 from the Open Graph Benchmark (OGB). It is a collection of abstract syntax trees (ASTs) of about 450,000 Python method definitions from 13,587 popular GitHub…","title":"OGB ogbg-code2: Code Summarization as Graph Prediction (Open Graph Benchmark)","updatedAt":"2026-11-14T17:37:54.043Z","visibility":"public","websiteUrl":"https://ogb.stanford.edu/docs/graphprop/#ogbg-code2"}}