SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2206.13289 · NAACL · 2022

Analyzing Encoded Concepts in Transformer Language Models

Nadir Durrani, Jia Xu, Hassan Sajjad, Rafae Khan, ⋄ Fahim, Dalvi Firoj, Alam Abdul

arXiv · PDF · Open in the Atlas

Code that ran

5 of 5 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 5 have no contract verdict; 0 failures of our instrument; 0 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/2206.13289.json · badge: /api/ran/2206.13289.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
hsajjad/conceptx canonical (classifier label)
classifier basis not recorded on the link
5 ran · 0 no recorded run
FunctionStatusWhere it lives
convert_examples_to_features Ran
ran on a synthesized input
hsajjad/conceptx/auto_labels/Taggers/Chunking/utils_ner.py
code served (permissive licence) · get_code("28cacb28a4c8d0bc")
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 logging
from dataclasses import dataclass
from typing import List, Optional

# Configure logging to suppress info messages
logging.basicConfig(level=logging.WARNING)

# Create a minimal stand-in tokenizer
class MockTokenizer:
    def __init__(self):
        self.model_input_names = ['input_ids', 'attention_mask', 'token_type_ids']
    
    def tokenize(self, word):
        # Simple tokenization: split into characters or return word as single token
        if word.lower() == 'hello':
            return ['hello']
        elif word.lower() == 'world':
            return ['world']
        else:
            return [word]
    
    def convert_tokens_to_ids(self, tokens):
        # Simple token to id mapping
        token_to_id = {
            '[CLS]': 101,
            '[SEP]': 102,
            '[PAD]': 0,
            'hello': 1000,
            'world': 1001,
            'my': 1002,
            'name': 1003,
            'is': 1004,
            'john': 1005,
        }
        return [token_to_id.get(token, 999) for token in tokens]
    
    def num_special_tokens_to_add(self):
        # BERT-like: [CLS] and [SEP]
        return 2

# Create InputExample instances
examples = [
    {
        'guid': 'train-1',
        'words': ['hello', 'world'],
        'labels': ['O', 'O']
    },
    {
        'guid': 'train-2',
        'words': ['my', 'name', 'is', 'john'],
        'labels': ['O', 'O', 'O', 'B-PER']
    }
]

# Convert to InputExample dataclass instances
@dataclass
class InputExample:
    guid: str
    words: List[str]
    labels: Optional[List[str]]

input_examples = [
    InputExample(guid=ex['guid'], words=ex['words'], labels=ex['labels'])
    for ex in examples
]

# Label list for NER task
label_list = ['O', 'B-PER', 'I-PER', 'B-LOC', 'I-LOC']

# Create tokenizer
tokenizer = MockTokenizer()

# Define all arguments
ARGS = {
    'examples': input_examples,
    'label_list': label_list,
    'max_seq_length': 16,
    'tokenizer': tokenizer,
    'cls_token_at_end': False,
    'cls_token': '[CLS]',
    'cls_token_segment_id': 0,
    'sep_token': '[SEP]',
    'sep_token_extra': False,
    'pad_on_left': False,
    'pad_token': 0,
    'pad_token_segment_id': 0,
    'pad_token_label_id': -100,
    'sequence_a_segment_id': 0,
    'mask_padding_with_zero': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
fileRead Ran
ran on a synthesized input
hsajjad/conceptx/auto_labels/Taggers/Chunking/changeToSent.py
code served (permissive licence) · get_code("c8fb56215e59f08e")
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 test data
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt')
temp_file.write("word1 word2 word3\n")
temp_file.write("word4 word5 word6\n")
temp_file.write("\n")
temp_file.write("word7 word8 word9\n")
temp_file.write("word10 word11 word12\n")
temp_file.write("\n")
temp_file.close()

fname = temp_file.name
index = 1

ARGS = {
    'fname': fname,
    'index': index
}
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
get_labels Ran
ran on a synthesized input
hsajjad/conceptx/auto_labels/Taggers/Chunking/utils_ner.py
code served (permissive licence) · get_code("d39c306c0c99b333")
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 labels
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt')
temp_file.write('B-MISC\nI-MISC\nB-PER\nI-PER\nB-ORG\nI-ORG\nB-LOC\nI-LOC')
temp_file.close()
temp_path = temp_file.name

ARGS = {
    'path': temp_path
}

# Clean up will happen after execution, but we pass the valid path
# Alternatively, test with empty path:
# ARGS = {
#     '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 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
read_examples_from_file Ran
ran on a synthesized input
hsajjad/conceptx/auto_labels/Taggers/Chunking/utils_ner.py
code served (permissive licence) · get_code("10fcfcf3616b6150")
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 os
import tempfile
from dataclasses import dataclass
from enum import Enum
from typing import List, Optional, Union

@dataclass
class InputExample:
    """
    A single training/test example for token classification.
    Args:
        guid: Unique id for the example.
        words: list. The words of the sequence.
        labels: (Optional) list. The labels for each word of the sequence. This should be
        specified for train and dev examples, but not for test examples.
    """
    guid: str
    words: List[str]
    labels: Optional[List[str]]

class Split(Enum):
    train = 'train'
    dev = 'dev'
    test = 'test'

def read_examples_from_file(data_dir, mode: Union[Split, str]) -> List[InputExample]:
    if isinstance(mode, Split):
        mode = mode.value
    file_path = os.path.join(data_dir, f'{mode}.txt')
    guid_index = 1
    examples = []
    with open(file_path, encoding='utf-8') as f:
        words = []
        labels = []
        for line in f:
            if line.startswith('-DOCSTART-') or line == '' or line == '\n':
                if words:
                    examples.append(InputExample(guid=f'{mode}-{guid_index}', words=words, labels=labels))
                    guid_index += 1
                    words = []
                    labels = []
            else:
                splits = line.split(' ')
                words.append(splits[0])
                if len(splits) > 1:
                    labels.append(splits[-1].replace('\n', ''))
                else:
                    labels.append('O')
        if words:
            examples.append(InputExample(guid=f'{mode}-{guid_index}', words=words, labels=labels))
    return examples

# Create a temporary directory with a test file
temp_dir = tempfile.mkdtemp()
test_file_path = os.path.join(temp_dir, 'train.txt')

# Write sample data to the test file
with open(test_file_path, 'w', encoding='utf-8') as f:
    f.write('John B-PER\n')
    f.write('Doe I-PER\n')
    f.write('works O\n')
    f.write('at O\n')
    f.write('Google B-ORG\n')
    f.write('\n')
    f.write('Paris B-LOC\n')
    f.write('is O\n')
    f.write('nice O\n')

ARGS = {
    'data_dir': temp_dir,
    'mode': 'train'
}
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
strSorting Ran
ran on a synthesized input
hsajjad/conceptx/auto_labels/Trivials/trivialLabels.py
code served (permissive licence) · get_code("5e3b932e47c623b7")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

ARGS = {
    "lst": ["apple", "pie", "a", "banana", "testing"]
}
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 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

Also present in other papers' code

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

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 propose a novel framework ConceptX, to analyze how latent concepts are encoded in representations learned within pre-trained language models. It uses clustering to discover the encoded concepts and explains them by aligning with a large set of human-defined concepts. Our analysis on seven transformer language models reveal interesting insights: i) the latent space within the learned representations overlap with different linguistic concepts to a varying degree, ii) the lower layers in the model are dominated by lexical concepts (e.g., affixation), whereas the core-linguistic concepts (e.g., morphological or syntactic relations) are better represented in the middle and higher layers, iii) some encoded concepts are multi-faceted and cannot be adequately explained using the existing human-defined concepts. 1

For agents

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

get_harvested_code_for_paper("2206.13289")
get_code_for_paper("2206.13289")
have("2206.13289")

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

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

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

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

Connect an agent — have() is free.