| build_messages |
Ran ran; our contract draft was wrong, not the code |
umass-ml4ed/generalization-in-essay-scoring/infer_traits.py code served (permissive licence) · get_code("5f467ab96140f274") 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
torch.manual_seed(0)
# Construct arguments for build_messages function
# The function takes:
# 1. prompt_template: str - a template string that may contain {ESSAY_TEXT} placeholder
# 2. essay_text: str - the actual essay text to insert
# Test case 1: template with the expected essay block format
prompt_template = """You are an expert essay analyzer. Analyze the following essay for traits.
Essay:
<<<
{ESSAY_TEXT}
>>>
Provide detailed analysis."""
essay_text = """This is a sample essay about the importance of education.
Education shapes our future and enables personal growth.
It provides opportunities and opens doors to success."""
ARGS = {
'prompt_template': prompt_template,
'essay_text': essay_text,
}
- 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
|
| calculate_rmse |
Ran ran, honoured the contract we drafted |
umass-ml4ed/generalization-in-essay-scoring/analyze_results.py code served (permissive licence) · get_code("6be2bf8b8ae3d3a5") 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 float64, ndim 0, 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
# Construct ground truth labels - mix of valid categorical labels
ground_truth = ['not applicable', 'below emerging', 'emerging', 'expanding', 'exemplifying', 'emerging']
# Construct predicted labels - mix of valid categorical labels with some variation
predicted = ['not applicable', 'emerging', 'emerging', 'expanding', 'expanding', 'below emerging']
ARGS = {
'ground_truth': ground_truth,
'predicted': predicted
}
- 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 float64, ndim 0, dtype family float — no output shape is stated: observe_signature.py recorded float ndim 0, which disagrees with the fixture run
- 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
|
| construct_prompt_message |
Ran ran on a synthesized input |
umass-ml4ed/generalization-in-essay-scoring/prompt_llm_utils.py code served (permissive licence) · get_code("f8f7f419c5b351b2") 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 numpy as np
torch.manual_seed(0)
# Define the arguments
system_prompt = "You are a helpful assistant that answers questions concisely."
user_prompt = "What is the capital of France?"
few_shot_prompt = {
0: {
'User': 'What is the capital of Germany?',
'Assistant': 'The capital of Germany is Berlin.'
},
1: {
'User': 'What is the capital of Spain?',
'Assistant': 'The capital of Spain is Madrid.'
}
}
ARGS = {
'system_prompt': system_prompt,
'user_prompt': user_prompt,
'few_shot_prompt': few_shot_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 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
|
| create_data_splits |
Ran ran; our contract draft was wrong, not the code |
umass-ml4ed/generalization-in-essay-scoring/llama_data.py code served (permissive licence) · get_code("4fb9b0736c4f60d3") 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. 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 pandas as pd
import numpy as np
# Create a small sample dataframe with realistic structure
np.random.seed(47)
data = {
'text': [f'sample text {i}' for i in range(100)],
'label': np.random.randint(0, 2, 100),
'id': range(100)
}
gt_df = pd.DataFrame(data)
ARGS = {
'gt_df': gt_df,
'random_state': 47
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type tuple — a tuple output has no array shape of its own; none is stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| extract_observations_dict |
Ran ran; our contract draft was wrong, not the code |
umass-ml4ed/generalization-in-essay-scoring/llama_train_wrubric_traits.py code served (permissive licence) · get_code("45f2dde85a993307") 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 torch
import numpy as np
TRAIT_KEYS_ORDER = ['claim_explicitness', 'structural_coherence', 'evidence_presence', 'evidence_claim_linkage', 'alternative_perspectives', 'analytical_depth']
def extract_observations_dict(entry):
"""
Extract per-trait observation strings from a trait entry payload.
Supports:
- {"observations": {"claim_explicitness": "...", ...}, ...}
Returns a dict keyed by trait name, or an empty dict.
"""
if not isinstance(entry, dict):
return {}
obs_source = entry.get('observations', {})
if not isinstance(obs_source, dict):
return {}
observations = {}
for key in TRAIT_KEYS_ORDER:
if key in obs_source and obs_source[key]:
observations[key] = obs_source[key]
return observations
# Test case 1: Valid entry with observations for all traits
entry_full = {
'observations': {
'claim_explicitness': 'The claim is clearly stated.',
'structural_coherence': 'The argument flows logically.',
'evidence_presence': 'Strong empirical evidence provided.',
'evidence_claim_linkage': 'Evidence directly supports the claim.',
'alternative_perspectives': 'Multiple viewpoints considered.',
'analytical_depth': 'Deep analysis of the topic.'
},
'other_field': 'some value'
}
# Test case 2: Entry with partial observations
entry_partial = {
'observations': {
'claim_explicitness': 'Claim is explicit.',
'analytical_depth': 'Moderate depth.'
}
}
# Test case 3: Entry with empty observations
entry_empty = {
'observations': {}
}
# Test case 4: Entry with non-dict observations (should return {})
entry_non_dict = {
'observations': 'not a dict'
}
# Test case 5: Entry that is not a dict (should return {})
entry_not_dict = 'string entry'
# Test case 6: Entry with None observations
entry_none = {
'observations': None
}
# Use the most comprehensive test case
ARGS = {
'entry': entry_full
}
- 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 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
|
| extract_trait_dict |
Ran ran; our contract draft was wrong, not the code |
umass-ml4ed/generalization-in-essay-scoring/llama_train_wrubric_traits.py code served (permissive licence) · get_code("c5d9af799ba2fdb5") 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 torch
import numpy as np
TRAIT_KEYS_ORDER = ['claim_explicitness', 'structural_coherence', 'evidence_presence', 'evidence_claim_linkage', 'alternative_perspectives', 'analytical_depth']
# Test case 1: entry with nested 'traits' dict
entry_with_traits_key = {
'traits': {
'claim_explicitness': 'explicit',
'structural_coherence': 'high',
'evidence_presence': 'present',
'evidence_claim_linkage': 'strong',
'alternative_perspectives': 'considered',
'analytical_depth': 'deep'
},
'raw': 'some raw text that should be ignored'
}
# Test case 2: entry with flat trait keys
entry_flat_traits = {
'claim_explicitness': 'implicit',
'structural_coherence': 'low',
'evidence_presence': 'absent',
'observations': 'this should be ignored'
}
# Test case 3: entry with partial traits
entry_partial_traits = {
'traits': {
'claim_explicitness': 'mixed',
'evidence_presence': 'partial'
}
}
# Test case 4: entry with no traits (empty dict)
entry_no_traits = {
'observations': 'only non-trait fields',
'raw': 'text'
}
# Test case 5: non-dict entry
entry_non_dict = None
ARGS = {
'entry': entry_with_traits_key
}
- 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 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
|
| filter_dataset_by_subskills |
Ran ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT) |
umass-ml4ed/generalization-in-essay-scoring/llama_train_wrubric.py code served (permissive licence) · get_code("b3401fcaab0399b3") 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 DataFrame. 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 pandas as pd
# Create a sample dataframe with subskill_full column
df = pd.DataFrame({
'subskill_full': [
'1.Introduction',
'1.1.Basics',
'2.Advanced',
'2.1.Details',
'3.Expert',
'1.2.More'
]
})
# Define subskill numbers to filter by
subskill_nums = [1, 2]
ARGS = {
'df': df,
'subskill_nums': subskill_nums
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- pandas — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 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_trait_text |
Ran ran; our contract draft was wrong, not the code |
umass-ml4ed/generalization-in-essay-scoring/llama_train_wrubric_traits.py code served (permissive licence) · get_code("7da3b1c8eb845e35") 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
ARGS = {
"value": "snake_case_trait_name"
}
- 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
|
| get_few_shot_text |
Ran ran; our contract draft was wrong, not the code |
umass-ml4ed/generalization-in-essay-scoring/classify.py code served (permissive licence) · get_code("eb44e2383591feea") 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 pandas as pd
import numpy as np
# Create a small dataframe with essay data
data = {
'essay_id': ['essay_1', 'essay_2', 'essay_3'],
'essay_text': [
'This is the first essay about writing skills.',
'This is the second essay about critical thinking.',
'This is the third essay about communication.'
]
}
gt_df = pd.DataFrame(data)
# Create few_shot_cats dictionary mapping categories to essay IDs
few_shot_cats = {
'writing skills': ['essay_1'],
'critical thinking': ['essay_2', 'essay_3'],
'communication': None
}
ARGS = {
'few_shot_cats': few_shot_cats,
'gt_df': gt_df
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, pandas — 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_few_shot_text |
Ran ran; our contract draft was wrong, not the code |
umass-ml4ed/generalization-in-essay-scoring/classify_justification.py code served (permissive licence) · get_code("3b521b00a7bc1332") 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 pandas as pd
# Create a minimal DataFrame with the required structure
gt_df = pd.DataFrame({
'essay_id': ['essay_001', 'essay_002', 'essay_003'],
'essay_text': [
'This is the first sample essay about mathematics.',
'This is the second sample essay about science.',
'This is the third sample essay about history.'
]
})
# Create few_shot_cats dictionary with category names and corresponding essay IDs
few_shot_cats = {
'excellent writing': 'essay_001',
'good structure': 'essay_002',
'needs improvement': None,
}
ARGS = {
'few_shot_cats': few_shot_cats,
'gt_df': gt_df,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- pandas — 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_label_and_justification |
Ran ran; our contract draft was wrong, not the code |
umass-ml4ed/generalization-in-essay-scoring/classify.py code served (permissive licence) · get_code("c3bd338ec75c117c") 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 torch
ARGS = {
'response': 'Label - 1: positive\nJustification - This is a great product with excellent quality.'
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| get_label_and_obs |
Ran ran; our contract draft was wrong, not the code |
umass-ml4ed/generalization-in-essay-scoring/majority_vote_traits.py code served (permissive licence) · get_code("d1a39f56a947a1c7") 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 torch
torch.manual_seed(0)
essay_data = {
'traits': {
'trait_A': 8,
'trait_B': 7,
'observations': {
'trait_A': 'This essay demonstrates strong analytical skills.',
'trait_B': 'Good use of evidence.'
}
}
}
trait = 'trait_A'
ARGS = {
'essay_data': essay_data,
'trait': trait
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| load_prompt_template |
Ran ran; our contract draft was wrong, not the code |
umass-ml4ed/generalization-in-essay-scoring/infer_traits.py code served (permissive licence) · get_code("c78179a9cf42084f") 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 tempfile
import os
# Create a temporary directory and a temporary prompt file
temp_dir = tempfile.mkdtemp()
prompt_path = os.path.join(temp_dir, 'traits.txt')
# Write a sample prompt template to the temporary file
with open(prompt_path, 'w') as f:
f.write("This is a sample prompt template for traits.\nIt contains multiple lines.\nAnd various prompt instructions.")
# Define the arguments dictionary
ARGS = {
'path': prompt_path
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| parse_trait_response |
Ran ran; our contract draft was wrong, not the code |
umass-ml4ed/generalization-in-essay-scoring/infer_traits.py code served (permissive licence) · get_code("5ad62a429309eac8") 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
import ast
import re
import logging
logger = logging.getLogger(__name__)
def _flatten_traits(parsed: dict) -> dict:
"""
Normalize a parsed trait dict into a flat label dict.
Handles two formats:
- nested (CoT): {"trait": {"observation": "...", "label": "label_value"}, ...}
- flat (legacy): {"trait": "label_value", ...}
Returns a flat dict of trait -> label, with an additional "observations" key
(mapping trait -> observation string) when the nested format is present.
"""
flat = {}
observations = {}
for key, val in parsed.items():
if isinstance(val, dict) and 'label' in val:
flat[key] = val['label']
if 'observation' in val:
observations[key] = val['observation']
elif isinstance(val, str):
flat[key] = val
if observations:
flat['observations'] = observations
return flat
def parse_trait_response(response_text: str) -> dict:
"""
Parse the model's response into a flat trait-label dict.
Accepts both the new CoT nested format and the legacy flat format.
Tries json.loads first (preferred), then ast.literal_eval as fallback.
Extracts the outermost {...} block if the response contains extra text.
Returns:
Flat dict with trait keys (+ optional "observations" key),
or {"parse_error": True, "raw": ...} on failure.
"""
cleaned = response_text.strip()
def _try_parse(text: str) -> dict | None:
for parser in (json.loads, ast.literal_eval):
try:
result = parser(text)
if isinstance(result, dict):
return _flatten_traits(result)
except Exception:
pass
return None
result = _try_parse(cleaned)
if result is not None:
return result
match = re.search('\\{.*\\}', cleaned, re.DOTALL)
if match:
result = _try_parse(match.group(0))
if result is not None:
return result
logger.warning(f'Could not parse response: {cleaned[:300]}')
return {'parse_error': True, 'raw': response_text}
# Test cases for different input formats
ARGS = {
"response_text": '{"trait1": "label1", "trait2": "label2"}'
}
- 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_pseudo_label_training_data |
Ran ran; our contract draft was wrong, not the code |
umass-ml4ed/generalization-in-essay-scoring/llama_train_wrubric.py code served (permissive licence) · get_code("058e5870d7e482cb") 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 DataFrame. 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 pandas as pd
import logging
logging.basicConfig(level=logging.INFO)
# Create test_df with essay_id and essay_text columns
test_df = pd.DataFrame({
'essay_id': ['essay_1', 'essay_2', 'essay_1'],
'essay_text': [
'This is the first essay about writing skills.',
'This is the second essay about reading comprehension.',
'This is the first essay about writing skills.'
]
})
# Create rubric_df with required columns
rubric_df = pd.DataFrame({
'Subskill': ['3.1 Main Idea', '3.2 Supporting Details', '4.1 Grammar', '4.2 Punctuation'],
'Definition': [
'Ability to identify main idea',
'Ability to provide supporting details',
'Understanding of grammar rules',
'Understanding of punctuation rules'
],
'Not Applicable': [
'Not applicable for this skill',
'Not applicable for this skill',
'Not applicable for this skill',
'Not applicable for this skill'
],
'Below Emerging': [
'Does not identify main idea',
'No supporting details',
'Grammar errors present',
'Punctuation errors present'
],
'Emerging': [
'Partially identifies main idea',
'Few supporting details',
'Minor grammar errors',
'Minor punctuation errors'
],
'Expanding': [
'Clearly identifies main idea',
'Some supporting details',
'Good grammar',
'Good punctuation'
],
'Exemplifying': [
'Exceptionally identifies main idea',
'Excellent supporting details',
'Excellent grammar',
'Excellent punctuation'
]
})
# Create pseudo_labels dict
pseudo_labels = {
'essay_1': {
'3.1 Main Idea': {
'label': 'exemplifying',
'justification': 'The essay clearly articulates the main idea throughout.'
},
'3.2 Supporting Details': {
'label': 'expanding',
'justification': 'Good use of supporting details.'
}
},
'essay_2': {
'4.1 Grammar': {
'label': 'emerging',
'justification': 'Minor grammar issues present.'
},
'4.2 Punctuation': {
'label': 'expanding',
'justification': 'Punctuation is mostly correct.'
}
}
}
# train_subskill_nums list
train_subskill_nums = [3, 4]
ARGS = {
'test_df': test_df,
'rubric_df': rubric_df,
'pseudo_labels': pseudo_labels,
'train_subskill_nums': train_subskill_nums
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- pandas — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 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_training_data |
Ran ran; our contract draft was wrong, not the code |
umass-ml4ed/generalization-in-essay-scoring/llama_data.py code served (permissive licence) · get_code("6d66bc0a52473e77") 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 DataFrame. 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 pandas as pd
# Create essay_df with essay data
essay_data = {
'essay_id': [1, 2],
'essay_text': ['This is a sample essay about writing.', 'Another essay example for testing.'],
'Subskill 1': ['exemplifying', 'emerging'],
'Subskill 2': ['expanding', 'below_emerging'],
'Subskill 1: Writing Clarity': ['exemplifying', 'emerging'],
'Subskill 2: Organization': ['expanding', 'below_emerging']
}
essay_df = pd.DataFrame(essay_data)
# Create rubric_df with rubric definitions
rubric_data = {
'Subskill': [
'Subskill 1: Writing Clarity',
'Subskill 2: Organization'
],
'Definition': [
'The ability to express ideas clearly and concisely.',
'The ability to structure ideas in a logical order.'
],
'Not Applicable': [
'N/A - not applicable for this essay',
'N/A - not applicable for this essay'
],
'Below Emerging': [
'Writing is unclear and difficult to follow.',
'Ideas are disorganized and hard to follow.'
],
'Emerging': [
'Writing is somewhat clear with minor issues.',
'Ideas are mostly organized with some gaps.'
],
'Expanding': [
'Writing is clear and generally well-expressed.',
'Ideas are well-organized with logical flow.'
],
'Exemplifying': [
'Writing is exceptionally clear and compelling.',
'Ideas are excellently organized and coherent.'
]
}
rubric_df = pd.DataFrame(rubric_data)
# Create justification_df with justifications
justification_data = {
'Essay ID': ['1', '1', '2'],
'Subskill': ['Subskill 1', 'Subskill 2', 'Subskill 1'],
'Justification': [
'The essay demonstrates exemplary writing clarity with well-constructed sentences.',
'The essay shows good organization with clear transitions between paragraphs.',
'This essay shows emerging clarity with some awkward phrasing.'
]
}
justification_df = pd.DataFrame(justification_data)
split_name = 'train'
ARGS = {
'essay_df': essay_df,
'rubric_df': rubric_df,
'justification_df': justification_df,
'split_name': split_name
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- pandas — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 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
|
| analyze_token_lengths |
Not yet run unverified (harvested, no recorded run) |
umass-ml4ed/generalization-in-essay-scoring/llama_data.py code served (permissive licence) · get_code("a116a51e8dfc0b6a") How it ran |
| load_version |
Not yet run unverified (harvested, no recorded run) |
umass-ml4ed/generalization-in-essay-scoring/majority_vote_traits.py code served (permissive licence) · get_code("2f207ee0f029edcd") How it ran |
| majority_vote |
Not yet run unverified (harvested, no recorded run) |
umass-ml4ed/generalization-in-essay-scoring/majority_vote_traits.py code served (permissive licence) · get_code("965991a74fc77621") How it ran |