SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2402.16041 · ICLR · 2024

Detecting Machine-Generated Texts by Multi-Population Aware Optimization for Maximum Mean Discrepancy

Mingkui Tan, Bo Han, Shuhai Zhang, Jiahao Yang, Yiliao Song, Yuanqing Li, Mp_Kxy Mmd-Mp_Kyy

arXiv · PDF · Open in the Atlas

Code that ran

5 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 5 failures of our instrument; 3 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2402.16041.json · badge: /api/ran/2402.16041.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
ZSHsh98/MMD-MP canonical (classifier label)
classifier basis: classifier_2025
4 ran · 2 no recorded run
zshsh98/mmd-mp community
Papers with Code archive
1 ran · 1 no recorded run
FunctionStatusWhere it lives
L2_distance_get Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
ZSHsh98/MMD-MP/MMD_calculate.py
code served (permissive licence) · get_code("e551e996caa9f1c6")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 2, dtype family float, shape (2, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Create small tensors for x and y
# x: shape (2, 4) - 2 samples, 4 dimensions
# y: shape (3, 4) - 3 samples, 4 dimensions (different first dim for clarity)
x = torch.randn(2, 4, dtype=torch.float32)
y = torch.randn(3, 4, dtype=torch.float32)

# value_factor is a scalar
value_factor = 1

ARGS = {
    "x": x,
    "y": y,
    "value_factor": value_factor,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 3) — shape (2, 3) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
MMDu Ran
ran; our contract draft was wrong, not the code
zshsh98/mmd-mp/utils_MMD.py
code served (permissive licence) · get_code("d65d3167162aac86")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned tuple. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create small tensors for testing
# Fea: combined feature matrix (X and Y stacked), shape (n_total, feature_dim)
# len_s: number of samples in X (first len_s rows are X, rest are Y)
n_x = 2
n_y = 2
feature_dim = 4

Fea = torch.randn(n_x + n_y, feature_dim)
Fea_org = torch.randn(n_x + n_y, feature_dim)

ARGS = {
    'Fea': Fea,
    'len_s': n_x,
    'Fea_org': Fea_org,
    'sigma': 1.0,
    'sigma0': 0.1,
    'epsilon': 1e-10,
    'is_smooth': True,
    'is_var_computed': True,
    'use_1sample_U': True,
    'is_unbiased': True,
    'coeff_xy': 2,
    'is_yy_zero': False,
    'is_xx_zero': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
guassian_kernel Ran
ran; our contract draft was wrong, not the code
ZSHsh98/MMD-MP/MMD_calculate.py
code served (permissive licence) · get_code("ab7fc708c9f89c7b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 2, dtype family float, shape (2, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Create small sample tensors
# source: sample_size_1 * feature_size
source = torch.randn(2, 4)

# target: sample_size_2 * feature_size
target = torch.randn(3, 4)

# kernel_mul: bandwidth multiplier
kernel_mul = 2.0

# kernel_num: number of kernels
kernel_num = 10

# fix_sigma: fixed bandwidth (None means compute from data)
fix_sigma = None

ARGS = {
    "source": source,
    "target": target,
    "kernel_mul": kernel_mul,
    "kernel_num": kernel_num,
    "fix_sigma": fix_sigma,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 3) — shape (2, 3) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
mmd Ran
ran; our contract draft was wrong, not the code
ZSHsh98/MMD-MP/MMD_calculate.py
code served (permissive licence) · get_code("93ebe405ab37744d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Create small tensors for source and target
# source: sample_size_1 x feature_size
source = torch.randn(2, 4)

# target: sample_size_2 x feature_size
target = torch.randn(3, 4)

ARGS = {
    "source": source,
    "target": target,
    "kernel_mul": 2.0,
    "kernel_num": 10,
    "fix_sigma": None,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
plot_mi Ran
ran; our contract draft was wrong, not the code
ZSHsh98/MMD-MP/run_meta_mmd_trans.py
code served (permissive licence) · get_code("86fe7cc4da80a8e3")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Create small tensors with some NaN values to test the filtering logic
clean = torch.tensor([0.5, 0.6, float('nan'), 0.7], dtype=torch.float32)
adv = torch.tensor([0.2, float('nan'), 0.3, 0.1], dtype=torch.float32)

ARGS = {
    'clean': clean,
    'adv': adv,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, sklearn, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
count_masks Not yet run
unverified (harvested, no recorded run)
ZSHsh98/MMD-MP/run_meta_mmd_trans.py
code served (permissive licence) · get_code("23c3416429f69fee")
How it ran

no invocation recorded. this sample carries JSON test cases instead of a setup block; get_reference_implementation serves them with the level they back.

h1_mean_var_gram Not yet run
unverified (harvested, no recorded run)
zshsh98/mmd-mp/utils_MMD.py
code served (permissive licence) · get_code("a33795f74c93c01f")
How it ran

no invocation recorded.

tokenize_and_mask Not yet run
unverified (harvested, no recorded run)
ZSHsh98/MMD-MP/run_meta_mmd_trans.py
code served (permissive licence) · get_code("374e995ebc355414")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 1 the same month, 1 later) and 6 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
count_masks 11 other papers
5 dated earlier, 1 the same month, 5 later
2023.emnlp-main.616 (2023 (year only))
MULTITuDE: Large-Scale Multilingual Machine-Generated Text Detection Benchmark
2303.14822 (2023-03)
MGTBench: Benchmarking Machine-Generated Text Detection
2305.18462 (2023-05)
Membership Inference Attacks against Language Models via Neighbourhood Comparison
and 8 more not named here
tokenize_and_mask 2 other papers
2 dated earlier
2305.19713 (2023-05)
Red Teaming Language Model Detectors with Language Models
2307.11729 (2023-07)
OUTFOX: LLM-Generated Essay Detection Through In-Context Learning with Adversarially Generated Examples

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Large language models (LLMs) such as ChatGPT have exhibited remarkable performance in generating human-like texts. However, machine-generated texts (MGTs) may carry critical risks, such as plagiarism issues, misleading information, or hallucination issues. Therefore, it is very urgent and important to detect MGTs in many situations. Unfortunately, it is challenging to distinguish MGTs and human-written texts because the distributional discrepancy between them is often very subtle due to the remarkable performance of LLMs. In this paper, we seek to exploit maximum mean discrepancy (MMD) to address this issue in the sense that MMD can well identify distributional discrepancies. However, directly training a detector with MMD using diverse MGTs will incur a significantly increased variance of MMD since MGTs may contain multiple text populations due to various LLMs. This will severely impair MMD's ability to measure the difference between two samples. To tackle this, we propose a novel multi-population aware optimization method for MMD called MMD-MP, which can avoid variance increases and thus improve the stability to measure the distributional discrepancy. Relying on MMD-MP, we develop two methods for paragraph-based and sentence-based detection, respectively. Extensive experiments on various LLMs, e.g., GPT2 and ChatGPT, show superior detection performance of our MMD-MP. The source code is available at https://github.com/ZSHsh98/MMD-MP.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2402.16041")
get_code_for_paper("2402.16041")
have("2402.16041")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2402.16041.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2402.16041.svg)](https://syntology.ai/paper/2402.16041)

Connect an agent — have() is free.