%% SemEval-2026 Task 13 System Description Paper
%% Template: ACL 2026

\documentclass[11pt]{article}

% Change "review" to "final" to generate the camera-ready version.
\usepackage{acl}

% Standard package includes
\usepackage{times}
\usepackage{latexsym}

% For proper rendering and hyphenation of words containing Latin characters
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{microtype}
\usepackage{inconsolata}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{subcaption}

%% -----------------------------------------------
%%  TITLE
%% -----------------------------------------------
\title{ASTraNet at SemEval-2026 Task 13: Not All Code Looks the Same: Multi-View Structural and Semantic Detection of Machine-Generated Code}

%% -----------------------------------------------
%%  AUTHORS  (fill in real names / affiliations)
%% -----------------------------------------------
\author{
  Ruwad Naswan\thanks{\ Equal contribution.},
  Dipit Saha$^*$,
  Md.\ Rafat Kabir$^*$,
  Nabiha Tahseen$^*$ \\
  Bangladesh University of Engineering and Technology \\
  \texttt{\{ruwad45678, sdipit099, rafatkabir054, ntahseen03\}@gmail.com}
}

\date{}

\begin{document}
\maketitle

%% -----------------------------------------------
%%  ABSTRACT
%% -----------------------------------------------

\begin{abstract}
The growing adoption of large language models for code generation
poses challenges for code quality, security, and authorship
verification---particularly when test conditions involve unseen
programming languages, generators, or application domains. We
present our system, which combines three code-pretrained
transformer encoders (CodeT5p-220M, CodeBERT, UniXcoder) with a
structure-first Flow-Augmented AST (FA-AST) encoder implemented as
a Gated Graph Neural Network. On Subtask~A our best single model
achieves macro~F1 of 0.559; a post-competition layered rank-fusion
ensemble across all three encoders raises this to 0.643. On
Subtask~C we obtain 0.585 officially; a three-stage ensemble
combining neural probabilities with LightGBM-based features and
class-priority routing raises this to 0.652. Our contributions
include a language-agnostic structural detector, a diversity-driven
rank-fusion strategy exploiting low inter-model correlation for
binary classification, and a meta-learner stacking pipeline for
multi-class detection under distribution shift.
\end{abstract}

%% -----------------------------------------------
%%  1. INTRODUCTION
%% -----------------------------------------------
\section{Introduction}

SemEval-2026 Task~13~\cite{orel-etal-2026-semeval-2026} presents a
large-scale benchmark for detecting machine-generated code across
diverse programming languages, generators, and application
domains. It poses three main challenges: (1)~\textit{Distribution
shift}---test data contain unseen languages (Go, PHP, C\#, C,
JavaScript) and unseen domains (research and production code) that
never appear during training; (2)~\textit{Class complexity}---Subtask~C
introduces hybrid and adversarial categories alongside human and
machine labels, requiring fine-grained distinctions;
(3)~\textit{Structural diversity}---surface-level token cues that work
well within a single language often fail to transfer across
languages and domains~\cite{orel2025droid,orel-etal-2025-codet}.

To address these challenges, we present a system that
trains three code-pretrained encoders---CodeT5p-220M, CodeBERT, and
UniXcoder---with attention pooling, contrastive learning, and focal
loss, alongside a structure-first FA-AST encoder implemented as a
GGNN. Our contributions are:

\begin{itemize}
  \item A language-agnostic, structure-first detector based on
    canonicalized FA-ASTs and a GGNN that generalizes across
    programming languages by relying on structural topology rather
    than surface tokens.
  \item A layered rank-fusion ensemble for Subtask~A that exploits
    low inter-model correlation (Spearman $r{=}0.35$--$0.57$)
    through diversity-weighted rank combination and cascading
    rescue layers, raising macro~F1 from 0.559 to 0.643.
  \item A three-stage ensemble for Subtask~C combining neural
    probabilities, LightGBM over StarCoder2-derived features, and
    class-priority routing, raising macro~F1 from 0.585 to 0.652.
\end{itemize}

%% -----------------------------------------------
%%  2. BACKGROUND
%% -----------------------------------------------
\section{Background}
\label{sec:background}

\paragraph{Task Description.}
SemEval-2026 Task~13~\cite{orel-etal-2026-semeval-2026} provides
large-scale datasets for three subtasks.
Subtask~A is a binary classification problem with 500K training
samples (238K human-written, 262K machine-generated) drawn from
algorithmic problem-solving contexts in C++, Python, and Java.
Subtask~C scales to 900K training samples and introduces two
additional categories---\textit{hybrid} code (partially written or
completed by LLMs) and \textit{adversarial} code (generated to
mimic human style)---for a total of four classes.
All subtasks are evaluated using macro~F1, and test sets
deliberately include unseen programming languages (Go, PHP, C\#,
C, JavaScript) and unseen domains (research and production code),
making cross-lingual and cross-domain generalization the central
challenge. Further details are described in
\citet{orel2026aicdbenchchallengingbenchmark}.

\paragraph{Related Work.}
Detecting AI-generated text has been studied extensively for natural
language, with approaches ranging from fine-tuned
classifiers~\cite{orel2025droid} to zero-shot methods based on
perplexity and statistical properties. For code specifically,
\citet{orel-etal-2025-codet} introduced the CoDet-M4 benchmark and
demonstrated that cross-lingual and cross-domain generalization
remain open problems even for strong transformer baselines.
More recently, \citet{CODEGPTSENSOR} showed that contrastive
learning on code representations can effectively distinguish
LLM-generated code from human-written code.
Stylometric and AST-based features have also been explored for code
authorship attribution~\cite{CALISKAN2015,KALGUTKAR2019}, though
primarily in human-vs-human settings. We build on these ideas and
adapt them to the human-vs-machine detection problem under
distribution shift.

%% -----------------------------------------------
%%  3. SYSTEM OVERVIEW
%% -----------------------------------------------
\section{System Overview}
\label{sec:system}

Our approach builds on the observation that token-level and
structure-level representations capture complementary aspects of
code authorship. We train three code-pretrained encoders---CodeT5p-220M~\cite{CODET5PLUS}, CodeBERT~\cite{CODEBERT},
and UniXcoder~\cite{UNIXCODER}---using the same frozen-encoder
pipeline with attention pooling, contrastive learning, and focal
loss (Section~\ref{sec:encoders}). A Flow-Augmented AST (FA-AST)
encoder implemented as a GGNN (Figure~\ref{fig:system}) operates
on canonicalized syntax trees to capture structural signatures
that persist across languages. For Subtask~A we combine the three encoders via layered rank
fusion (Section~\ref{sec:ensemble_a}); for Subtask~C we fuse
neural and non-neural signals through meta-learner stacking
(Section~\ref{sec:ensemble}).

\begin{figure}[t]
  \centering
  \includegraphics[width=\linewidth]{figures/ast.pdf}
  \caption{Flow-Augmented AST (FA-AST) Construction and GGNN-Based Structural Encoding Pipeline}
  \label{fig:system}
\end{figure}
\begin{figure}[t]
  \centering
  \includegraphics[width=0.9\linewidth]{figures/transformer_encoder_classification.pdf}
  \caption{CodeT5p-220M Encoder Architecture with Attention Pooling and Contrastive Projection Head}
  \label{fig:transformer}
\end{figure}
\subsection{Transformer Encoders}
\label{sec:encoders}
\paragraph{Frozen-encoder pipeline.}
We train three code-pretrained encoders---CodeT5p-220M~\cite{CODET5PLUS}, CodeBERT~\cite{CODEBERT}, and
UniXcoder~\cite{UNIXCODER}---using a shared architecture. Each
input is tokenized and passed through the frozen encoder,
producing token embeddings
$\mathbf{H} = [\mathbf{h}_1, \ldots, \mathbf{h}_n] \in
\mathbb{R}^{n \times d}$ where $d{=}768$. We apply attention
pooling to obtain a fixed-length representation:
\begin{equation}
  \alpha_i = \frac{\exp(\mathbf{w}^\top \mathbf{h}_i)}
    {\sum_{j=1}^{n} \exp(\mathbf{w}^\top \mathbf{h}_j)}, \quad
  \mathbf{r} = \sum_{i=1}^{n} \alpha_i \, \mathbf{h}_i
  \label{eq:attnpool}
\end{equation}
where $\mathbf{w} \in \mathbb{R}^d$ is a learnable query vector. A
projection head $g(\cdot)$ maps the pooled representation to
$\mathbf{e} = g(\mathbf{r})$, trained with supervised contrastive
loss to pull same-class embeddings together and push apart
different classes. The classification head is trained with focal
loss ($\gamma{=}2$) with per-class weighting, which down-weights
easy examples and mitigates the class imbalance present in the
training data. For Subtask~A this pipeline is used standalone; for
Subtask~C we pass the predicted class probabilities to the
ensemble stacking stage (Section~\ref{sec:ensemble}).
Figure~\ref{fig:transformer} illustrates the complete encoder
pipeline.



\subsection{AST-Based Structural Features}
\label{sec:ast_features}

A key observation motivating this component is that human-written
and machine-generated code differ not only in surface tokens but
also in structural patterns---such as nesting depth, expression
complexity, identifier naming conventions, and comment
density---that tend to persist across languages and domains.

For each code snippet, we parse the abstract syntax tree using
Tree-sitter and extract a hand-crafted metric vector
$\mathbf{f} \in \mathbb{R}^m$ comprising node-type distributions,
nesting depth statistics, leaf ratios, identifier-length statistics,
comment-to-code ratios, and operator/keyword frequencies. We
quantify the discriminative power of each feature~$f_j$ using
Cohen's~$d$ effect size between the human and machine class
distributions:
\begin{equation}
  d_j = \frac{\mu_j^{\text{machine}} - \mu_j^{\text{human}}}
    {s_j^{\text{pooled}}}
  \label{eq:effectsize}
\end{equation}
where $s_j^{\text{pooled}}$ is the pooled standard deviation.
Features with $|d_j| > 0.2$ were considered useful for model
selection diagnostics (Section~\ref{sec:results}).
Figure~\ref{fig:category} shows the average discriminative power
by metric category; MAGECODE Core~\cite{MAGECODE} and GLTR
Bucket~\cite{GLTR} features exhibit the largest effect sizes ($|d| > 0.37$), confirming
that token-probability and rank-based signals are among the strongest
discriminators between human and machine code. The metric vector is
used as an auxiliary signal during analysis, while the FA-AST graph
representation is encoded by the GGNN described below.

\begin{figure}[t]
  \centering
  \includegraphics[width=\linewidth]{figures/metrics_analysis/category_comparison.png}
  \caption{Effect-Size Analysis (Average |Cohen’s d|) of Feature Categories for Human and Machine-Generated Code}
  \label{fig:category}
\end{figure}





\subsection{Structure-first FA-AST Detector}
\label{sec:fasst_detector}

This component is designed to capture topology-level differences
between human-written and machine-generated code, intentionally
decoupled from surface lexical signals to improve cross-language
and cross-domain generalization.

As shown in Figure~\ref{fig:system}, the FA-AST pipeline augments
syntax trees with flow-aware edges, yielding a graph that is then
encoded with a four-layer GGNN.

\paragraph{Parsing and Error Handling.}
Following prior work on flow-augmented ASTs~\cite{FAUST}, we parse
each snippet with Tree-sitter for seven languages (Python, Java, C,
C++, C\#, Go, JavaScript) and canonicalize node types into a shared
vocabulary. Since code snippets in the dataset may be incomplete,
ambiguous, or stylistically atypical, Tree-sitter occasionally
produces \textit{error nodes}---placeholder AST nodes inserted by
the parser to recover gracefully from syntactic constructs it cannot
fully resolve. To minimize their influence, we attempt parsing with
all seven language grammars and retain the parse that yields the
fewest error nodes, returning immediately if any parse is
error-free. Error nodes are not discarded; they are mapped to a
reserved \texttt{error} token in the shared vocabulary, preserving
dataset coverage while attenuating their structural influence.

This strategy does not introduce systematic bias between human and
machine classes. Parse failures stem from surface syntactic
ambiguity---truncated snippets, mixed-language constructs, or
unusual formatting---rather than from authorship signal. The
\texttt{error} mapping therefore ensures that structurally corrupt
subtrees contribute uniformly attenuated signal rather than
class-specific noise.

\paragraph{Canonicalization and Cross-Language Consistency.}
After parsing, node types are mapped to a shared cross-language
vocabulary of 137 unified labels covering 267 language-specific
source types (e.g., \texttt{function\_definition},
\texttt{method\_declaration}, and \texttt{func\_literal} all
resolve to \texttt{func\_def}). This canonicalization substantially
reduces language-induced structural divergence: syntactically
equivalent constructs across Python, Java, and C++ collapse to the
same node type, exposing structural regularities that the GGNN can
exploit. Residual cross-language differences---arising from
genuinely distinct language semantics rather than surface
notation---are further attenuated by the GGNN's message-passing
scheme, which aggregates multi-hop structural context and is robust
to local variation in node distribution. Additionally, node-level
inputs are deliberately minimal---canonical node IDs, node degree,
and coarse position indices---and identifier names are normalized
to prevent lexical leakage, further insulating the model from
parser-specific artifacts.

\paragraph{Graph Construction and Encoding.}
We then augment the AST with eight edge types---bidirectional
parent--child links that let context flow both up and down the tree
and seven unidirectional types (control-flow, data-flow,
call/return, block, loop-back, and sibling) whose directions follow
their natural semantics (e.g., control flows forward, returns flow
backward, loop-backs re-enter headers). The resulting graph
$G = (V, E)$ is encoded with a four-layer GGNN. At each layer~$t$,
node states are updated via gated message passing:
\begin{equation}
  \mathbf{m}_v^{(t)} = \sum_{e \in \mathcal{E}}
    \sum_{u \in \mathcal{N}_e(v)}
    \mathbf{W}_e \, \mathbf{h}_u^{(t-1)}
  \label{eq:ggnn}
\end{equation}
\begin{equation}
  \mathbf{h}_v^{(t)} = \mathrm{GRU}\!\left(
    \mathbf{h}_v^{(t-1)},\; \mathbf{m}_v^{(t)}\right)
  \label{eq:gru}
\end{equation}
where $\mathcal{E}$ is the set of edge types,
$\mathcal{N}_e(v)$ are the neighbors of node~$v$ under edge
type~$e$, and $\mathbf{W}_e$ is an edge-type-specific weight
matrix that learns to weight structural signals differently per
relation (e.g., distinguishing control-flow context from
parent--child hierarchies). The hidden state $\mathbf{h}_v^{(t)}$
encodes the structural neighborhood of node~$v$ up to $t$ hops,
accumulating topology-level context that is largely invariant to
surface token identity. After four rounds of message passing, node
embeddings are pooled via attention (Equation~\ref{eq:attnpool})
and classified with an MLP head. This pipeline achieves a
macro~F1 of 0.493 on Subtask~A.




\subsection{Ensemble Strategy (Subtask A)}
\label{sec:ensemble_a}

Post-competition, we trained CodeBERT and UniXcoder in the same
frozen-encoder pipeline alongside CodeT5p-220M and built a
five-layer cascading ensemble. The core intuition is simple:
no single model is reliably correct near the decision boundary,
so we use model agreement as a confidence signal—overriding
cautious base predictions when independent models concur.

To quantify agreement, we convert each model's raw probability
into a \textit{percentile rank} within the test set, making scores
comparable across models. The Spearman rank correlation between
CodeT5p and UniXcoder ($r{=}0.35$) and between CodeT5p and
CodeBERT ($r{=}0.57$) confirms that the models provide
substantially independent signals—a prerequisite for effective
ensembling.

The five layers progressively refine a single base prediction:

\textit{Layer~1 (Base prediction).} We form a weighted rank score
that favors CodeT5p (our strongest single model) while incorporating
a small UniXcoder contribution:
\begin{equation}\label{eq:rank}
\begin{aligned}
  r_c &= 0.85\,r_{\text{CodeT5p}} + 0.15\,r_{\text{UniXcoder}}\\
  \hat{y} &= \mathbb{1}[r_c \geq \tau]
\end{aligned}
\end{equation}
where $\tau{=}0.843$ corresponds to CodeT5p's empirically optimal
probability threshold (F1~0.633).

\textit{Layer~2 (Near-threshold rescue).} Predictions just below
the threshold are uncertain by definition. We flip these to positive
when both models independently agree, providing a second opinion
on borderline cases:
\begin{equation}\label{eq:rescue}
  \tau - 0.008 \leq r_c < \tau \;\wedge\;
  |r_{\text{CodeT5p}} - r_{\text{UniXcoder}}| \leq 0.25
\end{equation}
This recovers some false negatives, pushing F1 to 0.634.

\textit{Layer~3 (Consensus overrides).} When both models are highly
confident in the same direction, we trust them unconditionally,
overriding any intermediate score:
\begin{equation}\label{eq:consensus}
  \begin{cases}
    \hat{y}=1 & \text{if } r_{\text{CodeT5p}} \geq 0.8 \;\wedge\; r_{\text{UniXcoder}} \geq 0.8 \\
    \hat{y}=0 & \text{if } r_{\text{CodeT5p}} \leq 0.2 \;\wedge\; r_{\text{UniXcoder}} \leq 0.2
  \end{cases}
\end{equation}
F1 rises to 0.635.

\textit{Layer~4 (UniXcoder rescue).} Because UniXcoder correlates
weakly with CodeT5p ($r{=}0.35$), its high-confidence positive
predictions carry independent evidential weight. We recover false
negatives where $p_{\text{UniXcoder}} \geq 0.76$ and
$p_{\text{CodeT5p}} \geq 0.70$, lifting F1 to 0.638.

\textit{Layer~5 (CodeBERT rescue).} We apply an analogous rescue
using CodeBERT, but set a higher probability bar
($p_{\text{CodeBERT}} \geq 0.88$) reflecting its stronger
correlation with CodeT5p ($r{=}0.57$)—a correlated model must
be more certain to add new information. Final F1: \textbf{0.643},
up from the CodeT5p-only baseline of 0.559.

\subsection{Ensemble Strategy (Subtask C)}
\label{sec:ensemble}

Post-competition, we designed a three-stage ensemble to address the
four-class setting of Subtask~C, which benefits from combining
diverse model families.

\paragraph{Stage~1: Orthogonal feature classifier.}
We train a LightGBM on features the neural encoder does not
explicitly model: TF-IDF character n-grams ($n{=}2$--$4$, 5K
features), the same 32~handcrafted stylometric features defined in
Section~\ref{sec:ast_features}, and
40~token-level statistical features from
StarCoder2-3B~\cite{STARCODER2}---including perplexity,
log-probability distributions, GLTR rank buckets~\cite{GLTR},
and per-token entropy. For each sample~$x$, this yields a
feature vector
$\mathbf{x}_{\text{lgb}} = [\mathbf{x}_{\text{tfidf}};\;
\mathbf{x}_{\text{hc}};\; \mathbf{x}_{\text{sc}}]
\in \mathbb{R}^{5072}$,
from which LightGBM produces class probabilities
$\mathbf{p}^{\text{lgb}} \in \mathbb{R}^4$.


\paragraph{Stage~2: Meta-learner stacking.}
We stack the neural and LightGBM probability vectors into a
meta-feature vector that captures both raw predictions and
inter-model agreement:
\begin{equation}
  \mathbf{m} = \bigl[\mathbf{p}^{\text{nn}};\;
  \mathbf{p}^{\text{lgb}};\;
  \hat{c};\; \mathbf{H};\; a;\;
  \boldsymbol{\delta}\bigr]
  \in \mathbb{R}^{17}
  \label{eq:meta}
\end{equation}
where $\hat{c} = [\max_y p^{\text{nn}}_y,\; \max_y
p^{\text{lgb}}_y]$ captures each model's confidence,
$\mathbf{H} = [-\!\sum_y p_y \log p_y]$ for each model measures
prediction entropy, $a = \mathbb{1}[\arg\max
\mathbf{p}^{\text{nn}} = \arg\max \mathbf{p}^{\text{lgb}}]$
indicates agreement, and $\boldsymbol{\delta} =
\mathbf{p}^{\text{nn}} - \mathbf{p}^{\text{lgb}}$ captures
per-class disagreement. A second LightGBM trained on
$\mathbf{m}$ learns when to trust each base model, producing
final probabilities $\mathbf{p}^{\text{meta}} \in \mathbb{R}^4$.

\paragraph{Stage~3: Class-priority post-processing.}
Since neural models systematically under-predict minority classes,
we apply threshold-based routing to the meta-learner output:
\begin{equation}
  \hat{y} = \begin{cases}
    \text{Adv}     & \text{if } p^{\text{meta}}_{\text{adv}} > \tau_{\text{adv}} \\
    \text{Machine} & \text{if } p^{\text{meta}}_{\text{mach}} > \tau_{\text{mach}} \\
    \arg\max_y\, \mathbf{p}^{\text{meta}} & \text{otherwise}
  \end{cases}
  \label{eq:priority}
\end{equation}
where thresholds $\tau_{\text{adv}}$ and $\tau_{\text{mach}}$ are
tuned via grid search on the validation set. The priority ordering
(Adversarial checked first) reflects the observation that
Adversarial samples are the most under-predicted class. The
metric-driven pipeline (Figure~\ref{fig:allmetrics}) guided
feature selection and threshold tuning. To address class
imbalance, we downsampled dominant classes and used stratified
folds to prevent domain leakage. This ensemble raises the official
CodeT5p-only score of 0.585 to \textbf{0.652}.

\begin{figure}[t]
  \centering
  \includegraphics[width=0.95\linewidth]{figures/metrics_analysis/all_metrics_ranked.png}
  \caption{Ranked metric effectiveness across candidate features.
    Features with the largest effect sizes guided selection of
    complementary signals for the ensemble.}
  \label{fig:allmetrics}
\end{figure}

%% -----------------------------------------------
%%  4. EXPERIMENTAL SETUP
%% -----------------------------------------------
\section{Experimental Setup}
\label{sec:experiments}

\paragraph{Data.}
We use the official training and validation splits for all
subtasks (500K samples for Subtask~A; 900K for Subtask~C). No
external data was used. We reserved a stratified 10\% of the
training set as an internal development split for hyperparameter
tuning.

\paragraph{Training.}
All transformer models were fine-tuned with AdamW (learning rate
2e-5, linear warmup over 6\% of steps, batch size 16) for up to 7
epochs with early stopping on validation macro~F1. We also
experimented with class downsampling and test-time
augmentation~\cite{TENT}. Maximum sequence length was 512 tokens.

\paragraph{Evaluation.}
All results use macro~F1, the official metric.

%% -----------------------------------------------
%%  5. RESULTS
%% -----------------------------------------------
\section{Results}
\label{sec:results}

\subsection{Official Results}

Table~\ref{tab:main_results} presents the official leaderboard
results for our system on Subtask~A and Subtask~C.

\begin{table}[h]
\centering
\small
\resizebox{\columnwidth}{!}{%
\begin{tabular}{llc}
\toprule
\textbf{Task} & \textbf{System} & \textbf{Macro F1} \\
\midrule
A & FA-AST (GGNN)                      & 0.493 \\
A & CodeT5p-220M                       & 0.559 \\
A & \quad + downsampling + TTA              & 0.561 \\
A & \quad + rank-fusion ens.$^\dagger$       & 0.643 \\
\midrule
C & CodeT5p-220M                       & 0.585 \\
C & \quad + meta-learner ens.$^\dagger$      & 0.652 \\
\bottomrule
\end{tabular}%
}
\caption{Test set results. $^\dagger$Post-competition.
  Subtask~A ensemble fuses CodeT5p, CodeBERT, and UniXcoder via
  layered rank fusion. Subtask~C ensemble uses meta-learner
  stacking with class-priority routing.}
\label{tab:main_results}
\end{table}

\subsection{Distribution Shift Analysis}

Table~\ref{tab:shift} quantifies the distribution shift between
validation and test for both subtasks. The gap is striking: on
Subtask~A both approaches---the CodeT5p-220M encoder and the
FA-AST detector---achieve 0.980 macro~F1 on the validation
set, yet drop to 0.559 and 0.493 respectively on the final test
set. A similar pattern holds for Subtask~C, where validation performance
of 0.810 falls to 0.790 on a preliminary 1K test sample released on
HuggingFace and further to 0.585 on the full 500K test set.
These gaps confirm that the test sets introduce substantial language
and domain shifts absent from training and validation.

\begin{table}[h]
\centering
\small
\begin{tabular}{lccc}
\toprule
\textbf{Subtask} & \textbf{Val} & \textbf{Test} & \textbf{$\Delta$} \\
\midrule
A (CodeT5p)    & 0.980 & 0.559 & --0.421 \\
A (FA-AST)     & 0.980 & 0.493 & --0.487 \\
C (CodeT5p)    & 0.810 & 0.585 & --0.225 \\
C (1K HF test) & --    & 0.790 & -- \\
\bottomrule
\end{tabular}
\caption{Validation vs.\ test macro~F1, illustrating massive
  distribution shift in both subtasks. Both Subtask~A approaches
  achieve near-perfect validation scores yet degrade sharply on the
  final test set.}
\label{tab:shift}
\end{table}

AST features partially recover this loss for unseen languages,
where structural patterns transfer more reliably than token-level
representations (see Appendix for t-SNE visualizations).

\subsection{Error Analysis}

Manual inspection of 100 misclassified Subtask~A validation
examples reveals two dominant failure modes: (1)~short snippets
(under 20 tokens) from unseen domains, where both token and
structural features lack sufficient signal, and (2)~terse
competitive-programming solutions whose algorithmic style
overlaps with LLM outputs.

%% -----------------------------------------------
%%  6. CONCLUSION
%% -----------------------------------------------
\section{Conclusion}
\label{sec:conclusion}

We presented our system for SemEval-2026 Task~13, combining
three code-pretrained encoders with a structure-first FA-AST
detector. For Subtask~A, a layered rank-fusion ensemble
exploiting low inter-model correlation (Spearman
$r{=}0.35$--$0.57$) raises macro~F1 from 0.559 to 0.643. For
Subtask~C, meta-learner stacking with class-priority routing
raises macro~F1 from 0.585 to 0.652. Both results highlight that
ensemble diversity---measured through rank correlation and
complementary feature spaces---is more valuable than individual
model strength under distribution shift. Future work could explore
domain-adaptive pretraining to further close the gap between
validation and test performance.

%% -----------------------------------------------
%%  REFERENCES
%% -----------------------------------------------
\bibliography{custom}

\clearpage
\appendix

\section{Additional Visualizations}
\label{sec:appendix}

\subsection{Distribution Shift: t-SNE of Embeddings}

Figure~\ref{fig:tsne_overlap} visualizes the pooled 768-dimensional
CodeT5p-220M embeddings for 1,000 training and 1,000 test samples
from Subtask~A using t-SNE. Training and test points occupy largely
disjoint regions, confirming the massive distributional gap between
splits. Figure~\ref{fig:tsne_lang} shows the same embedding space
colored by programming language; unseen test languages (C\#, Go,
JavaScript, PHP, C) form distinct clusters with minimal overlap to
the training languages (Python, Java, C++), explaining the sharp
performance degradation reported in Table~\ref{tab:shift}.

\begin{figure}[h]
  \centering
  \includegraphics[width=\linewidth]{figures/train_test_overlap_subtaskA_onasubset.png}
  \caption{t-SNE Projection of Pooled CodeT5p-220M Embeddings(Subtask A). Illustrating Train–Test Distribution Shift}
  \label{fig:tsne_overlap}
\end{figure}

\begin{figure}[h]
  \centering
  \includegraphics[width=\linewidth]{figures/language_wise_tsne.png}
  \caption{Language-Wise t-SNE Projection of CodeT5p Embeddings(Subtask A).}
  \label{fig:tsne_lang}
\end{figure}

\subsection{Token Length Analysis (Subtask C)}

Figures~\ref{fig:token_before} and~\ref{fig:token_after} compare
the token-length distribution of Subtask~C before and after
preprocessing. The raw data has a long tail with only 72.5\% of
samples fitting within the 512-token context window. After cleaning
(removal of artifacts, comment stripping, and whitespace
normalization), coverage at 512 tokens rises to 83.6\%, reducing
truncation-related noise during training.

\begin{figure}[h]
  \centering
  \includegraphics[width=\linewidth]{figures/before_preprocess_token_subtaskC.png}
  \caption{Token length distribution for Subtask~C before
    preprocessing. Only 72.5\% of samples fit within 512 tokens.}
  \label{fig:token_before}
\end{figure}

\begin{figure}[h]
  \centering
  \includegraphics[width=\linewidth]{figures/after_post_processing_subtaskC.png}
  \caption{Token-Length Distribution for Subtask C After Preprocessing. Only 83.6\% of samples fit within 512 tokens.}
  \label{fig:token_after}
\end{figure}


\subsection{Supplementary Experiment: Subtask B}
\label{sec:appendix-subtaskb}
The raw code snippets are fed into the \textbf{CodeT5p-770M} model. The encoder is fully trained end-to-end.
On top of the encoder, we attach an \textbf{Attention Pooling} layer that computes soft per-token weights over the encoder's last hidden states. Two heads operate on this pooled representation: (i)~a \textbf{Projection Head}
($1024\!\to\!512\!\to\!256$, L2-normalised) used solely to compute the
Supervised Contrastive loss and (ii)~a
\textbf{Classification Head} ($1024\!\to\!512\!\to\!256\!\to\!11$, with
Batch Normalization and progressive dropout) trained with Focal Loss. \textbf{Focal Loss} down-weights well-classified samples,
while \textbf{Supervised Contrastive Loss} shapes the embedding space so that generators form
tight, separable clusters—both losses jointly address the severe
class imbalance (88.4\% Human). Additionally, several classes had comparatively low representation in the training dataset, such as gemma (0.39\%) and bigcode (0.45\%).

\begin{figure}[t]
    \centering
    \includegraphics[width=\linewidth]{figures/taskB_final_encoder_output.png}
    \caption{t-SNE of CodeT5p-770M Embeddings (Subtask~B): pre-trained (left)
vs.\ fine-tuned (right). Fine-tuning induces clear per-generator clustering.}
    \label{fig:taskb_encoder_final_output}
\end{figure}

We train on the full dataset rather than a
class-balanced variant.  In a separate experiment, down-sampling the
Human class to 10K samples peaked at macro F1 of 0.480 (epoch~10),
whereas the full dataset reached 0.577 (epoch~10)---a
relative gain of 20.1\%.
The extra Human samples provide richer negatives for the contrastive
objective, sharpening the decision boundaries between generators.


We also chose \emph{not} to apply comment or whitespace removal. Stripping comments degraded performance in preliminary runs:
commenting style and inline documentation patterns differ across
generators and carry useful authorship signal.

Using the official test set released prior to the competition, our best post-competition evaluation achieved a score of \textbf{0.40759} on Subtask~B.

\end{document}