## 4 Methodology And Implementation
### Prompt Engineering  
A single-prompt approach assures a constant prompt accross all tested models, which eliminates variablity introduced by alternative phrasings or sampling noise. This ensures that any differences in UDC assignment stem from the models' capabilities, not from prompt engineering or ensembling effects. During the initial testing phase, we found that prompting different chatbots and LLMs with the same prompt does not always lead to quality results. Because of this, we tailored the prompts using the RISEN prompt engineering framework. The acronym stands for Role, Instructions, Steps, End goal, and Narrowing. By systematically defining each component (Role, Instructions, Steps, End goal, and Narrowing constraints), the chatbots and LLMs had more context on the task at hand. Narrowing the format of the result proved to be the most beneficial, as we struggled to obtain a single UDC code as a response without it. This structured approach helped ensure consistent, parseable outputs across different model architectures. Below are some examples of the prompts we used with the corresponding chatbot or LLM. For chatbots ChatGPT and Claude, the following prompt was used:  
_Act as a librarian and an expert in UDC classification. You have been asked to assign a UDC code to a document in a library collection. The document is titled: {title}. The document contains the following keywords: {keywords}. The abstract of the document is as follows: {abstract}. Your task is to generate a single UDC code based on the title, keywords and abstract. Return only one UDC code, without text, explanation or markdown._  
Some additional narrowing steps were required for use with Gemini models. Building from the above prompt, the following prompt was used:  
_... Your task is to generate a single UDC code, based on the title, keywords and abstract. Do not give any explanation in the response. In the response return only the UDC code, do not write any additional words. Do not return the response in markdown. Do not split the UDC code into small parts._  
When using LLMs directly (namely DeepSeek, Llama, and Gemma models), some additional narrowing instructions were required to obtain quality responses. Most notably, the limitation for the response length needed to be set. For all tested LLMs, an explicit requirement that the result is given in one line of text seemed to work well. Furthermore, we added limitations on the length of the UDC code and required a result without any other text before or after the resulting UDC code. This proved instrumental in obtaining quality responses from the LLMs. By adding on to the previous prompts, we added even more narrowing instructions:  
_... The generated UDC code should be in one line. The UDC code should not be longer than 50 characters. The response must not contain anything else before and after the UDC code._  
A special addition in the prompt was needed for the DeepSeek-R1-7B model, since this is a reasoning model and it provides thinking steps in the output. We omitted the thinking steps and prompted this model with the following prompt:  
_Act as librarian and an expert in UDC classification. You have been asked to assign a UDC code to a document in a library collection. The document is titled: \"{title}\". The document contains the following keywords: \"{keywords}\". The abstract of the document is as follows: \"{abstract}\". Your task is to generate only one UDC code, based on the title, keywords and abstract. Do not write any explanation in response. In the response, write only the UDC code, do not write any additional words. Do not write the response with markdown. Do not break the code into small parts. Do not show your thinking._The different versions of the initial prompt were then used as templates in the process of recommending the UDC codes for each document from the dataset (Appendix A.1). These prompt templates were also translated into Slovenian when used with documents in the Slovenian language (Appendix A.2).