SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2105.12848 · ACL · 2021

BERTifying the Hidden Markov Model for Multi-Source Weakly Supervised Named Entity Recognition

Le Song, Chao Zhang, Yinghao Li, Pranav Shetty, Lucas Liu

arXiv · PDF · Open in the Atlas

Code that ran

10 of 20 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 3 have no contract verdict; 7 failures of our instrument; 10 no recorded run), measured 2026-11-23; 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/2105.12848.json · badge: /api/ran/2105.12848.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
Yinghao-Li/CHMM-ALT canonical (classifier label)
classifier basis: census
7 ran · 8 no recorded run
Yinghao-Li/Sparse-CHMM community (classifier label)
classifier basis not recorded on the link
3 ran · 2 no recorded run
FunctionStatusWhere it lives
batch_prep Ran
ran on a synthesized input
Yinghao-Li/Sparse-CHMM/sparse_chmm/collate.py
code served (permissive licence) · get_code("6a3a0bf29f78b0d6")
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)

# Parameters for batch_prep
# emb_list: list of embedding tensors, each of shape [seq_len, d_emb]
# obs_list: list of observation tensors, each of shape [seq_len, n_src, n_obs]
# txt_list: optional list of text lists
# lbs_list: optional list of label dicts

d_emb = 4
n_src = 3
n_obs = 5

# Create first instance
seq_len_1 = 6
emb_1 = torch.randn(seq_len_1, d_emb)
obs_1 = torch.randn(seq_len_1, n_src, n_obs)
txt_1 = ["text_0", "text_1", "text_2", "text_3", "text_4", "text_5"]
lbs_1 = {i: {"label": i} for i in range(seq_len_1)}

# Create second instance
seq_len_2 = 4
emb_2 = torch.randn(seq_len_2, d_emb)
obs_2 = torch.randn(seq_len_2, n_src, n_obs)
txt_2 = ["text_0", "text_1", "text_2", "text_3"]
lbs_2 = {i: {"label": i} for i in range(seq_len_2)}

emb_list = [emb_1, emb_2]
obs_list = [obs_1, obs_2]
txt_list = [txt_1, txt_2]
lbs_list = [lbs_1, lbs_2]

ARGS = {
    "emb_list": emb_list,
    "obs_list": obs_list,
    "txt_list": txt_list,
    "lbs_list": lbs_list,
}
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
binary_search Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
Yinghao-Li/CHMM-ALT/data_constr/src/data.py
code served (permissive licence) · get_code("07c3eac7eb4ccba4")
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, 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

# Analyzing the function:
# - start: int, used in comparison with interval_end and interval_start
# - end: int, used in comparison with interval_end and interval_start
# - intervals: list/sequence, indexed with mid, each element unpacked as (interval_start, interval_end)

# The function performs binary search on a list of intervals
# Each interval is a tuple of (start, end) values

# Create a list of intervals (tuples of start, end positions)
intervals = [
    (0, 5),
    (5, 10),
    (10, 15),
    (15, 20),
    (20, 25),
]

# Create test parameters for binary search
start = 7
end = 18

ARGS = {
    "start": start,
    "end": end,
    "intervals": intervals,
}
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, ndim 1, dtype family int — a tuple 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
first_nonzero_idx Ran
ran; our contract draft was wrong, not the code
Yinghao-Li/CHMM-ALT/data_constr/src/util.py
code served (permissive licence) · get_code("0bbaea3681a4d767")
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 1, dtype family int, shape (2,) 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 numpy as np

torch.manual_seed(0)

# Create a small tensor with some zeros
x = torch.tensor([
    [1.0, 0.0, 2.0, 0.0],
    [0.0, 3.0, 0.0, 4.0]
])

ARGS = {
    "x": x,
    "dim": -1
}
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 Tensor, ndim 1, dtype family int, shape (2,) — shape (2,) 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_overlaps Ran
ran; our contract draft was wrong, not the code
Yinghao-Li/CHMM-ALT/data_constr/src/data.py
code served (permissive licence) · get_code("93b0b65911d51415")
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 2, 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

torch.manual_seed(0)

# Construct annotations dictionary
# annotations[source][interval] = value
# where interval is a tuple (start, end)
annotations = {
    "source_1": {
        (0, 5): "label_a",
        (10, 15): "label_b",
        (20, 25): "label_c",
    },
    "source_2": {
        (3, 8): "label_x",
        (18, 22): "label_y",
    },
}

# Sort intervals for binary_search to work correctly
for source in annotations:
    annotations[source] = dict(sorted(annotations[source].items()))

start = 4
end = 21
sources = ["source_1", "source_2"]

ARGS = {
    "start": start,
    "end": end,
    "annotations": annotations,
    "sources": sources,
}
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, ndim 2, 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
load_conll_2003_data Ran
ran; our contract draft was wrong, not the code
Yinghao-Li/CHMM-ALT/data_constr/src/io.py
code served (permissive licence) · get_code("80f211d366ececf3")
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 tempfile
import os

# Create a temporary file with CoNLL 2003 format data
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt')

# Write sample CoNLL 2003 format data
conll_data = """-DOCSTART- -X- -X- O

The O
quick O
brown O
fox B-PER
jumps O
.  O

John B-PER
Doe I-PER
works O
here O
.  O

-DOCSTART- -X- -X- O

Paris B-LOC
is O
nice O
.  O

"""

temp_file.write(conll_data)
temp_file.close()

ARGS = {
    'file_name': temp_file.name
}
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 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
load_src_metrics Ran
ran; our contract draft was wrong, not the code
Yinghao-Li/CHMM-ALT/src/chmm/dataset.py
code served (permissive licence) · get_code("f837fba980069ba0")
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 json
import tempfile
import os

# Create a temporary file with sample metrics data
temp_dir = tempfile.mkdtemp()
file_path = os.path.join(temp_dir, "metrics.json")

# Create sample metrics data structure
sample_metrics = {
    "source_1": {
        "accuracy": 0.95,
        "precision": 0.92,
        "recall": 0.88,
        "f1": 0.90
    },
    "source_2": {
        "accuracy": 0.87,
        "precision": 0.85,
        "recall": 0.89,
        "f1": 0.87
    },
    "source_3": {
        "accuracy": 0.91,
        "precision": 0.90,
        "recall": 0.92,
        "f1": 0.91
    }
}

# Write the metrics to the temporary file
with open(file_path, 'w', encoding='UTF-8') as f:
    json.dump(sample_metrics, f)

ARGS = {
    "file_path": file_path
}
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
log_matmul Ran
ran on a synthesized input
Yinghao-Li/Sparse-CHMM/sparse_chmm/math.py
code served (permissive licence) · get_code("294c159dee8bc557")
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, 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 two log-domain matrices for log_matmul
# a should be m x n
# b should be n x p
# Using distinct sizes: m=2, n=4, p=3

a = torch.randn(2, 4)  # m x n matrix in log domain
b = torch.randn(4, 3)  # n x p matrix in log domain

ARGS = {
    "a": a,
    "b": b,
}
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, 3) — shape (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
logsumexp Ran
ran on a synthesized input
Yinghao-Li/Sparse-CHMM/sparse_chmm/math.py
code served (permissive licence) · get_code("9b68df96cc5a0174")
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 numpy as np

torch.manual_seed(0)

# Create a small tensor for testing
x = torch.randn(2, 4)

ARGS = {
    'x': x,
    'dim': None,
    'keepdim': False,
}
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 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
one_hot Ran
ran; our contract draft was wrong, not the code
Yinghao-Li/CHMM-ALT/data_constr/src/util.py
code served (permissive licence) · get_code("94f946467c015b2d")
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, 3, 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
import numpy as np

torch.manual_seed(0)

# Create a small batch of integer indices
# Shape: (batch_size=2, seq_length=3)
x = torch.LongTensor([[0, 1, 2], [1, 2, 0]])

# Number of classes
n_class = 3

ARGS = {
    "x": x,
    "n_class": n_class,
}
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 Tensor, ndim 3, dtype family float, shape (2, 3, 3) — shape (2, 3, 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
one_hot_to_string Ran
ran; our contract draft was wrong, not the code
Yinghao-Li/CHMM-ALT/data_constr/src/util.py
code served (permissive licence) · get_code("ceaaa5aea0a1ffec")
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 torch.nn as nn

torch.manual_seed(0)

# The function takes a tensor x of shape (lengths, |obs_set|)
# It calls x.max(dim=1)[1] which returns the indices of max values along dim 1
# Then it iterates over those indices to create a list

# Create a small one-hot encoded tensor
# Shape: (batch_size=2, num_classes=4)
x = torch.tensor([
    [0.1, 0.9, 0.0, 0.0],  # max at index 1
    [0.0, 0.0, 0.8, 0.2],  # max at index 2
], dtype=torch.float32)

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 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
batch_prep Not yet run
unverified (harvested, no recorded run)
Yinghao-Li/CHMM-ALT/src/chmm/dataset.py
code served (permissive licence) · get_code("796e527adb2ed3d8")
How it ran

no invocation recorded.

bc5cdr_annotators Not yet run
unverified (harvested, no recorded run)
Yinghao-Li/CHMM-ALT/data_constr/src/wiser_annotator.py
code served (permissive licence) · get_code("ebe8e4be2bc36479")
How it ran

no invocation recorded.

collate_fn Not yet run
unverified (harvested, no recorded run)
Yinghao-Li/CHMM-ALT/src/chmm/dataset.py
code served (permissive licence) · get_code("0e2242a9ea204327")
How it ran

no invocation recorded.

collate_fn Not yet run
unverified (harvested, no recorded run)
Yinghao-Li/Sparse-CHMM/sparse_chmm/collate.py
code served (permissive licence) · get_code("e14737726145e981")
How it ran

no invocation recorded.

construct_spacy_doc Not yet run
unverified (harvested, no recorded run)
Yinghao-Li/CHMM-ALT/data_constr/src/skweak_annotator.py
code served (permissive licence) · get_code("1513a7e3c40ee51a")
How it ran

no invocation recorded.

laptop_annotators Not yet run
unverified (harvested, no recorded run)
Yinghao-Li/CHMM-ALT/data_constr/src/wiser_annotator.py
code served (permissive licence) · get_code("b7f01e56a9691559")
How it ran

no invocation recorded.

load_bc5cdr_sentences Not yet run
unverified (harvested, no recorded run)
Yinghao-Li/CHMM-ALT/data_constr/src/io.py
code served (permissive licence) · get_code("4182f6dbfbb21083")
How it ran

no invocation recorded.

load_wikigold_data Not yet run
unverified (harvested, no recorded run)
Yinghao-Li/CHMM-ALT/data_constr/src/io.py
code served (permissive licence) · get_code("223f33cec8c8003d")
How it ran

no invocation recorded.

log_maxmul Not yet run
unverified (harvested, no recorded run)
Yinghao-Li/Sparse-CHMM/sparse_chmm/math.py
code served (permissive licence) · get_code("e89483f11a57dcbe")
How it ran

no invocation recorded.

ncbi_annotators Not yet run
unverified (harvested, no recorded run)
Yinghao-Li/CHMM-ALT/data_constr/src/wiser_annotator.py
code served (permissive licence) · get_code("092662782020e348")
How it ran

no invocation recorded.

Also present in other papers' code

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

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

We study the problem of learning a named entity recognition (NER) tagger using noisy labels from multiple weak supervision sources. Though cheap to obtain, the labels from weak supervision sources are often incomplete, inaccurate, and contradictory, making it difficult to learn an accurate NER model. To address this challenge, we propose a conditional hidden Markov model (CHMM), which can effectively infer true labels from multi-source noisy labels in an unsupervised way. CHMM enhances the classic hidden Markov model with the contextual representation power of pretrained language models. Specifically, CHMM learns token-wise transition and emission probabilities from the BERT embeddings of the input tokens to infer the latent true labels from noisy observations. We further refine CHMM with an alternate-training approach (CHMM-ALT). It fine-tunes a BERT-NER model with the labels inferred by CHMM, and this BERT-NER's output is regarded as an additional weak source to train the CHMM in return. Experiments on four NER benchmarks from various domains show that our method outperforms state-of-the-art weakly supervised NER models by wide margins.

For agents

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

get_harvested_code_for_paper("2105.12848")
get_code_for_paper("2105.12848")
have("2105.12848")

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

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

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

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

Connect an agent — have() is free.