CODer: UniXcoder checkpoints

Fine-tuned UniXcoder classifiers that detect LLM-written Python code, trained on mparts/CODer-aigcodeset, a cleaned version of AIGCodeSet split by programming problem. They are the models behind Detecting LLM-Written Code on AIGCodeSet: Tuned Code Encoders versus N-gram Baselines. The code, the predictions and the paper are at github.com/mparts/CODer.

Layout

24 checkpoints: six seeds (seed3 to seed8) × four task variants. The paper's seed ensemble averages the six seeds' probabilities.

Folder Task Labels
seed<N>/binary human vs LLM, all data 0 human, 1 ai
seed<N>/binary_generate human vs LLM, without LLM-edited code 0 human, 1 ai
seed<N>/multiclass human or which LLM, all data 0 Human, 1 GEMINI, 2 LLAMA, 3 CODESTRAL
seed<N>/multiclass_generate human or which LLM, without LLM-edited code 0 Human, 1 GEMINI, 2 LLAMA, 3 CODESTRAL

The configs keep the default label names (LABEL_0, LABEL_1, ...); the table gives their meaning.

Usage

from transformers import AutoModelForSequenceClassification, AutoTokenizer

repo, variant = "mparts/CODer-unixcoder", "seed3/binary"
tok = AutoTokenizer.from_pretrained(repo, subfolder=variant)
model = AutoModelForSequenceClassification.from_pretrained(repo, subfolder=variant)
inputs = tok(code, truncation=True, max_length=256, return_tensors="pt")  # code: one normalised string
probs = model(**inputs).logits.softmax(-1)

The models were trained on whitespace-normalised code (line endings unified, tabs expanded to four spaces, trailing spaces and outer blank lines removed: normalise() in src/code_origin/data/preprocess.py), truncated to 256 tokens. Normalise inputs the same way, and keep truncation=True, max_length=256: the saved tokenizer has no length limit of its own, so without them longer code is not cut at 256 tokens as in training.

Training

Fine-tuned on the train rows of mparts/CODer-aigcodeset, without the rows flagged conflict. No programming problem is shared between train, dev and test. Hyperparameters: 4 epochs, learning rate 2e-5, batch size 16, max length 256, weight decay 0.01, warmup ratio 0.1, dropout 0.0 (instead of the default 0.1), no class weights. The saved weights are from the epoch with the best dev macro-F1.

Limitations

Trained on Python solutions to 317 CodeNet problems, against three LLMs (CodeLlama 34B, Codestral 22B, Gemini 1.5 Flash). It is a research artefact for this setting, not a general-purpose detector of AI-written code.

License

The weights are released under the MIT license, like the code. The training data, mparts/CODer-aigcodeset (derived from AIGCodeSet), is under CDLA-Permissive-2.0.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for mparts/CODer-unixcoder

Finetuned
(19)
this model

Datasets used to train mparts/CODer-unixcoder