SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2104.08671 · 2021

When Does Pretraining Help? Assessing Self-Supervised Learning for Law and the CaseHOLD Dataset

arXiv · PDF · Open in the Atlas

Code that ran

6 of 9 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 5 have no contract verdict; 1 failure of our instrument; 3 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/2104.08671.json · badge: /api/ran/2104.08671.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
reglab/casehold canonical (classifier label)
classifier basis: census
1 ran · 0 no recorded run
trusthlt/privacy-legal-nlp-lm community (classifier label)
classifier basis not recorded on the link
5 ran · 3 no recorded run
FunctionStatusWhere it lives
apply_threshs Ran
ran on a synthesized input
trusthlt/privacy-legal-nlp-lm/downstream_tasks/utils.py
code served (permissive licence) · get_code("e1f72af0ac263f37")
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 ndarray, 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 numpy as np

# Create sample probability data: shape (batch_size=2, num_classes=4)
probas = np.array([
    [0.1, 0.5, 0.8, 0.3],
    [0.6, 0.2, 0.4, 0.9]
], dtype=np.float32)

# Create thresholds: one per class (length=4)
threshs = np.array([0.3, 0.4, 0.7, 0.5], dtype=np.float32)

ARGS = {
    "probas": probas,
    "threshs": threshs
}
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 ndarray, 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
convert_examples_to_features Ran
ran; our contract draft was wrong, not the code
reglab/casehold/multiple_choice/utils_multiple_choice.py
code served (permissive licence) · get_code("68377121bfc285a9")
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 logging
from dataclasses import dataclass
from typing import List, Optional

torch.manual_seed(0)
logging.basicConfig(level=logging.INFO)

@dataclass(frozen=True)
class InputExample:
    example_id: str
    question: str
    contexts: List[str]
    endings: List[str]
    label: Optional[str]

@dataclass(frozen=True)
class InputFeatures:
    example_id: str
    input_ids: List[List[int]]
    attention_mask: Optional[List[List[int]]]
    token_type_ids: Optional[List[List[int]]]
    label: Optional[int]

class MockTokenizer:
    def __call__(self, text_a, text_b, add_special_tokens=True, max_length=128, 
                 padding='max_length', truncation=True, return_overflowing_tokens=True):
        input_ids = [101, 2054, 2003, 102, 1045, 2572, 103, 0][:max_length]
        input_ids += [0] * (max_length - len(input_ids))
        
        attention_mask = [1 if x != 0 else 0 for x in input_ids]
        token_type_ids = [0] * max_length
        
        return {
            'input_ids': input_ids,
            'attention_mask': attention_mask,
            'token_type_ids': token_type_ids
        }

examples = [
    InputExample(
        example_id="ex_1",
        question="What is the _?",
        contexts=["Context 1", "Context 2"],
        endings=["answer1", "answer2"],
        label="label_0"
    ),
    InputExample(
        example_id="ex_2",
        question="Where is it?",
        contexts=["Context A", "Context B"],
        endings=["option1", "option2"],
        label="label_1"
    )
]

label_list = ["label_0", "label_1"]
max_length = 16
tokenizer = MockTokenizer()

ARGS = {
    'examples': examples,
    'label_list': label_list,
    'max_length': max_length,
    'tokenizer': tokenizer
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm, transformers — 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
create_instance_from_document Ran
ran on a synthesized input
trusthlt/privacy-legal-nlp-lm/data_prepare/utils.py
code served (permissive licence) · get_code("36a781e6d5afa906")
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
from random import seed as set_seed

set_seed(42)

# Create a minimal datasets structure
# Each dataset entry has 'input_ids' which is a list of token sequences
datasets = [
    {
        'input_ids': [
            [101, 2054, 2003, 102],  # sentence 1
            [1045, 2572, 3231, 102],  # sentence 2
            [2054, 2003, 1045, 102],  # sentence 3
        ]
    },
    {
        'input_ids': [
            [101, 1045, 2572, 102],
            [2054, 2003, 1045, 102],
        ]
    },
    {
        'input_ids': [
            [101, 2003, 1045, 102],
            [1045, 2054, 2572, 102],
        ]
    },
]

# Create a document (list of token id sequences)
document = [
    [101, 2054, 2003, 102],
    [1045, 2572, 3231, 102],
    [2054, 2003, 1045, 102],
]

# Special tokens mapping
special_tokens = {
    '[CLS]': 101,
    '[SEP]': 102,
}

ARGS = {
    'document': document,
    'doc_idx': 0,
    'datasets': datasets,
    'version': 'normal',
    'max_seq_length': 20,
    'short_seq_prob': 0.1,
    'special_tokens': special_tokens,
}
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
equal Ran
ran on a synthesized input
trusthlt/privacy-legal-nlp-lm/pretrain/utils.py
code served (permissive licence) · get_code("45127374f48c9723")
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

torch.manual_seed(0)

ARGS = {
    "x1": 5.0,
    "x2": 5.000001,
    "diff": 1e-06
}
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
generate_random_next Ran
ran on a synthesized input
trusthlt/privacy-legal-nlp-lm/data_prepare/utils.py
code served (permissive licence) · get_code("efbd156ad839d2bf")
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 int; 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 random import random, randrange, randint

torch.manual_seed(0)

# Build datasets parameter
# The function expects a list of dicts, each with 'input_ids' key
# input_ids should be indexable and contain sequences
datasets = [
    {
        'input_ids': [
            [101, 202, 303],
            [404, 505],
            [606, 707, 808, 909]
        ]
    },
    {
        'input_ids': [
            [1001, 1002, 1003, 1004],
            [2001, 2002]
        ]
    },
    {
        'input_ids': [
            [3001, 3002, 3003],
            [4001]
        ]
    }
]

# doc_idx: index into datasets
doc_idx = 0

# target_b_length: target length for the ids_b list
target_b_length = 5

ARGS = {
    'datasets': datasets,
    'doc_idx': doc_idx,
    'target_b_length': target_b_length
}
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 list, ndim 1, dtype family int — 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
multihot Ran
ran on a synthesized input
trusthlt/privacy-legal-nlp-lm/downstream_tasks/data_loader.py
code served (permissive licence) · get_code("851b9497b3ad4904")
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 ndarray, ndim 1, dtype family int, shape (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 numpy as np

# Construct arguments for the multihot function
# The function takes labels (list/iterable of label names) and label_map (dict mapping label names to indices)

labels = ['cat', 'dog', 'bird']
label_map = {'cat': 0, 'dog': 1, 'bird': 2, 'fish': 3}

ARGS = {
    'labels': labels,
    'label_map': label_map
}
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 ndarray, ndim 1, dtype family int, shape (4,) — shape (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
build_dataset Not yet run
unverified (harvested, no recorded run)
trusthlt/privacy-legal-nlp-lm/downstream_tasks/data_loader.py
code served (permissive licence) · get_code("f252d20c754d3bcf")
How it ran

no invocation recorded.

split_corpus Not yet run
unverified (harvested, no recorded run)
trusthlt/privacy-legal-nlp-lm/downstream_tasks/data_loader.py
code served (permissive licence) · get_code("14ea19820452ef31")
How it ran

no invocation recorded.

tune_threshs Not yet run
unverified (harvested, no recorded run)
trusthlt/privacy-legal-nlp-lm/downstream_tasks/utils.py
code served (permissive licence) · get_code("a58a2a6534b81101")
How it ran

no invocation recorded.

Also present in other papers' code

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

While self-supervised learning has made rapid advances in natural language processing, it remains unclear when researchers should engage in resource-intensive domain-specific pretraining (domain pretraining). The law, puzzlingly, has yielded few documented instances of substantial gains to domain pretraining in spite of the fact that legal language is widely seen to be unique. We hypothesize that these existing results stem from the fact that existing legal NLP tasks are too easy and fail to meet conditions for when domain pretraining can help. To address this, we first present CaseHOLD (Case Holdings On Legal Decisions), a new dataset comprised of over 53,000+ multiple choice questions to identify the relevant holding of a cited case. This dataset presents a fundamental task to lawyers and is both legally meaningful and difficult from an NLP perspective (F1 of 0.4 with a BiLSTM baseline). Second, we assess performance gains on CaseHOLD and existing legal NLP datasets. While a Transformer architecture (BERT) pretrained on a general corpus (Google Books and Wikipedia) improves performance, domain pretraining (using corpus of approximately 3.5M decisions across all courts in the U.S. that is larger than BERT's) with a custom legal vocabulary exhibits the most substantial performance gains with CaseHOLD (gain of 7.2% on F1, representing a 12% improvement on BERT) and consistent performance gains across two other legal tasks. Third, we show that domain pretraining may be warranted when the task exhibits sufficient similarity to the pretraining corpus: the level of performance increase in three legal tasks was directly tied to the domain specificity of the task. Our findings inform when researchers should engage resource-intensive pretraining and show that Transformer-based architectures, too, learn embeddings suggestive of distinct legal language.

For agents

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

get_harvested_code_for_paper("2104.08671")
get_code_for_paper("2104.08671")
have("2104.08671")

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

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

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

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

Connect an agent — have() is free.