SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2021.findings-emnlp.138 · EMNLP Findings · 2021

ProtoInfoMax: Prototypical Networks with Mutual Information Maximization for Out-of-Domain Detection

Vlado Menkovski, Mykola Pechenizkiy, Meng Fang, Iftitahu Ni'mah

Code that ran

7 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 7 have no contract verdict; 0 failures of our instrument; 0 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/2021.findings-emnlp.138.json · badge: /api/ran/2021.findings-emnlp.138.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
inimah/protoinfomax canonical (classifier label)
classifier basis: census
7 ran · 0 no recorded run
FunctionStatusWhere it lives
cleaning_text Ran
ran on a synthesized input
inimah/protoinfomax/src/eval_imax.py
code served (permissive licence) · get_code("8e446cd980186cd6")
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 str. 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 re
import string

def cleaning_text(txt):
    punct = ''.join([p for p in string.punctuation])
    txt = txt.replace('i.e.', 'id est')
    txt = txt.replace('e.g.', 'exempli gratia')
    txt = txt.lower().replace('q&a', 'question and answer')
    txt = txt.replace('&', 'and')
    txt = re.sub('@\\w+', '', txt)
    txt = re.sub('[-+]?[.\\d]*[\\d]+[:,.\\d]*', '', txt)
    txt = re.sub('[^\\x00-\\x7f]', '', txt)
    txt = re.sub('\\b\\w{1}\\b', '', txt)
    txt = re.sub('\\b\\w{20,1000}\\b', '', txt)
    regex = re.compile('[%s]' % re.escape(punct))
    txt = regex.sub(' ', txt)
    txt = ' '.join(txt.split())
    return txt

ARGS = {
    'txt': 'Hello world! This is a test i.e. example with e.g. Q&A @user123 and numbers 42 like this: 3.14, plus some punctuation.'
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
get_all_parameters Ran
ran on a synthesized input
inimah/protoinfomax/src/all_parameters_intent.py
code served (permissive licence) · get_code("09c744894380b841")
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 configparser
import io

# Create a minimal config parser with test parameters
config_content = """
[test_section]
total_epoch = 260
single_workspace = False
w2vfile = /home/datasets/NLP_datasets/Glove/glove.6B.100d.txt
training_dir1 = /train1
training_dir2 = /train2
training_list1 = train1.txt
training_list2 = train2.txt
testing_dir1 = /test1
testing_dir2 = /test2
testing_list1 = test1.txt
testing_list2 = test2.txt
model_string = test_model
model_dir = models
batch_size = 64
max_length = 30
emb_size = 100
min_ss_size = 100
hidden_size = 100
softmax_factor = 10.0
learning_rate = 5e-05
remove_target_from_support_set = True
dropout_keep_prob = 1.0
offtopic_label = oos
sampling_classes = 10
sampling_classes_test = 2
topk_ss = 0
layer_num = 1
enable_batchnorm = True
mtl_num_tasks = 0
filter_size = 3
ood_threshold = 0.6
ood_threshold_margin = 0.2
ood_example_size = 5
alpha_pos = 1.0
alpha_neg = 1.0
alpha_indomain = 1.0
seed = 3143
"""

config_parser = configparser.ConfigParser()
config_parser.read_string(config_content)

ARGS = {
    'config_parser': config_parser,
    'section': 'test_section',
    'print_params': False
}
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
get_all_parameters Ran
ran on a synthesized input
inimah/protoinfomax/src/all_parameters_sentiment.py
code served (permissive licence) · get_code("ca41d63e0dcfb1ed")
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 configparser
import io

# Create a minimal config parser with a test section
config_content = """
[test_section]
total_epoch = 61
single_workspace = False
w2vfile = /home/datasets/NLP_datasets/Glove/glove.6B.100d.txt
training_dir1 = 
training_dir2 = 
training_list1 = 
training_list2 = 
testing_dir1 = 
testing_dir2 = 
testing_list1 = 
testing_list2 = 
model_string = dummy
model_dir = models
batch_size = 64
max_length = 40
emb_size = 100
min_ss_size = 100
hidden_size = 100
softmax_factor = 10.0
learning_rate = 5e-05
remove_target_from_support_set = True
dropout_keep_prob = 1.0
vocabulary = 
wordvectors = 
offtopic_label = UNCONFIDENT_INTENT_FROM_SLAD
sampling_classes = 2
topk_ss = 0
layer_num = 1
enable_batchnorm = True
mtl_num_tasks = 0
filter_size = 3
ood_threshold = 0.6
ood_threshold_margin = 0.2
ood_example_size = 1
alpha_pos = 1.0
alpha_neg = 1.0
alpha_indomain = 1.0
seed = 3143
"""

config_parser = configparser.ConfigParser()
config_parser.read_string(config_content)

ARGS = {
    'config_parser': config_parser,
    'section': 'test_section',
    'print_params': False
}
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
get_stop_words Ran
ran on a synthesized input
inimah/protoinfomax/src/eval_imax.py
code served (permissive licence) · get_code("bf4f83cce3b45e7e")
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 frozenset. 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 os

# Create a temporary file with stop words
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, encoding='utf-8', suffix='.txt')
temp_file.write("the\n")
temp_file.write("a\n")
temp_file.write("an\n")
temp_file.write("and\n")
temp_file.write("or\n")
temp_file.write("but\n")
temp_file.close()

stop_file_path = temp_file.name

ARGS = {
    "stop_file_path": stop_file_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
nltk — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type frozenset — a frozenset output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a frozenset 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
l2norm Ran
ran on a synthesized input
inimah/protoinfomax/models/model_imax_kw_intent.py
code served (permissive licence) · get_code("e639380bfda1f139")
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

torch.manual_seed(0)

# The function l2norm takes a tensor X and normalizes it by its L2 norm along the last dimension
# It performs: X / ||X||_2 where the norm is computed over the last dimension

# Create a small tensor with shape (batch=2, features=4)
X = torch.randn(2, 4)

ARGS = {
    "X": X
}
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
read_pickle Ran
ran on a synthesized input
inimah/protoinfomax/src/eval_imax.py
code served (permissive licence) · get_code("af2e7b8cff355044")
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 os
import _pickle as cPickle
import tempfile

# Create a temporary directory and a pickle file
temp_dir = tempfile.mkdtemp()
test_data = {"key": "value", "number": 42, "list": [1, 2, 3]}

# Write a pickle file to the temporary directory
temp_filename = "test.pkl"
temp_filepath = os.path.join(temp_dir, temp_filename)
with open(temp_filepath, 'wb') as f:
    cPickle.dump(test_data, f)

ARGS = {
    "filepath": temp_dir,
    "filename": temp_filename
}
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
str2bool Ran
ran on a synthesized input
inimah/protoinfomax/src/all_parameters_intent.py
code served (permissive licence) · get_code("9e7bc58b5a573d9e")
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 bool, 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

def str2bool(v):
    if v == 'True':
        return True
    elif v == 'False':
        return False
    else:
        raise Exception('bad string for boolean')

ARGS = {
    'v': 'True'
}
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 bool, 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

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, 2 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 1 later) and 5 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
l2norm 1 other paper
1 later
2023.findings-emnlp.153 (2023 (year only))
Chain of Thought with Explicit Evidence Reasoning for Few-shot Relation Extraction
str2bool 1 other paper
1 dated earlier
1909.05357 (2019-09)
Out-of-Domain Detection for Low-Resource Text Classification Tasks

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

The ability to detect Out-of-Domain (OOD) inputs has been a critical requirement in many real-world NLP applications. For example, intent classification in dialogue systems. The reason is that the inclusion of unsupported OOD inputs may lead to catastrophic failure of systems. However, it remains an empirical question whether current methods can tackle such problems reliably in a realistic scenario where zero OOD training data is available. In this study, we propose ProtoInfoMax, a new architecture that extends Prototypical Networks to simultaneously process in-domain and OOD sentences via Mutual Information Maximization (InfoMax) objective. Experimental results show that our proposed method can substantially improve performance up to 20% for OOD detection in low resource settings of text classification. We also show that ProtoInfoMax is less prone to typical overconfidence errors of Neural Networks, leading to more reliable prediction results. 1 * * Komplek LIPI, Jl. Sangkuriang, Dago, Coblong, Bandung, Indonesia 40135. Phone: (+6222) 2504711. 1 Code and preprocessed data are available at https://github.com/inimah/protoinfomax.git. 2 System built under this assumption should be able to not only correctly analyze In-Domain (ID) inputs but also reliably reject Out-of-Domain (OOD) inputs that are not supported by the system.

For agents

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

get_harvested_code_for_paper("2021.findings-emnlp.138")
get_code_for_paper("2021.findings-emnlp.138")
have("2021.findings-emnlp.138")

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

curl https://syntology.ai/api/ran/2021.findings-emnlp.138.json

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

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

Connect an agent — have() is free.