| compute_perturbation_scores |
Ran ran on a synthesized input |
causalate-mitigates-bias/causal-ate-mitigates-bias/archived/train_ate_20240708.py code served (permissive licence) · get_code("fe2766538003bcfe") 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 torch.utils.data import DataLoader
torch.manual_seed(0)
# Create a minimal model that accepts long tensor input and outputs scores
class SimpleModel(nn.Module):
def __init__(self, vocab_size=100, output_dim=1):
super().__init__()
self.embedding = nn.Embedding(vocab_size, 8)
self.linear = nn.Linear(8, output_dim)
def forward(self, x):
# x shape: (batch_size, seq_len)
embedded = self.embedding(x) # (batch_size, seq_len, 8)
pooled = embedded.mean(dim=1) # (batch_size, 8)
output = self.linear(pooled) # (batch_size, output_dim)
return output
# Create model instance
model = SimpleModel(vocab_size=100, output_dim=1)
# Create perturbed_loader - list of (perturbed_batch, rejoined_batch) tuples
# Each batch is a tensor of shape (batch_size, seq_len) with long values
perturbed_loader = [
(
torch.randint(0, 100, (2, 4)), # perturbed_batch: (2, 4)
torch.randint(0, 100, (2, 3)) # rejoined_batch: (2, 3) - different seq_len
),
(
torch.randint(0, 100, (2, 5)), # perturbed_batch: (2, 5)
torch.randint(0, 100, (2, 4)) # rejoined_batch: (2, 4)
)
]
device = 'cpu'
padding_value = 0
ARGS = {
'model': model,
'perturbed_loader': perturbed_loader,
'device': device,
'padding_value': padding_value
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- torch, tqdm — 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
|
| compute_perturbation_scores_old |
Ran ran on a synthesized input |
causalate-mitigates-bias/causal-ate-mitigates-bias/archived/train_ate_202407082243.py code served (permissive licence) · get_code("5461a6a98fcc9b1e") 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 torch.utils.data import DataLoader
torch.manual_seed(0)
# Define a minimal model that satisfies the function's usage
class SimpleModel(nn.Module):
def __init__(self, vocab_size=100, output_size=1):
super().__init__()
self.embedding = nn.Embedding(vocab_size, 8)
self.linear = nn.Linear(8, output_size)
def forward(self, x):
# x shape: (batch_size, seq_len)
embedded = self.embedding(x) # (batch_size, seq_len, 8)
pooled = embedded.mean(dim=1) # (batch_size, 8)
output = self.linear(pooled) # (batch_size, output_size)
return output
# Create model instance
model = SimpleModel(vocab_size=100, output_size=1)
# Create perturbed_loader as a list of (perturbed_batch, rejoined_batch) tuples
# Each batch contains token indices (long tensors)
perturbed_loader = [
(
torch.randint(0, 100, (2, 4), dtype=torch.long), # perturbed_batch: (batch_size=2, seq_len=4)
torch.randint(0, 100, (2, 4), dtype=torch.long), # rejoined_batch: (batch_size=2, seq_len=4)
),
(
torch.randint(0, 100, (2, 4), dtype=torch.long),
torch.randint(0, 100, (2, 4), dtype=torch.long),
),
]
device = 'cpu'
ARGS = {
'model': model,
'perturbed_loader': perturbed_loader,
'device': device,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- torch, tqdm — 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
|
| generate_perturbed_dataloader |
Ran ran on a synthesized input |
causalate-mitigates-bias/causal-ate-mitigates-bias/utilities/generate_ate_data.py code served (permissive licence) · get_code("9096f3e3c31357a5") 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 DataLoader. 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 random
from torch.utils.data import DataLoader
torch.manual_seed(0)
random.seed(0)
class SimpleVocab:
def __init__(self, words):
self.words = words
def get_itos(self):
return self.words
# Create a minimal vocab
vocab = SimpleVocab(["the", "cat", "dog", "sat", "on", "mat", "quick", "brown"])
# Create minimal training data: list of (text, label) tuples
train_data = [
("the cat sat on the mat", 0),
("the dog sat on the mat", 1),
("the quick brown cat", 0),
]
# Create a simple data loader
def collate_fn_train(batch):
texts, labels = zip(*batch)
return list(texts), list(labels)
train_loader = DataLoader(
train_data,
batch_size=2,
shuffle=False,
collate_fn=collate_fn_train
)
# Define all arguments for generate_perturbed_dataloader
ARGS = {
"train_loader": train_loader,
"vocab": vocab,
"batch_size": 2,
"perturbation_rate": 0.5,
"num_perturbations": 2,
"n_gram_length": 2,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type DataLoader — a DataLoader output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataLoader 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
|
| getATEScores |
Ran ran on a synthesized input |
causalate-mitigates-bias/causal-ate-mitigates-bias/experiments/compute_ate_scores.py code served (permissive licence) · get_code("95bdecf0755bcbdc") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import numpy as np
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LogisticRegression
import tempfile
import os
# Create a simple mock vectorizer that has a transform method
vectorizer = TfidfVectorizer(max_features=10)
# Create sample text data to fit the vectorizer
sample_texts = [
"this is a test sentence",
"another sample text here",
"some more example data",
"final test document"
]
vectorizer.fit(sample_texts)
# Create a simple mock classifier with predict_proba method
classifier = LogisticRegression(random_state=0)
X_dummy = vectorizer.transform(sample_texts)
y_dummy = np.array([0, 1, 0, 1])
classifier.fit(X_dummy, y_dummy)
# Create input dataframe with required columns
input_df = pd.DataFrame({
'text': [
'this is original text',
'another original sentence'
],
'unmasked_sentences': [
'this is replaced text',
'another replaced sentence'
],
'masked_words': [
'word1',
'word2'
]
})
# Create temporary output directory
temp_dir = tempfile.mkdtemp()
output_file1 = os.path.join(temp_dir, 'unmasked_with_scores.csv')
output_file2 = os.path.join(temp_dir, 'scores.csv')
ARGS = {
'input_unmasked_df': input_df,
'input_classifier': classifier,
'input_vectorizer': vectorizer,
'output_unmasked_file_with_scores': output_file1,
'output_ate_csv_file': output_file2
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, pandas, sklearn — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| perturb_sentence |
Ran ran on a synthesized input |
causalate-mitigates-bias/causal-ate-mitigates-bias/archived/generate_ate_data_20240710.py code served (permissive licence) · get_code("7b4df577196dbcd5") 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 random
# Set seed for reproducibility
random.seed(0)
# Define the arguments
original_input = "the quick brown fox jumps over the lazy dog"
vocab = ["the", "a", "quick", "fast", "brown", "red", "fox", "dog", "cat", "jumps", "runs", "over", "under", "lazy", "sleepy"]
num_perturbations = 5
ARGS = {
"original_input": original_input,
"vocab": vocab,
"num_perturbations": num_perturbations,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type list, ndim 2, dtype family float — a list output has no array shape of its own; none is stated
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| perturb_sentence |
Ran ran on a synthesized input |
causalate-mitigates-bias/causal-ate-mitigates-bias/archived/generate_ate_data_20240712_1316.py code served (permissive licence) · get_code("8cbd7c91d1c7eb17") 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 random
# Set seed for reproducibility
random.seed(0)
# Define arguments for perturb_sentence function
original_input = "the quick brown fox jumps over the lazy dog"
vocab = ["cat", "dog", "bird", "fish", "elephant", "car", "house", "tree", "flower", "book"]
perturbation_rate = 0.5
num_perturbations = 10
n_gram_length = 5
ARGS = {
"original_input": original_input,
"vocab": vocab,
"perturbation_rate": perturbation_rate,
"num_perturbations": num_perturbations,
"n_gram_length": n_gram_length
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type list, ndim 2, dtype family float — a list output has no array shape of its own; none is stated
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| perturb_sentence |
Ran ran on a synthesized input |
causalate-mitigates-bias/causal-ate-mitigates-bias/archived/train_ate_20240708.py code served (permissive licence) · get_code("77af5a0a462285b5") 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 random
# Set seed for reproducibility
random.seed(42)
# Define a simple sentence
sentence = "the quick brown fox jumps over the lazy dog"
# Define a vocabulary as a list of words
vocab = ["the", "a", "quick", "slow", "brown", "red", "fox", "dog", "cat", "jumps", "runs", "walks", "over", "under", "on"]
# Define the number of perturbations
num_perturbations = 5
# Construct the ARGS dictionary
ARGS = {
"sentence": sentence,
"vocab": vocab,
"num_perturbations": num_perturbations
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type list, ndim 2, dtype family float — a list output has no array shape of its own; none is stated
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| perturb_sentence |
Ran ran on a synthesized input |
causalate-mitigates-bias/causal-ate-mitigates-bias/utilities/generate_ate_data.py code served (permissive licence) · get_code("5c31fb2c09b40f18") 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 random
# Set seed for reproducibility
random.seed(0)
# Create a small vocabulary list
vocab = ["cat", "dog", "bird", "fish", "tree", "house", "car", "book", "apple", "run", "jump", "sleep", "eat", "play", "walk"]
# Create a sample input sentence (space-separated tokens)
original_input = "the cat sat on the mat and looked at the tree"
# Create an original label
original_label = "positive"
# Define all arguments for the function
ARGS = {
"original_input": original_input,
"original_label": original_label,
"vocab": vocab,
"perturbation_rate": 0.5,
"num_perturbations": 10,
"n_gram_length": 5
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type list, ndim 2, dtype family float — a list output has no array shape of its own; none is stated
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| train_sklearn_ate_model |
Ran ran on a synthesized input |
causalate-mitigates-bias/causal-ate-mitigates-bias/utilities/train_ate.py code served (permissive licence) · get_code("dd709e49ce602b82") 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 LinearRegression. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import numpy as np
from sklearn.linear_model import LinearRegression
# Create a small sklearn model that has fit() and predict() methods
ate_model = LinearRegression()
# Create small training data
# 5 samples, 3 features
new_batch_inputs = [[1.0, 2.0, 3.0],
[2.0, 3.0, 4.0],
[3.0, 4.0, 5.0],
[4.0, 5.0, 6.0],
[5.0, 6.0, 7.0]]
# 5 samples, 1 output (regression targets)
new_batch_outputs = [10.0, 15.0, 20.0, 25.0, 30.0]
# Number of epochs
num_epochs = 3
ARGS = {
'ate_model': ate_model,
'new_batch_inputs': new_batch_inputs,
'new_batch_outputs': new_batch_outputs,
'num_epochs': num_epochs
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, sklearn — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type LinearRegression — a LinearRegression output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a LinearRegression 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
|
| generate_perturbed_dataloader |
Not yet run unverified (harvested, no recorded run) |
causalate-mitigates-bias/causal-ate-mitigates-bias/archived/generate_ate_data_20240712_1316.py code served (permissive licence) · get_code("55cca739ac4df98f") How it ran |