SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2203.08459 · ACL · 2022

KinyaBERT: a Morphology-aware Kinyarwanda Language Model

Andre Rubungo, Antoine Nzeyimana

arXiv · PDF · Open in the Atlas

Code that ran

6 of 12 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 2 have no contract verdict; 4 failures 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/2203.08459.json · badge: /api/ran/2203.08459.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
anzeyimana/kinyabert-acl2022 marked official in Papers with Code
Papers with Code archive
6 ran · 6 no recorded run
FunctionStatusWhere it lives
BertHeadTransform Ran
ran on a synthesized input · constructed an object; no result was computed
anzeyimana/kinyabert-acl2022/code/morpho_model.py
code served (permissive licence) · get_code("569684d0b33a366a")
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, BertHeadTransform: 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
import math

torch.manual_seed(0)

ARGS = {
    "tr_d_model": 4,
    "cls_ctxt_size": 3,
    "layernorm_epsilon": 1e-12
}
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 BertHeadTransform — 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 BertHeadTransform 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
TransformerEncoder Ran
ran on a synthesized input · constructed an object; no result was computed
anzeyimana/kinyabert-acl2022/code/morpho_model.py
code served (permissive licence) · get_code("2a17165c2e7e0311")
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, TransformerEncoder: 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)

class TransformerEncoderLayer(nn.Module):
    """Minimal TransformerEncoderLayer for testing"""
    def __init__(self, d_model, nhead):
        super().__init__()
        self.d_model = d_model
        self.nhead = nhead
        self.self_attn = nn.MultiheadAttention(d_model, nhead, batch_first=False)
        self.linear1 = nn.Linear(d_model, d_model * 4)
        self.linear2 = nn.Linear(d_model * 4, d_model)
        self.norm1 = nn.LayerNorm(d_model)
        self.norm2 = nn.LayerNorm(d_model)
        self.dropout = nn.Dropout(0.1)
    
    def forward(self, src, src_mask=None, attn_bias=None, src_key_padding_mask=None):
        # Self-attention
        attn_output, _ = self.self_attn(
            src, src, src, 
            attn_mask=src_mask,
            key_padding_mask=src_key_padding_mask
        )
        src = src + self.dropout(attn_output)
        src = self.norm1(src)
        
        # Feed-forward
        ff_output = self.linear2(self.dropout(torch.relu(self.linear1(src))))
        src = src + self.dropout(ff_output)
        src = self.norm2(src)
        
        return src

# Create encoder layer
encoder_layer = TransformerEncoderLayer(d_model=4, nhead=2)

# Create LayerNorm for the encoder
norm = nn.LayerNorm(4)

# Create source tensor: (seq_len=3, batch_size=2, d_model=4)
src = torch.randn(3, 2, 4)

# Optional mask (attention mask)
mask = None

# Optional attention bias
attn_bias = None

# Optional source key padding mask
src_key_padding_mask = None

ARGS = {
    "encoder_layer": encoder_layer,
    "num_layers": 2,
    "norm": norm,
}
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 TransformerEncoder — 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 TransformerEncoder 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
_get_activation_fn Ran
ran; our contract draft was wrong, not the code
anzeyimana/kinyabert-acl2022/code/morpho_model.py
code served (permissive licence) · get_code("b97233bc0d62d1ca")
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 torch
import torch.nn as nn
import torch.nn.functional as F

torch.manual_seed(0)

ARGS = {
    'activation': 'relu'
}
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 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
_get_clones Ran
ran; our contract draft was wrong, not the code
anzeyimana/kinyabert-acl2022/code/morpho_model.py
code served (permissive licence) · get_code("6f8db6b6c8658306")
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) and returned ModuleList. 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
from torch.nn import Module, Linear, LayerNorm, Dropout, ModuleList
import copy

torch.manual_seed(0)

# Create a simple module to be cloned
class SimpleModule(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = Linear(4, 3)
        self.norm = LayerNorm(3)
        self.dropout = Dropout(0.1)
    
    def forward(self, x):
        x = self.linear(x)
        x = self.norm(x)
        x = self.dropout(x)
        return x

# Instantiate the module
module = SimpleModule()

# Number of clones to create
N = 3

ARGS = {
    "module": module,
    "N": N
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ModuleList — a ModuleList output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ModuleList output the recorded ndim 1 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
multi_head_attention_forward Ran
ran; our contract draft was wrong, not the code
anzeyimana/kinyabert-acl2022/code/morpho_model.py
code served (permissive licence) · get_code("6b3df8438d1f1eb3")
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

torch.manual_seed(0)

# Parameters
batch_size = 2
seq_len_query = 3
seq_len_key = 4
embed_dim = 8
num_heads = 2
head_dim = embed_dim // num_heads

# Create input tensors
query = torch.randn(seq_len_query, batch_size, embed_dim)
key = torch.randn(seq_len_key, batch_size, embed_dim)
value = torch.randn(seq_len_key, batch_size, embed_dim)

# Create projection weights and biases
in_proj_weight = torch.randn(3 * embed_dim, embed_dim)
in_proj_bias = torch.randn(3 * embed_dim)
out_proj_weight = torch.randn(embed_dim, embed_dim)
out_proj_bias = torch.randn(embed_dim)

# Optional projection weights (for use_separate_proj_weight=True case)
q_proj_weight = torch.randn(embed_dim, embed_dim)
k_proj_weight = torch.randn(embed_dim, embed_dim)
v_proj_weight = torch.randn(embed_dim, embed_dim)

# Optional bias tensors
bias_k = torch.randn(1, 1, embed_dim)
bias_v = torch.randn(1, 1, embed_dim)

# Optional masks
key_padding_mask = torch.zeros(batch_size, seq_len_key, dtype=torch.bool)
attn_mask = torch.zeros(seq_len_query, seq_len_key)

# Optional static key/value
static_k = torch.randn(batch_size * num_heads, seq_len_key, head_dim)
static_v = torch.randn(batch_size * num_heads, seq_len_key, head_dim)

# Optional attn_bias
attn_bias = torch.zeros(batch_size, num_heads, seq_len_query, seq_len_key)

ARGS = {
    'query': query,
    'key': key,
    'value': value,
    'embed_dim_to_check': embed_dim,
    'num_heads': num_heads,
    'in_proj_weight': in_proj_weight,
    'in_proj_bias': in_proj_bias,
    'bias_k': bias_k,
    'bias_v': bias_v,
    'add_zero_attn': False,
    'dropout_p': 0.1,
    'out_proj_weight': out_proj_weight,
    'out_proj_bias': out_proj_bias,
    'training': True,
    'key_padding_mask': key_padding_mask,
    'need_weights': True,
    'attn_mask': attn_mask,
    'use_separate_proj_weight': False,
    'q_proj_weight': q_proj_weight,
    'k_proj_weight': k_proj_weight,
    'v_proj_weight': v_proj_weight,
    'static_k': None,
    'static_v': None,
    'attn_bias': None,
    'scale_factor': 1,
}
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
tupe_relative_position_bucket Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
anzeyimana/kinyabert-acl2022/code/morpho_model.py
code served (permissive licence) · get_code("514537bcd2ff58d8")
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 int, 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 math

torch.manual_seed(0)

# Construct a relative_position tensor
# The function expects a tensor of positions (can be any shape)
relative_position = torch.tensor([[-5, -2, 0, 3], [1, 10, 50, 100]], dtype=torch.long)

ARGS = {
    "relative_position": relative_position,
    "bidirectional": True,
    "num_buckets": 32,
    "max_distance": 128,
}
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 int, 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
KinyaBERT Not yet run
unverified (harvested, no recorded run)
anzeyimana/kinyabert-acl2022/code/morpho_model.py
code served (permissive licence) · get_code("f5ddc36bd8862619")
How it ran

no invocation recorded.

KinyaBERT_MorphoEncoder Not yet run
unverified (harvested, no recorded run)
anzeyimana/kinyabert-acl2022/code/morpho_model.py
code served (permissive licence) · get_code("e68dff82485137db")
How it ran

no invocation recorded.

MorphoHeadPredictor Not yet run
unverified (harvested, no recorded run)
anzeyimana/kinyabert-acl2022/code/morpho_model.py
code served (permissive licence) · get_code("5f012bd177034410")
How it ran

no invocation recorded.

MultiheadAttention Not yet run
unverified (harvested, no recorded run)
anzeyimana/kinyabert-acl2022/code/morpho_model.py
code served (permissive licence) · get_code("4639b692ef625093")
How it ran

no invocation recorded.

TransformerEncoderLayer Not yet run
unverified (harvested, no recorded run)
anzeyimana/kinyabert-acl2022/code/morpho_model.py
code served (permissive licence) · get_code("820fca5082f9435e")
How it ran

no invocation recorded.

init_bert_params Not yet run
unverified (harvested, no recorded run)
anzeyimana/kinyabert-acl2022/code/morpho_model.py
code served (permissive licence) · get_code("3d27c291c5dad777")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 2 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 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
_get_activation_fn
brick of this paper's assembly: helper
6 other papers
3 dated earlier, 3 later · 5 only as an assembly brick
2103.03027 (2021-03)
Modeling Multi-Label Action Dependencies for Temporal Action Localization
2103.06495 (2021-03)
Read Like Humans: Autonomous, Bidirectional and Iterative Language Modeling for Scene Text Recognition
2108.00202 (2021-08)
HiFT: Hierarchical Feature Transformer for Aerial Tracking
and 3 more not named here
_get_clones
brick of this paper's assembly: helper
6 other papers
3 dated earlier, 3 later · 2 only as an assembly brick
2103.06495 (2021-03)
Read Like Humans: Autonomous, Bidirectional and Iterative Language Modeling for Scene Text Recognition
2103.14146 (2021-03)
Describing and Localizing Multiple Changes with Transformers
2108.00202 (2021-08)
HiFT: Hierarchical Feature Transformer for Aerial Tracking
and 3 more not named here

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

Pre-trained language models such as BERT have been successful at tackling many natural language processing tasks. However, the unsupervised sub-word tokenization methods commonly used in these models (e.g., byte-pair encoding -BPE) are sub-optimal at handling morphologically rich languages. Even given a morphological analyzer, naive sequencing of morphemes into a standard BERT architecture is inefficient at capturing morphological compositionality and expressing word-relative syntactic regularities. We address these challenges by proposing a simple yet effective twotier BERT architecture that leverages a morphological analyzer and explicitly represents morphological compositionality. Despite the success of BERT, most of its evaluations have been conducted on high-resource languages, obscuring its applicability on low-resource languages. We evaluate our proposed method on the low-resource morphologically rich Kinyarwanda language, naming the proposed model architecture KinyaBERT. A robust set of experimental results reveal that KinyaBERT outperforms solid baselines by 2% in F1 score on a named entity recognition task and by 4.3% in average score of a machine-translated GLUE benchmark. KinyaBERT fine-tuning has better convergence and achieves more robust results on multiple tasks even in the presence of translation noise. 1

For agents

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

get_harvested_code_for_paper("2203.08459")
get_code_for_paper("2203.08459")
have("2203.08459")

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

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

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

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

Connect an agent — have() is free.