Particle Swarm Optimization for Automating Prompt Optimization in Large Language Models on Text Classification and Generation Tasks
Large Language Models (LLMs) have demonstrated remarkable abilities in responding to natural language instructions, but their performance depends on prompts, with high-quality prompts requiring human expertise and effort. Current prompt optimization techniques include continuous prompt-based and discrete prompt-based methods. The former requires access to LLMs' parameters which is time-consuming and the latter might lead to suboptimal results due to confined search space. To address the above limitations, we propose PSOPrompt, which retains exploratin capabilities of continuous prompts without altering LLMs' parameters. Noting the continuous nature of embeddings and the success of PSO for continuous optimization problems, it is used as the optimization method, with each embedding treated as an individual. To integrate continuous prompts with discrete prompts, embedding inversion is employed and a new encoding strategy is conceived. In the evolution process, it is discovered that incorporating expert knowledge into the initialization contributes to better outcomes. Experimental results demonstrate that PSOPrompt matches or outperforms existing approaches.
Authors
- Bin Wang (ORCID: https://orcid.org/0000-0002-9417-1956)
- Bing Xue (ORCID: https://orcid.org/0000-0002-4865-8026)
- Mengjie Zhang (ORCID: https://orcid.org/0000-0003-4463-9538)
- Linsen Li (ORCID: https://orcid.org/0009-0006-2059-6181)
Institutions
- Victoria University of Wellington (NZ)
- Hebei University (CN)
Publication Details
- Journal
- Proceedings of the Genetic and Evolutionary Computation Conference Companion
- Published
- 2025-07-14
- DOI
- https://doi.org/10.1145/3712255.3726598
- Primary Topic
- Topic Modeling
- Type
- article
- Field-Weighted Citation Impact
- 0.00