SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2304.01665 · ICLR · 2024

Mastering Symbolic Operations: Augmenting Language Models with Compiled Neural Networks

Bin Li, Yixuan Weng, Fei Xia, Minjun Zhu, Shizhu He, Kang Liu, Jun Zhao

arXiv · PDF · Open in the Atlas

Code that ran

5 of 11 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (2 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 1 failure of our instrument; 6 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2304.01665.json · badge: /api/ran/2304.01665.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
wengsyx/neural-comprehension canonical (classifier label)
classifier basis: classifier_2025
2 ran · 5 no recorded run
wengsyx/controllm community
Papers with Code archive
2 ran · 1 no recorded run
copy not recorded community
not in the paper's declared repositories
1 ran · 0 no recorded run
FunctionStatusWhere it lives
AttnWrapper Ran
ran on a synthesized input · constructed an object; no result was computed
wengsyx/controllm/ControlLM/falcon/model.py
code served (permissive licence) · get_code("2fdba0a9c7efc372")
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 an instance of its own class, AttnWrapper: the run constructed the object and did not call it, so no result was computed. 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)

# Create a minimal attention module that returns a tuple with activations as first element
class MinimalAttn(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def forward(self, x, *args, **kwargs):
        # Return a tuple where first element is activations (as expected by AttnWrapper)
        output = self.linear(x)
        return (output, None)

# Instantiate the minimal attention module
attn_module = MinimalAttn()

# Define ARGS dict with all parameters of AttnWrapper.__init__
ARGS = {
    'attn': attn_module
}
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 AttnWrapper — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a AttnWrapper 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
BlockOutputWrapper Ran
ran on a synthesized input · constructed an object; no result was computed
wengsyx/controllm/ControlLM/falcon/model.py
code served (permissive licence) · get_code("fbe4b9e916cb63e1")
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 an instance of its own class, BlockOutputWrapper: the run constructed the object and did not call it, so no result was computed. 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)

# Create a minimal stand-in tokenizer
class StandInTokenizer:
    def decode(self, token_id):
        return f"token_{token_id}"

# Create a minimal self-attention module
class MinimalSelfAttention(nn.Module):
    def __init__(self, hidden_size):
        super().__init__()
        self.hidden_size = hidden_size
    
    def forward(self, hidden_states, position_ids=None, **kwargs):
        # Return attention output (same shape as input)
        return (hidden_states,)

# Create a minimal MLP module
class MinimalMLP(nn.Module):
    def __init__(self, hidden_size):
        super().__init__()
        self.linear = nn.Linear(hidden_size, hidden_size)
    
    def forward(self, hidden_states):
        return self.linear(hidden_states)

# Create a minimal transformer block
class MinimalBlock(nn.Module):
    def __init__(self, hidden_size):
        super().__init__()
        self.self_attention = MinimalSelfAttention(hidden_size)
        self.mlp = MinimalMLP(hidden_size)
    
    def forward(self, hidden_states, position_ids=None, **kwargs):
        # Self attention
        attn_out = self.self_attention(hidden_states, position_ids=position_ids, **kwargs)
        hidden_states = attn_out[0]
        
        # MLP
        mlp_out = self.mlp(hidden_states)
        hidden_states = mlp_out
        
        return (hidden_states,)

# Create minimal components
hidden_size = 4
vocab_size = 8

block = MinimalBlock(hidden_size)
unembed_matrix = nn.Linear(hidden_size, vocab_size)
norm = nn.LayerNorm(hidden_size)
tokenizer = StandInTokenizer()

ARGS = {
    "block": block,
    "unembed_matrix": unembed_matrix,
    "norm": norm,
    "tokenizer": tokenizer,
}
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 BlockOutputWrapper — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a BlockOutputWrapper 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
CoNNEmbeddings Ran
ran on a synthesized input
wengsyx/neural-comprehension/NeuralCom/CoNN/modeling_conn.py
code served (permissive licence) · get_code("dd791f54ccd3df38")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float, shape (2, 3, 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
from torch import nn

class CoNNEmbeddings(nn.Module):
    """Construct the embeddings from word, position and token_type embeddings."""

    def __init__(self, config):
        super().__init__()
        self.word_embeddings = nn.Embedding(config.vocab_size, config.hidden_size, padding_idx=config.pad_token_id)
        self.position_embeddings = nn.Embedding(config.max_position_embeddings, config.hidden_size)
        self.dropout = nn.Dropout(config.hidden_dropout_prob)

    def forward(self, input_ids: torch.LongTensor = None) -> torch.Tensor:
        embeddings = self.word_embeddings(input_ids)
        position_embeddings = self.position_embeddings(torch.tensor(list(range(input_ids.size(1)))).to(input_ids.device))
        embeddings += position_embeddings
        embeddings = self.dropout(embeddings)
        return embeddings


class Config:
    def __init__(self, vocab_size, hidden_size, pad_token_id, max_position_embeddings, hidden_dropout_prob):
        self.vocab_size = vocab_size
        self.hidden_size = hidden_size
        self.pad_token_id = pad_token_id
        self.max_position_embeddings = max_position_embeddings
        self.hidden_dropout_prob = hidden_dropout_prob


INIT_ARGS = {
    "config": Config(
        vocab_size=100,
        hidden_size=4,
        pad_token_id=0,
        max_position_embeddings=16,
        hidden_dropout_prob=0.1
    )
}

ARGS = {
    "input_ids": torch.randint(0, 100, (2, 3), dtype=torch.long)
}

if __name__ == "__main__":
    model = CoNNEmbeddings(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Output: {output}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 3, 4) — shape (2, 3, 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
TransformerEncoder Ran
ran on a synthesized input
wengsyx/neural-comprehension/NeuralCom/CoNN/modeling_conn.py
code served (permissive licence) · get_code("9df2036489261543")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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
from torch import nn
from types import SimpleNamespace

# Create a minimal config
config = SimpleNamespace(
    num_hidden_layers=2,
    hidden_size=8,
    layer_norm=True
)

# Create a minimal encoder layer that matches the expected interface
class MinimalEncoderLayer(nn.Module):
    def __init__(self, hidden_size):
        super().__init__()
        self.linear = nn.Linear(hidden_size, hidden_size)
    
    def forward(self, src, src_mask=None, src_key_padding_mask=None):
        return self.linear(src)

encoder_layer = MinimalEncoderLayer(config.hidden_size)

INIT_ARGS = {
    'encoder_layer': encoder_layer,
    'config': config
}

# Create input tensor with shape (seq_len=5, batch_size=2, hidden_size=8)
src = torch.randn(5, 2, 8)

ARGS = {
    'src': src,
    'mask': None,
    'src_key_padding_mask': None
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
add_vector_after_position Ran
ran; our contract draft was wrong, not the code
this paper's copy was not recorded; identical code first harvested from wengsyx/controllm
pointer only · get_code("756d705bfd684fbd")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

CoNNConfig Not yet run
unverified (harvested, no recorded run)
wengsyx/neural-comprehension/NeuralCom/CoNN/modeling_conn.py
code served (permissive licence) · get_code("0d3b9b4818b3579c")
How it ran

no invocation recorded.

CoNNModel Not yet run
unverified (harvested, no recorded run)
wengsyx/neural-comprehension/NeuralCom/CoNN/modeling_conn.py
code served (permissive licence) · get_code("67acc76bace2a9f7")
How it ran

no invocation recorded.

CoNNPreTrainedModel Not yet run
unverified (harvested, no recorded run)
wengsyx/neural-comprehension/NeuralCom/CoNN/modeling_conn.py
code served (permissive licence) · get_code("5944800bcff3213c")
How it ran

no invocation recorded.

FalconControlLM Not yet run
unverified (harvested, no recorded run)
wengsyx/controllm/ControlLM/falcon/model.py
code served (permissive licence) · get_code("d533386a26ebc88e")
How it ran

no invocation recorded.

MultiheadAttention Not yet run
unverified (harvested, no recorded run)
wengsyx/neural-comprehension/NeuralCom/CoNN/modeling_conn.py
code served (permissive licence) · get_code("3e1a3d7b3bf9ed48")
How it ran

no invocation recorded.

TransformerEncoderLayer Not yet run
unverified (harvested, no recorded run)
wengsyx/neural-comprehension/NeuralCom/CoNN/modeling_conn.py
code served (permissive licence) · get_code("17a235d61eb3ac7a")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 1 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 1 later) and 10 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
add_vector_after_position
brick of this paper's assembly: helper
1 other paper
1 later
2402.10151 (2024-02)
ControlLM: Crafting Diverse Personalities for Language Models

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

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

Abstract

Language models' (LMs) proficiency in handling deterministic symbolic reasoning and rule-based tasks remains limited due to their dependency implicit learning on textual data. To endow LMs with genuine rule comprehension abilities, we propose "Neural Comprehension" -a framework that synergistically integrates compiled neural networks (CoNNs) into the standard transformer architecture. CoNNs are neural modules designed to explicitly encode rules through artificially generated attention weights. By incorporating CoNN modules, the Neural Comprehension framework enables LMs to accurately and robustly execute rule-intensive symbolic tasks. Extensive experiments demonstrate the superiority of our approach over existing techniques in terms of length generalization, efficiency, and interpretability for symbolic operations. Furthermore, it can be applied to LMs across different model scales, outperforming tool-calling methods in arithmetic reasoning tasks while maintaining superior inference efficiency. Our work highlights the potential of seamlessly unifying explicit rule learning via CoNNs and implicit pattern learning in LMs, paving the way for true symbolic comprehension capabilities.

For agents

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

get_harvested_code_for_paper("2304.01665")
get_code_for_paper("2304.01665")
have("2304.01665")

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

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

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

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

Connect an agent — have() is free.