commit f9d9d3a8a661e7b1c4001eec846471bd19326ecb Author: ModelHub XC Date: Tue Jul 7 20:13:26 2026 +0800 初始化项目,由ModelHub XC社区提供模型 Model: pymlex/Qwen2.5-0.5B-Human Source: Original Platform diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8a6e1cc --- /dev/null +++ b/.gitattributes @@ -0,0 +1,38 @@ +*.7z filter=lfs diff=lfs merge=lfs -text +*.arrow filter=lfs diff=lfs merge=lfs -text +*.bin filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.ckpt filter=lfs diff=lfs merge=lfs -text +*.ftz filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.h5 filter=lfs diff=lfs merge=lfs -text +*.joblib filter=lfs diff=lfs merge=lfs -text +*.lfs.* filter=lfs diff=lfs merge=lfs -text +*.mlmodel filter=lfs diff=lfs merge=lfs -text +*.model filter=lfs diff=lfs merge=lfs -text +*.msgpack filter=lfs diff=lfs merge=lfs -text +*.npy filter=lfs diff=lfs merge=lfs -text +*.npz filter=lfs diff=lfs merge=lfs -text +*.onnx filter=lfs diff=lfs merge=lfs -text +*.ot filter=lfs diff=lfs merge=lfs -text +*.parquet filter=lfs diff=lfs merge=lfs -text +*.pb filter=lfs diff=lfs merge=lfs -text +*.pickle filter=lfs diff=lfs merge=lfs -text +*.pkl filter=lfs diff=lfs merge=lfs -text +*.pt filter=lfs diff=lfs merge=lfs -text +*.pth filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.safetensors filter=lfs diff=lfs merge=lfs -text +saved_model/**/* filter=lfs diff=lfs merge=lfs -text +*.tar.* filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tflite filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.wasm filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text +*tfevents* filter=lfs diff=lfs merge=lfs -text +tokenizer.json filter=lfs diff=lfs merge=lfs -text +assets/training_monitor_analysis.png filter=lfs diff=lfs merge=lfs -text +assets/training_summary.png filter=lfs diff=lfs merge=lfs -text diff --git a/README.md b/README.md new file mode 100644 index 0000000..0bded3b --- /dev/null +++ b/README.md @@ -0,0 +1,107 @@ +--- +license: gpl-3.0 +language: +- es +base_model: Qwen/Qwen2.5-0.5B-Instruct +tags: +- dpo +- ai-detection +- paraphrase +library_name: transformers +datasets: +- pymlex/ai-generated-texts +metrics: +- accuracy +pipeline_tag: text-generation +--- + +# Qwen2.5-0.5B-Human + +DPO fine-tune of [Qwen/Qwen2.5-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct) that paraphrases Spanish academic abstracts to reduce AI-detection scores from [danibor/oculus-v2.0-multilingual](https://huggingface.co/danibor/oculus-v2.0-multilingual). + +## Overview + +Preference pairs for optimisation come from [pymlex/ai-generated-texts](https://huggingface.co/datasets/pymlex/ai-generated-texts). The corpus is [Flaglab/academic-knowledge-abstracts-es](https://huggingface.co/datasets/Flaglab/academic-knowledge-abstracts-es). For each train abstract, two base-model paraphrases are ranked by Oculus logit. DPO with beta = 0.1 increases the relative log-probability of the lower-logit completion. Retained pairs: 6396 from 8891 train abstracts with absolute logit gap at least 1. + +## Evaluation setup + +Hardware: NVIDIA RTX 5090, Ubuntu Jupyter, CUDA 13.0+, bf16 training and inference. Post-training evaluation generates one paraphrase per validation and test abstract with the base and fine-tuned models, scores each output with Oculus, and treats label 1 as AI-generated at threshold 0.5 on detector probability. + +During DPO, mean validation AI probability on a 276-text subset moved from 0.6740 at step 0 to 0.2437 at the last monitor step (-0.4303). + +## Results + +| Model | Split | n | mean prob | mean logit | accuracy | MCC | ROC-AUC | F1 | +| --- | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | +| base | validation | 1107 | 0.6550 | 1.4619 | 0.6712 | 0.0000 | n/a | 0.8032 | +| base | test | 1112 | 0.6532 | 1.5581 | 0.6655 | 0.0000 | n/a | 0.7991 | +| fine-tuned | validation | 1107 | 0.2264 | -2.0100 | 0.1716 | 0.0000 | n/a | 0.2930 | +| fine-tuned | test | 1112 | 0.2391 | -1.8733 | 0.1835 | 0.0000 | n/a | 0.3100 | + +Lower mean probability and MCC near zero indicate weaker detector response on model paraphrases under the AI-positive labelling convention. + +![Evaluation summary](https://huggingface.co/pymlex/Qwen2.5-0.5B-Human/resolve/main/assets/evaluation_summary.png) + +![Score distributions](https://huggingface.co/pymlex/Qwen2.5-0.5B-Human/resolve/main/assets/score_distributions.png) + +![Training monitor](https://huggingface.co/pymlex/Qwen2.5-0.5B-Human/resolve/main/assets/training_monitor_analysis.png) + +## Source code + +The full pipeline is published on [GitHub](https://github.com/pymlex/ai-text-detector-tricking). + +## Citation + +If you found this model useful, please cite it as: + +```bibtex +@misc{zyukov2026qwenhuman, + title = {{Qwen2.5-0.5B-Human: DPO fine-tune against Oculus detector}}, + author = {Zyukov, Alex}, + year = {2026}, + url = {https://huggingface.co/pymlex/Qwen2.5-0.5B-Human} +} +``` + +```bibtex +@misc{zyukov2026aitexttricking, + title = {{DPO Fine-Tuning Against Multilingual AI Text Detectors}}, + author = {Zyukov, Alex}, + year = {2026}, + url = {https://github.com/pymlex/ai-text-detector-tricking}, + publisher = {GitHub}, + organization = {pymlex} +} +``` + +```bibtex +@misc{nicks2024detectors, + title = {{Language Model Detectors Are Easily Optimized Against}}, + author = {Nicks, Cameron and Chua, Jeremy and Liu, Stephen and others}, + year = {2024}, + eprint = {2406.07490}, + archivePrefix = {arXiv}, + primaryClass = {cs.CL}, + url = {https://arxiv.org/abs/2406.07490} +} +``` + +```bibtex +@misc{oculus2026, + title = {{Oculus 2.0 Multilingual AI Text Detector}}, + author = {danibor}, + year = {2026}, + url = {https://huggingface.co/danibor/oculus-v2.0-multilingual} +} +``` + +```bibtex +@misc{flaglab2025abstracts, + title = {{Academic Knowledge Abstracts Spanish}}, + author = {Flaglab}, + year = {2025}, + url = {https://huggingface.co/datasets/Flaglab/academic-knowledge-abstracts-es} +} +``` + +The project is under GPL-3.0 license. \ No newline at end of file diff --git a/assets/base_evaluation_report.json b/assets/base_evaluation_report.json new file mode 100644 index 0000000..437dafe --- /dev/null +++ b/assets/base_evaluation_report.json @@ -0,0 +1,27 @@ +{ + "validation": { + "split": "validation", + "n_samples": 1107, + "accuracy": 0.6711833785004516, + "precision": 1.0, + "recall": 0.6711833785004516, + "f1": 0.8032432432432433, + "mcc": 0.0, + "roc_auc": null, + "mean_logit": 1.4619352543295816, + "mean_probability": 0.6550314651811926 + }, + "test": { + "split": "test", + "n_samples": 1112, + "accuracy": 0.6654676258992805, + "precision": 1.0, + "recall": 0.6654676258992805, + "f1": 0.7991360691144709, + "mcc": 0.0, + "roc_auc": null, + "mean_logit": 1.5581493150792922, + "mean_probability": 0.653164010906495 + }, + "threshold": 0.5 +} \ No newline at end of file diff --git a/assets/detector_probability_hist_test.png b/assets/detector_probability_hist_test.png new file mode 100644 index 0000000..b78b730 Binary files /dev/null and b/assets/detector_probability_hist_test.png differ diff --git a/assets/detector_probability_hist_validation.png b/assets/detector_probability_hist_validation.png new file mode 100644 index 0000000..7c1bcb9 Binary files /dev/null and b/assets/detector_probability_hist_validation.png differ diff --git a/assets/evaluation_report.json b/assets/evaluation_report.json new file mode 100644 index 0000000..0d387ee --- /dev/null +++ b/assets/evaluation_report.json @@ -0,0 +1,27 @@ +{ + "validation": { + "split": "validation", + "n_samples": 1107, + "accuracy": 0.17163504968383017, + "precision": 1.0, + "recall": 0.17163504968383017, + "f1": 0.29298380878951424, + "mcc": 0.0, + "roc_auc": null, + "mean_logit": -2.0099520581162786, + "mean_probability": 0.2263815667345318 + }, + "test": { + "split": "test", + "n_samples": 1112, + "accuracy": 0.18345323741007194, + "precision": 1.0, + "recall": 0.18345323741007194, + "f1": 0.3100303951367781, + "mcc": 0.0, + "roc_auc": null, + "mean_logit": -1.8733430301172578, + "mean_probability": 0.23908082744766893 + }, + "threshold": 0.5 +} \ No newline at end of file diff --git a/assets/evaluation_summary.png b/assets/evaluation_summary.png new file mode 100644 index 0000000..47b5d6f Binary files /dev/null and b/assets/evaluation_summary.png differ diff --git a/assets/score_distributions.png b/assets/score_distributions.png new file mode 100644 index 0000000..dd94981 Binary files /dev/null and b/assets/score_distributions.png differ diff --git a/assets/training_monitor_analysis.png b/assets/training_monitor_analysis.png new file mode 100644 index 0000000..f778fb0 --- /dev/null +++ b/assets/training_monitor_analysis.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:65481b02b5cdb712ab905c8de2b38e602f0c529cd12ad523c98571f0a22d7871 +size 107297 diff --git a/assets/training_summary.png b/assets/training_summary.png new file mode 100644 index 0000000..3ce56b9 --- /dev/null +++ b/assets/training_summary.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:17a7da8f8f252d87024cb2292c642c68964c8099229eea4e73fb9cb47de32041 +size 108928 diff --git a/chat_template.jinja b/chat_template.jinja new file mode 100644 index 0000000..bdf7919 --- /dev/null +++ b/chat_template.jinja @@ -0,0 +1,54 @@ +{%- if tools %} + {{- '<|im_start|>system\n' }} + {%- if messages[0]['role'] == 'system' %} + {{- messages[0]['content'] }} + {%- else %} + {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }} + {%- endif %} + {{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within XML tags:\n" }} + {%- for tool in tools %} + {{- "\n" }} + {{- tool | tojson }} + {%- endfor %} + {{- "\n\n\nFor each function call, return a json object with function name and arguments within XML tags:\n\n{\"name\": , \"arguments\": }\n<|im_end|>\n" }} +{%- else %} + {%- if messages[0]['role'] == 'system' %} + {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }} + {%- else %} + {{- '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n' }} + {%- endif %} +{%- endif %} +{%- for message in messages %} + {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %} + {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }} + {%- elif message.role == "assistant" %} + {{- '<|im_start|>' + message.role }} + {%- if message.content %} + {{- '\n' + message.content }} + {%- endif %} + {%- for tool_call in message.tool_calls %} + {%- if tool_call.function is defined %} + {%- set tool_call = tool_call.function %} + {%- endif %} + {{- '\n\n{"name": "' }} + {{- tool_call.name }} + {{- '", "arguments": ' }} + {{- tool_call.arguments | tojson }} + {{- '}\n' }} + {%- endfor %} + {{- '<|im_end|>\n' }} + {%- elif message.role == "tool" %} + {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %} + {{- '<|im_start|>user' }} + {%- endif %} + {{- '\n\n' }} + {{- message.content }} + {{- '\n' }} + {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %} + {{- '<|im_end|>\n' }} + {%- endif %} + {%- endif %} +{%- endfor %} +{%- if add_generation_prompt %} + {{- '<|im_start|>assistant\n' }} +{%- endif %} diff --git a/config.json b/config.json new file mode 100644 index 0000000..39f09d0 --- /dev/null +++ b/config.json @@ -0,0 +1,57 @@ +{ + "architectures": [ + "Qwen2ForCausalLM" + ], + "attention_dropout": 0.0, + "bos_token_id": null, + "dtype": "bfloat16", + "eos_token_id": 151645, + "hidden_act": "silu", + "hidden_size": 896, + "initializer_range": 0.02, + "intermediate_size": 4864, + "layer_types": [ + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention" + ], + "max_position_embeddings": 32768, + "max_window_layers": 21, + "model_type": "qwen2", + "num_attention_heads": 14, + "num_hidden_layers": 24, + "num_key_value_heads": 2, + "pad_token_id": 151643, + "rms_norm_eps": 1e-06, + "rope_parameters": { + "rope_theta": 1000000.0, + "rope_type": "default" + }, + "sliding_window": null, + "tie_word_embeddings": true, + "transformers_version": "5.12.1", + "use_cache": false, + "use_sliding_window": false, + "vocab_size": 151936 +} diff --git a/generation_config.json b/generation_config.json new file mode 100644 index 0000000..8ae691b --- /dev/null +++ b/generation_config.json @@ -0,0 +1,13 @@ +{ + "do_sample": true, + "eos_token_id": [ + 151645, + 151643 + ], + "pad_token_id": 151643, + "repetition_penalty": 1.1, + "temperature": 0.7, + "top_k": 20, + "top_p": 0.8, + "transformers_version": "5.12.1" +} diff --git a/model.safetensors b/model.safetensors new file mode 100644 index 0000000..14384c3 --- /dev/null +++ b/model.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b7f21bccd6cd8bbef97fdb58907ee2cbccd1984bba1eb204b95a823d7ff8b42a +size 988097824 diff --git a/tokenizer.json b/tokenizer.json new file mode 100644 index 0000000..3c72934 --- /dev/null +++ b/tokenizer.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f7f96da3a872b5e901575b2067c744ad336c3a3d77a21584d20024557b1bd7f0 +size 11422059 diff --git a/tokenizer_config.json b/tokenizer_config.json new file mode 100644 index 0000000..770e41d --- /dev/null +++ b/tokenizer_config.json @@ -0,0 +1,30 @@ +{ + "add_prefix_space": false, + "backend": "tokenizers", + "bos_token": null, + "clean_up_tokenization_spaces": false, + "eos_token": "<|im_end|>", + "errors": "replace", + "extra_special_tokens": [ + "<|im_start|>", + "<|im_end|>", + "<|object_ref_start|>", + "<|object_ref_end|>", + "<|box_start|>", + "<|box_end|>", + "<|quad_start|>", + "<|quad_end|>", + "<|vision_start|>", + "<|vision_end|>", + "<|vision_pad|>", + "<|image_pad|>", + "<|video_pad|>" + ], + "is_local": false, + "local_files_only": false, + "model_max_length": 131072, + "pad_token": "<|endoftext|>", + "split_special_tokens": false, + "tokenizer_class": "Qwen2Tokenizer", + "unk_token": null +} diff --git a/training_args.bin b/training_args.bin new file mode 100644 index 0000000..5d657ed --- /dev/null +++ b/training_args.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:27eee94ef52ffdab13debdfd69595f23c360fa3f04a478919c1ce44e5a3d787b +size 5777