SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2023.findings-emnlp.139 · EMNLP Findings · 2023

LLMDet: A Third Party Large Language Models Generated Text Detection Tool

Huawei Shen, Xueqi Cheng, Tat-Seng Chua, Liang Pang, Kangxi Wu

Open in the Atlas

Code that ran

5 of 7 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 4 have no contract verdict; 1 failure of our instrument; 2 no recorded run), measured 2026-11-24; 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/2023.findings-emnlp.139.json · badge: /api/ran/2023.findings-emnlp.139.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
TrustedLLM/LLMDet canonical (classifier label)
classifier basis: census
5 ran · 2 no recorded run
FunctionStatusWhere it lives
calculate_perplexity Ran
ran on a synthesized input
TrustedLLM/LLMDet/llmdet/truth_perplexity.py
code served (permissive licence) · get_code("23f93efbe9cb73dd")
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, through the batch API) 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 torch.nn as nn

torch.manual_seed(0)

# Create a minimal tokenizer stand-in
class MinimalTokenizer:
    def encode(self, text, return_tensors=None):
        # Return a tensor of token ids
        # Create a long enough sequence to test the stride logic
        token_ids = torch.tensor([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]])
        if return_tensors == 'pt':
            return token_ids
        return token_ids

# Create a minimal language model
class MinimalLM(nn.Module):
    def __init__(self):
        super().__init__()
        self.embedding = nn.Embedding(100, 4)
        self.linear = nn.Linear(4, 100)
    
    def forward(self, input_ids, labels=None):
        x = self.embedding(input_ids)
        logits = self.linear(x)
        
        # Compute loss if labels provided
        if labels is not None:
            loss_fn = nn.CrossEntropyLoss()
            loss = loss_fn(logits.view(-1, 100), labels.view(-1))
        else:
            loss = None
        
        # Return object with loss attribute
        class Output:
            def __init__(self, loss_val):
                self.loss = loss_val
        
        return Output(loss)

# Instantiate components
text = "This is a sample text for perplexity calculation."
model = MinimalLM()
tokenizer = MinimalTokenizer()
device = 'cpu'

ARGS = {
    'text': text,
    'model': model,
    'tokenizer': tokenizer,
    'device': device
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
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
compress_data Ran
ran on a synthesized input
TrustedLLM/LLMDet/llmdet/new_proxy_perplexity.py
code served (permissive licence) · get_code("1e61883a1ec4c164")
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, through the batch API) and returned dict. The image it ran in was 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 tempfile
import json
import os

# Create a temporary JSON file with n-gram probability data
temp_file = tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False, encoding='utf-8')

# Create sample n-gram probability data
sample_data = {
    "(1, 2)": {"10": 0.5, "20": 0.3, "30": 0.2},
    "(3, 4)": {"15": 0.6, "25": 0.4},
    "(5, 6)": {"100": 0.7, "200": 0.2, "300": 0.1}
}

json.dump(sample_data, temp_file)
temp_file.close()

ARGS = {
    'n_grams_probability_file': temp_file.name
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not 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
new_proxy_perplexity Ran
ran on a synthesized input
TrustedLLM/LLMDet/llmdet/new_proxy_perplexity.py
code served (permissive licence) · get_code("42231f9451d09f9f")
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, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 numpy as np
import tempfile
import os

# Create a temporary numpy file with the required n-gram data
temp_dir = tempfile.mkdtemp()
sample_probability_file = os.path.join(temp_dir, "sample_probs.npz")

# Create mock n-gram data
two_grams_prefix = np.array([1, 2, 3])
two_grams_keys = [np.array([10, 11]), np.array([12, 13]), np.array([14, 15])]
two_grams_probs_value = [np.array([0.5, 0.3]), np.array([0.4, 0.2]), np.array([0.6, 0.1])]

three_grams_prefix = np.array([[1, 2], [2, 3], [3, 4]])
three_grams_keys = [np.array([20, 21]), np.array([22, 23]), np.array([24, 25])]
three_grams_probs_value = [np.array([0.45, 0.35]), np.array([0.55, 0.25]), np.array([0.35, 0.4])]

four_grams_prefix = np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5]])
four_grams_keys = [np.array([30, 31]), np.array([32, 33]), np.array([34, 35])]
four_grams_probs_value = [np.array([0.7, 0.2]), np.array([0.3, 0.5]), np.array([0.6, 0.15])]

np.savez(
    sample_probability_file,
    two_grams_prefix=two_grams_prefix,
    two_grams_keys=two_grams_keys,
    two_grams_probs_value=two_grams_probs_value,
    three_grams_prefix=three_grams_prefix,
    three_grams_keys=three_grams_keys,
    three_grams_probs_value=three_grams_probs_value,
    four_grams_prefix=four_grams_prefix,
    four_grams_keys=four_grams_keys,
    four_grams_probs_value=four_grams_probs_value,
)

# Create args object
class Args:
    def __init__(self):
        self.sample_probability_file = sample_probability_file
        self.vocab_length = 1000

args = Args()

# Create text_tokenize_ids: list of dicts where each dict maps labels to token id sequences
text_tokenize_ids = [
    {
        "label1": np.array([1, 2, 3, 4, 5, 6, 7]),
        "label2": np.array([2, 3, 4, 5, 6, 7, 8])
    },
    {
        "label3": np.array([1, 2, 20, 21, 30, 31, 32]),
        "label4": np.array([3, 4, 22, 23, 34, 35, 36])
    }
]

ARGS = {
    "text_tokenize_ids": text_tokenize_ids,
    "args": args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
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
perplexity Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
TrustedLLM/LLMDet/llmdet/detector.py
code served (permissive licence) · get_code("77f51d6b5b8208af")
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 list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 numpy as np
import math

# Build n_grams_probability structure
# The function expects a dict with keys 0-5 containing n-gram data
# Keys 0, 2, 4 map n-gram tuples to numpy arrays of next token IDs
# Keys 1, 3, 5 map n-gram tuples to numpy arrays of probabilities

n_grams_probability = {}

# 1-gram (unigram): key 0 -> next tokens, key 1 -> probabilities
n_grams_probability[0] = {
    (5,): np.array([10, 11, 12]),
    (6,): np.array([13, 14]),
}
n_grams_probability[1] = {
    (5,): np.array([0.3, 0.4, 0.2]),
    (6,): np.array([0.5, 0.3]),
}

# 2-gram (bigram): key 2 -> next tokens, key 3 -> probabilities
n_grams_probability[2] = {
    (5, 10): np.array([11, 12, 13]),
    (6, 14): np.array([15, 16]),
}
n_grams_probability[3] = {
    (5, 10): np.array([0.25, 0.35, 0.3]),
    (6, 14): np.array([0.4, 0.4]),
}

# 3-gram (trigram): key 4 -> next tokens, key 5 -> probabilities
n_grams_probability[4] = {
    (5, 10, 11): np.array([12, 13, 14]),
    (6, 14, 15): np.array([16, 17]),
}
n_grams_probability[5] = {
    (5, 10, 11): np.array([0.2, 0.3, 0.4]),
    (6, 14, 15): np.array([0.5, 0.3]),
}

# Build text_set_token_ids - list of token ID sequences
text_set_token_ids = [
    [5, 10, 11, 12, 13, 14, 15],
    [6, 14, 15, 16, 17, 18, 19],
]

# Vocabulary size
vocab_size = 100

ARGS = {
    "text_set_token_ids": text_set_token_ids,
    "n_grams_probability": n_grams_probability,
    "vocab_size": vocab_size,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
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
proxy_perplexity Ran
ran on a synthesized input
TrustedLLM/LLMDet/llmdet/new_proxy_perplexity.py
code served (permissive licence) · get_code("5d73afafeb6311f8")
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, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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
from collections import defaultdict

class Args:
    def __init__(self):
        self.vocab_length = 100

# Create text_tokenize_ids: list of dicts, each dict maps label to token id sequences
text_tokenize_ids = [
    {
        "label_1": [5, 10, 15, 20, 25, 30, 35, 40],
        "label_2": [3, 8, 12, 18, 22, 28, 33, 38]
    },
    {
        "label_3": [7, 11, 16, 21, 26, 31, 36, 41],
        "label_4": [4, 9, 14, 19, 24, 29, 34, 39]
    }
]

# Create n_grams_probability structure
# For 2-grams: keys are single-token tuples, values map to next tokens and their probabilities
# For 3-grams: keys are 2-token tuples
# For 4-grams: keys are 3-token tuples

n_grams_probability = {
    'sample_probs': [
        # 2-grams
        {
            'keys': {
                (5,): torch.tensor([10, 15]),
                (10,): torch.tensor([15, 20]),
                (15,): torch.tensor([20, 25]),
                (20,): torch.tensor([25, 30]),
            },
            'values': {
                (5,): torch.tensor([0.4, 0.3]),
                (10,): torch.tensor([0.35, 0.4]),
                (15,): torch.tensor([0.45, 0.3]),
                (20,): torch.tensor([0.5, 0.2]),
            }
        },
        # 3-grams
        {
            'keys': {
                (5, 10): torch.tensor([15, 20]),
                (10, 15): torch.tensor([20, 25]),
                (15, 20): torch.tensor([25, 30]),
            },
            'values': {
                (5, 10): torch.tensor([0.5, 0.25]),
                (10, 15): torch.tensor([0.45, 0.35]),
                (15, 20): torch.tensor([0.6, 0.15]),
            }
        },
        # 4-grams
        {
            'keys': {
                (5, 10, 15): torch.tensor([20, 25]),
                (10, 15, 20): torch.tensor([25, 30]),
            },
            'values': {
                (5, 10, 15): torch.tensor([0.6, 0.2]),
                (10, 15, 20): torch.tensor([0.55, 0.25]),
            }
        }
    ]
}

args = Args()

ARGS = {
    'text_tokenize_ids': text_tokenize_ids,
    'n_grams_probability': n_grams_probability,
    'args': args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
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
generate Not yet run
unverified (harvested, no recorded run)
TrustedLLM/LLMDet/main-experiment/run_main.py
code served (permissive licence) · get_code("0985978d9c86c7ad")
How it ran

no invocation recorded.

generate_seq2seq Not yet run
unverified (harvested, no recorded run)
TrustedLLM/LLMDet/main-experiment/run_main.py
code served (permissive licence) · get_code("013b74b1329e7d23")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 3 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 4 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
generate 1 other paper
1 same year, order not determinable
2305.15004 (2023-05)
LLMDet: A Third Party Large Language Models Generated Text Detection Tool
generate_seq2seq 1 other paper
1 same year, order not determinable
2305.15004 (2023-05)
LLMDet: A Third Party Large Language Models Generated Text Detection Tool
perplexity 1 other paper
1 same year, order not determinable
2305.15004 (2023-05)
LLMDet: A Third Party Large Language Models Generated Text Detection Tool

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-24.

Repositories linked to this paper

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

Abstract

Generated texts from large language models (LLMs) are remarkably close to high-quality human-authored text, raising concerns about their potential misuse in spreading false information and academic misconduct. Consequently, there is an urgent need for a highly practical detection tool capable of accurately identifying the source of a given text. However, existing detection tools typically rely on access to LLMs and can only differentiate between machine-generated and human-authored text, failing to meet the requirements of fine-grained tracing, intermediary judgment, and rapid detection. Therefore, we propose LLMDet, a model-specific, secure, efficient, and extendable detection tool, that can source text from specific LLMs, such as GPT-2, OPT, LLaMA, and others. In LLMDet, we record the nexttoken probabilities of salient n-gram as features to calculate proxy perplexity for each LLM. By jointly analyzing the proxy perplexities of LLMs, we can determine the source of the generated text. Experimental results show that LLMDet yields impressive detection performance while ensuring speed and security, achieving 98.54% precision and about ×5.0 faster for recognizing human-authored text. Additionally, LLMDet can effortlessly extend its detection capabilities to a new open-source model. We will provide an open-source tool at https://github.com/TrustedLLM/LLMDet.

For agents

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

get_harvested_code_for_paper("2023.findings-emnlp.139")
get_code_for_paper("2023.findings-emnlp.139")
have("2023.findings-emnlp.139")

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

curl https://syntology.ai/api/ran/2023.findings-emnlp.139.json

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

[![Syntology run record](https://syntology.ai/api/ran/2023.findings-emnlp.139.svg)](https://syntology.ai/paper/2023.findings-emnlp.139)

Connect an agent — have() is free.