TLDR: DuoLens is a novel framework that utilizes fine-tuned Small Language Models (SLMs) like RoBERTa and CodeBERTa to accurately and efficiently detect machine-generated multilingual text and source code. It significantly outperforms larger Large Language Models (LLMs) in binary classification tasks, achieving high accuracy (AUROC 0.97-0.99, macro-F1 0.89-0.94) while drastically reducing computational resources (8-12x less latency, 3-5x less VRAM). The framework also demonstrates robust performance against various adversarial transformations and cross-generator shifts, making AI content detection more accessible.
The rapid advancement of Large Language Models (LLMs) has led to an explosion of machine-generated content, from written articles in various languages to complex computer code. While this technology offers significant productivity boosts, it also introduces serious concerns like plagiarism, the spread of misinformation, and unfair advantages in academic or professional settings. The need for accurate and efficient detectors of AI-generated content has never been more critical.
Current detection methods often face a dilemma: they are either computationally expensive, requiring substantial resources, or they lack sufficient accuracy, especially when dealing with multiple languages or different types of content like source code. Many existing tools are primarily effective for English text and struggle with other languages, leading to unreliable results. Furthermore, some sophisticated detection approaches can be prohibitively slow or resource-intensive.
A new research paper, DuoLens: A Framework for Robust Detection of Machine-Generated Multilingual Text and Code, proposes an innovative solution to these challenges. The core idea behind DuoLens is to leverage the power of fine-tuned encoder-only Small Language Models (SLMs) rather than larger, more resource-intensive LLMs for the binary classification task of identifying machine-generated content.
The researchers specifically focused on fine-tuning pre-trained models like RoBERTa and CodeBERTa. They developed specialized datasets for both source code and natural language to demonstrate that SLMs can significantly outperform LLMs in this specific detection task, all while using a mere fraction of the computational power.
Key Contributions of DuoLens
The DuoLens framework makes several important contributions. Firstly, it introduces large-scale datasets tailored for evaluating detection in both source code and multilingual text. These datasets are designed to align with the optimal input range of SLMs and include samples across multiple programming languages (Python, Java, JavaScript, C, C++, C#, Go) and eight natural languages (English, Russian, Arabic, Dutch, German, Spanish, Portuguese, Romanian). Crucially, these datasets are carefully balanced between human-written and machine-generated samples to prevent bias.
Secondly, DuoLens provides a comprehensive evaluation, benchmarking its performance against existing detectors. The framework consistently achieves superior accuracy and F1-Macro scores, even in challenging scenarios such as cross-model and cross-language settings. This robust performance supports the hypothesis that SLMs can indeed surpass LLMs for binary classification of human-written versus machine-generated content.
How DuoLens Works
For code detection, DuoLens employs CodeBERT and CodeBERTa. CodeBERT is trained on both natural language and source code, while CodeBERTa is smaller and exclusively trained on source code. Both models are fine-tuned with a classification head to distinguish between human-written and machine-generated code. DuoLens itself is a dual-encoder detector that intelligently combines the representations from CodeBERT and CodeBERTa. It uses a lightweight fusion head to merge these signals, emphasizing unique features from each encoder while down-weighting redundant ones, before feeding the combined representation to a linear classifier.
For multilingual text classification, DuoLens fine-tunes widely used pre-trained encoders such as XLM-RoBERTa-base, XLM-RoBERTa-large, and Multilingual BERT (mBERT). These models are fine-tuned using a consistent protocol, ensuring reliable and comparable results.
Impressive Results with Reduced Resources
The experimental results are compelling. In code detection, powerful LLMs like GPT-4o and Qwen2.5 Coder 3B performed significantly worse than the SLMs. For instance, GPT-4o achieved an AUCROC of only 0.535 and F1-Macro of 0.414, whereas fine-tuned CodeBERTa achieved an AUCROC of 0.985 and F1-Macro of 0.937. Similarly, for multilingual text detection, fine-tuned SLMs like XLM-RoBERTa-large achieved an AUCROC of 0.974 and F1-Macro of 0.924, vastly outperforming GPT-4o’s 0.573 AUCROC and 0.490 F1-Macro.
Beyond accuracy, DuoLens demonstrates remarkable efficiency. It reduces latency by 8-12 times and peak VRAM usage by 3-5 times for 512-token inputs compared to LLMs. The framework also maintains strong performance (retaining ≥92% of clean AUROC) even under adversarial transformations like paraphrasing, back-translation, code formatting, and renaming, highlighting its robustness.
Also Read:
- Unmasking AI-Generated Text in Urdu: A New Detection System
- Efficient and Transparent Misinformation Detection with Lightweight Language Models
Looking Ahead
While DuoLens represents a significant leap forward, the researchers acknowledge areas for future development. These include expanding coverage to more natural and programming languages, incorporating sentence-level detection, and potentially integrating LLMs into hybrid systems to provide explanatory insights for classification outcomes. Despite some inherent limitations, such as language imbalances in the multilingual dataset and inherited biases from underlying models, DuoLens offers a highly effective and accessible solution for detecting AI-generated content across diverse domains, making this crucial technology available regardless of computational constraints.


