SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2010.00309 · 2020

CoLAKE: Contextualized Language and Knowledge Embedding

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; 0 honoured the contract we drafted, 0 violated it and 6 have no contract verdict; 0 failures of our instrument; 1 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/2010.00309.json · badge: /api/ran/2010.00309.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/CoLAKE canonical (classifier label)
classifier basis: census
6 ran · 1 no recorded run
FunctionStatusWhere it lives
batchify Ran
ran on a synthesized input
txsun1997/CoLAKE/lama/batch_eval_KB_completion.py
code served (permissive licence) · get_code("11b8618df0ea9846")
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 sample data
# Each sample needs 'masked_sentences' which is a list of sentences
# The function sorts by the length of ' '.join(masked_sentences).split()
# So we create samples with different sentence lengths

sample1 = {
    'masked_sentences': ['The cat sat on the mat'],
    'label': 0
}

sample2 = {
    'masked_sentences': ['A quick brown fox'],
    'label': 1
}

sample3 = {
    'masked_sentences': ['The dog ran very quickly through the park today'],
    'label': 2
}

sample4 = {
    'masked_sentences': ['Hello world'],
    'label': 3
}

data = [sample1, sample2, sample3, sample4]
batch_size = 2

ARGS = {
    'data': data,
    'batch_size': batch_size
}
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
build_label_vocab Ran
ran on a synthesized input
txsun1997/CoLAKE/finetune/utils.py
code served (permissive licence) · get_code("8dbb7d15478e3d54")
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 os
import json
import tempfile

# Create a temporary directory for our test data
temp_dir = tempfile.mkdtemp()

# Create train.json for 're' task type
re_data = [
    {'label': 'relation1'},
    {'label': 'relation2'},
    {'label': 'relation1'},
    {'label': 'relation3'},
]

with open(os.path.join(temp_dir, 'train.json'), 'w', encoding='utf-8') as f:
    json.dump(re_data, f)

ARGS = {
    'data_dir': temp_dir,
    'task_type': 're'
}
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
build_temp_ent_vocab Ran
ran on a synthesized input
txsun1997/CoLAKE/finetune/utils.py
code served (permissive licence) · get_code("4319c3972840dc94")
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 os
import json
import tempfile
import shutil

# Create a temporary directory structure with the required JSON files
temp_dir = tempfile.mkdtemp()

# Create sample data files
train_data = [
    {
        'nodes': ['Q1', 'Q2', 'some_string', 'Q3']
    },
    {
        'nodes': ['Q1', 'not_entity']
    }
]

dev_data = [
    {
        'nodes': ['Q2', 'Q4', 'Q1']
    }
]

test_data = [
    {
        'nodes': ['Q5', 'Q1', 'random_text']
    }
]

# Write the JSON files
with open(os.path.join(temp_dir, 'train.json'), 'w', encoding='utf-8') as f:
    json.dump(train_data, f)

with open(os.path.join(temp_dir, 'dev.json'), 'w', encoding='utf-8') as f:
    json.dump(dev_data, f)

with open(os.path.join(temp_dir, 'test.json'), 'w', encoding='utf-8') as f:
    json.dump(test_data, f)

ARGS = {
    'path': temp_dir
}
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
filter_samples Ran
ran on a synthesized input
txsun1997/CoLAKE/lama/batch_eval_KB_completion.py
code served (permissive licence) · get_code("a2861d9c873073be")
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 torch.nn as nn

class StandInModel(nn.Module):
    def __init__(self):
        super().__init__()
        # vocab maps indices to words
        self.vocab = ['the', 'cat', 'dog', 'sat', 'on', 'mat', 'jumped', 'over']
    
    def get_id(self, word):
        """Return list of indices for a word, or None if not in vocab"""
        if word in self.vocab:
            idx = self.vocab.index(word)
            return [idx]
        # Check if word is a multi-word phrase
        parts = word.split()
        if all(p in self.vocab for p in parts):
            return [self.vocab.index(p) for p in parts]
        return None

model = StandInModel()

samples = [
    {
        'obj_label': 'cat',
        'sub_label': 'subject1',
        'masked_sentences': ['the', 'cat', 'sat'],
        'judgments': [
            {'judgment': 'yes'},
            {'judgment': 'yes'},
            {'judgment': 'no'}
        ]
    },
    {
        'obj_label': 'dog',
        'sub_label': 'subject2',
        'masked_sentences': ['the', 'dog', 'jumped', 'over', 'mat'],
        'judgments': [
            {'judgment': 'yes'},
            {'judgment': 'yes'}
        ]
    },
    {
        'obj_label': 'elephant',
        'sub_label': 'subject3',
        'masked_sentences': ['the', 'elephant', 'walked']
    },
    {
        'sub_label': 'subject4',
        'masked_sentences': ['incomplete', 'sample']
    }
]

vocab_subset = {'cat', 'dog', 'sat', 'the', 'jumped', 'over', 'mat'}

max_sentence_length = 10

template = []

ARGS = {
    'model': model,
    'samples': samples,
    'vocab_subset': vocab_subset,
    'max_sentence_length': max_sentence_length,
    'template': template
}
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_negation_metric Ran
ran on a synthesized input
txsun1997/CoLAKE/lama/evaluation_metrics.py
code served (permissive licence) · get_code("f553046649ddd6e7")
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 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 numpy as np
import scipy.stats

torch.manual_seed(0)

# Create small tensors for log probabilities
# Shape: [batch_size, vocab_size] = [2, 1000] (vocab size must be large enough for topk=1000)
log_probs = torch.randn(2, 1000)
log_probs_negated = torch.randn(2, 1000)

# Create masked indices - these index into the first dimension of log_probs
masked_indices = torch.tensor([0, 1])
masked_indices_negated = torch.tensor([0])

# Create a small vocab (dict mapping indices to words)
vocab = {i: f"word_{i}" for i in range(1000)}

# Index list parameter (optional, set to None as it's not used in the function body)
index_list = None

# topk parameter
topk = 10

ARGS = {
    "log_probs": log_probs,
    "masked_indices": masked_indices,
    "log_probs_negated": log_probs_negated,
    "masked_indices_negated": masked_indices_negated,
    "vocab": vocab,
    "index_list": index_list,
    "topk": topk,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy, 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 float — 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
get_ranking Ran
ran on a synthesized input
txsun1997/CoLAKE/lama/evaluation_metrics.py
code served (permissive licence) · get_code("c992a67a3fe6661d")
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 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 numpy as np

torch.manual_seed(0)

# Create log_probs: a 2D tensor of shape (2, 5) containing log probabilities
log_probs = torch.randn(2, 5)

# Create masked_indices: a tensor indicating which row to select
masked_indices = torch.tensor([0, 1])

# Create vocab: a dictionary mapping indices to token strings
vocab = {
    0: "the",
    1: "cat",
    2: "sat",
    3: "on",
    4: "mat"
}

# Create index_list: a mapping from filtered indices to actual vocab indices
index_list = [0, 1, 2, 3, 4]

# label_index: the index we're looking for in the ranking
label_index = 1

ARGS = {
    "log_probs": log_probs,
    "masked_indices": masked_indices,
    "vocab": vocab,
    "label_index": label_index,
    "index_list": index_list,
    "topk": 5,
    "P_AT": 10,
    "print_generation": True
}
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 float — 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
download_file_from_google_drive Not yet run
unverified (harvested, no recorded run)
txsun1997/CoLAKE/download_gdrive.py
code served (permissive licence) · get_code("c23741b45f0d0d67")
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, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 1 later) and 6 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
download_file_from_google_drive 2 other papers
1 dated earlier, 1 later
1903.03372 (2019-03)
Semantically Tied Paired Cycle Consistency for Zero-Shot Sketch-based Image Retrieval
2025.emnlp-industry.89 (2025 (year only))
L4: Mutual Learning Helps Lifelong Language Learning

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

With the emerging branch of incorporating factual knowledge into pre-trained language models such as BERT, most existing models consider shallow, static, and separately pre-trained entity embeddings, which limits the performance gains of these models. Few works explore the potential of deep contextualized knowledge representation when injecting knowledge. In this paper, we propose the Contextualized Language and Knowledge Embedding (CoLAKE), which jointly learns contextualized representation for both language and knowledge with the extended MLM objective. Instead of injecting only entity embeddings, CoLAKE extracts the knowledge context of an entity from large-scale knowledge bases. To handle the heterogeneity of knowledge context and language context, we integrate them in a unified data structure, word-knowledge graph (WK graph). CoLAKE is pre-trained on large-scale WK graphs with the modified Transformer encoder. We conduct experiments on knowledge-driven tasks, knowledge probing tasks, and language understanding tasks. Experimental results show that CoLAKE outperforms previous counterparts on most of the tasks. Besides, CoLAKE achieves surprisingly high performance on our synthetic task called word-knowledge graph completion, which shows the superiority of simultaneously contextualizing language and knowledge representation.

For agents

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

get_harvested_code_for_paper("2010.00309")
get_code_for_paper("2010.00309")
have("2010.00309")

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

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

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

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

Connect an agent — have() is free.