| _is_eos_token |
Ran ran, violated the contract we drafted |
halfmorepiece/PhantomCircuit/co_xsub_identifier.py code served (permissive licence) · get_code("011699c99d460851") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned bool, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
class MockTokenizer:
def __init__(self, eos_token):
self.eos_token = eos_token
class MockModel(nn.Module):
def __init__(self, tokenizer=None):
super().__init__()
self.tokenizer = tokenizer
# Test case 1: Model with tokenizer that has eos_token
tokenizer_with_eos = MockTokenizer(eos_token='<|endoftext|>')
model_with_tokenizer = MockModel(tokenizer=tokenizer_with_eos)
# Test case 2: Model without tokenizer attribute (uses default)
model_without_tokenizer = MockModel(tokenizer=None)
# Test token string - using the default eos_token
token_str = '<|endoftext|>'
ARGS = {
'token_str': token_str,
'model': model_with_tokenizer
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| clean_prompt_tokens |
Ran ran; our contract draft was wrong, not the code |
halfmorepiece/PhantomCircuit/co_xsub_identifier.py code served (permissive licence) · get_code("942e288739fc5fad") 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)
class MockTokenizer:
def __init__(self):
self.eos_token = '<|endoftext|>'
class MockModel(nn.Module):
def __init__(self):
super().__init__()
self.tokenizer = MockTokenizer()
prompt_tokens = ['hello', 'world', '<|endoftext|>', 'foo', '<|endoftext|>', 'bar']
model = MockModel()
ARGS = {
'prompt_tokens': prompt_tokens,
'model': model
}
- 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
|
| compute_logprob_variance_across_masks |
Ran ran; our contract draft was wrong, not the code |
halfmorepiece/PhantomCircuit/co_xsub_identifier.py code served (permissive licence) · get_code("ff663579f9e9503f") 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 torch.nn as nn
import numpy as np
torch.manual_seed(0)
# Build a minimal model that satisfies the function's requirements
class MinimalLanguageModel(nn.Module):
def __init__(self, vocab_size=100, hidden_dim=4):
super().__init__()
self.vocab_size = vocab_size
self.hidden_dim = hidden_dim
self.embedding = nn.Embedding(vocab_size, hidden_dim)
self.linear = nn.Linear(hidden_dim, vocab_size)
def forward(self, tokens):
# tokens shape: (batch, seq_len)
# output shape: (batch, seq_len, vocab_size)
embedded = self.embedding(tokens)
logits = self.linear(embedded)
return logits
def to_tokens(self, text, prepend_bos=False):
# Convert text to token indices
# Simple: hash each character and map to vocab
token_ids = [hash(c) % self.vocab_size for c in text]
tokens = torch.tensor(token_ids, dtype=torch.long)
return tokens
def to_string(self, token_indices):
# Convert token indices back to strings
# Simple: map index back to characters
if isinstance(token_indices, list):
return [f"token_{idx}" for idx in token_indices]
return f"token_{token_indices}"
# Build model
model = MinimalLanguageModel(vocab_size=100, hidden_dim=4)
model.eval()
# Build tokenizer (minimal stand-in)
class MinimalTokenizer:
def convert_tokens_to_string(self, tokens):
return ''.join(str(t) for t in tokens)
tokenizer = MinimalTokenizer()
# Create prompt tokens (list of token strings or indices)
prompt_tokens = ["hello", "world", "test"]
# Get original predictions by calling get_top_k_predictions
def safe_to_tokens(model, prompt):
return model.to_tokens(prompt, prepend_bos=False)
def get_top_k_predictions(prompt_text, model, tokenizer, top_k=10):
tokens = safe_to_tokens(model, prompt_text)
if tokens.dim() == 1:
tokens = tokens.unsqueeze(0)
model_device = next(model.parameters()).device
tokens = tokens.to(model_device)
with torch.no_grad():
logits = model(tokens)
next_token_logits = logits[:, -1, :]
log_probs = torch.log_softmax(next_token_logits, dim=-1)
top_k_log_probs, top_k_indices = torch.topk(log_probs, top_k, dim=-1)
top_k_tokens = []
for idx in top_k_indices[0]:
token_str = model.to_string([idx.item()])
if isinstance(token_str, list):
token_str = token_str[0]
top_k_tokens.append(token_str)
predictions = []
for token_str, log_prob_val in zip(top_k_tokens, top_k_log_probs[0]):
predictions.append((token_str, log_prob_val.item()))
return predictions
# Generate original predictions list
prompt_text = "hello world test"
original_predictions_list = get_top_k_predictions(prompt_text, model, tokenizer, top_k=5)
# Define arguments for compute_logprob_variance_across_masks
ARGS = {
"prompt_tokens": prompt_tokens,
"model": model,
"tokenizer": tokenizer,
"original_predictions_list": original_predictions_list,
"top_k": 5
}
- 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
|
| get_top_k_predictions |
Ran ran; our contract draft was wrong, not the code |
halfmorepiece/PhantomCircuit/co_xsub_identifier.py code served (permissive licence) · get_code("4e43ea55d6c051ca") 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 torch
import torch.nn as nn
torch.manual_seed(0)
class MockModel(nn.Module):
def __init__(self, vocab_size=100, hidden_dim=4):
super().__init__()
self.vocab_size = vocab_size
self.hidden_dim = hidden_dim
self.embedding = nn.Embedding(vocab_size, hidden_dim)
self.linear = nn.Linear(hidden_dim, vocab_size)
def forward(self, tokens):
"""
Input: tokens of shape (batch_size, seq_len)
Output: logits of shape (batch_size, seq_len, vocab_size)
"""
x = self.embedding(tokens)
logits = self.linear(x)
return logits
def to_tokens(self, prompt, prepend_bos=False):
"""Convert prompt string to token tensor"""
token_ids = [hash(prompt) % self.vocab_size for _ in range(3)]
return torch.tensor(token_ids, dtype=torch.long)
def to_string(self, token_indices):
"""Convert token indices to strings"""
return [f"token_{idx}" for idx in token_indices]
class MockTokenizer:
def __init__(self):
self.vocab_size = 100
def encode(self, text):
return [1, 2, 3]
def decode(self, tokens):
return "decoded text"
prompt_text = "hello world"
model = MockModel(vocab_size=100, hidden_dim=4)
tokenizer = MockTokenizer()
top_k = 10
ARGS = {
"prompt_text": prompt_text,
"model": model,
"tokenizer": tokenizer,
"top_k": top_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 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
|
| identify_xsub_by_phantomcircuit |
Ran ran; our contract draft was wrong, not the code |
halfmorepiece/PhantomCircuit/co_xsub_identifier.py code served (permissive licence) · get_code("de73d191312197fe") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) 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
import numpy as np
torch.manual_seed(0)
class SimpleTokenizer:
def __init__(self):
self.eos_token = '<|endoftext|>'
def convert_tokens_to_string(self, tokens):
return ''.join(tokens)
class SimpleModel(nn.Module):
def __init__(self, vocab_size=100, hidden_dim=4):
super().__init__()
self.embedding = nn.Embedding(vocab_size, hidden_dim)
self.linear = nn.Linear(hidden_dim, vocab_size)
self.tokenizer = SimpleTokenizer()
self.vocab_size = vocab_size
def forward(self, tokens):
# tokens shape: (batch, seq_len)
embedded = self.embedding(tokens) # (batch, seq_len, hidden_dim)
logits = self.linear(embedded) # (batch, seq_len, vocab_size)
return logits
def to_tokens(self, prompt, prepend_bos=False):
# Simple tokenization: convert each character to a token id
token_ids = [ord(c) % self.vocab_size for c in prompt]
return torch.tensor(token_ids, dtype=torch.long)
def to_str_tokens(self, prompt):
# Return string tokens (characters)
return list(prompt)
def to_string(self, token_ids):
# Convert token ids back to string
if isinstance(token_ids, list):
return ''.join([chr(tid % 256) for tid in token_ids])
return chr(token_ids.item() % 256)
model = SimpleModel(vocab_size=100, hidden_dim=4)
model.eval()
tokenizer = SimpleTokenizer()
prompt = "hello world"
ARGS = {
'prompt': prompt,
'model': model,
'tokenizer': tokenizer,
'top_k': 5,
'verbose': False
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1
- Imports
- numpy, torch, tqdm — 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
|
| safe_to_str_tokens |
Ran ran; our contract draft was wrong, not the code |
halfmorepiece/PhantomCircuit/co_xsub_identifier.py code served (permissive licence) · get_code("ce9db70729fd9a34") 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)
class MockTokenizer:
def __init__(self):
self.eos_token = '<|endoftext|>'
class MockModel(nn.Module):
def __init__(self):
super().__init__()
self.tokenizer = MockTokenizer()
def to_str_tokens(self, prompt):
# Simple mock: split prompt into tokens and add eos token
tokens = prompt.split()
tokens.append(self.tokenizer.eos_token)
return tokens
# Create model instance
model = MockModel()
# Create prompt string
prompt = "hello world test"
# Define arguments dict
ARGS = {
"model": model,
"prompt": prompt
}
- 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
|
| safe_to_tokens |
Ran ran, honoured the contract we drafted |
halfmorepiece/PhantomCircuit/co_xsub_identifier.py code served (permissive licence) · get_code("7967a02919473231") 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 (1, 11) 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(nn.Module):
def __init__(self):
super().__init__()
self.vocab_size = 256
def to_tokens(self, prompt, prepend_bos=False):
# Simple mock: convert string to token ids
# Return a tensor of shape (1, seq_len) or similar
if isinstance(prompt, str):
tokens = [ord(c) % self.vocab_size for c in prompt]
else:
tokens = [1, 2, 3]
token_tensor = torch.tensor([tokens], dtype=torch.long)
return token_tensor
model = MockTokenizer()
prompt = "hello world"
ARGS = {
"model": model,
"prompt": prompt
}
- 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 (1, 11) — shape (1, 11) 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
|