SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2403.13786 · 2024

Chain-of-Interaction: Enhancing Large Language Models for Psychiatric Behavior Understanding by Dyadic Contexts

arXiv · PDF · Open in the Atlas

Code that ran

7 of 8 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; 1 honoured the contract we drafted, 2 violated it and 0 have 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/2403.13786.json · badge: /api/ran/2403.13786.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
trust-nlp/coi-psychotherapy canonical (classifier label)
classifier basis: census
7 ran · 1 no recorded run
FunctionStatusWhere it lives
count_parameters Ran
ran, honoured the contract we drafted
trust-nlp/coi-psychotherapy/src/llmtuner/extras/misc.py
code served (permissive licence) · get_code("b2f47ceb183063e1")
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 int; 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 SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        # Create a simple model with some parameters
        self.linear1 = nn.Linear(4, 3)
        self.linear2 = nn.Linear(3, 2)
        # Create a parameter that won't require gradients
        self.register_parameter('frozen_param', nn.Parameter(torch.randn(2, 2)))
        self.frozen_param.requires_grad = False
    
    def forward(self, x):
        x = self.linear1(x)
        x = self.linear2(x)
        return x

model = SimpleModel()

ARGS = {
    "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 tuple, ndim 1, dtype family int — 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
get_logger Ran
ran; our contract draft was wrong, not the code
trust-nlp/coi-psychotherapy/src/llmtuner/extras/logging.py
code served (permissive licence) · get_code("0905fc3e8ed7fea3")
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 Logger. 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 sys
import logging

ARGS = {
    "name": "test_logger"
}
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 Logger — a Logger output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Logger 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_package_version Ran
ran; our contract draft was wrong, not the code
trust-nlp/coi-psychotherapy/src/llmtuner/extras/packages.py
code served (permissive licence) · get_code("14c9fb02d60eea83")
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 importlib.util

ARGS = {
    "name": "torch"
}
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
infer_optim_dtype Ran
ran; our contract draft was wrong, not the code
trust-nlp/coi-psychotherapy/src/llmtuner/extras/misc.py
code served (permissive licence) · get_code("a9e798cf22bd399b")
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 dtype. 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)

# The function takes model_dtype as a parameter
# It checks against torch.bfloat16 and uses torch.float16 and torch.float32
# We need to set up the global variables that the function references

# Mock the availability flags that the function uses
_is_bf16_available = True
_is_fp16_available = True

# Inject these into the module namespace so infer_optim_dtype can access them
import sys
current_module = sys.modules[__name__]
current_module._is_bf16_available = _is_bf16_available
current_module._is_fp16_available = _is_fp16_available

def infer_optim_dtype(model_dtype: torch.dtype) -> torch.dtype:
    """
    Infers the optimal dtype according to the model_dtype and device compatibility.
    """
    if _is_bf16_available and model_dtype == torch.bfloat16:
        return torch.bfloat16
    elif _is_fp16_available:
        return torch.float16
    else:
        return torch.float32

# Build arguments
ARGS = {
    "model_dtype": torch.float32
}
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 dtype — a dtype output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dtype 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
is_package_available Ran
ran, violated the contract we drafted
trust-nlp/coi-psychotherapy/src/llmtuner/extras/packages.py
code served (permissive licence) · get_code("2e71330e34fbbfd7")
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 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 importlib.util

def is_package_available(name: str) -> bool:
    return importlib.util.find_spec(name) is not None

ARGS = {
    "name": "torch"
}
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 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
parse_args Ran
ran; our contract draft was wrong, not the code
trust-nlp/coi-psychotherapy/src/llmtuner/extras/misc.py
code served (permissive licence) · get_code("fadfc4128068a6f6")
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 sys
from typing import Any, Dict, Optional
from dataclasses import dataclass


# Create a mock HfArgumentParser that has the methods the function calls
class MockHfArgumentParser:
    def __init__(self):
        self.call_log = []
    
    def parse_dict(self, args: Dict[str, Any]):
        self.call_log.append(('parse_dict', args))
        return (args,)
    
    def parse_yaml_file(self, filepath: str):
        self.call_log.append(('parse_yaml_file', filepath))
        return ({},)
    
    def parse_json_file(self, filepath: str):
        self.call_log.append(('parse_json_file', filepath))
        return ({},)
    
    def parse_args_into_dataclasses(self):
        self.call_log.append(('parse_args_into_dataclasses',))
        return ({},)


# Create mock arguments dict with various data types
mock_args = {
    'learning_rate': 1e-3,
    'batch_size': 32,
    'num_epochs': 3,
    'model_name': 'test_model',
    'use_cuda': False,
}

# Create the parser
parser = MockHfArgumentParser()

# Build ARGS dict with all parameters for parse_args
ARGS = {
    'parser': parser,
    'args': mock_args,
}
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
smooth Ran
ran, violated the contract we drafted
trust-nlp/coi-psychotherapy/src/llmtuner/extras/ploting.py
code served (permissive licence) · get_code("70c7f6d657ef0a9e")
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 math
from typing import List

torch_imported = False
try:
    import torch
    torch_imported = True
except ImportError:
    pass

# Create a simple list of float scalars for testing
scalars = [1.0, 2.5, 3.2, 4.1, 5.0, 6.3, 7.1, 8.5]

ARGS = {
    "scalars": scalars
}
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
get_eval_template Not yet run
unverified (harvested, no recorded run)
trust-nlp/coi-psychotherapy/src/llmtuner/eval/MMCBtemplate.py
code served (permissive licence) · get_code("e180bbd09fe3a2f2")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 6 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 0 the same month, 4 later) and 2 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.

FunctionAlso present inEarliest-datedOthers named
get_logger 8 other papers
2 dated earlier, 6 later
2311.13246 (2023-11)
CoachLM: Automatic Instruction Revisions Improve the Data Quality in LLM Instruction Tuning
2312.02554 (2023-12)
ULMA: Unified Language Model Alignment with Human Demonstration and Point-wise Preference
2405.19266 (2024-05)
PediatricsGPT: Large Language Models as Chinese Medical Assistants for Pediatric Applications
and 5 more not named here
infer_optim_dtype 5 other papers
1 dated earlier, 4 later
2303.18223 (2023-03)
A Survey of Large Language Models
2406.15786 (2024-06)
What Matters in Transformers? Not All Attention is Needed
2410.07672 (2024-10)
MACPO: Weak-to-Strong Alignment via Multi-Agent Contrastive Preference Optimization
and 2 more not named here
smooth 5 other papers
5 later
2406.15786 (2024-06)
What Matters in Transformers? Not All Attention is Needed
2410.14157 (2024-10)
Beyond Autoregression: Discrete Diffusion for Complex Reasoning and Planning
2410.17599 (2024-10)
Cross-model Control: Improving Multiple Large Language Models in One-time Training
and 2 more not named here
count_parameters 4 other papers
4 later
2406.15786 (2024-06)
What Matters in Transformers? Not All Attention is Needed
2410.07672 (2024-10)
MACPO: Weak-to-Strong Alignment via Multi-Agent Contrastive Preference Optimization
2410.14157 (2024-10)
Beyond Autoregression: Discrete Diffusion for Complex Reasoning and Planning
and 1 more not named here
get_package_version 1 other paper
1 dated earlier
2303.18223 (2023-03)
A Survey of Large Language Models
is_package_available 1 other paper
1 dated earlier
2303.18223 (2023-03)
A Survey of Large Language Models

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

Automatic coding patient behaviors is essential to support decision making for psychotherapists during the motivational interviewing (MI), a collaborative communication intervention approach to address psychiatric issues, such as alcohol and drug addiction. While the behavior coding task has rapidly adapted machine learning to predict patient states during the MI sessions, lacking of domain-specific knowledge and overlooking patient-therapist interactions are major challenges in developing and deploying those models in real practice. To encounter those challenges, we introduce the Chain-of-Interaction (CoI) prompting method aiming to contextualize large language models (LLMs) for psychiatric decision support by the dyadic interactions. The CoI prompting approach systematically breaks down the coding task into three key reasoning steps, extract patient engagement, learn therapist question strategies, and integrates dyadic interactions between patients and therapists. This approach enables large language models to leverage the coding scheme, patient state, and domain knowledge for patient behavioral coding. Experiments on real-world datasets can prove the effectiveness and flexibility of our prompting method with multiple state-of-the-art LLMs over existing prompting baselines. We have conducted extensive ablation analysis and demonstrate the critical role of dyadic interactions in applying LLMs for psychotherapy behavior understanding.

For agents

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

get_harvested_code_for_paper("2403.13786")
get_code_for_paper("2403.13786")
have("2403.13786")

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

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

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

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

Connect an agent — have() is free.