SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2107.10064 · 2021

Few Shots Are All You Need: A Progressive Few Shot Learning Approach for Low Resource Handwritten Text Recognition

arXiv · PDF · Open in the Atlas

Code that ran

8 of 11 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 7 have no contract verdict; 1 failure of our instrument; 3 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/2107.10064.json · badge: /api/ran/2107.10064.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
dali92002/htrbymatching canonical (classifier label)
classifier basis: census
8 ran · 3 no recorded run
FunctionStatusWhere it lives
asciitochar Ran
ran on a synthesized input
dali92002/htrbymatching/htr_utils.py
code served (permissive licence) · get_code("c444dbf1b8a85650")
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 str. 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)

# Analyze the function: asciitochar(a)
# - Takes parameter 'a' which is iterated over
# - Each element 'ch' is used in chr(50 + ch)
# - This suggests 'a' should be an iterable of integers
# - chr() expects integers in valid Unicode range
# - Since we're adding to 50, small integers work well (0-100 range)

# Create a simple iterable of integers
a = [0, 1, 2, 3, 5]

ARGS = {
    'a': a
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
crop_im Ran
ran on a synthesized input
dali92002/htrbymatching/generate_data.py
code served (permissive licence) · get_code("67ac021b09d39a95")
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 (4, 0) 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 4x3 image tensor
# The function expects a 2D array-like object with .shape attribute
# It performs operations like sum() on slices and indexing with [:, i] and [i, :]
image = torch.tensor([
    [50.0, 30.0, 40.0],
    [60.0, 25.0, 35.0],
    [45.0, 20.0, 55.0],
    [55.0, 28.0, 45.0]
])

ARGS = {
    "image": image
}
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 2, dtype family float, shape (4, 0) — shape (4, 0) 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
fastrcnn_loss Ran
ran on a synthesized input
dali92002/htrbymatching/src/roi_heads.py
code served (permissive licence) · get_code("97a923f20b7a1ce7")
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 torch.nn.functional as F

torch.manual_seed(0)

# Construct arguments for fastrcnn_loss
# class_logits: (N, num_classes) tensor
# box_regression: (N, num_classes, 4) tensor
# labels: list of tensors that will be concatenated
# regression_targets: list of tensors that will be concatenated

N = 2  # batch size
num_classes = 2

# class_logits: shape (2, 2)
class_logits = torch.randn(N, num_classes)

# box_regression: shape (2, 2, 4) - N x num_classes x 4
box_regression = torch.randn(N, num_classes, 4)

# labels: list of tensors that concatenate to shape (2,)
# Each should be 1D tensors with class indices (0 or 1)
# At least one should be > 0 to avoid empty sampled_pos_inds_subset
labels = [torch.tensor([0]), torch.tensor([1])]

# regression_targets: list of tensors that concatenate to shape (2, 4)
# These correspond to regression targets for positive examples
regression_targets = [torch.randn(1, 4), torch.randn(1, 4)]

ARGS = {
    "class_logits": class_logits,
    "box_regression": box_regression,
    "labels": labels,
    "regression_targets": regression_targets,
}
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, 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_boundary Ran
ran on a synthesized input
dali92002/htrbymatching/generate_data.py
code served (permissive licence) · get_code("e1b2b778016dbd2b")
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 numpy as np

# Construct a small 2D image array with varying column and row sums
# The function looks for boundaries by checking column and row sums
# Create an image where some columns/rows have low sums (edges) and some have high sums (content)

image = np.array([
    [10, 1, 10, 10, 1, 10],
    [10, 1, 10, 10, 1, 10],
    [10, 1, 10, 10, 1, 10],
    [10, 1, 10, 10, 1, 10],
], dtype=np.float32)

# Verify the image has the right properties:
# - max_p will be 10
# - Some columns have sum < 10*4 - 2*10 = 20 (the columns with all 1s have sum 4)
# - Some rows have sum < 10*6 - 2*10 = 40 (all rows have sum 52)

ARGS = {
    'image': image
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — 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
maskrcnn_inference Ran
ran on a synthesized input
dali92002/htrbymatching/src/roi_heads.py
code served (permissive licence) · get_code("2989d6cc54f3abaf")
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)

# BoxList stand-in class that mimics the minimal interface needed
class BoxList:
    def __init__(self, boxes, image_size, mode="xyxy"):
        self.boxes = boxes
        self.image_size = image_size
        self.mode = mode
        self.extra_fields = {}
    
    def __len__(self):
        return len(self.boxes)
    
    def add_field(self, name, field):
        self.extra_fields[name] = field
    
    def get_field(self, name):
        return self.extra_fields.get(name)

# Create mask logits tensor: [num_masks, num_classes, height, width]
# num_masks=5, num_classes=4, height=3, width=3
x = torch.randn(5, 4, 3, 3)

# Create labels as list of BoxList objects
# First image has 2 boxes, second image has 3 boxes
# We need class labels for each box (total 5 boxes)
# Create BoxLists with dummy boxes
boxlist1 = BoxList(torch.tensor([[0., 0., 10., 10.], [5., 5., 15., 15.]]), (20, 20))
boxlist1_labels = torch.tensor([0, 2], dtype=torch.long)  # class labels for 2 boxes

boxlist2 = BoxList(torch.tensor([[0., 0., 5., 5.], [10., 10., 20., 20.], [2., 2., 8., 8.]]), (20, 20))
boxlist2_labels = torch.tensor([1, 3, 0], dtype=torch.long)  # class labels for 3 boxes

# Stack all labels into a single tensor (this is what the function expects)
labels = [boxlist1_labels, boxlist2_labels]

ARGS = {
    "x": x,
    "labels": labels
}
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
merge Ran
ran on a synthesized input
dali92002/htrbymatching/generate_data.py
code served (permissive licence) · get_code("9ec01de95a2f7631")
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 ndarray, ndim 2, dtype family float, shape (4, 9) 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 numpy as np

# Analyze the function:
# - a: 2D array, used with a.shape[0] (rows), a.shape[1] (cols)
# - b: 2D array, used with b.shape[1] (cols), indexed as b[i][...] 
# - r: integer, used in range arithmetic

# The function merges two 2D arrays with overlap of r columns
# Output shape: (a.shape[0], a.shape[1] + b.shape[1] - r)

# Create test arrays
# a has shape (4, 6) - 4 rows, 6 cols
# b has shape (4, 5) - 4 rows, 5 cols  
# r = 2 (overlap of 2 columns)
# Result will be (4, 6 + 5 - 2) = (4, 9)

a = np.array([
    [1.0, 2.0, 3.0, 4.0, 5.0, 6.0],
    [7.0, 8.0, 9.0, 10.0, 11.0, 12.0],
    [13.0, 14.0, 15.0, 16.0, 17.0, 18.0],
    [19.0, 20.0, 21.0, 22.0, 23.0, 24.0]
], dtype=np.float32)

b = np.array([
    [0.5, 0.6, 0.7, 0.8, 0.9],
    [1.0, 1.1, 1.2, 1.3, 1.4],
    [1.5, 1.6, 1.7, 1.8, 1.9],
    [2.0, 2.1, 2.2, 2.3, 2.4]
], dtype=np.float32)

r = 2

ARGS = {
    'a': a,
    'b': b,
    'r': r
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (4, 9) — shape (4, 9) 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
merge Ran
ran on a synthesized input
dali92002/htrbymatching/src/coco_eval.py
code served (permissive licence) · get_code("faf33cdfe03460be")
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 numpy as np
from unittest.mock import MagicMock

# Create a mock utils module with all_gather function
class MockUtils:
    @staticmethod
    def all_gather(data):
        # Simulate distributed gathering by returning a list containing the data
        # all_gather typically returns a list of tensors/arrays from all processes
        return [data]

utils = MockUtils()

# Inject the mock utils into the function's namespace
import sys
current_module = sys.modules[__name__]
current_module.utils = utils

# Construct arguments for the merge function
img_ids = [1, 2, 3, 1, 2]  # List of image IDs with some duplicates
eval_imgs = np.random.rand(4, 5, 3)  # Shape: (height=4, width=5, num_images=3)

ARGS = {
    "img_ids": img_ids,
    "eval_imgs": eval_imgs
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — 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
permute_and_flatten Ran
ran; our contract draft was wrong, not the code
dali92002/htrbymatching/src/rpn.py
code served (permissive licence) · get_code("2028ba00ac3a78ae")
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, 90, 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

torch.manual_seed(0)

# Construct arguments for permute_and_flatten
# The function expects:
# - layer: a tensor that will be reshaped to (N, -1, C, H, W)
# - N: batch size
# - A: second dimension after reshape (the -1 in view)
# - C: channels
# - H: height
# - W: width

N = 2
A = 3
C = 4
H = 5
W = 6

# Create a tensor with total elements = N * A * C * H * W
# This will be reshaped to (N, -1, C, H, W) where -1 becomes A
total_elements = N * A * C * H * W
layer = torch.randn(total_elements)

ARGS = {
    "layer": layer,
    "N": N,
    "A": A,
    "C": C,
    "H": H,
    "W": W
}
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 3, dtype family float, shape (2, 90, 4) — shape (2, 90, 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
concat_box_prediction_layers Not yet run
unverified (harvested, no recorded run)
dali92002/htrbymatching/src/rpn.py
code served (permissive licence) · get_code("77c66eaf1f969329")
How it ran

no invocation recorded.

contrastive_loss_torch Not yet run
unverified (harvested, no recorded run)
dali92002/htrbymatching/src/roi_heads.py
code served (permissive licence) · get_code("895f70f0bc4cf2ac")
How it ran

no invocation recorded.

get_data2 Not yet run
unverified (harvested, no recorded run)
dali92002/htrbymatching/load_data.py
code served (permissive licence) · get_code("c06c6fdc886c0cda")
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 (1 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
permute_and_flatten 3 other papers
2 dated earlier, 1 later
1506.01497 (2015-06)
Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks
2106.08322 (2021-06)
Dynamic Head: Unifying Object Detection Heads with Attentions
Guo_Knowledge_Distillation_for_6D_Pose_Estimation_by_Aligning_Distributions_of_CVPR_2023_paper (2023 (year only))
Knowledge Distillation for 6D Pose Estimation by Aligning Distributions of Local Predictions

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

Handwritten text recognition in low resource scenarios, such as manuscripts with rare alphabets, is a challenging problem. The main difficulty comes from the very few annotated data and the limited linguistic information (e.g. dictionaries and language models). Thus, we propose a few-shot learning-based handwriting recognition approach that significantly reduces the human labor annotation process, requiring only few images of each alphabet symbol. The method consists in detecting all the symbols of a given alphabet in a textline image and decoding the obtained similarity scores to the final sequence of transcribed symbols. Our model is first pretrained on synthetic line images generated from any alphabet, even though different from the target domain. A second training step is then applied to diminish the gap between the source and target data. Since this retraining would require annotation of thousands of handwritten symbols together with their bounding boxes, we propose to avoid such human effort through an unsupervised progressive learning approach that automatically assigns pseudo-labels to the non-annotated data. The evaluation on different manuscript datasets show that our model can lead to competitive results with a significant reduction in human effort. The code will be publicly available in this repository: \url{https://github.com/dali92002/HTRbyMatching}

For agents

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

get_harvested_code_for_paper("2107.10064")
get_code_for_paper("2107.10064")
have("2107.10064")

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

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

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

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

Connect an agent — have() is free.