SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2023.findings-emnlp.517 · EMNLP Findings · 2023

Text2Tree: Aligning Text Representation to the Label Tree Hierarchy for Imbalanced Medical Classification

Kai Zhang, Jintai Chen, Jiahuan Yan, Jian Wu, Danny Chen, Weize Liu, Haojun Gao

Open in the Atlas

Code that ran

16 of 18 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 14 have no contract verdict; 2 failures of our instrument; 2 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/2023.findings-emnlp.517.json · badge: /api/ran/2023.findings-emnlp.517.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
jyansir/Text2Tree canonical (classifier label)
classifier basis: census
16 ran · 2 no recorded run
FunctionStatusWhere it lives
build_masks Ran
ran on a synthesized input
jyansir/Text2Tree/label_embeddings.py
code served (permissive licence) · get_code("01d8540c3d84a8b3")
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 numpy as np

# Build a label2id dictionary
# The function expects a dict mapping node labels to integer indices
# Based on the code, we need 'Root' and some child nodes

label2id = {
    'Root': 0,
    'child1': 1,
    'child2': 2,
    'child1.grandchild1': 3,
    'child1.grandchild2': 4,
    'child2.grandchild1': 5,
}

# Set up the layer_nodes structure that the function uses
# This is a global variable in the function's module context
# We need to define it before calling build_masks
layer_nodes = [
    ['Root'],
    ['child1', 'child2'],
    ['child1.grandchild1', 'child1.grandchild2', 'child2.grandchild1']
]

ARGS = {
    'label2id': label2id,
}
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 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
build_metric Ran
ran on a synthesized input
jyansir/Text2Tree/trainer_utils.py
code served (permissive licence) · get_code("bf91cae8167d71a8")
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 function. 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

# Test for multiclass task type
ARGS = {
    'task_type': 'multiclass'
}

# Alternative test case for multilabel (commented out, but valid)
# ARGS = {
#     'task_type': 'multilabel'
# }
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 function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
dis_mixup Ran
ran on a synthesized input
jyansir/Text2Tree/aug_utils.py
code served (permissive licence) · get_code("da7e0b865394c97f")
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 tiny tensors matching the function's requirements
b = 2  # batch size
d = 4  # feature dimension

# Xs: shape (b, d) - batch of feature vectors
Xs = torch.randn(b, d)

# soft_distance: shape (b, b) - pairwise distances between batch elements
soft_distance = torch.abs(torch.randn(b, b))

ARGS = {
    "Xs": Xs,
    "soft_distance": soft_distance,
}
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
extract_graph_info Ran
ran on a synthesized input
jyansir/Text2Tree/label_embeddings.py
code served (permissive licence) · get_code("57825b83d252407d")
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

# Setup for extract_graph_info function
# The function takes a list of strings and an optional separator
# It builds a nested dictionary representing a graph structure

label_list = [
    "animal.mammal.dog",
    "animal.mammal.cat",
    "animal.bird.eagle",
    "plant.tree.oak"
]

ARGS = {
    "label_list": label_list,
    "sep": "."
}
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
extract_mesh_subids Ran
ran on a synthesized input
jyansir/Text2Tree/data_preprocess.py
code served (permissive licence) · get_code("1be24adfdd4048fc")
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 pandas as pd
from collections import Counter

# Create a minimal dataframe with meshid column
# The function expects meshid values that can be eval'd into nested structures
# Based on the code: df.meshid.values -> eval(mesh) -> iterate through mesh -> iterate through each -> split strings

# Create valid MeSH ID data structures
# mesh should be iterable of iterables of strings with dot-separated components
mesh_data_1 = [
    ['D000001.B02.C03', 'D000002.B04.C05'],
    ['D000010.B01.C02', 'D000011.B03.C04']
]

mesh_data_2 = [
    ['D000100.X02.Y03', 'D000101.X04.Y05'],
    ['D000102.X01.Y02']
]

# Create dataframe with meshid column containing string representations
df = pd.DataFrame({
    'meshid': [
        str(mesh_data_1),
        str(mesh_data_2)
    ]
})

ARGS = {
    'df': df,
    'max_level': 2
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — 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
extract_mesh_subids Ran
ran on a synthesized input
jyansir/Text2Tree/label_embeddings.py
code served (permissive licence) · get_code("425b2170d2aa0a6f")
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 pandas as pd
from collections import Counter
import tempfile
import os

# Create a temporary CSV file with mock data
temp_dir = tempfile.mkdtemp()
csv_path = os.path.join(temp_dir, 'all.csv')

# Create mock data that matches the function's expectations
# The function expects df.meshid.values to contain strings that eval to lists of lists
mock_data = {
    'meshid': [
        "[['D000001.A.B', 'D000001.A.C'], ['D000002.X.Y']]",
        "[['D000001.A.B', 'D000003.Z.W'], ['D000002.X.Y']]",
        "[['D000004.P.Q', 'D000001.A.B']]",
        "[['D000001.A.B', 'D000002.X.Y', 'D000005.R.S']]",
        "[['D000003.Z.W', 'D000006.T.U']]",
    ],
    'other_col': [1, 2, 3, 4, 5]
}

df = pd.DataFrame(mock_data)
df.to_csv(csv_path, index=False)

# Monkey-patch the function to use our temporary file
import sys
original_read_csv = pd.read_csv

def patched_read_csv(path, *args, **kwargs):
    if 'pubmed_multilabel/all.csv' in path:
        return pd.read_csv(csv_path, *args, **kwargs)
    return original_read_csv(path, *args, **kwargs)

pd.read_csv = patched_read_csv

ARGS = {
    'max_level': 2,
    'k': 100
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — 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
l2norm Ran
ran on a synthesized input
jyansir/Text2Tree/losses.py
code served (permissive licence) · get_code("f26223f429554600")
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)

# Test case 1: single tensor
tensor_single = torch.randn(2, 4)

# Test case 2: list of tensors
tensor_list = [torch.randn(2, 4), torch.randn(2, 4)]

ARGS = {
    "tensor": tensor_single
}
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
merge_inputs Ran
ran on a synthesized input
jyansir/Text2Tree/model_utils.py
code served (permissive licence) · get_code("10da40a328920cb1")
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 (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)

# Test case 1: Both inputs are tensors
inputs1_tensor = torch.randn(2, 4)
inputs2_tensor = torch.randn(2, 4)

# Test case 2: Both inputs are dicts of tensors
inputs1_dict = {
    "hidden_state": torch.randn(2, 4),
    "attention": torch.randn(2, 3)
}
inputs2_dict = {
    "hidden_state": torch.randn(2, 4),
    "attention": torch.randn(2, 3)
}

# Create ARGS for tensor case
ARGS = {
    "inputs1": inputs1_tensor,
    "inputs2": inputs2_tensor
}
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 (4, 4) — shape (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
naive_mixup Ran
ran on a synthesized input
jyansir/Text2Tree/aug_utils.py
code served (permissive licence) · get_code("b40712dd7ca322cf")
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
import numpy as np

torch.manual_seed(0)
np.random.seed(0)

# Create a small batch of data: batch size 2, feature dimension 4
Xs = torch.randn(2, 4)

ARGS = {
    "Xs": Xs,
    "beta": 0.5,
}
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 — 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
nested_detach Ran
ran on a synthesized input
jyansir/Text2Tree/trainer_utils.py
code served (permissive licence) · get_code("f2706f7bacae40ee")
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. 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)

# The function nested_detach accepts nested structures of tensors (lists/tuples)
# and calls .detach() on each tensor. We need to construct a nested structure
# with at least one tensor that requires gradients so detach() is meaningful.

# Create a simple nested structure of tensors
tensor1 = torch.randn(2, 4, requires_grad=True)
tensor2 = torch.randn(2, 3, requires_grad=True)
tensor3 = torch.randn(2, 5, requires_grad=True)

# Build a nested list/tuple structure
nested_tensors = [
    tensor1,
    (tensor2, tensor3),
    [tensor1, tensor2]
]

ARGS = {
    "tensors": nested_tensors
}
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 list — a list 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
one_hot Ran
ran on a synthesized input
jyansir/Text2Tree/htc_baselines/hgclr/model/contrast.py
code served (permissive licence) · get_code("288a6497283d4ac5")
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 (4, 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)

# The function takes:
# - labels: a 1D tensor of integer indices
# - num_labels: an integer specifying the number of classes

# Create a small 1D tensor of label indices
labels = torch.tensor([0, 2, 1, 0], dtype=torch.long)

# Number of labels (classes)
num_labels = 3

ARGS = {
    "labels": labels,
    "num_labels": num_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 Tensor, ndim 2, dtype family float, shape (4, 3) — shape (4, 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
parse_multilabel Ran
ran on a synthesized input
jyansir/Text2Tree/data_preprocess.py
code served (permissive licence) · get_code("b49bf3ddd5f004f0")
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 numpy as np

# Construct arguments for parse_multilabel function
# The function takes:
# - meshid: a collection of labels (strings) to check
# - label2id: a dict mapping label strings to integer indices

meshid = {"Disease A", "Disease B", "Disease C"}

label2id = {
    "Disease A": 0,
    "Disease B": 1,
    "Disease C": 2,
    "Disease D": 3,
    "Disease E": 4,
}

ARGS = {
    "meshid": meshid,
    "label2id": label2id,
}
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 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
preprocess Ran
ran on a synthesized input
jyansir/Text2Tree/data_preprocess.py
code served (permissive licence) · get_code("9f81a3991d170eb6")
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 os
import json
import pandas as pd
import numpy as np
from collections import Counter

# Create a minimal dataset structure that mimics HuggingFace datasets
class MockDataset:
    def __init__(self, df):
        self._df = df
    
    def to_pandas(self):
        return self._df

class MockDatasets:
    def __init__(self, train_df):
        self.train = MockDataset(train_df)
    
    def __getitem__(self, key):
        if key == 'train':
            return self.train
        raise KeyError(key)

# Create sample data for pubmed_multilabel
def create_pubmed_dataset():
    # Create mock MeSH ID data as strings containing lists
    mesh_data = [
        "[['D000001.001', 'D000001.002', 'D000002.001']]",
        "[['D000003.001', 'D000001.001']]",
        "[['D000001.002', 'D000002.001', 'D000004.001']]",
        "[['D000001.001', 'D000003.001', 'D000004.001']]",
        "[['D000002.001', 'D000003.001']]",
    ] * 10000  # Repeat to get ~50k samples
    
    df = pd.DataFrame({
        'meshid': mesh_data[:50000],
        'text': ['sample text'] * 50000,
    })
    
    dataset = MockDatasets(df)
    return dataset

# Setup for the function call
ARGS = {
    'data_name': 'pubmed_multilabel',
    'dataset': create_pubmed_dataset(),
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
mimic_utils, numpy, pandas — 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
proc_htc_label Ran
ran on a synthesized input
jyansir/Text2Tree/data_utils.py
code served (permissive licence) · get_code("56f7fcb44fe9424c")
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

torch.manual_seed(0)

# Build label2id mapping
# The function expects labels like "A", "AB", "ABC" based on the to_one_hot logic
label2id = {
    "A": 0,
    "AB": 1,
    "ABC": 2,
    "D": 3,
    "DE": 4,
    "DEF": 5,
}

# Build old_id2label mapping (inverse of label mapping)
# Maps integer IDs to hierarchical label strings
old_id2label = {
    0: "ABC",
    1: "ABC",
    2: "DEF",
    3: "DEF",
}

# Test with 'gastroenterology' dataset
dataset = 'gastroenterology'

# label_info will be used as key to old_id2label
label_info = 0

# dummy flag - test with False to trigger to_one_hot
dummy = False

ARGS = {
    'label_info': label_info,
    'label2id': label2id,
    'old_id2label': old_id2label,
    'dataset': dataset,
    'dummy': dummy,
}
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
reduce_loss Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
jyansir/Text2Tree/balanced_loss_utils.py
code served (permissive licence) · get_code("93358ba7aa223343")
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 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
import torch.nn.functional as F

torch.manual_seed(0)

# Create a small elementwise loss tensor
loss = torch.randn(2, 4)

# Test with different reduction modes
ARGS = {
    "loss": loss,
    "reduction": "mean"
}
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 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
weight_reduce_loss Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
jyansir/Text2Tree/balanced_loss_utils.py
code served (permissive licence) · get_code("8553862254d49840")
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 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
import torch.nn.functional as F

torch.manual_seed(0)

# Create tiny tensors for the function parameters
loss_tensor = torch.randn(2, 4)  # Elementwise loss tensor
weight_tensor = torch.ones(2, 4)  # Element-wise weights

ARGS = {
    'loss': loss_tensor,
    'weight': weight_tensor,
    'reduction': 'mean',
    'avg_factor': None
}
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 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
binary_cross_entropy Not yet run
unverified (harvested, no recorded run)
jyansir/Text2Tree/balanced_loss_utils.py
code served (permissive licence) · get_code("b6381cea04a4f316")
How it ran

no invocation recorded.

read_class_weights Not yet run
unverified (harvested, no recorded run)
jyansir/Text2Tree/model_utils.py
code served (permissive licence) · get_code("80a7b6ea489abd05")
How it ran

no invocation recorded.

Also present in other papers' code

Of 18 samples lifted from this paper's linked repositories, 18 carry a function identity and 0 do not. Of the 18 distinct functions with an identity, 3 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 2 later) and 15 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
reduce_loss 18 other papers
5 dated earlier, 7 later, 6 same year, order not determinable
2003.10152 (2020-03)
SOLOv2: Dynamic and Fast Instance Segmentation
2003.10778 (2020-03)
PanNuke Dataset Extension, Insights and Baselines
2107.08430 (2021-07)
YOLOX: Exceeding YOLO Series in 2021
and 15 more not named here
weight_reduce_loss 7 other papers
3 dated earlier, 2 later, 2 same year, order not determinable
2003.10152 (2020-03)
SOLOv2: Dynamic and Fast Instance Segmentation
2003.10778 (2020-03)
PanNuke Dataset Extension, Insights and Baselines
2107.08430 (2021-07)
YOLOX: Exceeding YOLO Series in 2021
and 4 more not named here
binary_cross_entropy 1 other paper
1 same year, order not determinable
2305.04536 (2023-05)
LMPT: Prompt Tuning with Class-Specific Embedding Loss for Long-tailed Multi-Label Visual Recognition

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

Deep learning approaches exhibit promising performances on various text tasks. However, they are still struggling on medical text classification since samples are often extremely imbalanced and scarce. Different from existing mainstream approaches that focus on supplementary semantics with external medical information, this paper aims to rethink the data challenges in medical texts and present a novel framework-agnostic algorithm called Text2Tree that only utilizes internal label hierarchy in training deep learning models. We embed the ICD code tree structure of labels into cascade attention modules for learning hierarchy-aware label representations. Two new learning schemes, Similarity Surrogate Learning (SSL) and Dissimilarity Mixup Learning (DML), are devised to boost text classification by reusing and distinguishing samples of other labels following the label representation hierarchy, respectively. Experiments on authoritative public datasets and real-world medical records show that our approach stably achieves superior performances over classical and advanced imbalanced classification methods. Our code is available at https://github.com/jyansir/Text2Tree.

For agents

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

get_harvested_code_for_paper("2023.findings-emnlp.517")
get_code_for_paper("2023.findings-emnlp.517")
have("2023.findings-emnlp.517")

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

curl https://syntology.ai/api/ran/2023.findings-emnlp.517.json

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

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

Connect an agent — have() is free.