| CosineGate |
Ran ran on a synthesized input · constructed an object; no result was computed |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("521b89dcdbcd7d90") 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 an instance of its own class, CosineGate: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
from dataclasses import dataclass
torch.manual_seed(0)
# Stand-in tokenizer
class StandInTokenizer:
def __call__(self, text, return_tensors=None, truncation=None, max_length=None, add_special_tokens=None):
# Return a simple tokenizer output with input_ids
ids = torch.tensor([[1, 2, 3, 4]], dtype=torch.long)
class TokenizerOutput:
def __init__(self, ids):
self.input_ids = ids
def to(self, device):
return TokenizerOutput(self.input_ids.to(device))
return TokenizerOutput(ids)
# Minimal model that satisfies the function's requirements
class StandInModel(nn.Module):
def __init__(self, embedding_dim=4):
super().__init__()
self.embedding_dim = embedding_dim
self.embeddings = nn.Embedding(100, embedding_dim)
def get_input_embeddings(self):
return self.embeddings
def forward(self, input_ids, output_hidden_states=False, use_cache=False):
# Return a simple output with hidden_states
batch_size = input_ids.shape[0]
seq_len = input_ids.shape[1]
hidden = torch.randn(batch_size, seq_len, self.embedding_dim, dtype=torch.float32)
class ModelOutput:
def __init__(self, hidden_states):
self.hidden_states = hidden_states
return ModelOutput([hidden, hidden])
# Create instances
model = StandInModel(embedding_dim=4)
tokenizer = StandInTokenizer()
# Create GateConfig
from dataclasses import dataclass
@dataclass
class GateConfig:
accept_threshold: float = 0.2
locality_threshold: float = 0.35
drift_window: int = 4
drift_threshold: float = 0.3
consecutive_to_rollback: int = 2
encoder_max_tokens: int = 256
config = GateConfig()
ARGS = {
'config': config
}
- 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 CosineGate — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a CosineGate 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
|
| GateConfig |
Ran ran on a synthesized input · constructed an object; no result was computed |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("9ce3914e50095785") 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 an instance of its own class, GateConfig: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import numpy as np
from dataclasses import dataclass
torch.manual_seed(0)
ARGS = {
"accept_threshold": 0.2,
"locality_threshold": 0.35,
"drift_window": 4,
"drift_threshold": 0.3,
"consecutive_to_rollback": 2,
"encoder_max_tokens": 256,
}
- 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 GateConfig — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a GateConfig 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
|
| LMHandle |
Ran ran on a synthesized input · constructed an object; no result was computed |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("35455cd1fdcd31cc") 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 an instance of its own class, LMHandle: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
torch.manual_seed(0)
class SimpleModel(nn.Module):
def __init__(self):
super().__init__()
self.linear = nn.Linear(4, 3)
def forward(self, x):
return self.linear(x)
class SimpleTokenizer:
def __init__(self):
self.vocab_size = 1000
def encode(self, text):
return [1, 2, 3, 4]
def decode(self, tokens):
return "decoded text"
ARGS = {
"name": "test_model",
"model": SimpleModel(),
"tokenizer": SimpleTokenizer(),
}
- 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 LMHandle — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a LMHandle 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
|
| LoRAFTConfig |
Ran ran on a synthesized input · constructed an object; no result was computed |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("0b7133a154d20bcd") 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 an instance of its own class, LoRAFTConfig: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
from dataclasses import dataclass
from typing import Tuple
torch.manual_seed(0)
ARGS = {
"rank": 8,
"alpha": 16,
"dropout": 0.05,
"target_modules": ('q_proj', 'k_proj', 'v_proj', 'o_proj', 'gate_proj', 'up_proj', 'down_proj'),
"steps": 60,
"batch_size": 2,
"lr": 0.0002,
"weight_decay": 0.01,
"grad_clip": 1.0,
"max_seq_length": 1024,
"early_stop_patience": 20,
"early_stop_min_delta": 0.001,
}
- 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 LoRAFTConfig — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a LoRAFTConfig 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
|
| SOMAConfig |
Ran ran on a synthesized input · constructed an object; no result was computed |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("c9908b5ffa9879a1") 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 an instance of its own class, SOMAConfig: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
from dataclasses import dataclass, field
from typing import List, Tuple
torch.manual_seed(0)
@dataclass
class GateConfig:
accept_threshold: float = 0.2
locality_threshold: float = 0.35
drift_window: int = 4
drift_threshold: float = 0.3
consecutive_to_rollback: int = 2
encoder_max_tokens: int = 256
@dataclass
class LoRAFTConfig:
rank: int = 8
alpha: int = 16
dropout: float = 0.05
target_modules: Tuple[str, ...] = ('q_proj', 'k_proj', 'v_proj', 'o_proj', 'gate_proj', 'up_proj', 'down_proj')
steps: int = 60
batch_size: int = 2
lr: float = 0.0002
weight_decay: float = 0.01
grad_clip: float = 1.0
max_seq_length: int = 1024
early_stop_patience: int = 20
early_stop_min_delta: float = 0.001
@dataclass
class SemanticDivergenceConfig:
"""Hyperparameters for the prompt-mining objective."""
soft_len: int = 16
n_candidates: int = 3
iters: int = 30
lr: float = 0.001
weight_decay: float = 0.01
grad_clip: float = 1.0
neighborhood_k: int = 32
teacher_topm: int = 100
temperature: float = 0.7
lambda_exp: float = 1.0
beta_anti_degen: float = 0.05
lambda_P: float = 0.0001
init_std: float = 0.02
scale: float = 0.25
max_prompt_tokens: int = 768
max_teacher_tokens: int = 96
@dataclass
class SOMAConfig:
warm_window: int = 4
compressed_prefix_turns: int = 2
max_new_tokens: int = 200
acceptance_min_turns: int = 2
mining: SemanticDivergenceConfig = field(default_factory=SemanticDivergenceConfig)
lora: LoRAFTConfig = field(default_factory=LoRAFTConfig)
gate: GateConfig = field(default_factory=GateConfig)
ARGS = {
'warm_window': 4,
'compressed_prefix_turns': 2,
'max_new_tokens': 200,
'acceptance_min_turns': 2,
'mining': SemanticDivergenceConfig(
soft_len=16,
n_candidates=3,
iters=30,
lr=0.001,
weight_decay=0.01,
grad_clip=1.0,
neighborhood_k=32,
teacher_topm=100,
temperature=0.7,
lambda_exp=1.0,
beta_anti_degen=0.05,
lambda_P=0.0001,
init_std=0.02,
scale=0.25,
max_prompt_tokens=768,
max_teacher_tokens=96
),
'lora': LoRAFTConfig(
rank=8,
alpha=16,
dropout=0.05,
target_modules=('q_proj', 'k_proj', 'v_proj', 'o_proj', 'gate_proj', 'up_proj', 'down_proj'),
steps=60,
batch_size=2,
lr=0.0002,
weight_decay=0.01,
grad_clip=1.0,
max_seq_length=1024,
early_stop_patience=20,
early_stop_min_delta=0.001
),
'gate': GateConfig(
accept_threshold=0.2,
locality_threshold=0.35,
drift_window=4,
drift_threshold=0.3,
consecutive_to_rollback=2,
encoder_max_tokens=256
)
}
- 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 SOMAConfig — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a SOMAConfig 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
|
| SemanticDivergenceConfig |
Ran ran on a synthesized input · constructed an object; no result was computed |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("ba9b99e7e09e0541") 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 an instance of its own class, SemanticDivergenceConfig: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import numpy as np
from dataclasses import dataclass, field
torch.manual_seed(0)
ARGS = {
"soft_len": 16,
"n_candidates": 3,
"iters": 30,
"lr": 0.001,
"weight_decay": 0.01,
"grad_clip": 1.0,
"neighborhood_k": 32,
"teacher_topm": 100,
"temperature": 0.7,
"lambda_exp": 1.0,
"beta_anti_degen": 0.05,
"lambda_P": 0.0001,
"init_std": 0.02,
"scale": 0.25,
"max_prompt_tokens": 768,
"max_teacher_tokens": 96,
}
- 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 SemanticDivergenceConfig — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a SemanticDivergenceConfig 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
|
| SoftPrompt |
Ran ran on a synthesized input · constructed an object; no result was computed |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("3f989f78df25c6dd") 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 an instance of its own class, SoftPrompt: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
torch.manual_seed(0)
# Define the arguments for SoftPrompt.__init__
ARGS = {
"emb_dim": 4,
"length": 3,
"dtype": torch.float32,
"device": torch.device("cpu"),
"init_std": 0.02,
"scale": 0.25,
}
- 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 SoftPrompt — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a SoftPrompt 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
|
| TurnLog |
Ran ran on a synthesized input · constructed an object; no result was computed |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("4da5dea573c333a1") 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 an instance of its own class, TurnLog: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
from dataclasses import dataclass, field
torch.manual_seed(0)
@dataclass
class TurnLog:
turn_idx: int
served_by: str
response: str
note: str = ''
ARGS = {
'turn_idx': 0,
'served_by': 'agent_1',
'response': 'Hello, how can I help you?',
'note': 'Initial greeting'
}
- 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 TurnLog — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a TurnLog 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
|
| _build_aligned_inputs |
Ran ran; our contract draft was wrong, not the code |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("e94372d620e92f1c") 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 torch
import torch.nn as nn
from typing import List, Tuple
torch.manual_seed(0)
class SoftPrompt(nn.Module):
"""Learnable soft prompt prepended at the embedding layer."""
def __init__(self, emb_dim: int, length: int, dtype: torch.dtype, device: torch.device, init_std: float=0.02, scale: float=0.25) -> None:
super().__init__()
self.length = length
self.emb_dim = emb_dim
self.scale = scale
self._model_dtype = dtype
self.prompt = nn.Parameter(torch.zeros(length, emb_dim, dtype=torch.float32, device=device))
nn.init.normal_(self.prompt, mean=0.0, std=init_std)
def squashed(self) -> torch.Tensor:
return torch.tanh(self.prompt) * self.scale
def prepend(self, x_emb: torch.Tensor) -> torch.Tensor:
sp = self.squashed().to(x_emb.dtype)
sp = sp.unsqueeze(0).expand(x_emb.size(0), -1, -1)
return torch.cat([sp, x_emb], dim=1)
def frob_sq(self) -> torch.Tensor:
return self.prompt.float().pow(2).sum()
def clone_detached(self) -> 'SoftPrompt':
clone = SoftPrompt(emb_dim=self.emb_dim, length=self.length, dtype=self._model_dtype, device=self.prompt.device, scale=self.scale)
with torch.no_grad():
clone.prompt.copy_(self.prompt.detach())
return clone
class SimpleTokenizer:
"""Minimal tokenizer stand-in."""
def __init__(self):
self.vocab_size = 100
def __call__(self, text, return_tensors=None, truncation=False, max_length=None, add_special_tokens=False):
# Simple: hash the text to deterministic token ids
tokens = [hash(text) % self.vocab_size for _ in range(3)]
input_ids = torch.tensor([tokens], dtype=torch.long)
if return_tensors == 'pt':
return type('obj', (object,), {'input_ids': input_ids})()
return input_ids
class SimpleEmbedding(nn.Module):
"""Minimal embedding layer stand-in."""
def __init__(self, vocab_size: int, emb_dim: int):
super().__init__()
self.embedding = nn.Embedding(vocab_size, emb_dim)
def forward(self, input_ids):
return self.embedding(input_ids)
device = torch.device('cpu')
dtype = torch.float32
tokenizer = SimpleTokenizer()
embed_layer = SimpleEmbedding(vocab_size=100, emb_dim=4)
soft_prompt = SoftPrompt(emb_dim=4, length=3, dtype=dtype, device=device, init_std=0.02, scale=0.25)
ARGS = {
'tokenizer': tokenizer,
'embed_layer': embed_layer,
'context': 'This is a context.',
'query': 'What is the answer?',
'soft_prompt': soft_prompt,
'teacher_text': 'The answer is 42.',
'max_prompt_tokens': 16,
'max_teacher_tokens': 8,
'device': device,
'dtype': dtype,
}
- 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 — 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
|
| _build_supervised_batch |
Ran ran; our contract draft was wrong, not the code |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("8327ee00efeff10e") 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 torch
from unittest.mock import Mock
torch.manual_seed(0)
class MockTokenizer:
def __init__(self):
self.pad_token_id = 0
self.eos_token_id = 1
def __call__(self, text, add_special_tokens=False):
result = Mock()
result.input_ids = [2, 3, 4] if len(text) > 10 else [2, 3]
return result
tokenizer = MockTokenizer()
pairs = [
("context one", "what is this", "this is a response", 1.0),
("context two", "another query", "another response here", 0.5),
]
max_seq_length = 16
device = torch.device('cpu')
ARGS = {
'tokenizer': tokenizer,
'pairs': pairs,
'max_seq_length': max_seq_length,
'device': device,
}
- 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 — 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
|
| _encode |
Ran ran, honoured the contract we drafted |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("8e512f8cc17a2d0e") 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 Tensor, ndim 1, dtype family float, shape (4,) 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
torch.manual_seed(0)
class MockTokenizer:
def __call__(self, text, return_tensors=None, truncation=None, max_length=None, add_special_tokens=None):
# Return a mock tokenizer output with input_ids
class TokenizerOutput:
def __init__(self):
self.input_ids = torch.tensor([[101, 2054, 2003, 102]], dtype=torch.long)
def to(self, device):
self.input_ids = self.input_ids.to(device)
return self
return TokenizerOutput()
class MockModel(nn.Module):
def __init__(self, hidden_dim=4):
super().__init__()
self.hidden_dim = hidden_dim
self.embedding = nn.Embedding(1000, hidden_dim)
def get_input_embeddings(self):
return self.embedding
def forward(self, input_ids, output_hidden_states=False, use_cache=False):
# Return mock output with hidden_states
batch_size = input_ids.shape[0]
seq_len = input_ids.shape[1]
class ModelOutput:
def __init__(self, hidden_dim, batch_size, seq_len):
# Create 12 hidden states (like BERT), last one is [batch, seq, hidden]
self.hidden_states = [
torch.randn(batch_size, seq_len, hidden_dim, dtype=torch.float32)
for _ in range(12)
]
return ModelOutput(self.hidden_dim, batch_size, seq_len)
model = MockModel(hidden_dim=4)
tokenizer = MockTokenizer()
text = "What is this?"
max_tokens = 128
ARGS = {
"text": text,
"model": model,
"tokenizer": tokenizer,
"max_tokens": max_tokens
}
- 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 Tensor, ndim 1, dtype family float, shape (4,) — shape (4,) 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
|
| _expectation_weighted_divergence_loss |
Ran ran; our contract draft was wrong, not the code |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("a1619f947861f21a") 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 Tensor, 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.functional as F
torch.manual_seed(0)
# Analyze the function to determine tensor shapes and values:
# - logits: [1, L+T_S+T_y, V] - used with indexing [0, pred_positions], topk on last dim
# - labels: [1, L+T_S+T_y] - used to find positions where != -100
# - teacher_ids: [T_y] - indexed by pred_positions.numel()
# - embed_weight: [V, d] - embedding matrix, indexed by token ids
# - neighbors: [T_y, k+1] - neighborhood indices, indexed and gathered
# - temperature: float - used in division
# - lambda_exp: float - scalar multiplier
# - teacher_topm: int - used in topk
# Set up dimensions
V = 16 # vocabulary size
d = 4 # embedding dimension
T_y = 3 # number of teacher tokens
k = 2 # neighborhood size (k+1 total neighbors)
L_plus_T = 5 # total sequence length including teacher positions
teacher_topm = 3 # top-m for expectation
# Create logits: [1, L+T_S+T_y, V]
logits = torch.randn(1, L_plus_T, V)
# Create labels: [1, L+T_S+T_y] with -100 for non-teacher positions
# Set last T_y positions to have valid labels (not -100)
labels = torch.full((1, L_plus_T), -100, dtype=torch.long)
labels[0, L_plus_T - T_y:] = torch.randint(0, V, (T_y,))
# Create teacher_ids: [T_y] - valid token ids in vocab
teacher_ids = torch.randint(0, V, (T_y,))
# Create embed_weight: [V, d] - embedding matrix
embed_weight = torch.randn(V, d)
# Create neighbors: [T_y, k+1] - semantic neighborhood indices
neighbors = torch.randint(0, V, (T_y, k + 1))
# Set scalar parameters
temperature = 0.5
lambda_exp = 0.1
teacher_topm = min(teacher_topm, V) # ensure topk doesn't exceed vocab size
ARGS = {
"logits": logits,
"labels": labels,
"teacher_ids": teacher_ids,
"embed_weight": embed_weight,
"neighbors": neighbors,
"temperature": temperature,
"lambda_exp": lambda_exp,
"teacher_topm": teacher_topm,
}
- 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 Tensor, 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
|
| _format_pair |
Ran ran; our contract draft was wrong, not the code |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("b7c5dd933aee0c10") 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
import torch.nn as nn
torch.manual_seed(0)
ARGS = {
'context': 'The sky is blue and the grass is green.',
'query': 'What color is the sky?',
'response': ' The sky is blue. '
}
- 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
|
| _gap |
Ran ran, honoured the contract we drafted |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("26c3c15633ed5399") 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
torch.manual_seed(0)
class StandInModel(nn.Module):
def __init__(self, hidden_dim=4):
super().__init__()
self.hidden_dim = hidden_dim
self.embedding = nn.Embedding(num_embeddings=100, embedding_dim=hidden_dim)
self.linear = nn.Linear(hidden_dim, hidden_dim)
def get_input_embeddings(self):
return self.embedding
def forward(self, input_ids, output_hidden_states=False, use_cache=False):
x = self.embedding(input_ids)
x = self.linear(x)
class Output:
def __init__(self, hidden_states_val):
self.hidden_states = hidden_states_val
if output_hidden_states:
return Output([torch.zeros_like(x), x])
return Output([x])
class StandInTokenizer:
def __call__(self, text, return_tensors=None, truncation=False, max_length=None, add_special_tokens=False):
tokens = text.split()[:max_length] if max_length else text.split()
token_ids = [hash(t) % 100 for t in tokens]
if not token_ids:
token_ids = [1]
class TokenizerOutput:
def __init__(self, ids):
self.input_ids = torch.tensor([ids], dtype=torch.long)
def to(self, device):
self.input_ids = self.input_ids.to(device)
return self
return TokenizerOutput(token_ids)
model = StandInModel(hidden_dim=4)
tokenizer = StandInTokenizer()
ARGS = {
"a_F": "hello world",
"a_G": "goodbye world",
"model": model,
"tokenizer": tokenizer,
"max_tokens": 512
}
- 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
|
| _semantic_neighbors |
Ran ran; our contract draft was wrong, not the code |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("dedc660f2559e46c") 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 Tensor, ndim 2, dtype family int, shape (2, 4) 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.functional as F
torch.manual_seed(0)
# embed_weight: torch.Tensor - embedding matrix of shape [vocab_size, embedding_dim]
# The function indexes into this with E[token_ids] and does E_n @ E_n.T
# So we need vocab_size distinct from embedding_dim
embed_weight = torch.randn(7, 4) # vocab_size=7, embedding_dim=4
# token_ids: torch.Tensor - indices into the embedding matrix, shape [batch_size]
# The function indexes E[token_ids] and uses unsqueeze(1) for scatter_
# Keep batch_size small and distinct from vocab_size and embedding_dim
token_ids = torch.tensor([0, 2]) # batch_size=2, values in [0, 7)
# k: int - number of neighbors to return (besides the token itself)
k = 3
ARGS = {
"embed_weight": embed_weight,
"token_ids": token_ids,
"k": k,
}
- 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 Tensor, ndim 2, dtype family int, shape (2, 4) — shape (2, 4) 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
|
| _summarize_context |
Ran ran; our contract draft was wrong, not the code |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("76d586af64e60597") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import numpy as np
from typing import Dict, List, Optional, Tuple
torch.manual_seed(0)
# Construct sample dialogue history
history = [
{
'user': 'What is machine learning?',
'assistant': 'Machine learning is a subset of artificial intelligence that focuses on learning from data.'
},
{
'user': 'Tell me about neural networks.',
'assistant': 'Neural networks are computational models inspired by biological neurons.'
},
{
'user': 'How do transformers work?',
'assistant': 'Transformers use self-attention mechanisms to process sequences in parallel.'
},
{
'user': 'What is the latest question?',
'assistant': 'I just explained how transformers work.'
}
]
ARGS = {
'history': history,
'keep_last': 2
}
- 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
|
| _tail_entropy |
Ran ran; our contract draft was wrong, not the code |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("acf2f406b0a0e110") 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 Tensor, 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.functional as F
torch.manual_seed(0)
# Create a small logits tensor
# Shape: (batch=1, seq_len=64, vocab_size=4)
# The function accesses logits[0, -min(tail_size, logits.size(1)):, :]
# So we need at least 1 batch, enough sequence length, and a vocab dimension
logits = torch.randn(1, 64, 4)
tail_size = 32
ARGS = {
"logits": logits,
"tail_size": tail_size,
}
- 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 Tensor, 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
|
| format_dialogue_context |
Ran ran; our contract draft was wrong, not the code |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("a70ceb18615ba919") 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
def format_dialogue_context(history):
"""Render past (user, assistant) turns into a single context string."""
lines = []
for turn in history:
u = turn.get('user', '')
a = turn.get('assistant', '')
if u:
lines.append(f'User: {u}')
if a:
lines.append(f'Assistant: {a}')
return '\n'.join(lines)
ARGS = {
'history': [
{'user': 'Hello, how are you?', 'assistant': 'I am doing well, thank you!'},
{'user': 'What is 2+2?', 'assistant': '2+2 equals 4.'},
{'user': 'Tell me a joke.', 'assistant': 'Why did the chicken cross the road? To get to the other side!'}
]
}
- 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 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
|
| SOMASession |
Not yet run unverified (harvested, no recorded run) |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("604f60e4bf4d8289") How it ran |
| attach_lora |
Not yet run unverified (harvested, no recorded run) |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("1f11dc1ed8e709c5") How it ran |
| generate_text |
Not yet run unverified (harvested, no recorded run) |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("375a736e73709078") How it ran |
| localized_lora_finetune |
Not yet run unverified (harvested, no recorded run) |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("f4be71fd7494ab51") How it ran |
| mine_soft_prompts |
Not yet run unverified (harvested, no recorded run) |
LabRAI/SOMA/soma/pipeline.py code served (permissive licence) · get_code("cca526db386c31e3") How it ran |