Mathematical decomposition of prompt engineering in Large Language Model architecture
Main Article Content
Abstract
Large Language Models (LLMs) represent the convergence of neural language processing and high-dimensional statistical inference. Despite their impressive capabilities, these systems remain inherently probabilistic, generating outputs via autoregressive sampling from learned distributions. The resulting stochastic nature manifests through phenomena such as hallucinations and semantic decomposition. This paper formalizes the mathematical framework of prompt engineering as a methodology for topological navigation through the model's latent space. Through a rigorous analysis of the Transformer architecture, multi-head attention mechanisms, positional encoding, and loss functions, we deconstruct how precisely constructed prompts manipulate probability distributions during autoregressive generation. We present a formal taxonomy of ten advanced techniques - including Chain-of-Verification (CoVe), Constitutional AI, and Meta-Prompting - and demonstrate their effect on reducing the entropy of output distributions. Experimental results indicate that the systemic application of these techniques can transform a model with a baseline accuracy of 62.3% into a system with 91.7% accuracy, effectively converting a stochastic generator into a quasi-deterministic reasoning engine.
Article Details

This work is licensed under a Creative Commons Attribution 4.0 International License.
References
[1] J. Kaplan, S. McCandlish, T. Henighan, T. B. Brown, B. Chess, R. Child, S. Gray, A. Radford, J. Wu, D. Amodei, "Scaling laws for neural language models", arXiv:2001.08361, https://doi.org/10.48550/arXiv.2001.08361, (2020)
[2] Z. Ji, N. Lee, R. Frieske, T. Yu, D. Su, Y. Xu, E. Ishii, Y. J. Bang, A. Madotto, and P. Fung, "Survey of hallucination in natural language generation", ACM Computing Surveys, Vol. 55(12), pp. 1–38, https://doi.org/10.1145/3571730, (2023)
[3] P. Liu, W. Yuan, J. Fu, Z. Jiang, H. Hayashi, and G. Neubig, "Pre-train, prompt, and predict: A systematic survey of prompting methods in natural language processing", ACM Computing Surveys, Vol. 55(9), pp. 1–35, https://doi.org/10.1145/3560815, (2023)
[4] S. Dhuliawala, M. Komeili, J. Xu, R. Raileanu, X. Li, A. Celikyilmaz, and J. Weston, "Chain-of-verification reduces hallucination in large language models", Findings of the Association for Computational Linguistics: ACL 2024, Bangkok (Thailand), pp. 3563–3578, https://doi.org/10.18653/v1/2024.findings-acl.212, (2024)
[5] A. Vaswani et al., "Attention is all you need", Advances in Neural Information Processing Systems 30, Proceedings of the 31st Annual Conference on Neural Information Processing Systems NIPS 2017, Long Beach, California (USA), (2017)
[6] C. E. Shannon, "A mathematical theory of communication", The Bell System Technical Journal, Vol. 27(3), pp. 379–423, https://doi.org/10.1002/j.1538-7305.1948.tb01338.x, (1948)
[7] L. Reynolds and K. McDonell, "Prompt programming for large language models: Beyond the few-shot paradigm", Proceedings of CHI EA '21: Extended Abstracts CHI Conference on Human Factors in Computing Systems, Yokohama (Japan), pp. 1–7, https://doi.org/10.1145/3411763.3451760, (2021)
[8] T. Mikolov, I. Sutskever, K. Chen, G. S. Corrado, and J. Dean, "Distributed representations of words and phrases and their compositionality", Advances in Neural Information Processing Systems 26, Proceedings of the 27th International Conference on Neural Information Processing Systems NIPS 2013, Lake Tahoe, Nevada (USA), (2013)
[9] J. Achiam et al, "GPT-4 technical report", arXiv:2303.08774, https://doi.org/10.48550/arXiv.2303.08774, (2023).
[10] J. L. Ba, J. R. Kiros, and G. E. Hinton, "Layer normalization", arXiv:1607.06450, https://doi.org/10.48550/arXiv.1607.06450, (2016)
[11] L. Ouyang et al, "Training language models to follow instructions with human feedback," in Advances in Neural Information Processing Systems 35, Proceedings of the 36th Conference on Neural Information Processing Systems NeurIPS 2022, New Orleans (USA), pp. 27730–27744, (2022)
[12] A. Holtzman, J. Buys, L. Du, M. Forbes, and Y. Choi, "The curious case of neural text degeneration", Proceedings of the 8th International Conference on Learning Representations ICLR2020, Addis Ababa (Ethiopia), (2020)
[13] S. Min, X. Lyu, A. Holtzman, M. Artetxe, M. Lewis, H. Hajishirzi, and L. Zettlemoyer, "Rethinking the role of demonstrations: What makes in-context learning work?", Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, Abu Dhabi (UAE), pp. 11048–11064, https://doi.org/10.18653/v1/2022.emnlp-main.759, (2022)
[14] S. Yao, D. Yu, J. Zhao, I. Shafran, T. L. Griffiths, Y. Cao, K. Narasimhan, "Tree of thoughts: Deliberate problem solving with large language models", arXiv:2305.10601, https://doi.org/10.48550/arXiv.2305.10601, (2023)
[15] J. Wei et al., "Chain-of-thought prompting elicits reasoning in large language models", Advances in Neural Information Processing Systems 35, Proceedings of the 36th Conference on Neural Information Processing Systems NeurIPS 2022, New Orleans (USA), pp. 24824–24837, (2022)
[16] T. B. Brown et al, "Language models are few-shot learners", Advances in Neural Information Processing Systems 33, Proceedings of the 34th International Conference on Neural Information Processing Systems NIPS 20, pp. 1877–1901, (2020)
[17] C. Guo, G. Pleiss, Y. Sun, and K. Q. Weinberger, "On calibration of modern neural networks", Proceedings of the 34th International Conference on Machine Learning ICML17, Sydney (Australia), Vol. 70, pp. 1321–1330, (2017)
[18] Y. Zhou, A. I. Muresanu, Z. Han, K. Paster, S. Pitis, H. Chan, and J. Ba, "Large language models are human-level prompt engineers", Proceedings of the 11th International Conference on Learning Representations ICLR 2023, Kigali (Rwanda), https://doi.org/10.48550/arXiv.2211.01910, (2023)
[19] Y. Bai et al, "Constitutional AI: Harmlessness from AI feedback", arXiv:2212.08073, https://doi.org/10.48550/arXiv.2212.08073, (2022)
[20] X. Wang, J. Loh Seong Wei, D. Schuurmans, Q. H. Le, E. H. Chi, and D. Zhou, “Self-consistency improves chain of thought reasoning in language models”, International Conference on Learning Representations, Vol. abs/2203.11171, https://doi.org/10.48550/arXiv.2203.11171, (2022)
[21] T. Kojima, S. S. Gu, M. Reid, Y. Matsuo, and Y. Iwasawa, "Large language models are zero-shot reasoners", Advances in Neural Information Processing Systems 35, Proceedings of the Thirty-Sixth Annual Conference on Neural Information Processing Systems NeurIPS 2022, New Orleans (USA), pp. 22199–22213, (2022)
[22] S. Lin, J. Hilton, and O. Evans, "TruthfulQA: Measuring how models mimic human falsehoods", Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics, Dublin (Ireland), pp. 3214–3252, https://doi.org/10.18653/v1/2022.acl-long.229, (2022)
[23] K. Cobbe, V. Kosaraju, M. Bavarian, M. Chen, H. Jun, L. Kaiser, M. Plappert, J. Tworek, J. Hilton, R. Nakano, C. Hesse, and J. Schulman, "Training verifiers to solve math word problems," arXiv:2110.14168, https://doi.org/10.48550/arXiv.2110.14168, (2021)
[24] Z. Yang, P. Qi, S. Zhang, Y. Bengio, W. W. Cohen, R. Salakhutdinov, and C. D. Manning, "HotpotQA: A dataset for diverse, explainable multi-hop question answering," in Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, Brussels (Belgium), pp. 2369–2380, https://doi.org/10.18653/v1/D18-1259, (2018)
[25] Anthropic, "The Claude 3 model family: Opus, Sonnet, Haiku", Anthropic, Technical Report, (2024)
[26] H. Touvron et al, "Llama 2: Open foundation and fine-tuned chat models," arXiv:2307.09288, https://doi.org/10.48550/arXiv.2307.09288, (2023)
[27] V. Milićević, I. Franc, M. Lutovac Banduka, N. Zdravković, and N. Dimitrijević, "Symbolic analysis of classical neural networks for deep learning", International Journal for Quality Research, Vol. 19(1), pp. 85-100, https://doi.org/10.24874/IJQR19.01-06, (2025)
[28] V. Milićević, I. Franc, and Z. Dobrosavljević, "Trends in the application of artificial intelligence in medication procurement systems," Engineering Today, Vol. 3(3), pp. 45-52, https://doi.org/10.5937/engtoday2400013M, (2024)