SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2203.01670 · ACL Findings · 2022

A Simple Hash-Based Early Exiting Approach For Language Understanding and Generation

Tianxiang Sun, Xuanjing Huang, Xipeng Qiu, Wei Zhu, Yuan Ni, Guotong Xie, Xiangyang Liu, Zhichao Geng, Lingling Wu, Yilong He

arXiv · PDF · Open in the Atlas

Code that ran

6 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; 1 honoured the contract we drafted, 0 violated it and 5 have no contract verdict; 0 failures of our instrument; 1 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/2203.01670.json · badge: /api/ran/2203.01670.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
txsun1997/hashee canonical (classifier label)
classifier basis not recorded on the link
6 ran · 1 no recorded run
FunctionStatusWhere it lives
attention_mask_func Ran
ran, honoured the contract we drafted
txsun1997/hashee/models/modeling_elasticbert_approx_hashee.py
code served (permissive licence) · get_code("ce106170b591f393")
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)

# attention_mask_func takes two parameters:
# 1. attention_scores: a tensor to which the mask is added
# 2. attention_mask: a tensor to be added to attention_scores

# Create small tensors with distinct shapes for clarity
attention_scores = torch.randn(2, 4)  # batch_size=2, sequence_length=4
attention_mask = torch.zeros(2, 4)    # same shape, mask of zeros

ARGS = {
    "attention_scores": attention_scores,
    "attention_mask": attention_mask,
}
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
get_dropped_hidden Ran
ran on a synthesized input
txsun1997/hashee/models/modeling_elasticbert_hashee.py
code served (permissive licence) · get_code("eaf0d81840f1d648")
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

torch.manual_seed(0)

# Construct valid arguments for get_dropped_hidden
# hidden: batch_size x seq_len x hidden_dim
# remain_layers: batch_size x seq_len

batch_size = 2
seq_len = 3
hidden_dim = 4

# Create hidden tensor: (batch_size=2, seq_len=3, hidden_dim=4)
hidden = torch.randn(batch_size, seq_len, hidden_dim)

# Create remain_layers tensor: (batch_size=2, seq_len=3)
# This tensor contains values that will be compared with 0 using .le(0)
# Some values should be <= 0 to create drop indices
remain_layers = torch.tensor([
    [1.0, -1.0, 0.0],
    [2.0, 0.0, -2.0]
], dtype=torch.float32)

ARGS = {
    "hidden": hidden,
    "remain_layers": remain_layers
}
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
get_extended_attention_mask Ran
ran on a synthesized input
txsun1997/hashee/models/modeling_elasticbert_approx_hashee.py
code served (permissive licence) · get_code("89bec46d4c56090c")
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 4, dtype family float, shape (2, 1, 4, 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)

# Create a small attention mask tensor
# Shape: [bsz, seq_len] = [2, 4]
# Values should be 0 and 1 (or binary mask values)
mask = torch.ones(2, 4, dtype=torch.float32)

# Specify the dtype for the expanded mask
dtype = torch.float32

ARGS = {
    "mask": mask,
    "dtype": dtype,
}
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 4, dtype family float, shape (2, 1, 4, 4) — shape (2, 1, 4, 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
get_reduced_hidden Ran
ran on a synthesized input
txsun1997/hashee/models/modeling_elasticbert_hashee.py
code served (permissive licence) · get_code("4977b7509775eb23")
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 3, dtype family float, shape (2, 2, 4) as a later run recorded it. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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 as nn

torch.manual_seed(0)

# Create tensors
batch_size = 2
seq_len = 3
hidden_dim = 4

# hidden: batch_size x seq_len x hidden_dim
hidden = torch.randn(batch_size, seq_len, hidden_dim)

# remain_layers: batch_size x seq_len
# Values > 0 indicate positions to keep
remain_layers = torch.tensor([
    [1, 0, 1],  # keep positions 0 and 2
    [1, 1, 0]   # keep positions 0 and 1
], dtype=torch.float32)

ARGS = {
    "hidden": hidden,
    "remain_layers": remain_layers
}
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 3, dtype family float, shape (2, 2, 4) — shape (2, 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
get_start_piece_outputs Ran
ran on a synthesized input
txsun1997/hashee/models/modeling_elasticbert_approx_hashee.py
code served (permissive licence) · get_code("2cff6510499768ce")
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 3, dtype family float, shape (2, 2, 3) 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)

# Create a small tensor with batch_size=2, sequence_length=4, and some feature_dim=3
tensor = torch.randn(2, 4, 3)

# Create index tensor with same batch_size=2 and some number of indices
# All indices must be < tensor.size(1) which is 4
index = torch.tensor([[0, 2], [1, 3]])

ARGS = {
    "tensor": tensor,
    "index": index,
}
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 3, dtype family float, shape (2, 2, 3) — shape (2, 2, 3) 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
shift_nonzero Ran
ran on a synthesized input
txsun1997/hashee/models/modeling_elasticbert_hashee.py
code served (permissive licence) · get_code("a834d201022a2476")
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 int, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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 as nn

torch.manual_seed(0)

# The function expects remain_layers to be a 2D tensor
# It iterates over rows (bsz dimension) and elements (seq_len dimension)
# It checks if v > 0 and filters/pads accordingly
# The function calls .shape, iterates, and converts back to tensor
# It also calls .cuda() which will fail on CPU, but we pass valid input

remain_layers = torch.tensor([
    [1, 0, 2, 0],
    [0, 3, 0, 1]
], dtype=torch.int32)

ARGS = {
    "remain_layers": remain_layers
}
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 int, 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
load_tf_weights_in_bert Not yet run
unverified (harvested, no recorded run)
txsun1997/hashee/difficulty/modeling_bert.py
code served (permissive licence) · get_code("26be70dca3249c0b")
How it ran

no invocation recorded.

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, 2 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
load_tf_weights_in_bert 28 other papers
5 dated earlier, 22 later, 1 same year, order not determinable
1905.12794 (2019-05)
Fashion IQ: A New Dataset Towards Retrieving Images by Natural Language Feedback
2021.emnlp-main.154 (2021 (year only))
Reconstruction Attack on Instance Encoding for Language Understanding
2104.06599 (2021-04)
Learning How to Ask: Querying LMs with Mixtures of Soft Prompts
and 25 more not named here
attention_mask_func 1 other paper
1 later
aaai_33874 (2025 (year only))
Scalable Acceleration for Classification-Based Derivative-Free Optimization

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

Early exiting allows instances to exit at different layers according to the estimation of difficulty. Previous works usually adopt heuristic metrics such as the entropy of internal outputs to measure instance difficulty, which suffers from generalization and threshold-tuning. In contrast, learning to exit, or learning to predict instance difficulty is a more appealing way. Though some effort has been devoted to employing such "learn-to-exit" modules, it is still unknown whether and how well the instance difficulty can be learned. As a response, we first conduct experiments on the learnability of instance difficulty, which demonstrates that modern neural models perform poorly on predicting instance difficulty. Based on this observation, we propose a simple-yeteffective Hash-based Early Exiting approach (HASHEE) that replaces the learn-to-exit modules with hash functions to assign each token to a fixed exiting layer. Different from previous methods, HASHEE requires no internal classifiers nor extra parameters, and therefore is more efficient. Experimental results on classification, regression, and generation tasks demonstrate that HASHEE can achieve higher performance with fewer FLOPs and inference time compared with previous state-of-the-art early exiting methods.

For agents

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

get_harvested_code_for_paper("2203.01670")
get_code_for_paper("2203.01670")
have("2203.01670")

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

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

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

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

Connect an agent — have() is free.