SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2503.00778 · 2025

AffordGrasp: In-Context Affordance Reasoning for Open-Vocabulary Task-Oriented Grasping in Clutter

arXiv · PDF · Open in the Atlas

Code that ran

8 of 8 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; 1 honoured the contract we drafted, 0 violated it and 6 have no contract verdict; 1 failure 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/2503.00778.json · badge: /api/ran/2503.00778.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
H-Freax/ThinkGrasp community (classifier label)
classifier basis not recorded on the link
8 ran · 0 no recorded run
FunctionStatusWhere it lives
build_bert_backbone Ran
ran on a synthesized input
H-Freax/ThinkGrasp/VLP/glip/bert_model.py
code served (permissive licence) · get_code("bde90808e65e6ec2")
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 Sequential. 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 collections import OrderedDict

torch.manual_seed(0)

class MockConfig:
    """Stand-in config class that mimics nested attribute access."""
    def __init__(self):
        self.MODEL = type('obj', (object,), {
            'LANGUAGE_BACKBONE': type('obj', (object,), {
                'MODEL_TYPE': 'bert-base-uncased',
                'USE_CHECKPOINT': False,
                'N_LAYERS': 2
            })(),
            'DYHEAD': type('obj', (object,), {
                'FUSE_CONFIG': type('obj', (object,), {
                    'USE_DOT_PRODUCT_TOKEN_LOSS': False
                })()
            })()
        })()

class MockBertModel(nn.Module):
    """Mock BERT model that returns the expected output structure."""
    def __init__(self):
        super().__init__()
        self.embedding = nn.Embedding(1000, 768)
    
    def forward(self, input_ids, attention_mask, output_hidden_states=False):
        batch_size = input_ids.shape[0]
        seq_len = input_ids.shape[1]
        
        # Create mock hidden states (13 layers for BERT: 1 embedding + 12 layers)
        hidden_states = [torch.randn(batch_size, seq_len, 768) for _ in range(13)]
        
        class MockOutput:
            pass
        
        output = MockOutput()
        output.hidden_states = hidden_states
        return output

class MockRobertaModel(nn.Module):
    """Mock RoBERTa model that returns the expected output structure."""
    def __init__(self):
        super().__init__()
        self.embedding = nn.Embedding(1000, 768)
    
    def forward(self, input_ids, attention_mask, output_hidden_states=False):
        batch_size = input_ids.shape[0]
        seq_len = input_ids.shape[1]
        
        # Create mock hidden states (13 layers for RoBERTa: 1 embedding + 12 layers)
        hidden_states = [torch.randn(batch_size, seq_len, 768) for _ in range(13)]
        
        class MockOutput:
            pass
        
        output = MockOutput()
        output.hidden_states = hidden_states
        return output

# Patch the model loading functions
import transformers
original_bert_from_pretrained = transformers.BertModel.from_pretrained
original_roberta_from_pretrained = transformers.RobertaModel.from_pretrained

transformers.BertModel.from_pretrained = classmethod(lambda cls, *args, **kwargs: MockBertModel())
transformers.RobertaModel.from_pretrained = classmethod(lambda cls, *args, **kwargs: MockRobertaModel())

transformers.BertConfig.from_pretrained = classmethod(lambda cls, *args, **kwargs: transformers.BertConfig())
transformers.RobertaConfig.from_pretrained = classmethod(lambda cls, *args, **kwargs: transformers.RobertaConfig())

cfg = MockConfig()

ARGS = {
    'cfg': cfg
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Sequential — a Sequential output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Sequential 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
create_cropping_box_from_boxes Ran
ran on a synthesized input
H-Freax/ThinkGrasp/simulation_main.py
code served (permissive licence) · get_code("b20c34ab2acaf8cb")
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 torch

torch.manual_seed(0)

# boxes: a list of bounding boxes, where each box is a tuple/list of (x1, y1, x2, y2)
boxes = [
    (10, 15, 50, 60),
    (30, 20, 80, 70),
    (5, 10, 40, 45)
]

# image_size: a tuple of (width, height)
image_size = (640, 480)

# margin: an integer for the margin to add around the cropping box
margin = 20

ARGS = {
    "boxes": boxes,
    "image_size": image_size,
    "margin": margin
}
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 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
get_heightmap Ran
ran on a synthesized input
H-Freax/ThinkGrasp/utils.py
code served (permissive licence) · get_code("eab615e8d72bd22e")
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

# Create sample 3D points in HxWx3 format
# Let's use a small 2x4x3 array (H=2, W=4, 3 coordinates)
np.random.seed(0)
points = np.random.uniform(low=-0.5, high=0.5, size=(2, 4, 3)).astype(np.float32)
# Ensure some points are within bounds for valid data
points[0, 0, :] = [0.1, 0.1, 0.2]
points[0, 1, :] = [0.15, 0.12, 0.25]
points[1, 0, :] = [0.2, 0.15, 0.22]
points[1, 1, :] = [0.25, 0.2, 0.28]

# Create corresponding colors in HxWx3 format (uint8, 0-255)
colors = np.random.randint(0, 256, size=(2, 4, 3), dtype=np.uint8)

# Define bounds: 3x2 array (rows: X, Y, Z; columns: min, max)
# X bounds: [-1, 1], Y bounds: [-1, 1], Z bounds: [0, 1]
bounds = np.array([
    [-1.0, 1.0],  # X min, max
    [-1.0, 1.0],  # Y min, max
    [0.0, 1.0]    # Z min, max
], dtype=np.float32)

# Define pixel size (in meters)
pixel_size = 0.1

ARGS = {
    "points": points,
    "colors": colors,
    "bounds": bounds,
    "pixel_size": pixel_size
}
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
get_pointcloud Ran
ran, honoured the contract we drafted
H-Freax/ThinkGrasp/utils.py
code served (permissive licence) · get_code("b6d3d8977853db90")
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 3, dtype family float, shape (4, 5, 3) 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

# Create a small depth image (HxW)
height, width = 4, 5
depth = np.random.rand(height, width).astype(np.float32) * 5.0 + 0.1

# Create a 3x3 camera intrinsics matrix
# Typical form: [[fx, 0, cx], [0, fy, cy], [0, 0, 1]]
intrinsics = np.array([
    [500.0, 0.0, width / 2.0],
    [0.0, 500.0, height / 2.0],
    [0.0, 0.0, 1.0]
], dtype=np.float32)

ARGS = {
    "depth": depth,
    "intrinsics": intrinsics
}
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 3, dtype family float, shape (4, 5, 3) — shape (4, 5, 3) 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
load_image_as_base64 Ran
ran on a synthesized input
H-Freax/ThinkGrasp/realarm.py
code served (permissive licence) · get_code("90e904e8ec69bd26")
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 base64
import tempfile
import os

# Create a temporary image file for testing
with tempfile.NamedTemporaryFile(mode='wb', suffix='.png', delete=False) as tmp_file:
    # Write a minimal valid PNG file (1x1 pixel)
    png_data = (
        b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01'
        b'\x08\x02\x00\x00\x00\x90wS\xde\x00\x00\x00\x0cIDATx\x9cc\xf8\x0f\x00'
        b'\x00\x01\x01\x00\x05\x18\r\n\x14\x00\x00\x00\x00IEND\xaeB`\x82'
    )
    tmp_file.write(png_data)
    temp_image_path = tmp_file.name

ARGS = {
    'image_path': temp_image_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 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
process_grasping_result Ran
ran on a synthesized input
H-Freax/ThinkGrasp/realarm.py
code served (permissive licence) · get_code("2f62971aa5d9996b")
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 torch
import torch.nn as nn

# Construct a valid output string that the function expects
output = """Selected Object/Object Part: [object: mug]
Cropping Box Coordinates: (10, 20, 30, 40)
Object: ceramic_mug
Grasping Score: 85
Material Composition: 90
Surface Texture: 75
Stability Assessment: 88
Centroid Coordinates: (100, 150)
Preferred Grasping Location: 5
Object: glass_cup
Grasping Score: 72
Material Composition: 60
Surface Texture: 80
Stability Assessment: 70
Centroid Coordinates: (200, 250)
Preferred Grasping Location: 3"""

ARGS = {
    'output': output
}
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 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
select_action Ran
ran on a synthesized input
H-Freax/ThinkGrasp/realarm.py
code served (permissive licence) · get_code("ae08b081b5d182e6")
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 int, ndim 0, dtype family int, shape () 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 tensors for the function arguments
# bboxes: used for parameter passing but not accessed in function body
bboxes = torch.randn(2, 4, 4)

# pos_bboxes: accessed as pos_bboxes[0, 0, 0] and pos_bboxes[0, 0, 1]
# Shape: (batch=2, num_pos=4, coords=2)
pos_bboxes = torch.randn(2, 4, 2)

# text: used for parameter passing but not accessed in function body
text = "dummy text"

# actions: accessed as actions[0, :, 0] and actions[0, :, 1]
# Shape: (batch=2, num_actions=5, coords=2)
actions = torch.randn(2, 5, 2)

# evaluate: boolean flag, default True
evaluate = True

ARGS = {
    "bboxes": bboxes,
    "pos_bboxes": pos_bboxes,
    "text": text,
    "actions": actions,
    "evaluate": evaluate
}
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 int, ndim 0, dtype family int, shape () — shape () 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
transform_pointcloud Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
H-Freax/ThinkGrasp/utils.py
code served (permissive licence) · get_code("09577e75397fa2ab")
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 3, dtype family float, shape (2, 3, 3) 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

# Create a small 3D pointcloud (HxWx3)
# Using H=2, W=3 for small but distinct dimensions
points = np.random.randn(2, 3, 3).astype(np.float32)

# Create a 4x4 rigid transformation matrix
# Identity transformation with some small rotation/translation
transform = np.array([
    [0.99, -0.05, 0.0, 0.1],
    [0.05, 0.99, 0.0, 0.2],
    [0.0, 0.0, 1.0, 0.3],
    [0.0, 0.0, 0.0, 1.0]
], dtype=np.float32)

ARGS = {
    "points": points,
    "transform": transform
}
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 3, dtype family float, shape (2, 3, 3) — shape (2, 3, 3) 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

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 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, 0 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
get_pointcloud 1 other paper
1 dated earlier
2210.03094 (2022-10)
VIMA: General Robot Manipulation with Multimodal Prompts
transform_pointcloud 1 other paper
1 dated earlier
2210.03094 (2022-10)
VIMA: General Robot Manipulation with Multimodal Prompts

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

Inferring the affordance of an object and grasping it in a task-oriented manner is crucial for robots to successfully complete manipulation tasks. Affordance indicates where and how to grasp an object by taking its functionality into account, serving as the foundation for effective task-oriented grasping. However, current task-oriented methods often depend on extensive training data that is confined to specific tasks and objects, making it difficult to generalize to novel objects and complex scenes. In this paper, we introduce AffordGrasp, a novel open-vocabulary grasping framework that leverages the reasoning capabilities of vision-language models (VLMs) for in-context affordance reasoning. Unlike existing methods that rely on explicit task and object specifications, our approach infers tasks directly from implicit user instructions, enabling more intuitive and seamless human-robot interaction in everyday scenarios. Building on the reasoning outcomes, our framework identifies task-relevant objects and grounds their part-level affordances using a visual grounding module. This allows us to generate task-oriented grasp poses precisely within the affordance regions of the object, ensuring both functional and context-aware robotic manipulation. Extensive experiments demonstrate that AffordGrasp achieves state-of-the-art performance in both simulation and real-world scenarios, highlighting the effectiveness of our method. We believe our approach advances robotic manipulation techniques and contributes to the broader field of embodied AI. Project website: https://eqcy.github.io/affordgrasp/.

For agents

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

get_harvested_code_for_paper("2503.00778")
get_code_for_paper("2503.00778")
have("2503.00778")

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

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

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

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

Connect an agent — have() is free.