| calculate_llmaaj_correctness |
Ran ran, honoured the contract we drafted |
ideas-labo/cds4rag/utils.py code served (permissive licence) · get_code("40ac0e0232fb29ad") 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 float, ndim 0, dtype family float, 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
import torch.nn as nn
class MockLLM:
"""Mock LLM that streams responses with numeric scores."""
def __init__(self, score=0.85):
self.score = score
def stream(self, messages):
"""Simulate streaming response from LLM."""
class Chunk:
def __init__(self, content):
self.content = content
# Yield response chunks that contain a numeric score
response_text = f"Based on the evaluation, I would give a score of {self.score}"
yield Chunk(response_text)
# Create test arguments
prediction = "the quick brown fox jumps over the lazy dog"
reference = "the quick brown fox jumps over a lazy dog"
llm = MockLLM(score=0.92)
ARGS = {
"prediction": prediction,
"reference": reference,
"llm": llm
}
- 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 float, ndim 0, dtype family float, 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
|
| calculate_retrieval_metrics |
Ran ran; our contract draft was wrong, not the code |
ideas-labo/cds4rag/utils.py code served (permissive licence) · get_code("a5b3c7b1c8deb3fb") 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 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 numpy as np
class MockDocument:
"""Mock document class with page_content attribute"""
def __init__(self, content):
self.page_content = content
class MockEmbeddingModel:
"""Mock embedding model - not actually called by the function"""
def embed(self, text):
return np.random.rand(4)
# Create test data
retrieved_docs = [
MockDocument("machine learning is a subset of artificial intelligence"),
MockDocument("deep learning uses neural networks for pattern recognition"),
MockDocument("artificial intelligence encompasses machine learning and robotics"),
MockDocument("data science involves statistics and programming")
]
true_context = "Machine Learning is a subset of Artificial Intelligence"
embedding_model = MockEmbeddingModel()
question = "What is the relationship between machine learning and AI?"
ARGS = {
'retrieved_docs': retrieved_docs,
'true_context': true_context,
'embedding_model': embedding_model,
'question': question
}
- 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 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
|
| calculate_retrieval_metrics_embedding |
Ran ran; our contract draft was wrong, not the code |
ideas-labo/cds4rag/utils.py code served (permissive licence) · get_code("b9b7237154a24b67") 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 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 numpy as np
class MockEmbedding:
"""Mock embedding model that returns fixed-size embeddings"""
def embed_query(self, text):
# Return a fixed 8-dimensional embedding based on text hash
np.random.seed(hash(text) % (2**31))
return np.random.randn(8).tolist()
class MockDocument:
"""Mock document with page_content attribute"""
def __init__(self, content):
self.page_content = content
# Create test data
embedding_model = MockEmbedding()
retrieved_docs = [
MockDocument("The quick brown fox jumps over the lazy dog"),
MockDocument("Python is a programming language"),
MockDocument("Machine learning is a subset of artificial intelligence"),
MockDocument("Natural language processing enables computers to understand text"),
]
true_context = "The quick brown fox jumps over the lazy dog"
question = "What does the fox do?"
ARGS = {
'retrieved_docs': retrieved_docs,
'true_context': true_context,
'embedding_model': embedding_model,
'question': question,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, sklearn — 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
|
| clean_json_string |
Ran ran; our contract draft was wrong, not the code |
ideas-labo/cds4rag/util.py code served (permissive licence) · get_code("098d9540e2614374") 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 clean_json_string(s):
s = s.strip().lstrip('\ufeff')
s = s.replace('\\n', '\n').replace('\\t', '\t')
s = re.sub('\\\\(?!["\\\\/bfnrt])', '', s)
return s
ARGS = {
's': ' \ufeff{"key": "value\\nwith\\ttabs\\\\invalid"} '
}
- 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
|
| format_docs |
Ran ran; our contract draft was wrong, not the code |
ideas-labo/cds4rag/Run_util.py code served (permissive licence) · get_code("8c3af9fd98991acd") 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.
class MockDoc:
def __init__(self, page_content):
self.page_content = page_content
docs = [
MockDoc("First document content"),
MockDoc("Second document content"),
MockDoc("Third document content")
]
ARGS = {
"docs": docs
}
- 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
|
| get_other_corpus |
Ran ran; our contract draft was wrong, not the code |
ideas-labo/cds4rag/Run_util.py code served (permissive licence) · get_code("c607ad93e9afd9fa") 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 numpy as np
np.random.seed(0)
main_category = 2
corpus_scale = 3
categories = {
1: 'sports',
2: 'politics',
3: 'technology',
4: 'health',
5: 'entertainment'
}
ARGS = {
'main_category': main_category,
'corpus_scale': corpus_scale,
'categories': categories
}
- 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 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
|
| load_jsonl |
Ran ran; our contract draft was wrong, not the code |
ideas-labo/cds4rag/Run_util.py code served (permissive licence) · get_code("4561fb8f5d531d34") 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 json
import tempfile
import os
# Create a temporary JSONL file with sample data
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "test.jsonl")
# Write sample JSONL data
with open(temp_file, 'w', encoding='utf-8') as f:
f.write(json.dumps({"id": 1, "text": "hello world"}) + "\n")
f.write(json.dumps({"id": 2, "text": "foo bar"}) + "\n")
f.write(json.dumps({"id": 3, "name": "test", "value": 42}) + "\n")
ARGS = {
"file_path": temp_file
}
- 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
|
| recursive_split_text |
Ran ran; our contract draft was wrong, not the code |
ideas-labo/cds4rag/word_chunker.py code served (permissive licence) · get_code("f3fbdd2dbdb3b6ee") 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 re
from typing import List
def _word_tokens(text: str) -> List[str]:
return re.findall('\\w+|[\\u4e00-\\u9fff]', text)
def _count_words(text: str) -> int:
return len(_word_tokens(text))
def recursive_split_text(text: str, chunk_size: int=100, chunk_overlap: int=20, separators: List[str]=('\n\n', '\n', '. ', ' ', '')) -> List[str]:
"""
Recursively split using natural boundaries (paragraph/line/sentence/space),
continue subdivision if length is not met;
when further subdivision is not possible, apply token sliding window with overlap.
"""
def _split(t: str, seps: List[str]) -> List[str]:
if _count_words(t) <= chunk_size * 1.2:
return [t]
if not seps:
tokens = _word_tokens(t)
windows = []
start = 0
step = max(chunk_size - chunk_overlap, 1)
while start < len(tokens):
end = min(start + chunk_size, len(tokens))
windows.append(' '.join(tokens[start:end]))
if end == len(tokens):
break
start += step
return windows
sep = seps[0]
parts = t.split(sep) if sep else [t]
out: List[str] = []
for p in parts:
p = p.strip()
if not p:
continue
if _count_words(p) <= chunk_size * 1.2:
out.append(p)
else:
out.extend(_split(p, seps[1:]))
return out
raw_chunks = _split(text, list(separators))
merged: List[str] = []
buf: List[str] = []
count = 0
for piece in raw_chunks:
pc = _count_words(piece)
if count + pc <= chunk_size or not buf:
buf.append(piece)
count += pc
else:
merged.append(' '.join(buf))
tail_tokens = _word_tokens(merged[-1])
overlap_tail = ' '.join(tail_tokens[max(0, len(tail_tokens) - chunk_overlap):])
buf = [overlap_tail, piece] if overlap_tail else [piece]
count = _count_words(' '.join(buf))
if buf:
merged.append(' '.join(buf))
return merged
ARGS = {
'text': 'This is a sample text. It contains multiple sentences.\n\nAnd even paragraphs. Here are some more words to make the text longer so that splitting will actually occur.\n\nThis section should trigger the recursive splitting mechanism because it has enough content.',
'chunk_size': 30,
'chunk_overlap': 5,
'separators': ['\n\n', '\n', '. ', ' ', '']
}
- 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
|
| save_vectorstore |
Ran ran, violated the contract we drafted |
ideas-labo/cds4rag/util.py code served (permissive licence) · get_code("abbdfd08c0e63fff") 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 bool, ndim 0, dtype family float, 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 pickle
import tempfile
import os
class MockVectorstore:
"""A minimal vectorstore that can be pickled"""
def __init__(self):
self.vectors = [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]
self.metadata = {"index": 0}
class MockVectorstoreWithSaveLocal:
"""A vectorstore with save_local method"""
def __init__(self):
self.vectors = [[1.0, 2.0], [3.0, 4.0]]
def save_local(self, directory):
"""Mock save_local method that creates a directory"""
os.makedirs(directory, exist_ok=True)
with open(os.path.join(directory, 'index.pkl'), 'wb') as f:
pickle.dump(self.vectors, f)
# Create a temporary directory for the filepath
temp_dir = tempfile.gettempdir()
vectorstore_path = os.path.join(temp_dir, 'test_vectorstore.pickle')
# Create a simple picklable vectorstore object
vectorstore = MockVectorstore()
ARGS = {
'vectorstore': vectorstore,
'filepath': vectorstore_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 bool, ndim 0, dtype family float, 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
|
| verify_json_format |
Ran ran, violated the contract we drafted |
ideas-labo/cds4rag/util.py code served (permissive licence) · get_code("a82ff54ee2e3ade2") 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 bool, ndim 0, dtype family float, 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 tempfile
import os
# Create a temporary file with valid content for testing
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.json', encoding='utf-8')
temp_file.write('{"valid": "json"}')
temp_file.close()
ARGS = {
'file_path': temp_file.name
}
- 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 bool, ndim 0, dtype family float, 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
|