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
Model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
base_model: microsoft/unixcoder-base
|
| 4 |
+
library_name: transformers
|
| 5 |
+
pipeline_tag: text-classification
|
| 6 |
+
datasets:
|
| 7 |
+
- basakdemirok/AIGCodeSet
|
| 8 |
+
tags:
|
| 9 |
+
- code
|
| 10 |
+
- python
|
| 11 |
+
- ai-generated-code-detection
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# CODer: UniXcoder checkpoints
|
| 15 |
+
|
| 16 |
+
Fine-tuned [UniXcoder](https://huggingface.co/microsoft/unixcoder-base) classifiers that detect LLM-written Python code, trained on [AIGCodeSet](https://huggingface.co/datasets/basakdemirok/AIGCodeSet). 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).
|
| 17 |
+
|
| 18 |
+
## Layout
|
| 19 |
+
|
| 20 |
+
24 checkpoints: six seeds (`seed3` to `seed8`) × four task variants. The paper's seed ensemble averages the six seeds' probabilities.
|
| 21 |
+
|
| 22 |
+
| Folder | Task | Labels |
|
| 23 |
+
|---|---|---|
|
| 24 |
+
| `seed<N>/binary` | human vs LLM, all data | 0 human, 1 ai |
|
| 25 |
+
| `seed<N>/binary_generate` | human vs LLM, without LLM-edited code | 0 human, 1 ai |
|
| 26 |
+
| `seed<N>/multiclass` | human or which LLM, all data | 0 Human, 1 GEMINI, 2 LLAMA, 3 CODESTRAL |
|
| 27 |
+
| `seed<N>/multiclass_generate` | human or which LLM, without LLM-edited code | 0 Human, 1 GEMINI, 2 LLAMA, 3 CODESTRAL |
|
| 28 |
+
|
| 29 |
+
The configs keep the default label names (`LABEL_0`, `LABEL_1`, ...); the table gives their meaning.
|
| 30 |
+
|
| 31 |
+
## Usage
|
| 32 |
+
|
| 33 |
+
~~~python
|
| 34 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
| 35 |
+
|
| 36 |
+
repo, variant = "mparts/CODer-unixcoder", "seed3/binary"
|
| 37 |
+
tok = AutoTokenizer.from_pretrained(repo, subfolder=variant)
|
| 38 |
+
model = AutoModelForSequenceClassification.from_pretrained(repo, subfolder=variant)
|
| 39 |
+
~~~
|
| 40 |
+
|
| 41 |
+
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.
|
| 42 |
+
|
| 43 |
+
## Training
|
| 44 |
+
|
| 45 |
+
Fine-tuned on the train split of the repository's problem-grouped split of AIGCodeSet, in which no programming problem is shared between train, dev and test: 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.
|
| 46 |
+
|
| 47 |
+
## Limitations
|
| 48 |
+
|
| 49 |
+
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.
|
| 50 |
+
|
| 51 |
+
## License
|
| 52 |
+
|
| 53 |
+
The weights are released under the MIT license, like the code. The training data, AIGCodeSet, is under CDLA-Permissive-2.0.
|