The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
Error code: DatasetGenerationError
Exception: CastError
Message: Couldn't cast
project: string
bug_id: int64
snapshot_commit: string
fix_commit: string
version: string
file_path: string
code: string
functions: list<item: struct<function_name: string, code: string, ast_nodes: list<item: string>, ast_edges: lis (... 47 chars omitted)
child 0, item: struct<function_name: string, code: string, ast_nodes: list<item: string>, ast_edges: list<item: lis (... 35 chars omitted)
child 0, function_name: string
child 1, code: string
child 2, ast_nodes: list<item: string>
child 0, item: string
child 3, ast_edges: list<item: list<item: int64>>
child 0, item: list<item: int64>
child 0, item: int64
child 4, func_label: int64
label: int64
language: string
sample_id: string
to
{'project': Value('string'), 'file_path': Value('string'), 'bug_id': Value('string'), 'snapshot_commit': Value('string'), 'fix_commit': Value('string'), 'code': Value('string'), 'functions': List({'function_name': Value('string'), 'code': Value('string'), 'ast_nodes': List(Value('string')), 'ast_edges': List(List(Value('int64'))), 'func_label': Value('int64')}), 'label': Value('int64'), 'language': Value('string'), 'sample_id': Value('string')}
because column names don't match
Traceback: Traceback (most recent call last):
File "/usr/local/lib/python3.14/site-packages/datasets/builder.py", line 1816, in _prepare_split_single
for key, table in generator:
^^^^^^^^^
File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 613, in wrapped
for item in generator(*args, **kwargs):
~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/datasets/packaged_modules/json/json.py", line 343, in _generate_tables
self._cast_table(pa_table, json_field_paths=json_field_paths),
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/datasets/packaged_modules/json/json.py", line 132, in _cast_table
pa_table = table_cast(pa_table, self.info.features.arrow_schema)
File "/usr/local/lib/python3.14/site-packages/datasets/table.py", line 2369, in table_cast
return cast_table_to_schema(table, schema)
File "/usr/local/lib/python3.14/site-packages/datasets/table.py", line 2297, in cast_table_to_schema
raise CastError(
...<3 lines>...
)
datasets.table.CastError: Couldn't cast
project: string
bug_id: int64
snapshot_commit: string
fix_commit: string
version: string
file_path: string
code: string
functions: list<item: struct<function_name: string, code: string, ast_nodes: list<item: string>, ast_edges: lis (... 47 chars omitted)
child 0, item: struct<function_name: string, code: string, ast_nodes: list<item: string>, ast_edges: list<item: lis (... 35 chars omitted)
child 0, function_name: string
child 1, code: string
child 2, ast_nodes: list<item: string>
child 0, item: string
child 3, ast_edges: list<item: list<item: int64>>
child 0, item: list<item: int64>
child 0, item: int64
child 4, func_label: int64
label: int64
language: string
sample_id: string
to
{'project': Value('string'), 'file_path': Value('string'), 'bug_id': Value('string'), 'snapshot_commit': Value('string'), 'fix_commit': Value('string'), 'code': Value('string'), 'functions': List({'function_name': Value('string'), 'code': Value('string'), 'ast_nodes': List(Value('string')), 'ast_edges': List(List(Value('int64'))), 'func_label': Value('int64')}), 'label': Value('int64'), 'language': Value('string'), 'sample_id': Value('string')}
because column names don't match
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1369, in compute_config_parquet_and_info_response
parquet_operations, partial, estimated_dataset_info = stream_convert_to_parquet(
~~~~~~~~~~~~~~~~~~~~~~~~~^
builder, max_dataset_size_bytes=max_dataset_size_bytes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 948, in stream_convert_to_parquet
builder._prepare_split(split_generator=splits_generators[split], file_format="parquet")
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/datasets/builder.py", line 1683, in _prepare_split
for job_id, done, content in self._prepare_split_single(
~~~~~~~~~~~~~~~~~~~~~~~~~~^
gen_kwargs=gen_kwargs, job_id=job_id, **_prepare_split_args
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
):
^
File "/usr/local/lib/python3.14/site-packages/datasets/builder.py", line 1869, in _prepare_split_single
raise DatasetGenerationError("An error occurred while generating the dataset") from e
datasets.exceptions.DatasetGenerationError: An error occurred while generating the datasetNeed help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
project string | file_path string | bug_id string | snapshot_commit string | fix_commit string | code string | functions list | label int64 | language string | sample_id string |
|---|---|---|---|---|---|---|---|---|---|
FFmpeg | libavformat/ape.c | CVE-2011-2161 | 8312e3fc9041027a33c8bc667bb99740fdf41dd5 | 8312e3fc9041027a33c8bc667bb99740fdf41dd5 | /*
* Monkey's Audio APE demuxer
* Copyright (c) 2007 Benjamin Zores <ben@geexbox.org>
* based upon libdemac from Dave Chapman.
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the... | [
{
"function_name": "ape_probe",
"code": "static int ape_probe(AVProbeData * p)\n{\n if (p->buf[0] == 'M' && p->buf[1] == 'A' && p->buf[2] == 'C' && p->buf[3] == ' ')\n return AVPROBE_SCORE_MAX;\n\n return 0;\n}",
"ast_nodes": [
"FUNC_DECL",
"IF",
"RETURN",
"PARAM",
... | 0 | c | FFmpeg-0 |
FFmpeg | libavcodec/dxva2_h264.c | CVE-2011-2161 | 8312e3fc9041027a33c8bc667bb99740fdf41dd5 | 8312e3fc9041027a33c8bc667bb99740fdf41dd5 | /*
* DXVA2 H264 HW acceleration.
*
* copyright (c) 2009 Laurent Aimar
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the Li... | [
{
"function_name": "fill_picture_entry",
"code": "static void fill_picture_entry(DXVA_PicEntry_H264 *pic,\n unsigned index, unsigned flag)\n{\n assert((index&0x7f) == index && (flag&0x01) == flag);\n pic->bPicEntry = index | (flag << 7);\n}",
"ast_nodes": [
"FUN... | 0 | c | FFmpeg-1 |
linux | tools/hv/hv_kvp_daemon.c | CVE-2012-5532 | 95a69adab9acfc3981c504737a2b6578e4d846ef | 95a69adab9acfc3981c504737a2b6578e4d846ef | "/*\n * An implementation of key value pair (KVP) functionality for Linux.\n *\n *\n * Copyright (C)(...TRUNCATED) | [{"function_name":"kvp_acquire_lock","code":"static void kvp_acquire_lock(int pool)\n{\n\tstruct flo(...TRUNCATED) | 1 | c | linux-2 |
linux | mm/memory_hotplug.c | CVE-2012-5517 | 08dff7b7d629807dbb1f398c68dd9cd58dd657a1 | 08dff7b7d629807dbb1f398c68dd9cd58dd657a1 | "/*\n * linux/mm/memory_hotplug.c\n *\n * Copyright (C)\n */\n\n#include <linux/stddef.h>\n#includ(...TRUNCATED) | [{"function_name":"lock_memory_hotplug","code":"void lock_memory_hotplug(void)\n{\n\tmutex_lock(&mem(...TRUNCATED) | 1 | c | linux-3 |
linux | fs/exofs/sys.c | CVE-2012-5517 | 08dff7b7d629807dbb1f398c68dd9cd58dd657a1 | 08dff7b7d629807dbb1f398c68dd9cd58dd657a1 | "/*\n * Copyright (C) 2012\n * Sachin Bhamare <sbhamare@panasas.com>\n * Boaz Harrosh <bharrosh@pana(...TRUNCATED) | [{"function_name":"odev_attr_show","code":"static ssize_t odev_attr_show(struct kobject *kobj, struc(...TRUNCATED) | 0 | c | linux-4 |
linux | net/ipv4/tcp_illinois.c | CVE-2012-4565 | 8f363b77ee4fbf7c3bbcf5ec2c5ca482d396d664 | 8f363b77ee4fbf7c3bbcf5ec2c5ca482d396d664 | "/*\n * TCP Illinois congestion control.\n * Home page:\n *\thttp://www.ews.uiuc.edu/~shaoliu/tcpill(...TRUNCATED) | [{"function_name":"rtt_reset","code":"static void rtt_reset(struct sock *sk)\n{\n\tstruct tcp_sock *(...TRUNCATED) | 1 | c | linux-5 |
linux | fs/ext4/extents.c | CVE-2012-4508 | dee1f973ca341c266229faa5a1a5bb268bed3531 | dee1f973ca341c266229faa5a1a5bb268bed3531 | "/*\n * Copyright (c) 2003-2006, Cluster File Systems, Inc, info@clusterfs.com\n * Written by Alex T(...TRUNCATED) | [{"function_name":"ext4_extent_block_csum","code":"static __le32 ext4_extent_block_csum(struct inode(...TRUNCATED) | 1 | c | linux-6 |
linux | net/socket.c | CVE-2012-4467 | ed6fe9d614fc1bca95eb8c0ccd0e92db00ef9d5d | ed6fe9d614fc1bca95eb8c0ccd0e92db00ef9d5d | "/*\n * NET\t\tAn implementation of the SOCKET network access protocol.\n *\n * Version:\t@(#)socket(...TRUNCATED) | [{"function_name":"move_addr_to_kernel","code":"int move_addr_to_kernel(void __user *uaddr, int ulen(...TRUNCATED) | 1 | c | linux-7 |
linux | net/ipv6/reassembly.c | CVE-2012-4444 | 70789d7052239992824628db8133de08dc78e593 | 70789d7052239992824628db8133de08dc78e593 | "/*\n *\tIPv6 fragment reassembly\n *\tLinux INET6 implementation\n *\n *\tAuthors:\n *\tPedro Roque(...TRUNCATED) | [{"function_name":"ip6_frag_nqueues","code":"int ip6_frag_nqueues(struct net *net)\n{\n\treturn net-(...TRUNCATED) | 1 | c | linux-8 |
linux | include/net/inet_sock.h | CVE-2012-3552 | f6d8bd051c391c1c0458a30b2a7abcd939329259 | f6d8bd051c391c1c0458a30b2a7abcd939329259 | "/*\n * INET\t\tAn implementation of the TCP/IP protocol suite for the LINUX\n *\t\toperating system(...TRUNCATED) | [{"function_name":"inet_rsk","code":"static inline struct inet_request_sock *inet_rsk(const struct r(...TRUNCATED) | 0 | c | linux-9 |
HAM-Net datasets
This repository provides the processed code datasets used in the HAM-Net experiments for cross-project software defect prediction.
Each JSONL record represents either:
- one source-code function, for the original Devign dataset;
- one source-code file or Java class containing multiple functions.
For datasets organized by file or class, HAM-Net treats the file/class as a bag and its functions as instances, following the multiple-instance learning (MIL) setting. Each record includes a binary defect label, a project identifier, and the extracted function-level code and AST information.
Record format
A simplified MIL record looks like:
{
"id": "stable-sample-id",
"project": "pandas",
"file_path": "pandas/core/example.py",
"label": 1,
"functions": [
{
"name": "example_function",
"code": "def example_function(...): ...",
"func_label": 1,
"ast_nodes": ["DECLARATION", "PARAMETER", "CONTROL", "RETURN"],
"ast_edges": [[0, 1], [0, 2], [2, 3]]
}
]
}
func_label is present only when it can be derived from patch or line-level
annotations. It is not available for PROMISE.
Published versions
The repository keeps the original JSONL filenames in every version. Select a version through the Hugging Face revision or Git tag:
| Version | Revision | Description |
|---|---|---|
| v1 | v1.0.0 |
Original published datasets, including the original source text and AST graphs. |
| v2 | v2.0.0 |
Reconstructed PROMISE, Defactors, BugsInPy, and Big-Vul datasets. Source comments are removed; Python docstrings are also removed. Bag membership, function order, and labels are preserved. AST graphs are regenerated after comment and docstring removal. Devign is not included in this revision. |
For example:
hf download Scream9371/hamnet-datasets promise_java.jsonl --revision v1.0.0
hf download Scream9371/hamnet-datasets promise_java.jsonl --revision v2.0.0
Original data sources
The published JSONL files are derived from the following public datasets. Some original datasets provide labels for functions, classes, files, or code lines. During preprocessing, HAM-Net converts several of them into a common file/class-level MIL format. The table distinguishes the original annotation level from the released HAM-Net representation.
| Dataset | Original source | Original annotations / content | HAM-Net representation |
|---|---|---|---|
devign_c (v1 only) |
Devign repository | Function-level vulnerability annotations from FFmpeg and QEMU C/C++ projects | Each C/C++ function is released as an individual sample with an AST graph and a binary label. |
promise_java |
PROMISE repository | Classic Java class-level defect metric datasets with a bug count/label |
Each Java class forms one MIL bag. The bag is positive when bug > 0. |
bigvul_c |
MSR 2020 Big-Vul dataset | Large-scale C/C++ vulnerability records containing code changes and CVE-related metadata | Each C/C++ file forms one MIL bag. Functions overlapping buggy-side changed lines are marked as positive. |
defactors_python |
Defactors | Line-level defect annotations from multiple Python projects | Each Python file forms one MIL bag. Functions overlapping annotated defect lines receive func_label=1. |
bugsinpy_python |
BugsInPy | Reproducible defects, buggy/fixed commits, and patch information from Python projects | Each Python file forms one MIL bag. Bags are constructed from buggy files and same-project negative files. |
Devign remains in its original function-level format, whereas PROMISE, Big-Vul, Defactors, and BugsInPy are converted into class-level or file-level bags for multiple-instance learning. The dataset sources provide the original labels or patch/line annotations; the exact sampling, parsing, AST normalization, and bag construction rules are described below.
Dataset summary
Percentages are computed from the final JSONL files. P50/P90/P99 are the numbers of functions per bag. mixed positive bags means positive bags containing both at least one func_label=1 function and at least one func_label=0 function. positive functions is computed only for datasets that retain function-level labels.
| Dataset | Language / granularity | Bags or samples | Positive / negative | Functions per bag P50 / P90 / P99 | Mixed positive bags | Positive functions |
|---|---|---|---|---|---|---|
promise_java |
Java class-level MIL bag | 1,695 bags | 647 / 1,048 (38.17% / 61.83%) | 8 / 26 / 94.12 | N/A: no function-level labels | N/A |
defactors_python |
Python file-level MIL bag | 1,700 bags | 873 / 827 (51.35% / 48.65%) | 18 / 86 / 227.06 | 808 / 873 (92.55%) | 3,190 / 58,028 (5.50%) |
bugsinpy_python |
Python file-level MIL bag | 2,416 bags | 525 / 1,891 (21.73% / 78.27%) | 9 / 79 / 205 | 503 / 525 (95.81%) | 1,076 / 63,818 (1.69%) |
bigvul_c |
C/C++ file-level MIL bag | 1,700 bags | 733 / 967 (43.12% / 56.88%) | 16 / 64 / 279.01 | 733 / 733 (100.00%) | 1,270 / 51,668 (2.46%) |
devign_c (v1 only) |
C/C++ function-level sample | 27,318 samples | 12,460 / 14,858 (45.61% / 54.39%) | N/A: function-level schema | N/A | N/A |
promise_java uses bug > 0 as its class/bag label and therefore does not claim function-level defect localization ground truth. devign_c is retained in its original function-level schema and does not contain a functions bag list.
How the MIL bags are constructed
The following rules define the published MIL samples.
PROMISE
- Unit of sampling: one target Java class is one bag; methods and constructors in that class are the bag instances.
- Source candidates: scan the available project/version CSV records and resolve each class name to its corresponding Java source file. Records without a source file, unparsable source, or fewer than three parseable methods/constructors are removed.
- Projects:
ant,camel,ivy,jedit,log4j,lucene,poi,velocity, andxalan. - Label:
label=1when the sourcebugvalue is greater than zero; otherwiselabel=0. - Function sampling: retain all parseable methods and constructors in the selected class. No positive/negative function sampling is performed.
Defactors
- Unit of sampling: one Python source file is one bag and every parseable function in that file is an instance.
- Projects:
pandas,scikit-learn,localstack,django,poetry,core,airflow,lightning,spaCy,ansible,ray,celery,sentry,cpython, andtransformers. - Function and bag labels: a function is positive when its span overlaps an annotated defect line; a bag is positive when it contains at least one positive function.
- Negative bags: sample files from the same project whose functions do not overlap the annotated defect lines; prefer the same commit and same module when available, then use other commits from the same project, with duplicate project/commit/file records removed.
- Function sampling: discard bags with fewer than three parseable functions during the original candidate construction.
BugsInPy
- Unit of sampling: one Python file at a buggy commit is one bag; each parseable function in the file is an instance.
- Projects:
pandas,keras,youtube-dl,scrapy,luigi,thefuck,matplotlib,black,ansible,fastapi,tornado,tqdm,spacy,sanic,httpie,cookiecutter, andPySnooper. - Positive candidates: use the buggy-side files touched by each BugsInPy patch. A function is positive when its span overlaps a buggy-side patch line, and the bag is positive when at least one such function exists.
- Negative candidates: for each bug, sample one same-project Python file from the same buggy snapshot that is not among the patched files. Half of the negative sampling quota targets files in the same directory or top-level module when such candidates exist; remaining candidates are sampled from the other files.
- Function sampling: use seed 42, discard files with no parseable function, and retain the complete parseable function list in the published full-function version.
Big-Vul
- Unit of sampling: one C/C++ file at the buggy snapshot is one bag; each parseable function is an instance.
- Projects:
linux,ImageMagick,Android,tcpdump,FFmpeg,php-src, andradare2. - Positive candidates: use the buggy-side files associated with the vulnerability patch. A function is positive when it overlaps a removed/changed buggy-side patch line; the file is a positive bag when at least one function is positive.
- Negative candidates: for each positive file, sample two unmodified same-project files from the same snapshot. Half of the negative quota targets the same directory or top-level module when possible; the remainder is sampled from other files. Sampling uses seed 42, with project and global output caps applied before writing the final set.
- Function sampling: discard files with fewer than three parseable functions and retain all remaining functions in the full-function version.
Devign (v1 only)
- Unit of sampling: one function is one labeled sample rather than a MIL bag.
- Projects:
qemuandFFmpeg.
AST and version rules
- To make ASTs from Java, Python, C, and C++ comparable, language-specific node types are mapped to a shared set of structural roles, such as declarations, control-flow statements, calls, assignments, returns, and literals.
- This normalization preserves coarse syntactic structure while removing language-specific lexical details. Identifiers, punctuation, comments, and documentation text are not retained as structural AST nodes. The normalized graph contains parent-child structure, reverse edges, and self-loops.
Optional Training-time function caps
The published JSONL files contain the full function lists. HAM-Net training, however, uses an optional deterministic cap of at most 16 functions per bag to control GPU memory and runtime. The cap does not modify the released JSONL files. It is applied only by the training data loader.
For each bag, cap generation follows this procedure:
- Discard only candidate functions whose source is empty or whose AST has no nodes; the remaining functions keep their original order and indices.
- Score each valid function as
log(1 + node_count) + 0.3 * log(1 + edge_count). - Rank candidates by score, then by node count, source start line, and original index as deterministic tie-breakers. Select the top 12 candidates first.
- If more functions are available, select additional candidates by evenly covering the remaining ranked list until the bag contains at most 16 functions. Bags with 16 or fewer valid functions retain all valid functions.
- Write the selected zero-based function indices and the policy metadata to the cap file under the stable bag identifier. Cap files are generated separately for each dataset revision and must be used only with the matching JSONL files.
At training time, the data loader reads the cap entry for each bag and replaces the full function list with the recorded indices before constructing the model input. The same label-agnostic procedure is therefore shared across datasets and models.
Files
- Both versions:
promise_java.jsonl,defactors_python.jsonl,bugsinpy_python.jsonl, andbigvul_c.jsonl. - v1 only:
devign_c.jsonl. - Each revision contains a
caps/directory. Its cap files are generated from the JSONL files in that same revision using the deterministicast_topk_v1policy. v1 has caps for all five datasets; v2 has caps for its four MIL datasets only. caps/caps_summary.jsonrecords the input bag count, cap-entry count, selected function count, and any bags omitted because they contain no valid function with both non-empty code and a non-empty AST. A cap file must only be used with the JSONL files from the same revision.
- Downloads last month
- 38