SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2004.10157 · ACL · 2020

Logic-Guided Data Augmentation and Regularization for Consistent Question Answering

Hannaneh Hajishirzi, Akari Asai

arXiv · PDF · Open in the Atlas

Code that ran

8 of 18 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 8 failures of our instrument; 10 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2004.10157.json · badge: /api/ran/2004.10157.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
AkariAsai/logic_guided_qa marked official in Papers with Code
Papers with Code archive
8 ran · 10 no recorded run
FunctionStatusWhere it lives
add_negation Ran
ran; our contract draft was wrong, not the code
AkariAsai/logic_guided_qa/wiqa_augmentation.py
code served (permissive licence) · get_code("51f66e8f1e74e6c8")
How it ran

Ran 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 numpy as np

torch.manual_seed(0)

# The function add_negation takes a single parameter 'sent' which is a string
# It performs various string operations to detect and handle negation patterns
# No complex objects needed, just a string

ARGS = {
    'sent': "he doesn't like pizza"
}
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 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
add_transitive_examples_one Ran
ran; our contract draft was wrong, not the code
AkariAsai/logic_guided_qa/wiqa_augmentation.py
code served (permissive licence) · get_code("f6c8f9aff2db5ca6")
How it ran

Ran 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 copy
import random

random.seed(0)

# Create minimal example objects that match the expected structure
examples = [
    {
        'metadata': {'ques_id': 'q1'},
        'question': {
            'stem': 'suppose water increases happens, how will it affect plant growth.',
            'answer_label': 'more'
        }
    },
    {
        'metadata': {'ques_id': 'q2'},
        'question': {
            'stem': 'suppose plant growth happens, how will it affect food production.',
            'answer_label': 'more'
        }
    },
    {
        'metadata': {'ques_id': 'q3'},
        'question': {
            'stem': 'suppose temperature rises happens, how will it affect ice melting.',
            'answer_label': 'more'
        }
    },
    {
        'metadata': {'ques_id': 'q4_symmetric'},
        'question': {
            'stem': 'suppose X happens, how will it affect Y.',
            'answer_label': 'more'
        }
    },
]

# Create args object with required attributes
class Args:
    def __init__(self):
        self.sample_ratio_augmentation = 0.8
        self.eval_mode = False

args = Args()

original_questions = set([
    'suppose water increases happens, how will it affect plant growth.',
    'suppose plant growth happens, how will it affect food production.',
    'suppose water increases happens, how will it affect food production.'
])

ARGS = {
    'examples': examples,
    'args': args,
    'original_questions': original_questions
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tqdm — 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
add_transitive_examples_two Ran
ran; our contract draft was wrong, not the code
AkariAsai/logic_guided_qa/wiqa_augmentation.py
code served (permissive licence) · get_code("497cb8886c3b4385")
How it ran

Ran 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 random
import copy

# Set seed for reproducibility
random.seed(0)

# Create minimal example objects that match the function's expectations
def create_minimal_example(ques_id, cause, effect, answer_label):
    """Create a minimal example dict with required structure"""
    return {
        'question': {
            'stem': f'suppose {cause} happens, how will it affect {effect}.',
            'answer_label': answer_label
        },
        'metadata': {
            'ques_id': ques_id,
            'answer_label': answer_label,
            'answer_label_as_choice': 'A' if answer_label == 'more' else 'B'
        }
    }

# Build examples list with transitive relationships
examples = [
    # First hop: cause1 -> effect1 (more)
    create_minimal_example('q1', 'temperature increases', 'ice melting', 'more'),
    # Second hop: effect1 (now cause) -> effect2 (less)
    create_minimal_example('q2', 'ice melting', 'polar area', 'less'),
    # Additional examples to test filtering
    create_minimal_example('q3', 'rainfall', 'soil moisture', 'more'),
    create_minimal_example('q4', 'soil moisture', 'vegetation', 'less'),
    # Examples with symmetric/transit tags (should be skipped)
    create_minimal_example('q5_symmetric', 'pressure', 'volume', 'more'),
    create_minimal_example('q6_transit', 'velocity', 'energy', 'more'),
    # Examples with 'True' answers (should be skipped)
    create_minimal_example('q7', 'True', 'something', 'more'),
    create_minimal_example('q8', 'something', 'True', 'less'),
]

# Create args object with required attribute
class Args:
    def __init__(self, sample_ratio_augmentation):
        self.sample_ratio_augmentation = sample_ratio_augmentation

args = Args(sample_ratio_augmentation=0.5)

# original_questions parameter (not used in function body, but required)
original_questions = []

ARGS = {
    'examples': examples,
    'args': args,
    'original_questions': original_questions
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tqdm — 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
extract_cause_effect Ran
ran; our contract draft was wrong, not the code
AkariAsai/logic_guided_qa/wiqa_augmentation.py
code served (permissive licence) · get_code("a306ceb694d0ae50")
How it ran

Ran 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 re

def extract_cause_effect(question):
    q_cause = re.findall('suppose (.*) happens', question)[0]
    q_effect = re.findall('how will it affect (.*).', question)[0]
    return (q_cause, q_effect)

ARGS = {
    'question': 'suppose the price of oil increases happens, how will it affect the economy.'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
flip_answer_label_as_choice Ran
ran; our contract draft was wrong, not the code
AkariAsai/logic_guided_qa/wiqa_augmentation.py
code served (permissive licence) · get_code("1d14d98b6b0e76b3")
How it ran

Ran 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.

ARGS = {
    'label_as_choice': 'A'
}
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
flip_label Ran
ran; our contract draft was wrong, not the code
AkariAsai/logic_guided_qa/wiqa_augmentation.py
code served (permissive licence) · get_code("902ccd6779092b1a")
How it ran

Ran 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

torch.manual_seed(0)

ARGS = {
    'label': 'more'
}
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
more_less_transforme Ran
ran; our contract draft was wrong, not the code
AkariAsai/logic_guided_qa/wiqa_augmentation.py
code served (permissive licence) · get_code("9123e010fd4a0874")
How it ran

Ran 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 random

# The function signature only has one parameter: sent
# Looking at the functions, they all take a string and return a tuple of (bool, str)

# For add_negation - test with a sentence containing a negation pattern
test_sent_1 = "the dog doesn't run fast"

# For replace_words - test with a sentence containing a word to replace
test_sent_2 = "there are more apples than oranges"

# We can call either function, so let's provide setup for both
# Since the code snippet shows these are standalone functions,
# we'll create ARGS for calling them

# For add_negation:
ARGS_add_negation = {
    "sent": "the cat doesn't sleep"
}

# For replace_words:
ARGS_replace_words = {
    "sent": "we need more resources and fewer distractions"
}

# Since the prompt asks for a function signature but the code shows two functions,
# I'll assume we're testing both. Let me provide ARGS for the most complete one:
# The function that would be called is likely one of these.
# Based on typical usage, I'll create args for replace_words as it's more complex:

ARGS = {
    "sent": "the results show more growth and fewer losses"
}
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
replace_words Ran
ran; our contract draft was wrong, not the code
AkariAsai/logic_guided_qa/wiqa_augmentation.py
code served (permissive licence) · get_code("ceddf9a4afdfb9f8")
How it ran

Ran 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.

# The function takes a string and replaces various words/phrases with their opposites
# It returns a tuple of (bool, modified_string)

# Simple test cases for the replace_words function
sent1 = "the temperature is more and larger"
sent2 = "this is less or smaller than before"
sent3 = "we need to increase the heat"
sent4 = "the object is smaller and heavier"
sent5 = "this solution is better than the alternative"

ARGS = {
    'sent': sent1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
create_examples Not yet run
unverified (harvested, no recorded run)
AkariAsai/logic_guided_qa/wiqa_augmentation.py
code served (permissive licence) · get_code("e250d92ff7a4e1c2")
How it ran

no invocation recorded.

create_symmetric_eight Not yet run
unverified (harvested, no recorded run)
AkariAsai/logic_guided_qa/wiqa_augmentation.py
code served (permissive licence) · get_code("06b700e5d1ed3afe")
How it ran

no invocation recorded.

create_symmetric_five Not yet run
unverified (harvested, no recorded run)
AkariAsai/logic_guided_qa/wiqa_augmentation.py
code served (permissive licence) · get_code("264777adb796f474")
How it ran

no invocation recorded.

create_symmetric_four Not yet run
unverified (harvested, no recorded run)
AkariAsai/logic_guided_qa/wiqa_augmentation.py
code served (permissive licence) · get_code("5bc487d92545d2e4")
How it ran

no invocation recorded.

create_symmetric_nine Not yet run
unverified (harvested, no recorded run)
AkariAsai/logic_guided_qa/wiqa_augmentation.py
code served (permissive licence) · get_code("fa8c05981e128568")
How it ran

no invocation recorded.

create_symmetric_one Not yet run
unverified (harvested, no recorded run)
AkariAsai/logic_guided_qa/wiqa_augmentation.py
code served (permissive licence) · get_code("90447dfa80f4cafb")
How it ran

no invocation recorded.

create_symmetric_seven Not yet run
unverified (harvested, no recorded run)
AkariAsai/logic_guided_qa/wiqa_augmentation.py
code served (permissive licence) · get_code("b1c84c791d839380")
How it ran

no invocation recorded.

create_symmetric_six Not yet run
unverified (harvested, no recorded run)
AkariAsai/logic_guided_qa/wiqa_augmentation.py
code served (permissive licence) · get_code("11ef557fab1d6b7b")
How it ran

no invocation recorded.

create_symmetric_three Not yet run
unverified (harvested, no recorded run)
AkariAsai/logic_guided_qa/wiqa_augmentation.py
code served (permissive licence) · get_code("f88f92a0c48c48a5")
How it ran

no invocation recorded.

create_symmetric_two Not yet run
unverified (harvested, no recorded run)
AkariAsai/logic_guided_qa/wiqa_augmentation.py
code served (permissive licence) · get_code("551c47e3d79424f2")
How it ran

no invocation recorded.

Also present in other papers' code

Of 18 samples lifted from this paper's linked repositories, 18 carry a function identity and 0 do not. Of the 18 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 18 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Many natural language questions require qualitative, quantitative or logical comparisons between two entities or events. This paper addresses the problem of improving the accuracy and consistency of responses to comparison questions by integrating logic rules and neural models. Our method leverages logical and linguistic knowledge to augment labeled training data and then uses a consistency-based regularizer to train the model. Improving the global consistency of predictions, our approach achieves large improvements over previous methods in a variety of question answering (QA) tasks including multiple-choice qualitative reasoning, cause-effect reasoning, and extractive machine reading comprehension. In particular, our method significantly improves the performance of RoBERTa-based models by 1-5% across datasets. We advance state of the art by around 5-8% on WIQA and QuaRel and reduce consistency violations by 58% on HotpotQA. We further demonstrate that our approach can learn effectively from limited data. 1 Q: The ceramic vase was less flexible than the plastic ball so it was A: more breakable Q: The ceramic vase was more flexible than the plastic ball so it was A: less breakable Q: If it is silent, does the outer ear collect less sound waves? A: more [positive causal relationship] Q: If the outer ear collect less sound waves, is less sound being detected? A: more [positive causal relationship] Q: If it is silent, is less sound being detected? A: more [positive causal relationship] RoBERTa more breakable more breakable RoBERTa more more less Conflict Conflict

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2004.10157")
get_code_for_paper("2004.10157")
have("2004.10157")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2004.10157.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2004.10157.svg)](https://syntology.ai/paper/2004.10157)

Connect an agent — have() is free.