Scientific Article 10 June 2026 DOI: 10.5678/sdcn.2026.002 English Publié
Journal of Machine Learning Research Vol. 27 No. 4 pp. 1-42 https://creativecommons.org/licenses/by-nc/4.0/

Deep Learning Architectures for Natural Language Processing: A Comparative Study of Transformer-Based Models

Benchmarking BERT, GPT, T5, and LLaMA on multilingual and domain-specific tasks

Prof. Alexander Petrov 1 Dr. Wei Zhang 2 Dr. Fatima Al-Rashid 3
1 Department of Computer Science, University of Oxford
2 Google DeepMind, London
906 views Received: Nov 03, 2025 Accepted: Feb 28, 2026

Abstract

This paper presents a comprehensive comparative study of state-of-the-art Transformer-based architectures for natural language processing tasks. We evaluate BERT, GPT-3, T5, and LLaMA across a diverse set of benchmarks including text classification, named entity recognition, question answering, and text generation. Our experiments on 12 standard NLP datasets reveal that while GPT-3 achieves superior performance on generative tasks (BLEU: 42.3, ROUGE-L: 58.7), BERT-based models remain the most effective for discriminative tasks (F1: 93.2 on CoNLL-2003 NER). LLaMA-7B achieves 92% of GPT-3 performance while requiring 40x fewer parameters.

Keywords

deep learning NLP Transformer BERT GPT LLaMA contrastive learning multilingual

Funding

This research was supported by the European Research Council (ERC) under the European Union Horizon 2020 programme (grant No. 101019342).

Acknowledgments

We thank the developers of Hugging Face Transformers for the open-source library. Compute resources provided by Jean Zay supercomputer (GENCI grant 2025-AD011012345).

Conflict of Interest

The authors declare no competing interests.

<

Introduction

Natural language processing (NLP) has undergone a revolutionary transformation since the introduction of the Transformer architecture by Vaswani et al. (2017). The self-attention mechanism has proven remarkably effective across a wide range of linguistic tasks, from BERT bidirectional encoding to GPT autoregressive generation.

Despite these impressive advances, the landscape of Transformer-based models has become increasingly fragmented. BERT-based models dominate discriminative tasks such as text classification and named entity recognition, while GPT-style models lead in generative tasks like summarization and dialogue.

<

Background: The Transformer Architecture

The core innovation of the Transformer is the scaled dot-product attention mechanism: Attention(Q,K,V) = softmax(QK^T/sqrt(d_k))V. This formulation allows the model to compute relevance scores between all pairs of positions in a sequence, capturing both local and long-range dependencies.

Transformer Architecture

Figure 1 : Architecture du Transformer original.

<

Experimental Setup

We evaluated all models on 12 standard NLP benchmarks spanning four task categories: text classification (IMDb, AG News, SST-2), named entity recognition (CoNLL-2003, OntoNotes 5.0), question answering (SQuAD 2.0, Natural Questions), and text generation (CNN/DailyMail, XSum, WMT 2014).

import torch\nimport torch.nn.functional as F\n\nclass ContrastiveDomainAdapter(nn.Module):\n    def __init__(self, encoder, temp=0.07):\n        super().__init__()\n        self.encoder = encoder\n        self.projection = nn.Linear(768, 768)\n        self.temperature = temp\n\n    def contrastive_loss(self, z, labels):\n        z = F.normalize(z, dim=-1)\n        sim = torch.mm(z, z.t()) / self.temperature\n        mask = torch.eq(labels.unsqueeze(0), labels.unsqueeze(1)).float()\n        mask.fill_diagonal_(0)\n        pos = (sim * mask).sum(dim=-1)\n        neg = torch.logsumexp(sim * (1 - mask), dim=-1)\n        return (-pos + neg).mean()
<

Results and Analysis

ModelParamsSST-2CoNLL F1SQuAD F1CNN/DM R-L
BERT-Base110M93.592.888.538.2
BERT-Large340M95.293.290.239.5
RoBERTa-L355M96.494.691.840.1
T5-3B3B96.891.591.042.8
GPT-3 175B175B96.288.486.758.7
LLaMA-7B7B95.890.288.954.1
LLaMA-65B65B96.592.190.557.2
GLUE Benchmark

Figure 2 : Performances sur le benchmark GLUE.

The results reveal several important patterns. BERT-based models consistently outperform GPT-style models on discriminative tasks by 3-5 F1 points on NER. LLaMA-7B achieves approximately 92% of GPT-3 performance on generative tasks while using 40x fewer parameters.

Attention Map

Figure 3 : Visualisation des poids d'attention.

The choice of Transformer architecture should be guided by the target task: BERT-based models for discriminative tasks, GPT-style models for generative tasks, and LLaMA-class models for resource-constrained deployments.
<

Conclusion

We have presented a comprehensive empirical comparison of Transformer-based architectures for NLP across 12 standard benchmarks. Our results provide practical guidance for model selection. All code and experimental configurations are released to facilitate reproducibility.

References

[1] Vaswani, A. et al. (2017). Attention is all you need. NeurIPS 2017.

https://doi.org/10.5555/3295222.3295349

[2] Devlin, J. et al. (2019). BERT: Pre-training of deep bidirectional transformers. NAACL 2019.

https://doi.org/10.18653/v1/N19-1423

[3] Brown, T. B. et al. (2020). Language models are few-shot learners. NeurIPS 2020.

https://doi.org/10.5555/3495724.3495883

[4] Raffel, C. et al. (2020). Exploring the limits of transfer learning with T5. JMLR, 21(140).

https://doi.org/10.5555/3455716.3455856

[5] Touvron, H. et al. (2023). LLaMA: Open and efficient foundation language models. arXiv:2302.13971.

https://doi.org/10.48550/arXiv.2302.13971

[6] Liu, Y. et al. (2019). RoBERTa: A robustly optimized BERT pretraining approach. arXiv:1907.11692.

https://doi.org/10.48550/arXiv.1907.11692

[7] Wang, A. et al. (2019). GLUE: A multi-task benchmark for NLU. ICLR 2019.

https://doi.org/10.22323/1.357.0001

[8] Chen, T. et al. (2020). A simple framework for contrastive learning. ICML 2020.

https://doi.org/10.5555/3524938.3525087

[9] Hu, J. et al. (2020). XTREME: A massively multilingual multi-task benchmark. ICML 2020.

https://doi.org/10.5555/3524938.3525312

[10] Wolf, T. et al. (2020). Transformers: State-of-the-art NLP. EMNLP 2020.

https://doi.org/10.18653/v1/2020.emnlp-demos.6

Figures

Architecture detaillee du Transformer original (Vaswani et al., 2017). L'encodeur (gauche) et le decodeur (droite) utilisent des couches d'auto-attention multi-tetes.

Figure 1: Architecture detaillee du Transformer original (Vaswani et al., 2017). L'encodeur (gauche) et le decodeur (droite) utilisent des couches d'auto-attention multi-tetes.

Performances comparatives sur le benchmark GLUE. Les barres d'erreur indiquent l'ecart-type sur 5 runs.

Figure 2: Performances comparatives sur le benchmark GLUE. Les barres d'erreur indiquent l'ecart-type sur 5 runs.

Visualisation des poids d'attention pour la resolution de coreference.

Figure 3: Visualisation des poids d'attention pour la resolution de coreference.