| format_candidate_entities |
Ran ran; our contract draft was wrong, not the code |
zhougengxian/CoG/CoG/kg/entity_link.py code served (permissive licence) · get_code("e7e9fc4366cbc5df") 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
# Construct valid arguments for format_candidate_entities
torch.manual_seed(0)
# Create a list of candidate dictionaries matching the structure expected by the function
candidates = [
{
'qid': 'Q123',
'label': 'Example Entity 1',
'description': 'This is an example entity used for testing',
'alias': ['Entity 1', 'Ex1', 'Example'],
'degree': {
'in': 5,
'out': 3,
'attr': 2
},
'triplets': {
'head': {
'knows': ['Q456', 'Q789'],
'located_in': ['Q999']
},
'tail': {
'created_by': ['Q111'],
'part_of': ['Q222', 'Q333']
}
},
'final_score': 0.9234,
'score_details': {
'name_sim': 0.95,
'pop_score': 0.87,
'desc_context_sim': 0.92,
'triplet_context_sim': 0.88
}
},
{
'qid': 'Q456',
'label': 'Example Entity 2',
'description': 'Another test entity',
'alias': ['Entity 2', 'Ex2'],
'degree': {
'in': 2,
'out': 4,
'attr': 1
},
'triplets': {
'head': {
'works_for': ['Q777']
},
'tail': {}
},
'final_score': 0.7856,
'score_details': {
'name_sim': 0.82,
'pop_score': 0.71,
'desc_context_sim': 0.79,
'triplet_context_sim': 0.75
}
}
]
ARGS = {
'candidates': candidates
}
- 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
|
| format_candidates_compact |
Ran ran; our contract draft was wrong, not the code |
zhougengxian/CoG/CoG/kg/entity_link.py code served (permissive licence) · get_code("3bcd0a6933c15878") 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
# Construct valid candidates list
candidates = [
{
'label': 'Entity One',
'qid': 'Q123',
'description': 'This is the first test entity',
'alias': ['alias1', 'alias2', 'entity_one'],
'degree': {
'in': 5,
'out': 3,
'attr': 2
},
'final_score': 0.8756,
'score_details': {
'name_sim': 0.92,
'pop_score': 0.75,
'desc_context_sim': 0.88,
'triplet_context_sim': 0.81
},
'triplets': {
'head': {
'knows': ['person_A', 'person_B'],
'located_in': ['city_X']
},
'tail': {
'knows': ['person_C'],
'created_by': ['org_Y', 'org_Z']
}
}
},
{
'label': 'Entity Two',
'qid': 'Q456',
'description': 'This is the second test entity with more details',
'alias': ['entity_two', 'alt_name'],
'degree': {
'in': 10,
'out': 7,
'attr': 4
},
'final_score': 0.9234,
'score_details': {
'name_sim': 0.95,
'pop_score': 0.85,
'desc_context_sim': 0.91,
'triplet_context_sim': 0.89
},
'triplets': {
'head': {
'works_for': ['company_A'],
'has_skill': ['skill_1', 'skill_2', 'skill_3']
},
'tail': {
'employed_by': ['employer_X'],
'trained_at': ['institution_Y']
}
}
}
]
ARGS = {
'candidates': candidates
}
- 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
|
| format_exploration_report |
Ran ran; our contract draft was wrong, not the code |
zhougengxian/CoG/CoG/kg/fact_prune_extract.py code served (permissive licence) · get_code("d3bf6f05b40580ed") 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 json
ARGS = {
'entity_mention': 'Albert Einstein',
'linked_candidates': [
{
'label': 'Albert Einstein',
'qid': 'Q937',
'description': 'German-born theoretical physicist who developed the theory of relativity'
},
{
'label': 'Einstein (surname)',
'qid': 'Q4123456',
'description': 'A common German surname meaning stone in German'
},
{
'label': 'Albert (given name)',
'qid': 'Q5678901',
'description': 'A Germanic given name meaning noble and bright'
},
{
'label': 'Albert Einstein Award',
'qid': 'Q9012345',
'description': 'An award named after the physicist Albert Einstein for scientific achievement'
},
{
'label': 'Einstein Institute',
'qid': 'Q3456789',
'description': 'A research institute named after Albert Einstein'
}
],
'linked_entity': {
'label': 'Albert Einstein',
'qid': 'Q937',
'description': 'German-born theoretical physicist, developer of the theory of relativity',
'analysis': 'Entity linking resolved "Albert Einstein" to Q937 based on high semantic similarity and entity frequency in knowledge graph.'
},
'extracted_info': '- Born: March 14, 1879 in Ulm, Germany\n- Died: April 18, 1955 in Princeton, New Jersey\n- Notable Works: Theory of Relativity, E=mc²\n- Awards: Nobel Prize in Physics (1921)',
'total_relations_count': 47,
'selected_pids_count': 12,
'total_facts_count': 89,
'relation_selection_reasoning': 'Selected relations based on relevance score > 0.7 and frequency in knowledge base. Prioritized biographical, scientific contribution, and award-related predicates.',
'fact_extraction_reasoning': 'Facts extracted from linked entity\'s knowledge graph neighborhood. Applied confidence filtering to ensure high-quality factual information.',
'max_candidates_display': 4,
'verbose': True
}
- 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_exploration_report |
Ran ran; our contract draft was wrong, not the code |
zhougengxian/CoG/CoG/kg/fact_prune_filter.py code served (permissive licence) · get_code("5f66ac28f22b1ff2") 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 json
ARGS = {
"entity_mention": "Albert Einstein",
"linked_candidates": [
{
"label": "Albert Einstein",
"qid": "Q937",
"description": "Theoretical physicist"
},
{
"label": "Einstein (surname)",
"qid": "Q1234",
"description": "A common surname"
},
{
"label": "Albert (given name)",
"qid": "Q5678",
"description": "A given name"
},
{
"label": "Albert Einstein Museum",
"qid": "Q9012",
"description": "A museum dedicated to Albert Einstein"
}
],
"linked_entity": {
"label": "Albert Einstein",
"qid": "Q937",
"description": "German-born theoretical physicist who developed the theory of relativity",
"analysis": "Entity mention 'Albert Einstein' matched with high confidence to the Wikidata entity Q937, a prominent physicist known for relativity theory."
},
"final_facts": {
"attributes": {
"birth_date": "1879-03-14",
"death_date": "1955-04-18",
"nationality": "German"
},
"outgoing": {
"developed": ["Theory of Relativity", "E=mc²"],
"worked_at": ["ETH Zurich", "Princeton Institute"]
},
"incoming": {
"influenced": ["Stephen Hawking", "Richard Feynman"],
"studied_by": ["Physics students worldwide"]
}
},
"total_relations_count": 45,
"selected_pids_count": 12,
"total_facts_count": 89,
"kept_facts_count": 23,
"relation_selection_reasoning": "Selected relations based on semantic relevance to physics and scientific contributions. Filtered out personal lifestyle facts.",
"fact_pruning_reasoning": "Removed duplicate facts and low-confidence assertions. Kept only facts with multiple source confirmations.",
"max_candidates_display": 4,
"verbose": True
}
- 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_facts_for_extraction_prompt |
Ran ran; our contract draft was wrong, not the code |
zhougengxian/CoG/CoG/kg/fact_prune_extract.py code served (permissive licence) · get_code("e388824b8c92195e") 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 json
import math
# Construct the retrieved_facts_by_pid dictionary
retrieved_facts_by_pid = {
"P31": {
"label": "instance of",
"outgoing_entities": [
{"entity": "Q5", "label": "human"},
{"entity": "Q6", "label": "work"},
{"entity": "Q7", "label": "location"}
],
"literal_values": [
{"value": "test_value_1"},
{"value": "test_value_2"}
],
"incoming_entities": [
{"entity": "Q100", "label": "item1"},
{"entity": "Q101", "label": "item2"}
]
},
"P21": {
"label": "sex or gender",
"outgoing_entities": [
{"entity": "Q6581097", "label": "male"},
{"entity": "Q6581098", "label": "female"}
],
"literal_values": None,
"incoming_entities": [
{"entity": "Q200", "label": "incoming_item1"},
{"entity": "Q201", "label": "incoming_item2"},
{"entity": "Q202", "label": "incoming_item3"},
{"entity": "Q203", "label": "incoming_item4"}
]
},
"P625": {
"label": "coordinate location",
"outgoing_entities": [],
"literal_values": [
{"value": "52.5200, 13.4050"}
],
"incoming_entities": []
}
}
entity_label = "Albert Einstein"
max_display_facts = 10
min_facts_per_group = 2
ARGS = {
"retrieved_facts_by_pid": retrieved_facts_by_pid,
"entity_label": entity_label,
"max_display_facts": max_display_facts,
"min_facts_per_group": min_facts_per_group
}
- 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_facts_for_pruning_prompt |
Ran ran; our contract draft was wrong, not the code |
zhougengxian/CoG/CoG/kg/fact_prune_filter.py code served (permissive licence) · get_code("739c851bff5145b4") 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 json
import math
# Construct a realistic retrieved_facts_by_pid dict
retrieved_facts_by_pid = {
"P123": {
"label": "birth_place",
"outgoing_entities": ["Paris", "France", "Europe"],
"literal_values": ["1990-01-15", "France"],
"incoming_entities": ["person_A", "person_B", "person_C", "person_D"]
},
"P456": {
"label": "occupation",
"outgoing_entities": ["Engineer", "Scientist"],
"literal_values": [],
"incoming_entities": ["John", "Jane", "Bob", "Alice", "Charlie"]
},
"P789": {
"label": "written_by",
"outgoing_entities": ["Author1"],
"literal_values": ["2020"],
"incoming_entities": ["Book1", "Book2", "Book3", "Book4", "Book5", "Book6", "Book7", "Book8"]
}
}
entity_label = "Einstein"
max_display_facts = 10
min_facts_per_group = 2
ARGS = {
"retrieved_facts_by_pid": retrieved_facts_by_pid,
"entity_label": entity_label,
"max_display_facts": max_display_facts,
"min_facts_per_group": min_facts_per_group
}
- 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_context_triplets |
Ran ran; our contract draft was wrong, not the code |
zhougengxian/CoG/CoG/kg/recall_entity.py code served (permissive licence) · get_code("423108972d75d28a") 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.
class MockWikidataClient:
def __init__(self):
pass
def query_all(self, query_type, *args):
if query_type == 'get_all_relations_of_an_entity':
return {
'head': [
{'pid': 'P31', 'label': 'instance of', 'counter': 150},
{'pid': 'P17', 'label': 'country', 'counter': 120},
{'pid': 'P625', 'label': 'coordinate location', 'counter': 90},
{'pid': 'P580', 'label': 'start time', 'counter': 75},
{'pid': 'P582', 'label': 'end time', 'counter': 60},
{'pid': 'P813', 'label': 'retrieved', 'counter': 50},
{'pid': 'P214', 'label': 'viaf id', 'counter': 40},
],
'tail': [
{'pid': 'P106', 'label': 'occupation', 'counter': 130},
{'pid': 'P22', 'label': 'father', 'counter': 110},
{'pid': 'P25', 'label': 'mother', 'counter': 100},
]
}
elif query_type == 'get_tail_entities_given_head_and_relation':
return {
'tail': [
{'label': 'Entity1'},
{'label': 'Entity2'},
{'label': 'Entity3'},
],
'head': [
{'label': 'HeadEntity1'},
{'label': 'HeadEntity2'},
]
}
elif query_type == 'get_tail_values_given_head_and_relation':
return ['value1', 'value2', 'value3']
return {}
client = MockWikidataClient()
qid = 'Q42'
max_relations = 6
max_tails_per_relation = 3
ARGS = {
'client': client,
'qid': qid,
'max_relations': max_relations,
'max_tails_per_relation': max_tails_per_relation,
}
- 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 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
|
| get_context_triplets_properties |
Ran ran; our contract draft was wrong, not the code |
zhougengxian/CoG/CoG/kg/recall_entity.py code served (permissive licence) · get_code("64b2d3d1dde1401f") 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 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.
# Create a mock client that implements the required query methods
class MockWikidataClient:
def query_all(self, method_name, *args):
if method_name == 'get_all_relations_of_an_entity':
# Returns all relations for an entity
return {
'head': [
{'pid': 'P31', 'label': 'instance of', 'counter': 5},
{'pid': 'P279', 'label': 'subclass of', 'counter': 3},
{'pid': 'P106', 'label': 'occupation', 'counter': 2},
{'pid': 'P101', 'label': 'field of work', 'counter': 1},
{'pid': 'P999', 'label': 'custom relation', 'counter': 4},
{'pid': 'P888', 'label': 'another custom relation', 'counter': 2},
{'pid': 'P777', 'label': 'yet another relation', 'counter': 1},
],
'tail': [
{'pid': 'P27', 'label': 'country of citizenship', 'counter': 3},
{'pid': 'P21', 'label': 'sex or gender', 'counter': 2},
]
}
elif method_name == 'get_tail_entities_given_head_and_relation':
# Returns tail entities for a given head entity and relation
qid, pid = args[0], args[1]
return {
'tail': [
{'label': 'Entity1', 'qid': 'Q1'},
{'label': 'Entity2', 'qid': 'Q2'},
{'label': 'Entity3', 'qid': 'Q3'},
{'label': 'Entity4', 'qid': 'Q4'},
],
'head': [
{'label': 'HeadEntity1', 'qid': 'Q10'},
{'label': 'HeadEntity2', 'qid': 'Q11'},
]
}
return {}
ARGS = {
'client': MockWikidataClient(),
'qid': 'Q42',
'max_relations': 6,
'num_priority_relations': 3,
'max_tails_per_relation': 3,
}
- 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 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_process_start_time_iso |
Ran ran; our contract draft was wrong, not the code |
zhougengxian/CoG/CoG/utils_log.py code served (permissive licence) · get_code("51e154287aad0754") 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 os
import psutil
from datetime import datetime, timezone
# Get the current process PID as a valid argument
current_pid = os.getpid()
ARGS = {
"pid": current_pid
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- psutil — 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
|
| parse_and_find_entity |
Ran ran; our contract draft was wrong, not the code |
zhougengxian/CoG/CoG/kg/entity_link.py code served (permissive licence) · get_code("cf1a41618e0ae56f") 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 re
# Test case 1: Valid QID that exists in candidates
result_text_valid = "q42"
candidates_valid = [
{'qid': 'Q42', 'label': 'Douglas Adams', 'description': 'English author'},
{'qid': 'Q1', 'label': 'Universe', 'description': 'physical reality'},
]
# Test case 2: NO_MATCH string
result_text_no_match = "NO_MATCH"
candidates_no_match = [
{'qid': 'Q42', 'label': 'Douglas Adams', 'description': 'English author'},
]
# Test case 3: Valid QID format but not in candidates (triggers retry)
result_text_hallucinated = "Q999"
candidates_hallucinated = [
{'qid': 'Q42', 'label': 'Douglas Adams', 'description': 'English author'},
]
# Test case 4: Invalid format (parsing failure)
result_text_invalid = "invalid text"
candidates_invalid = [
{'qid': 'Q42', 'label': 'Douglas Adams', 'description': 'English author'},
]
# Use the valid case for ARGS
ARGS = {
'result_text': result_text_valid,
'candidates': candidates_valid,
}
- 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 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
|
| parse_answer_generation_result |
Ran ran; our contract draft was wrong, not the code |
zhougengxian/CoG/CoG/answer/complete.py code served (permissive licence) · get_code("75d96c224a23b5a6") 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 re
def parse_answer_generation_result(result_text: str):
"""
Parses the LLM's output for the final answer generation.
"""
try:
thought_process_match = re.search('Final Thought Process:(.*?)Final Answer:', result_text, re.DOTALL)
final_answer_match = re.search('Final Answer:(.*)', result_text, re.DOTALL)
if not (thought_process_match and final_answer_match):
print("Parsing Error: Could not find 'Final Thought Process' or 'Final Answer' in the output.")
print(f'Full Response:\\n{result_text}')
return None
final_thought_process = thought_process_match.group(1).strip()
final_answer = final_answer_match.group(1).strip()
return {'final_thought_process': final_thought_process, 'final_answer': final_answer}
except Exception as e:
print(f'An unexpected exception occurred during answer parsing: {e}\\nInput text was: {result_text}')
return None
# Valid result text with both required sections
result_text_valid = """
Final Thought Process:
The problem requires careful analysis of the given constraints.
We need to consider multiple factors and derive the solution step by step.
The intermediate steps lead us to the conclusion that the answer is 42.
Final Answer:
The answer is 42 because it satisfies all the given conditions and represents the ultimate answer to life, the universe, and everything.
"""
ARGS = {
'result_text': result_text_valid
}
- 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 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
|
| parse_extraction_result |
Ran ran; our contract draft was wrong, not the code |
zhougengxian/CoG/CoG/kg/fact_prune_extract.py code served (permissive licence) · get_code("3a985ba901803d66") 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 re
def parse_extraction_result(result_text: str, retrieved_facts_by_pid: dict=None):
"""
Parses the LLM's output for fact extraction.
"""
try:
rationale_match = re.search('Rationale:(.*?)(?=\\nExtracted Info:|$)', result_text, re.DOTALL)
rationale = rationale_match.group(1).strip() if rationale_match else 'No rationale provided.'
info_match = re.search('Extracted Info:(.*)', result_text, re.DOTALL)
extracted_info_raw = info_match.group(1).strip() if info_match else ''
extracted_info = None if extracted_info_raw.lower() == 'none' else extracted_info_raw
if not rationale_match or not info_match:
print(f'Parsing Error: Missing required markers in the output.\nInput text was: {result_text}')
return None
print('Successfully parsed the extracted facts from LLM.')
return {'reasoning': rationale, 'extracted_info': extracted_info}
except Exception as e:
print(f'Parsing Error: Failed to parse LLM output. Error: {e}\nInput text was: {result_text}')
return None
# Setup code to construct valid arguments
result_text_valid = """Rationale: The document discusses the historical significance of the event.
Extracted Info: Event occurred in 2023, involved 150 participants."""
retrieved_facts_by_pid_dict = {
"pid_001": ["fact1", "fact2"],
"pid_002": ["fact3"]
}
ARGS = {
"result_text": result_text_valid,
"retrieved_facts_by_pid": retrieved_facts_by_pid_dict
}
- 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 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
|
| parse_failure_conclusion_result |
Ran ran; our contract draft was wrong, not the code |
zhougengxian/CoG/CoG/answer/fail.py code served (permissive licence) · get_code("b1c2d2b12574685c") 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 re
def parse_failure_conclusion_result(result_text: str):
"""
Parses the LLM's output for the failure conclusion.
"""
try:
thought_process_match = re.search('Final Thought Process:(.*?)Final Answer:', result_text, re.DOTALL)
final_answer_match = re.search('Final Answer:(.*?)Root Cause Analysis:', result_text, re.DOTALL)
analysis_match = re.search('Root Cause Analysis:(.*)', result_text, re.DOTALL)
if not (thought_process_match and final_answer_match and analysis_match):
print('Parsing Error: Could not find one or more required fields in the failure conclusion output.')
print(f'Full Response:\n{result_text}')
return None
final_thought_process = thought_process_match.group(1).strip()
final_answer = final_answer_match.group(1).strip()
root_cause_analysis = analysis_match.group(1).strip()
return {'final_thought_process': final_thought_process, 'final_answer': final_answer, 'root_cause_analysis': root_cause_analysis}
except Exception as e:
print(f'An unexpected exception occurred during failure conclusion parsing: {e}\nInput text was: {result_text}')
return None
# Valid test input with all required sections
valid_result_text = """
Final Thought Process:
The system failed because of a timeout issue. The request took longer than expected.
Final Answer:
The root cause is a performance bottleneck in the database query layer.
Root Cause Analysis:
The database connection pool was exhausted, causing all subsequent queries to queue indefinitely.
This led to the timeout error observed in the logs.
"""
ARGS = {
'result_text': valid_result_text
}
- 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 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
|
| parse_max_turns_conclusion_result |
Ran ran; our contract draft was wrong, not the code |
zhougengxian/CoG/CoG/answer/max_turn.py code served (permissive licence) · get_code("6ab9c49c62bb5f31") 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 re
def parse_max_turns_conclusion_result(result_text: str):
"""
Parses the LLM's output for the MAX_TURNS conclusion.
"""
try:
thought_process_match = re.search('Final Thought Process:(.*?)Final Answer:', result_text, re.DOTALL)
final_answer_match = re.search('Final Answer:(.*?)Analysis of Incompletion:', result_text, re.DOTALL)
analysis_match = re.search('Analysis of Incompletion:(.*)', result_text, re.DOTALL)
if not (thought_process_match and final_answer_match and analysis_match):
print('Parsing Error: Could not find one or more required fields in the MAX_TURNS output.')
print(f'Full Response:\n{result_text}')
return None
final_thought_process = thought_process_match.group(1).strip()
final_answer = final_answer_match.group(1).strip()
analysis_of_incompletion = analysis_match.group(1).strip()
return {'final_thought_process': final_thought_process, 'final_answer': final_answer, 'analysis_of_incompletion': analysis_of_incompletion}
except Exception as e:
print(f'An unexpected exception occurred during MAX_TURNS conclusion parsing: {e}\nInput text was: {result_text}')
return None
# Valid result text with all required sections
valid_result_text = """Final Thought Process: The model has reached maximum turns while processing the query. The reasoning has been extensive but incomplete due to the turn limit. Further analysis would be beneficial.
Final Answer: Based on the available processing, the model concludes that more computational resources and turns would be needed to fully resolve this query. The current answer represents a partial solution.
Analysis of Incompletion: The model stopped because MAX_TURNS was reached. The analysis is incomplete because the recursive reasoning loop terminated. Additional turn allocation would allow for deeper exploration of the problem space."""
ARGS = {
'result_text': valid_result_text
}
- 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 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
|
| parse_pruning_result |
Ran ran; our contract draft was wrong, not the code |
zhougengxian/CoG/CoG/kg/fact_prune_filter.py code served (permissive licence) · get_code("8887b37b59134cec") 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 json
# Define test data for parse_pruning_result
result_text = json.dumps({
"reasoning": "The LLM pruned facts based on relevance to the query.",
"pruned_facts": {
"outgoing": {
"P123": ["entity1", "entity2", "literal_value1"],
"P456": ["entity3"]
},
"incoming": {
"P789": ["entity4", "entity5"]
}
}
})
retrieved_facts_by_pid = {
"P123": {
"outgoing_entities": ["entity1", "entity2", "entity6"],
"literal_values": ["literal_value1", "literal_value2"],
"incoming_entities": []
},
"P456": {
"outgoing_entities": ["entity3", "entity7"],
"literal_values": ["literal_value3"],
"incoming_entities": []
},
"P789": {
"outgoing_entities": [],
"literal_values": [],
"incoming_entities": ["entity4", "entity5", "entity8"]
}
}
ARGS = {
"result_text": result_text,
"retrieved_facts_by_pid": retrieved_facts_by_pid
}
- 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 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
|
| prepare_question_queue |
Ran ran; our contract draft was wrong, not the code |
zhougengxian/CoG/CoG/utils_run.py code served (permissive licence) · get_code("83577334a4ef2765") 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 2, 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 os
import json
import tempfile
from pathlib import Path
# Create a minimal logger class that mimics ExperimentLogger
class MockLogger:
def __init__(self, run_dir):
self.run_dir = run_dir
# Create a minimal dataset
dataset = [
{"id": 0, "question": "What is the capital of France?"},
{"id": 1, "question": "What is the capital of Germany?"},
{"id": 2, "question": "What is the capital of Italy?"},
{"id": 3, "question": "What is the capital of Spain?"},
{"id": 4, "question": "What is the capital of Portugal?"},
]
# Create a temporary directory for logger
temp_dir = tempfile.mkdtemp()
logger = MockLogger(run_dir=temp_dir)
# Create results_complete directory with some completed results
results_complete_dir = os.path.join(temp_dir, 'results_complete')
os.makedirs(results_complete_dir, exist_ok=True)
# Add a couple of completed result files
with open(os.path.join(results_complete_dir, '0.json'), 'w') as f:
json.dump({"index": 0, "result": "Paris"}, f)
with open(os.path.join(results_complete_dir, '1.json'), 'w') as f:
json.dump({"index": 1, "result": "Berlin"}, f)
# Create summary_statistics.json for failed only mode testing
summary_stats = {
"reliability_stats": {
"wiki_failures": {
"failed_question_ids": [3]
},
"llm_failures": {
"error_details": {
"APITimeoutError('Request timed out.')": {
"question_ids": [4]
}
}
}
}
}
with open(os.path.join(temp_dir, 'summary_statistics.json'), 'w') as f:
json.dump(summary_stats, f)
# Define ARGS dictionary with all parameters
ARGS = {
"dataset": dataset,
"logger": logger,
"resume_run_id": None, # New run mode
"run_unfinished": True,
"rerun_specific_indices": None,
"run_specific_indices": None,
"rerun_failed_only": False,
"limit": None,
"start": 0,
}
- 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 2, 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
|
| run_llm |
Ran ran; our contract draft was wrong, not the code |
zhougengxian/CoG/CoG/utils.py code served (permissive licence) · get_code("eee3dea1160808bc") 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 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 time
import openai
from unittest.mock import Mock, MagicMock, patch
# Create a mock args object with all required attributes
class MockArgs:
def __init__(self):
self.base_url = "http://localhost:8000/v1"
self.model = "gpt-3.5-turbo"
self.kg_base_url = None
self.kg_model = None
self.wiki_base_url = None
self.wiki_model = None
self.enable_thinking = False
args = MockArgs()
# Create a mock OpenAI client and response
mock_message = Mock()
mock_message.content = "This is a helpful response."
mock_choice = Mock()
mock_choice.message = mock_message
mock_response = Mock()
mock_response.choices = [mock_choice]
# Patch the openai.OpenAI class to return a mock client
def mock_openai_init(base_url, timeout):
mock_client = Mock()
mock_client.chat = Mock()
mock_client.chat.completions = Mock()
mock_client.chat.completions.create = Mock(return_value=mock_response)
return mock_client
ARGS = {
'prompt': "What is the capital of France?",
'args': args,
'module': 'main',
'n': 1,
'generation_params': {'temperature': 0.7, 'top_p': 0.9}
}
# Patch openai.OpenAI for the function to work
openai.OpenAI = mock_openai_init
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- openai — 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
|
| generate_process |
Not yet run unverified (harvested, no recorded run) |
zhougengxian/CoG/CoG/utils.py code served (permissive licence) · get_code("3b7fdabd3eb9d86f") How it ran |
| prepare_dataset |
Not yet run unverified (harvested, no recorded run) |
zhougengxian/CoG/CoG/utils.py code served (permissive licence) · get_code("7d304feda300ff3f") How it ran |