SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2110.01799 · 2021

ContractNLI: A Dataset for Document-level Natural Language Inference for Contracts

arXiv · PDF · Open in the Atlas

Code that ran

7 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 6 have no contract verdict; 1 failure of our instrument; 1 no recorded run); 1 of them was also run on the host, not in the jail, by the peer-agreement lane that set its level, 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/2110.01799.json · badge: /api/ran/2110.01799.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
stanfordnlp/contract-nli-bert canonical (classifier label)
classifier basis not recorded on the link
7 ran · 1 no recorded run
FunctionStatusWhere it lives
to_list Ran
ran; our contract draft was wrong, not the code
stanfordnlp/contract-nli-bert/contract_nli/predictor.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from AI-secure/InfoBERT, is pointer only (licence: NONE) · get_code("9df40357afea56cc")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from AI-secure/InfoBERT, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

classification_converter Ran
ran on a synthesized input
stanfordnlp/contract-nli-bert/contract_nli/batch_converter.py
code served (permissive licence) · get_code("d082a08f956f9efe")
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 torch.nn as nn

torch.manual_seed(0)

# Build a minimal model with the required attributes
class MinimalModel(nn.Module):
    def __init__(self, model_type='bert'):
        super().__init__()
        self.model_type = model_type
        self.config = None
    
    def forward(self, input_ids, attention_mask, token_type_ids):
        return torch.randn(2, 4)

class MinimalModelWithConfig(nn.Module):
    def __init__(self, model_type='bert'):
        super().__init__()
        self.model_type = model_type
        self.config = MinimalConfig()
    
    def forward(self, input_ids, attention_mask, token_type_ids):
        return torch.randn(2, 4)

class MinimalConfig:
    def __init__(self):
        self.lang2id = {'en': 0, 'fr': 1}

class MinimalWrappedModel(nn.Module):
    def __init__(self, model_type='bert'):
        super().__init__()
        self.module = MinimalModel(model_type)
    
    def forward(self, input_ids, attention_mask, token_type_ids):
        return self.module(input_ids, attention_mask, token_type_ids)

# Create batch: (input_ids, attention_mask, token_type_ids, cls_index, p_mask, ?, class_labels)
batch = (
    torch.randint(0, 1000, (2, 4)),      # input_ids
    torch.ones((2, 4), dtype=torch.long),  # attention_mask
    torch.zeros((2, 4), dtype=torch.long), # token_type_ids
    torch.tensor([0, 1], dtype=torch.long),  # cls_index
    torch.zeros((2, 4), dtype=torch.float),  # p_mask
    torch.zeros((2, 4), dtype=torch.long),  # unused position
    torch.randint(0, 2, (2,), dtype=torch.long)  # class_labels
)

model = MinimalModel(model_type='bert')
device = 'cpu'
no_labels = False

ARGS = {
    'batch': batch,
    'model': model,
    'device': device,
    'no_labels': no_labels
}
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 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
evaluate_predicted_spans Ran
ran on a synthesized input
stanfordnlp/contract-nli-bert/contract_nli/evaluation.py
code served (permissive licence) · get_code("fdba9f2f38cf8b95")
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 numpy as np

# Create sample binary classification data
# y_true: ground truth binary labels
# y_pred: predicted binary labels

np.random.seed(0)

# Create small sample data with 10 samples
y_true = np.array([1, 0, 1, 1, 0, 1, 0, 0, 1, 1], dtype=int)
y_pred = np.array([1, 0, 1, 0, 0, 1, 1, 0, 1, 1], dtype=int)

ARGS = {
    'y_true': y_true,
    'y_pred': y_pred
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn — 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
evaluate_spans Ran
ran on a synthesized input
stanfordnlp/contract-nli-bert/contract_nli/evaluation.py
code served (permissive licence) · get_code("f6fc4ca1b76f30d2")
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 numpy as np
import sklearn.metrics

# Set random seed for reproducibility
np.random.seed(0)

# Create synthetic data for evaluation
# y_true: binary labels (0 or 1)
# y_prob: probability scores between 0 and 1

# Create a small dataset with some positive and negative examples
n_samples = 10
y_true = np.array([0, 1, 1, 0, 1, 0, 1, 1, 0, 1], dtype=int)
y_prob = np.array([0.1, 0.9, 0.8, 0.2, 0.95, 0.15, 0.85, 0.88, 0.25, 0.92], dtype=float)

# Ensure y_prob is 1D and y_true is 1D
assert y_prob.ndim == 1
assert y_true.ndim == 1
assert len(y_true) == len(y_prob)

# Ensure there are some positive samples for recall calculation
assert np.sum(y_true) > 0

ARGS = {
    'y_true': y_true,
    'y_prob': y_prob
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn — 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
identification_classification_converter Ran
ran on a synthesized input
stanfordnlp/contract-nli-bert/contract_nli/batch_converter.py
code served (permissive licence) · get_code("7b1144335117a3da")
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 torch.nn as nn

torch.manual_seed(0)

# Create a minimal model that satisfies the function's requirements
class MinimalModel(nn.Module):
    def __init__(self, model_type='bert'):
        super().__init__()
        self.model_type = model_type
        self.config = None

model = MinimalModel(model_type='bert')

# Create batch tuple with 9 elements (indices 0-8)
# batch[0]: input_ids
# batch[1]: attention_mask
# batch[2]: token_type_ids
# batch[3]: cls_index
# batch[4]: p_mask
# batch[5]: valid_span_missing_in_context
# batch[6]: (unused)
# batch[7]: class_labels
# batch[8]: span_labels

batch_size = 2
seq_length = 4

input_ids = torch.randint(0, 1000, (batch_size, seq_length))
attention_mask = torch.ones((batch_size, seq_length), dtype=torch.int64)
token_type_ids = torch.zeros((batch_size, seq_length), dtype=torch.int64)
cls_index = torch.zeros((batch_size,), dtype=torch.int64)
p_mask = torch.zeros((batch_size, seq_length), dtype=torch.float32)
valid_span_missing_in_context = torch.zeros((batch_size, seq_length), dtype=torch.int64)
unused = torch.zeros((batch_size, seq_length), dtype=torch.int64)
class_labels = torch.randint(0, 2, (batch_size,), dtype=torch.int64)
span_labels = torch.randint(0, 2, (batch_size, seq_length), dtype=torch.int64)

batch = (
    input_ids,
    attention_mask,
    token_type_ids,
    cls_index,
    p_mask,
    valid_span_missing_in_context,
    unused,
    class_labels,
    span_labels
)

device = 'cpu'
no_labels = False

ARGS = {
    'batch': batch,
    'model': model,
    'device': device,
    'no_labels': no_labels
}
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 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
precision_at_recall Ran
ran on a synthesized input
stanfordnlp/contract-nli-bert/contract_nli/evaluation.py
code served (permissive licence) · get_code("c3291c95aa178de9")
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 numpy as np
import sklearn.metrics

def precision_at_recall(y_true, y_prob, recall: float):
    assert 0.0 <= recall <= 1.0
    if len(y_true) == 0 or np.sum(y_true) == 0:
        return np.nan
    threshs = np.sort(np.unique(y_prob))[::-1]
    y_preds = y_prob[None, :] >= threshs[:, None]
    recalls = np.logical_and(y_true[None, :], y_preds).sum(axis=1) / np.sum(y_true)
    assert np.all(recalls == np.sort(recalls))
    thresh = threshs[np.where(recalls >= recall)[0][0]]
    y_pred = y_prob >= thresh
    return sklearn.metrics.precision_score(y_true, y_pred, zero_division=0.0)

# Construct test data
# y_true: binary labels (0 or 1)
y_true = np.array([0, 1, 1, 0, 1, 1])

# y_prob: probability scores between 0 and 1
y_prob = np.array([0.1, 0.9, 0.8, 0.2, 0.85, 0.95])

# recall: target recall value between 0 and 1
recall = 0.5

ARGS = {
    "y_true": y_true,
    "y_prob": y_prob,
    "recall": recall,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn — 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
tokenize Ran
ran on a synthesized input
stanfordnlp/contract-nli-bert/contract_nli/dataset/encoder.py
code served (permissive licence) · get_code("e6cc06f761aa91b0")
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. 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
from typing import List

class MockTokenizer:
    """Mock tokenizer that implements the tokenize method"""
    
    def __init__(self, name='BertTokenizer'):
        self.__class__.__name__ = name
    
    def tokenize(self, token, add_prefix_space=False):
        # Simple mock: split token into characters or return as single token
        if len(token) > 2:
            return [token[:2], token[2:]]
        return [token]

# Create test data
tokenizer = MockTokenizer('BertTokenizer')
tokens = ['hello', 'world', 'test']
splits = [0, 2]  # Indices where spans occur

ARGS = {
    'tokenizer': tokenizer,
    'tokens': tokens,
    'splits': splits
}
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 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
load_conf Not yet run
unverified (harvested, no recorded run)
stanfordnlp/contract-nli-bert/contract_nli/conf.py
code served (permissive licence) · get_code("0798376f519e92a4")
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, 1 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 7 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
to_list 41 other papers
24 dated earlier, 14 later, 3 same year, order not determinable
1902.01718 (2019-02)
End-to-End Open-Domain Question Answering with BERTserini
1910.06188 (2019-10)
Q8BERT: Quantized 8Bit BERT
1911.02984 (2019-11)
The TechQA Dataset
and 38 more not named here

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

Reviewing contracts is a time-consuming procedure that incurs large expenses to companies and social inequality to those who cannot afford it. In this work, we propose "document-level natural language inference (NLI) for contracts", a novel, real-world application of NLI that addresses such problems. In this task, a system is given a set of hypotheses (such as "Some obligations of Agreement may survive termination.") and a contract, and it is asked to classify whether each hypothesis is "entailed by", "contradicting to" or "not mentioned by" (neutral to) the contract as well as identifying "evidence" for the decision as spans in the contract. We annotated and release the largest corpus to date consisting of 607 annotated contracts. We then show that existing models fail badly on our task and introduce a strong baseline, which (1) models evidence identification as multi-label classification over spans instead of trying to predict start and end tokens, and (2) employs more sophisticated context segmentation for dealing with long documents. We also show that linguistic characteristics of contracts, such as negations by exceptions, are contributing to the difficulty of this task and that there is much room for improvement.

For agents

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

get_harvested_code_for_paper("2110.01799")
get_code_for_paper("2110.01799")
have("2110.01799")

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

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

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

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

Connect an agent — have() is free.