Instructions to use mparts/CODer-unixcoder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mparts/CODer-unixcoder with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="mparts/CODer-unixcoder")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("mparts/CODer-unixcoder", device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 2,931 Bytes
26306e0 e2bdabd 26306e0 44aa8ff 26306e0 44aa8ff 26306e0 e2bdabd 26306e0 44aa8ff | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | ---
license: mit
base_model: microsoft/unixcoder-base
library_name: transformers
pipeline_tag: text-classification
datasets:
- mparts/CODer-aigcodeset
- basakdemirok/AIGCodeSet
tags:
- code
- python
- ai-generated-code-detection
metrics:
- f1
---
# CODer: UniXcoder checkpoints
Fine-tuned [UniXcoder](https://huggingface.co/microsoft/unixcoder-base) classifiers that detect LLM-written Python code, trained on [mparts/CODer-aigcodeset](https://huggingface.co/datasets/mparts/CODer-aigcodeset), a cleaned version of [AIGCodeSet](https://huggingface.co/datasets/basakdemirok/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](https://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
~~~python
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)
~~~
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.
## Training
Fine-tuned on the train split of [mparts/CODer-aigcodeset](https://huggingface.co/datasets/mparts/CODer-aigcodeset), the repository's problem-grouped split of AIGCodeSet, in which no programming problem is shared between train, dev and test (rows flagged `conflict` dropped): 4 epochs, learning rate 2e-5, batch size 16, max length 256, weight decay 0.01, warmup ratio 0.1. 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. |