SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2306.09299 · NeurIPS · 2023

Can Language Models Teach Weaker Agents? Teacher Explanations Improve Students via Personalization

Peter Hase, Mohit Bansal, Swarnadeep Saha

arXiv · PDF · Open in the Atlas

Code that ran

5 of 6 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 1 has no contract verdict; 4 failures of our instrument; 1 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/2306.09299.json · badge: /api/ran/2306.09299.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
swarnahub/explanationintervention canonical (classifier label)
classifier basis: classifier_2025
4 ran · 1 no recorded run
swarnaHub/ExplanationIntervention canonical (classifier label)
classifier basis: census
1 ran · 0 no recorded run
FunctionStatusWhere it lives
choose_in_context_samples_for_mental_model Ran
ran; our contract draft was wrong, not the code
swarnahub/explanationintervention/src/main_single_turn.py
code served (permissive licence) · get_code("6a022d37a25fe112")
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) 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
import random

class StudentModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 2)
    
    def predict_single(self, test_sample, tm, inside_mm=False, intervene=False):
        # Returns (prediction, explanation)
        prediction = random.choice(['yes', 'no'])
        explanation = f"Student explanation for {test_sample['question']}"
        return prediction, explanation

class TeacherModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 2)
    
    def predict_single(self, test_sample):
        # Returns (prediction, explanation)
        prediction = random.choice(['yes', 'no'])
        explanation = f"Teacher explanation for {test_sample['question']}"
        return prediction, explanation

class Args:
    def __init__(self, dataset, intervention_strategy, ic_num):
        self.dataset = dataset
        self.intervention_strategy = intervention_strategy
        self.ic_num = ic_num

# Create train samples for strategyQA
train_samples_strategyqa = [
    {
        'question': 'Is the sky blue?',
        'answer': 'yes',
        'gold_explanation': 'The sky appears blue due to Rayleigh scattering.'
    },
    {
        'question': 'Do cats have wings?',
        'answer': 'no',
        'gold_explanation': 'Cats are mammals without wings.'
    },
    {
        'question': 'Is water wet?',
        'answer': 'yes',
        'gold_explanation': 'Water is a liquid that makes things wet.'
    },
    {
        'question': 'Can fish fly?',
        'answer': 'no',
        'gold_explanation': 'Fish are aquatic animals that cannot fly.'
    },
]

# Create train samples for ecqa
train_samples_ecqa = [
    {
        'question': 'What is 2+2?',
        'answer': '4',
        'options': ['3', '4', '5', '6'],
        'gold_explanation': 'Basic arithmetic addition.'
    },
    {
        'question': 'What is the capital of France?',
        'answer': 'Paris',
        'options': ['London', 'Paris', 'Berlin', 'Madrid'],
        'gold_explanation': 'Paris is the capital city of France.'
    },
    {
        'question': 'What color is grass?',
        'answer': 'green',
        'options': ['red', 'blue', 'green', 'yellow'],
        'gold_explanation': 'Grass is typically green due to chlorophyll.'
    },
]

torch.manual_seed(0)
random.seed(0)

sm = StudentModel()
tm = TeacherModel()

ARGS = {
    'args': Args(dataset='strategyQA', intervention_strategy='mm_both', ic_num=4),
    'sm': sm,
    'tm': tm,
    'train_samples': train_samples_strategyqa
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
choose_in_context_samples_for_mental_model Ran
ran; our contract draft was wrong, not the code
swarnahub/explanationintervention/src/main_multi_turn.py
code served (permissive licence) · get_code("03465b4ab579ba9f")
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) 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 random
import torch
import torch.nn as nn

class StudentModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 2)
    
    def predict_single(self, test_sample, tm, inside_mm=False, intervene=False):
        # Returns (prediction, explanation)
        prediction = random.choice(['yes', 'no'])
        explanation = f"Student explanation for {test_sample['question']}"
        return prediction, explanation

class TeacherModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 2)
    
    def predict_single(self, test_sample):
        # Returns (prediction, explanation)
        prediction = random.choice(['yes', 'no'])
        explanation = f"Teacher explanation for {test_sample['question']}"
        return prediction, explanation

class Args:
    def __init__(self, dataset, intervention_strategy, ic_num):
        self.dataset = dataset
        self.intervention_strategy = intervention_strategy
        self.ic_num = ic_num

# Create train samples for strategyQA
train_samples_strategyqa = [
    {
        'question': 'Is the sky blue?',
        'answer': 'yes',
        'gold_explanation': 'The sky appears blue due to Rayleigh scattering.'
    },
    {
        'question': 'Do cats have wings?',
        'answer': 'no',
        'gold_explanation': 'Cats are mammals without wings.'
    },
    {
        'question': 'Is water wet?',
        'answer': 'yes',
        'gold_explanation': 'Water is a liquid that makes things wet.'
    },
    {
        'question': 'Can fish fly?',
        'answer': 'no',
        'gold_explanation': 'Fish are aquatic animals that cannot fly.'
    },
]

# Create train samples for ecqa
train_samples_ecqa = [
    {
        'question': 'What is 2+2?',
        'answer': '4',
        'options': ['3', '4', '5', '6'],
        'gold_explanation': 'Basic arithmetic addition.'
    },
    {
        'question': 'What is the capital of France?',
        'answer': 'Paris',
        'options': ['London', 'Paris', 'Berlin', 'Madrid'],
        'gold_explanation': 'Paris is the capital city of France.'
    },
    {
        'question': 'What color is grass?',
        'answer': 'green',
        'options': ['red', 'blue', 'green', 'yellow'],
        'gold_explanation': 'Grass is typically green due to chlorophyll.'
    },
]

torch.manual_seed(0)
random.seed(0)

sm = StudentModel()
tm = TeacherModel()

ARGS = {
    'args': Args(dataset='strategyQA', intervention_strategy='mm_both', ic_num=4),
    'sm': sm,
    'tm': tm,
    'train_samples': train_samples_strategyqa
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
choose_in_context_samples_for_teacher_model Ran
ran; our contract draft was wrong, not the code
swarnahub/explanationintervention/src/main_single_turn.py
code served (permissive licence) · get_code("f0dac7c75f8dade3")
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) 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
import random

torch.manual_seed(0)

class StudentModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 2)
    
    def predict_single(self, test_sample, tm=None, inside_mm=False, intervene=False):
        # Returns a prediction and some auxiliary output
        # The function checks if predictions match and differ based on intervene flag
        x = torch.tensor(test_sample['input'], dtype=torch.float32).unsqueeze(0)
        logits = self.linear(x)
        pred = torch.argmax(logits, dim=1).item()
        return pred, None

class TeacherModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 2)
    
    def forward(self, x):
        return self.linear(x)

# Create sample data
train_samples = [
    {'input': [0.1, 0.2, 0.3, 0.4], 'answer': 0},
    {'input': [0.5, 0.6, 0.7, 0.8], 'answer': 1},
    {'input': [0.2, 0.3, 0.4, 0.5], 'answer': 0},
    {'input': [0.6, 0.7, 0.8, 0.9], 'answer': 1},
    {'input': [0.1, 0.1, 0.1, 0.1], 'answer': 0},
]

student_ics = [
    {'input': [0.1, 0.2, 0.3, 0.4], 'answer': 0},
    {'input': [0.5, 0.6, 0.7, 0.8], 'answer': 1},
]

class Args:
    def __init__(self, teacher_expl_type='blind_teacher_CoT', ic_num=2):
        self.teacher_expl_type = teacher_expl_type
        self.ic_num = ic_num

ARGS = {
    'args': Args(teacher_expl_type='blind_teacher_CoT', ic_num=2),
    'student_ics': student_ics,
    'train_samples': train_samples,
    'sm': StudentModel(),
    'tm': TeacherModel(),
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
choose_in_context_samples_for_teacher_model Ran
ran; our contract draft was wrong, not the code
swarnahub/explanationintervention/src/main_multi_turn.py
code served (permissive licence) · get_code("c42d583db2119d16")
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) 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
import random

torch.manual_seed(0)

class StudentModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 2)
    
    def predict_single(self, test_sample, tm=None, inside_mm=False, intervene=False):
        # Returns a prediction and some auxiliary output
        # The function checks if predictions match and differ based on intervene flag
        x = torch.tensor(test_sample['input'], dtype=torch.float32).unsqueeze(0)
        logits = self.linear(x)
        pred = torch.argmax(logits, dim=1).item()
        return pred, None

class TeacherModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 2)
    
    def forward(self, x):
        return self.linear(x)

# Create sample data
train_samples = [
    {'input': [0.1, 0.2, 0.3, 0.4], 'answer': 0},
    {'input': [0.5, 0.6, 0.7, 0.8], 'answer': 1},
    {'input': [0.2, 0.3, 0.4, 0.5], 'answer': 0},
    {'input': [0.6, 0.7, 0.8, 0.9], 'answer': 1},
    {'input': [0.1, 0.1, 0.1, 0.1], 'answer': 0},
]

student_ics = [
    {'input': [0.1, 0.2, 0.3, 0.4], 'answer': 0},
    {'input': [0.5, 0.6, 0.7, 0.8], 'answer': 1},
]

class Args:
    def __init__(self, teacher_expl_type='blind_teacher_CoT', ic_num=2):
        self.teacher_expl_type = teacher_expl_type
        self.ic_num = ic_num

ARGS = {
    'args': Args(teacher_expl_type='blind_teacher_CoT', ic_num=2),
    'student_ics': student_ics,
    'train_samples': train_samples,
    'sm': StudentModel(),
    'tm': TeacherModel(),
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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_accuracy Ran
ran on a synthesized input
swarnaHub/ExplanationIntervention/src/student_model.py
code served (permissive licence) · get_code("d46ff19844104d81")
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 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 numpy as np

torch.manual_seed(0)

# Analyze the function: compute_accuracy takes labels and predictions
# It iterates through them with zip, compares equality, and divides by len(labels)
# So we need two iterables of equal length containing comparable elements

# Create simple integer labels and predictions
labels = [0, 1, 1, 0, 1]
predictions = [0, 1, 0, 0, 1]

ARGS = {
    "labels": labels,
    "predictions": predictions
}
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 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
TeacherModel Not yet run
unverified (harvested, no recorded run)
swarnahub/explanationintervention/src/teacher_model.py
code served (permissive licence) · get_code("d1ab727264e7f5f9")
How it ran

no invocation recorded.

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 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 6 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

A hallmark property of explainable AI models is the ability to teach other agents, communicating knowledge of how to perform a task. While Large Language Models (LLMs) perform complex reasoning by generating explanations for their predictions, it is unclear whether they also make good teachers for weaker agents. To address this, we consider a student-teacher framework between two LLM agents and study if, when, and how the teacher should intervene with natural language explanations to improve the student's performance. Since communication is expensive, we define a budget such that the teacher only communicates explanations for a fraction of the data, after which the student should perform well on its own. We decompose the teaching problem along four axes: (1) if teacher's test time intervention improve student predictions, (2) when it is worth explaining a data point, (3) how the teacher should personalize explanations to better teach the student, and (4) if teacher explanations also improve student performance on future unexplained data. We first show that teacher LLMs can indeed intervene on student reasoning to improve their performance. Next, inspired by the Theory of Mind abilities of effective teachers, we propose building two few-shot mental models of the student. The first model defines an Intervention Function that simulates the utility of an intervention, allowing the teacher to intervene when this utility is the highest and improving student performance at lower budgets. The second model enables the teacher to personalize explanations for a particular student and outperform unpersonalized teachers. We also demonstrate that in multi-turn interactions, teacher explanations generalize and learning from explained data improves student performance on future unexplained data. Finally, we also verify that misaligned teachers can lower student performance to random chance by intentionally misleading them. 1 1 Code for all experiments: https://github.com/swarnaHub/ExplanationIntervention 37th Conference on Neural Information Processing Systems (NeurIPS 2023).

For agents

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

get_harvested_code_for_paper("2306.09299")
get_code_for_paper("2306.09299")
have("2306.09299")

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

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

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

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

Connect an agent — have() is free.