| extract_content_from_tag |
Ran ran; our contract draft was wrong, not the code |
GaMS-Team/local_ocr/postprocess_markdown/utils.py code served (permissive licence) · get_code("15774ca6895e9baa") How it ranRan 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 re
def extract_content_from_tag(model_output, tag):
"""
Extracts the content from a specific XML-like tag within a string.
Args:
model_output: The string containing the tagged content.
tag: The name of the tag (without the angle brackets).
Returns:
The content within the specified tag, or None if the tag is not found.
"""
pattern = f'<{tag}>(.*?)</{tag}>'
match = re.search(pattern, model_output, re.DOTALL)
if match:
return match.group(1)
else:
return None
ARGS = {
"model_output": "<response>Hello world</response><other>data</other>",
"tag": "response"
}
- 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
|
| generate_responses |
Ran ran; our contract draft was wrong, not the code |
GaMS-Team/local_ocr/postprocess_markdown/classify_pages.py code served (permissive licence) · get_code("98a5e3c65904b8da") How it ranRan 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
import torch.nn as nn
import warnings
torch.manual_seed(0)
class MockOutput:
def __init__(self, text):
self.text = text
class MockResponse:
def __init__(self, text):
self.outputs = [MockOutput(text)]
class MockModel:
def chat(self, messages, sampling_params, use_tqdm=False):
# Return a list of MockResponse objects, one per message
return [MockResponse(f"Response to message {i}") for i in range(len(messages))]
class MockTokenizer:
def apply_chat_template(self, messages, add_generation_prompt=False):
# Return a list of token lists, one per message
# Vary lengths to test the logic
return [
[1, 2, 3, 4, 5], # Normal length
[1, 2, 3], # Shorter
]
class MockSamplingParams:
def __init__(self):
self.temperature = 0.7
self.top_p = 0.9
prompts = [
"What is machine learning?",
"Explain neural networks",
]
model = MockModel()
tokenizer = MockTokenizer()
sampling_params = MockSamplingParams()
ARGS = {
'prompts': prompts,
'model': model,
'sampling_params': sampling_params,
'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 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
|
| generate_responses |
Ran ran; our contract draft was wrong, not the code |
GaMS-Team/local_ocr/postprocess_markdown/merge_pages.py code served (permissive licence) · get_code("a45378cd91f5e6d9") How it ranRan 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
import torch.nn as nn
from dataclasses import dataclass
# Stand-in tokenizer class
class StandInTokenizer:
def apply_chat_template(self, messages, add_generation_prompt=False):
# Return token lists for each message sequence
# Make some shorter, some longer to test the logic
return [
[1, 2, 3, 4, 5], # short
[1, 2, 3, 4, 5] * 8000, # very long (exceeds MAX_MODEL_LEN=32768)
]
# Stand-in output object
@dataclass
class StandInOutput:
text: str
# Stand-in response object
@dataclass
class StandInResponse:
outputs: list
# Stand-in model class
class StandInModel(nn.Module):
def __init__(self):
super().__init__()
self.linear = nn.Linear(4, 4)
def chat(self, messages, sampling_params, use_tqdm=False):
# Return responses for messages that don't have issues
responses = []
for msg in messages:
output_text = "Model response for: " + msg[0]['content'][:50]
responses.append(StandInResponse(outputs=[StandInOutput(text=output_text)]))
return responses
# Stand-in sampling params
class StandInSamplingParams:
def __init__(self):
self.temperature = 0.7
self.max_tokens = 512
# Create instances
torch.manual_seed(0)
model = StandInModel()
tokenizer = StandInTokenizer()
sampling_params = StandInSamplingParams()
# Prompts: one normal, one with the expected structure that's too long
prompts = [
"Normal prompt for testing",
"Vhod:<zadnji_odstavek>" + "x" * 1000 + "</zadnji_odstavek>\n<prvi_odstavek>" + "y" * 500 + "</prvi_odstavek>"
]
ARGS = {
'prompts': prompts,
'model': model,
'sampling_params': sampling_params,
'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 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_number_from_file |
Ran ran, honoured the contract we drafted |
GaMS-Team/local_ocr/postprocess_markdown/classify_pages.py code served (permissive licence) · get_code("08a3ead54a6bcf17") How it ranRan 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
# The function takes a filename string and extracts a number from it
# It splits by '_' to get the second part, then splits by '.' to remove extension
# Example: "file_123.txt" -> "123"
ARGS = {
"filename": "file_42.txt"
}
- 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
|
| get_page_prompt |
Ran ran; our contract draft was wrong, not the code |
GaMS-Team/local_ocr/nanonets_ocr/ocr_with_vllm.py code served (permissive licence) · get_code("1e23e5c57ca6fbe9") How it ranRan 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 base64
import io
# Create a small valid base64 encoded image (1x1 white pixel WebP)
# This is a minimal valid WebP image
webp_bytes = b'\x52\x49\x46\x46\x1a\x00\x00\x00\x57\x45\x42\x50\x56\x50\x38\x4c\x0d\x00\x00\x00\x2f\x00\x00\x00\x00\x00\x00\x00\x00\x00'
image_base64 = base64.b64encode(webp_bytes).decode('utf-8')
ARGS = {
'image': image_base64
}
- 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
|
| page_to_image |
Ran ran; our contract draft was wrong, not the code |
GaMS-Team/local_ocr/llama4_ocr/ocr_with_local_server.py code served (permissive licence) · get_code("2ae1456ceaa9bf01") How it ranRan 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
from unittest.mock import Mock, MagicMock
# Create a mock PDF page object that has the render method
mock_page = Mock()
# Create a mock rendered image object with to_pil method
mock_rendered = Mock()
# Create a mock PIL Image object
from PIL import Image
real_image = Image.new('RGBA', (100, 100), color='red')
# Set up the chain: page.render(...).to_pil() returns a PIL Image
mock_rendered.to_pil.return_value = real_image
mock_page.render.return_value = mock_rendered
ARGS = {
'page': mock_page,
'dpi': 150
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- PIL, 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
|
| page_to_image |
Ran ran; our contract draft was wrong, not the code |
GaMS-Team/local_ocr/chatgpt_ocr/chatgpt_ocr.py code served (permissive licence) · get_code("c7f87eb0059ed979") How it ranRan 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
from io import BytesIO
from unittest.mock import Mock, MagicMock
from PIL import Image
import io
# Create a mock page object that has a render method
# The render method should return an object with a to_pil method
mock_page = Mock()
# Create a mock render result that has to_pil method
render_result = Mock()
# Create a real PIL image to return from to_pil()
test_image = Image.new('RGBA', (100, 100), color='red')
render_result.to_pil.return_value = test_image
# Set up the mock page's render method to return our render_result
mock_page.render.return_value = render_result
# Define the arguments
ARGS = {
'page': mock_page,
'dpi': 96
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- PIL — 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
|
| preprocess_image |
Ran ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT) |
GaMS-Team/local_ocr/tesseract_ocr/tesseract_OCR.py code served (permissive licence) · get_code("98b689870c1001ec") How it ranRan 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 Image. 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 PIL import Image
# Create a small RGB image for testing
# Using a simple pattern: gradient with some structure
image_array = np.random.randint(0, 256, (10, 15, 3), dtype=np.uint8)
test_image = Image.fromarray(image_array, mode='RGB')
ARGS = {
'image': test_image
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- PIL, cv2, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type Image — a Image output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Image output the recorded ndim 2 and dtype family int 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_batch |
Ran ran; our contract draft was wrong, not the code |
GaMS-Team/local_ocr/postprocess_markdown/classify_pages.py code served (permissive licence) · get_code("7e629f856ba12aa0") How it ranRan 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
import torch.nn as nn
from unittest.mock import Mock, MagicMock
import warnings
torch.manual_seed(0)
# Create a mock model that implements the chat interface
class MockModel(nn.Module):
def __init__(self):
super().__init__()
self.linear = nn.Linear(4, 4)
def chat(self, messages, sampling_params, use_tqdm=False):
# Return mock response objects
mock_outputs = []
for msg in messages:
mock_output = Mock()
mock_output.outputs = [Mock(text=f"Response for: {msg[0]['content'][:20]}...")]
mock_outputs.append(mock_output)
return mock_outputs
# Create a mock tokenizer that implements apply_chat_template
class MockTokenizer:
def apply_chat_template(self, messages, add_generation_prompt=True):
# Return a list of token lists (simulating tokenized messages)
# Each message gets a token list of varying length
tokenized = []
for msg in messages:
content = msg[0]['content']
# Simulate tokenization: shorter content = fewer tokens
num_tokens = max(10, len(content) // 100)
tokenized.append(list(range(num_tokens)))
return tokenized
# Create mock sampling parameters
class MockSamplingParams:
def __init__(self):
self.temperature = 0.7
self.max_tokens = 256
# Create small batch of text data
batch = [
"This is a short page about machine learning.",
"Another short document for testing purposes."
]
# Create prompt template
prompt_template = "Classify this content: {input}"
# Instantiate all components
model = MockModel()
tokenizer = MockTokenizer()
sampling_params = MockSamplingParams()
ARGS = {
'batch': batch,
'model': model,
'sampling_params': sampling_params,
'prompt_template': prompt_template,
'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 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
|
| process_batch |
Ran ran; our contract draft was wrong, not the code |
GaMS-Team/local_ocr/postprocess_markdown/merge_pages.py code served (permissive licence) · get_code("ce57ccba583cfc9f") How it ranRan 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 warnings
class MockModel:
def chat(self, messages, sampling_params, use_tqdm=False):
# Return mock responses with outputs attribute
class MockOutput:
def __init__(self, text):
self.text = text
class MockResponse:
def __init__(self, text):
self.outputs = [MockOutput(text)]
return [MockResponse(f"Response for message {i}") for i in range(len(messages))]
class MockTokenizer:
def apply_chat_template(self, messages, add_generation_prompt=False):
# Return a list of token lists, with lengths proportional to message content
result = []
for message_list in messages:
# Create token count based on content length
content = message_list[0]['content'] if message_list else ""
token_count = len(content.split())
result.append([0] * max(10, token_count))
return result
class MockSamplingParams:
def __init__(self):
self.temperature = 0.7
self.top_p = 0.9
# Create batch data
batch = [
{
'last_paragraph': 'This is the last paragraph of the first page.',
'first_paragraph': 'This is the first paragraph of the second page.'
},
{
'last_paragraph': 'Another last paragraph text here.',
'first_paragraph': 'Another first paragraph text here.'
}
]
# Create prompt template with the required markers
prompt_template = 'Vhod:<zadnji_odstavek>{last_paragraph}</zadnji_odstavek>\n<prvi_odstavek>{first_paragraph}</prvi_odstavek>'
# Create model, tokenizer, and sampling params
model = MockModel()
tokenizer = MockTokenizer()
sampling_params = MockSamplingParams()
ARGS = {
'batch': batch,
'model': model,
'sampling_params': sampling_params,
'prompt_template': prompt_template,
'tokenizer': tokenizer
}
- 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
|
| process_too_long_prompt |
Ran ran; our contract draft was wrong, not the code |
GaMS-Team/local_ocr/postprocess_markdown/merge_pages.py code served (permissive licence) · get_code("4688d9e2055e2e04") How it ranRan 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
# Analyze the function to understand what it needs:
# - It takes a 'prompt' parameter (a string)
# - It splits on specific delimiters and processes text
# - It compares lengths and returns formatted predictions
# Construct a valid prompt string with the required structure
prompt = """Vhod:<zadnji_odstavek>To je zadnji odstavek prve strani. Vsebuje nekaj besed za testiranje.</zadnji_odstavek>
<prvi_odstavek>To je prvi odstavek druge strani.</prvi_odstavek>"""
ARGS = {
"prompt": prompt
}
- 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
|
| ocr_page |
Not yet run unverified (harvested, no recorded run) |
GaMS-Team/local_ocr/chatgpt_ocr/chatgpt_ocr.py code served (permissive licence) · get_code("ee6b631841b07773") How it ran |
| page_to_image |
Not yet run unverified (harvested, no recorded run) |
GaMS-Team/local_ocr/nanonets_ocr/ocr_with_transformers.py code served (permissive licence) · get_code("fdef91e5cde260ec") How it ran |
| page_to_image |
Not yet run unverified (harvested, no recorded run) |
GaMS-Team/local_ocr/nanonets_ocr/ocr_with_vllm.py code served (permissive licence) · get_code("25e0991010208c40") How it ran |
| send_image_to_model |
Not yet run unverified (harvested, no recorded run) |
GaMS-Team/local_ocr/llama4_ocr/ocr_with_local_server.py code served (permissive licence) · get_code("848422699e20d1e3") How it ran |
| send_image_to_model |
Not yet run unverified (harvested, no recorded run) |
GaMS-Team/local_ocr/nanonets_ocr/ocr_with_transformers.py code served (permissive licence) · get_code("ee3e3eb2d845f727") How it ran |