SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2401.06712 · 2024

Few-Shot Detection of Machine-Generated Text using Style Representations

arXiv · PDF · Open in the Atlas

Code that ran

5 of 6 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; 1 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 3 failures of our instrument; 1 no recorded run), measured 2026-11-23; 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/2401.06712.json · badge: /api/ran/2401.06712.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
llnl/luar canonical (classifier label)
classifier basis: census
5 ran · 1 no recorded run
FunctionStatusWhere it lives
create_batches Ran
ran; our contract draft was wrong, not the code
llnl/luar/machine_detection/machine_utils.py
code served (permissive licence) · get_code("7811eb1fab7ee8c5")
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 defaultdict. 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 torch
from collections import defaultdict

torch.manual_seed(0)

# Create small tokenized data
# embedding_size = 512, so we need input_ids and attention_mask as lists of lists
# Let's create 2 documents with different token counts
tokenized_data = {
    'input_ids': [
        list(range(100)) + [0] * 50,  # 150 tokens for first document
        list(range(200))  # 200 tokens for second document
    ],
    'attention_mask': [
        [1] * 100 + [0] * 50,  # attention mask for first document
        [1] * 200  # attention mask for second document
    ]
}

max_n_episodes = 2
max_batch_size = 3
device = 'cpu'
embedding_size = 512

ARGS = {
    'tokenized_data': tokenized_data,
    'max_n_episodes': max_n_episodes,
    'max_batch_size': max_batch_size,
    'device': device,
    'embedding_size': embedding_size
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
termcolor, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type defaultdict — a defaultdict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a defaultdict 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
extract_luar_embeddings Ran
ran, honoured the contract we drafted
llnl/luar/machine_detection/machine_utils.py
code served (permissive licence) · get_code("c330cda867fef7af")
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 2, 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 torch.nn as nn
import numpy as np

torch.manual_seed(0)

class MockLUARModel(nn.Module):
    """Minimal LUAR model that accepts batch kwargs and returns embeddings."""
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(8, 4)
    
    def forward(self, input_ids=None, attention_mask=None, **kwargs):
        # Accept arbitrary batch kwargs but use input_ids for processing
        if input_ids is None:
            input_ids = torch.zeros(2, 8)
        output = self.linear(input_ids.float())
        return output

# Create mock batches structure
batch_1 = [
    {
        'input_ids': torch.randn(2, 8),
        'attention_mask': torch.ones(2, 8)
    },
    {
        'input_ids': torch.randn(2, 8),
        'attention_mask': torch.ones(2, 8)
    }
]

batch_2 = [
    {
        'input_ids': torch.randn(2, 8),
        'attention_mask': torch.ones(2, 8)
    }
]

batches = {
    'train': batch_1,
    'test': batch_2
}

luar_model = MockLUARModel()

ARGS = {
    'batches': batches,
    'luar_model': luar_model
}
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 2, 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
get_data Ran
ran; our contract draft was wrong, not the code
llnl/luar/machine_detection/machine_utils.py
code served (permissive licence) · get_code("38a42652b6f8061b")
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 DataFrame. 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 os
import pandas as pd
import tempfile
import json

# Create a temporary directory and a test JSONL file
temp_dir = tempfile.mkdtemp()
file_name = "test_data.jsonl"
file_path = os.path.join(temp_dir, file_name)

# Write a small JSONL file with text key
test_data = [
    {"text": "Hello world", "label": 1},
    {"text": "This is a test", "label": 0},
    {"text": "Sample data", "label": 1},
]

with open(file_path, 'w') as f:
    for record in test_data:
        f.write(json.dumps(record) + '\n')

# Define ARGS
ARGS = {
    "data_path": temp_dir,
    "file_name": file_name,
    "nrows": 2
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 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
singleton Ran
ran on a synthesized input
llnl/luar/fewshot_iclr2024/file_utils.py
code served (permissive licence) · get_code("a65281ae25eff699")
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 SimpleService. 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 torch
import torch.nn as nn

# Define a simple class to be decorated as a singleton
class SimpleService:
    def __init__(self, value=42):
        self.value = value
    
    def get_value(self):
        return self.value

# The singleton decorator takes a class as its parameter
ARGS = {
    'cls': SimpleService
}
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 SimpleService — a SimpleService output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a SimpleService 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
tokenize_function Ran
ran; our contract draft was wrong, not the code
llnl/luar/fewshot_iclr2024/baseline_training/finetune_roberta.py
code served (permissive licence) · get_code("a3e19197e69c1a89")
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 torch
import numpy as np

class MockTokenizer:
    def __call__(self, text, padding=None, truncation=None):
        # Return a dict with 'input_ids' and 'attention_mask' as expected from tokenizers
        if isinstance(text, list):
            batch_size = len(text)
        else:
            batch_size = 1
        
        return {
            'input_ids': torch.tensor([[101, 2054, 2003, 102] for _ in range(batch_size)]),
            'attention_mask': torch.tensor([[1, 1, 1, 1] for _ in range(batch_size)])
        }

examples = {
    'text': ['Hello world', 'How are you']
}

tokenizer = MockTokenizer()

ARGS = {
    'examples': examples,
    'tokenizer': tokenizer
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — 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
optuna_hp_space Not yet run
unverified (harvested, no recorded run)
llnl/luar/fewshot_iclr2024/baseline_training/finetune_roberta.py
code served (permissive licence) · get_code("61923b3971011953")
How it ran

no invocation recorded.

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 0 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 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.

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

Repositories linked to this paper

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

Abstract

The advent of instruction-tuned language models that convincingly mimic human writing poses a significant risk of abuse. However, such abuse may be counteracted with the ability to detect whether a piece of text was composed by a language model rather than a human author. Some previous approaches to this problem have relied on supervised methods by training on corpora of confirmed human- and machine- written documents. Unfortunately, model under-specification poses an unavoidable challenge for neural network-based detectors, making them brittle in the face of data shifts, such as the release of newer language models producing still more fluent text than the models used to train the detectors. Other approaches require access to the models that may have generated a document in question, which is often impractical. In light of these challenges, we pursue a fundamentally different approach not relying on samples from language models of concern at training time. Instead, we propose to leverage representations of writing style estimated from human-authored text. Indeed, we find that features effective at distinguishing among human authors are also effective at distinguishing human from machine authors, including state-of-the-art large language models like Llama-2, ChatGPT, and GPT-4. Furthermore, given a handful of examples composed by each of several specific language models of interest, our approach affords the ability to predict which model generated a given document. The code and data to reproduce our experiments are available at https://github.com/LLNL/LUAR/tree/main/fewshot_iclr2024.

For agents

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

get_harvested_code_for_paper("2401.06712")
get_code_for_paper("2401.06712")
have("2401.06712")

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

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

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

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

Connect an agent — have() is free.