SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.03010 · 2023

Sentence Embedding Leaks More Information than You Expect: Generative Embedding Inversion Attack to Recover the Whole Sentence

arXiv · PDF · Open in the Atlas

Code that ran

6 of 13 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 6 have no contract verdict; 0 failures of our instrument; 7 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/2305.03010.json · badge: /api/ran/2305.03010.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
hkust-knowcomp/geia canonical (classifier label)
classifier basis: census
6 ran · 7 no recorded run
FunctionStatusWhere it lives
punctuation_remove Ran
ran on a synthesized input
hkust-knowcomp/geia/eval_classification.py
code served (permissive licence) · get_code("c70730d40d77dd50")
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 string

def punctuation_remove(sent_list):
    removed_list = []
    for sent in sent_list:
        word_list = []
        for word in sent.split():
            word_strip = word.strip(string.punctuation)
            if word_strip:
                word_list.append(word_strip)
        removed_sent = ' '.join(word_list)
        removed_list.append(removed_sent)
    return removed_list


ARGS = {
    "sent_list": [
        "Hello, world! How are you?",
        "Python is great... isn't it?",
    ]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — 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
read_gpt Ran
ran on a synthesized input
hkust-knowcomp/geia/eval_generation.py
code served (permissive licence) · get_code("44a7a4939b82527f")
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 json
import tempfile
import os

# Create a temporary JSON file with test data
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "test.json")

test_data = {
    "model": "gpt-2",
    "layers": 12,
    "hidden_size": 768,
    "config": {"attention_heads": 12, "dropout": 0.1}
}

with open(temp_file, 'w') as f:
    json.dump(test_data, f)

ARGS = {
    "path": temp_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — 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
sequence_cross_entropy_with_logits Ran
ran on a synthesized input
hkust-knowcomp/geia/attacker_models.py
code served (permissive licence) · get_code("6d2a894bf002fffc")
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 Tensor, ndim 1, dtype family float, shape (2,) 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.functional as F

torch.manual_seed(0)

# Create small tensors for the function
batch_size = 2
sequence_length = 3
num_classes = 4

# logits: shape (batch_size, sequence_length, num_classes)
logits = torch.randn(batch_size, sequence_length, num_classes)

# targets: shape (batch_size, sequence_length) with class indices
targets = torch.randint(0, num_classes, (batch_size, sequence_length))

# mask: shape (batch_size, sequence_length) with binary values
mask = torch.ones(batch_size, sequence_length)

# label_smoothing: float value between 0 and 1
label_smoothing = 0.1

# reduce: boolean or string to control reduction
reduce = True

ARGS = {
    "logits": logits,
    "targets": targets,
    "mask": mask,
    "label_smoothing": label_smoothing,
    "reduce": reduce,
}
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 Tensor, ndim 1, dtype family float, shape (2,) — shape (2,) 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
top_filtering Ran
ran on a synthesized input
hkust-knowcomp/geia/attacker_evaluation_gpt.py
code served (permissive licence) · get_code("980364a3d8631cf0")
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 Tensor, ndim 2, dtype family float, shape (2, 4) 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.functional as F

torch.manual_seed(0)

# Create a small batch of logits
# Shape: (batch_size=2, vocab_size=4)
logits = torch.randn(2, 4)

ARGS = {
    "logits": logits,
    "top_k": 2,
    "top_p": 0.9,
    "filter_value": -float('Inf')
}
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 Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) 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
train_on_batch Ran
ran on a synthesized input
hkust-knowcomp/geia/attacker.py
code served (permissive licence) · get_code("bbd4bd47170f5a88")
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 tuple, 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 torch.nn as nn
import numpy as np

torch.manual_seed(0)

# Create a minimal tokenizer stand-in
class MinimalTokenizer:
    def __init__(self):
        self.eos_token = "</s>"
        self.pad_token = "</s>"
    
    def encode(self, token):
        return [50256]  # arbitrary token id
    
    def __call__(self, texts, return_tensors=None, padding=None, truncation=None, max_length=None):
        batch_size = len(texts) if isinstance(texts, list) else 1
        input_ids = torch.randint(0, 1000, (batch_size, max_length or 40), dtype=torch.long)
        return {
            'input_ids': input_ids,
            'attention_mask': torch.ones((batch_size, max_length or 40), dtype=torch.long)
        }

# Create a minimal GPT2-like model
class MinimalGPT2Model(nn.Module):
    def __init__(self, vocab_size=1000, hidden_size=4, num_layers=1):
        super().__init__()
        self.transformer = nn.ModuleDict({
            'wte': nn.Embedding(vocab_size, hidden_size)
        })
        self.lm_head = nn.Linear(hidden_size, vocab_size)
    
    def forward(self, inputs_embeds, past_key_values=None, return_dict=False):
        # inputs_embeds shape: (batch_size, seq_len, hidden_size)
        batch_size, seq_len, hidden_size = inputs_embeds.shape
        logits = self.lm_head(inputs_embeds)  # (batch_size, seq_len, vocab_size)
        past = None
        if return_dict:
            return {'logits': logits, 'past_key_values': past}
        return (logits, past)

# Create a minimal loss function that matches the signature used
class MinimalCriterion(nn.Module):
    def forward(self, logits, target, target_mask, label_smoothing=0.0, reduce='batch'):
        # logits: (batch_size, seq_len, vocab_size)
        # target: (batch_size, seq_len)
        # target_mask: (batch_size, seq_len)
        batch_size, seq_len, vocab_size = logits.shape
        loss = torch.tensor(0.5, requires_grad=True)
        return loss

# Construct arguments
batch_size = 2
seq_len = 40
hidden_size = 4
vocab_size = 1000

batch_X = torch.randn(batch_size, hidden_size)
batch_D = ["hello world", "test sentence"]
model = MinimalGPT2Model(vocab_size=vocab_size, hidden_size=hidden_size)
tokenizer = MinimalTokenizer()
criterion = MinimalCriterion()
device = torch.device('cpu')
train = True

ARGS = {
    'batch_X': batch_X,
    'batch_D': batch_D,
    'model': model,
    'tokenizer': tokenizer,
    'criterion': criterion,
    'device': device,
    'train': train
}
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 tuple, ndim 1, dtype family float — a tuple 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
train_on_batch Ran
ran on a synthesized input
hkust-knowcomp/geia/attacker_opt.py
code served (permissive licence) · get_code("1da8afc0c30785e8")
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 tuple, 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 torch.nn as nn
import numpy as np

torch.manual_seed(0)

class MockTokenizer:
    def __init__(self):
        self.eos_token = "</s>"
        self.pad_token = "</s>"
    
    def encode(self, token):
        return [0]
    
    def __call__(self, texts, return_tensors=None, padding=None, truncation=None, max_length=None):
        batch_size = len(texts) if isinstance(texts, list) else 1
        input_ids = torch.randint(1, 100, (batch_size, max_length))
        return {
            'input_ids': input_ids,
            'attention_mask': torch.ones((batch_size, max_length))
        }

class MockDecoder(nn.Module):
    def __init__(self):
        super().__init__()
        self.embed_tokens = nn.Embedding(100, 4)
    
    def forward(self, input_ids):
        return self.embed_tokens(input_ids)

class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.model = nn.Module()
        self.model.decoder = MockDecoder()
    
    def forward(self, inputs_embeds=None, past_key_values=None, return_dict=False):
        batch_size = inputs_embeds.shape[0]
        seq_len = inputs_embeds.shape[1]
        logits = torch.randn(batch_size, seq_len, 100)
        
        class Output:
            pass
        
        output = Output()
        output.logits = logits
        return output

class MockCriterion(nn.Module):
    def __init__(self):
        super().__init__()
    
    def forward(self, logits, target, target_mask, label_smoothing=0.0, reduce='batch'):
        loss = torch.tensor(0.5, requires_grad=True)
        return loss

batch_X = torch.randn(2, 4)
batch_D = ["hello world", "test batch"]
model = MockModel()
tokenizer = MockTokenizer()
criterion = MockCriterion()
device = 'cpu'

ARGS = {
    'batch_X': batch_X,
    'batch_D': batch_D,
    'model': model,
    'tokenizer': tokenizer,
    'criterion': criterion,
    'device': device,
    'train': True
}
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 tuple, ndim 1, dtype family float — a tuple 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
beam_decode_sentence Not yet run
unverified (harvested, no recorded run)
hkust-knowcomp/geia/decode_beam_search.py
code served (permissive licence) · get_code("5f5f9fad1871e072")
How it ran

no invocation recorded.

beam_decode_sentence Not yet run
unverified (harvested, no recorded run)
hkust-knowcomp/geia/decode_beam_search_opt.py
code served (permissive licence) · get_code("2e10d39d2c034f27")
How it ran

no invocation recorded.

eval_on_batch_t5 Not yet run
unverified (harvested, no recorded run)
hkust-knowcomp/geia/attacker_t5.py
code served (permissive licence) · get_code("a797af62019f8fa4")
How it ran

no invocation recorded.

get_qnli_data Not yet run
unverified (harvested, no recorded run)
hkust-knowcomp/geia/data_process.py
code served (permissive licence) · get_code("86a19927df85ca2c")
How it ran

no invocation recorded.

greedy_decode Not yet run
unverified (harvested, no recorded run)
hkust-knowcomp/geia/decode_beam_search.py
code served (permissive licence) · get_code("352397365a26270f")
How it ran

no invocation recorded.

read_pt Not yet run
unverified (harvested, no recorded run)
hkust-knowcomp/geia/attacker_models.py
code served (permissive licence) · get_code("c318208d02661269")
How it ran

no invocation recorded.

vectorize Not yet run
unverified (harvested, no recorded run)
hkust-knowcomp/geia/eval_classification.py
code served (permissive licence) · get_code("2a52efec5d900b19")
How it ran

no invocation recorded.

Also present in other papers' code

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

Sentence-level representations are beneficial for various natural language processing tasks. It is commonly believed that vector representations can capture rich linguistic properties. Currently, large language models (LMs) achieve state-of-the-art performance on sentence embedding. However, some recent works suggest that vector representations from LMs can cause information leakage. In this work, we further investigate the information leakage issue and propose a generative embedding inversion attack (GEIA) that aims to reconstruct input sequences based only on their sentence embeddings. Given the black-box access to a language model, we treat sentence embeddings as initial tokens' representations and train or fine-tune a powerful decoder model to decode the whole sequences directly. We conduct extensive experiments to demonstrate that our generative inversion attack outperforms previous embedding inversion attacks in classification metrics and generates coherent and contextually similar sentences as the original inputs.

For agents

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

get_harvested_code_for_paper("2305.03010")
get_code_for_paper("2305.03010")
have("2305.03010")

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

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

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

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

Connect an agent — have() is free.