## 3 Proposed Method
### Input Layer
#### 3.1.3 User Input  
The user input component allows people to perform real-time sentiment analysis. Users submit natural language prompts or queries to achieve this. We enhance the contextual relevance of these inputs by first classifying them as either positive or negative sentiments. However, some queries consist of conflicting intents or ambiguous sentiments, which prompts the model to use a newly implemented intent-conflict-detection mechanism to better handle these types of inputs. Instructions that contradict each other and sentiment inconsistencies in the prompts that are flagged by this mechanism make the LLM easier to understand overall [100]. First, our model uses a default mechanism to determine the conflict type and set the sentiment type. This has worked to make our model more robust in a variety of ways. Consistency in decision-making across different input types is a big step toward a systematic mechanism for achieving accurate sentiment predictions across a range of inputs, as shown in Algorithm 1. Two primary input types are distinguished:  
**Prompt:** A prompt is a pre-defined instruction set that standardises how the model interprets and classifies sentiment. Defining sentiment polarity, contextual boundaries, and focus areas e.g., customer satisfaction, prompts limit ambiguity and creates a framework for consistent, context-aware sentiment analysis.  
**Query:** A query represents the specific input submitted by the user for sentiment classification. Each query operates within the framework set by the prompt and is enhanced by RAG-derived context, enabling the model to capture subtle sentiment cues. Examples include  
* Query: \"Analyse the following customer feedback as positive or negative: The service was fast and good, but the charges are very expensive\".
* Query with Context: \"The following are some similar reviews: The staff were helpful but the time taken to serve was long. Please classify whether the review is positive or negative\".  
```
1:User input \(Q\) (query) in natural language
2:Pre-defined prompt \(P\) for sentiment classification context
3:Sentiment classification output (positive or negative)
4:Initialise the prompt \(P\) with defined parameters (e.g., polarity, context boundaries, focus areas)
5:Define \(RAG\_context\leftarrow\) Retrieve relevant context from previously collected sentiment data
6:Step 1: Query Structuring and Preprocessing
7:Structure input \(Q\) based on the established prompt \(P\) for sentiment classification
8:Clean and normalise \(Q\) (e.g., remove unnecessary characters, standardise format)
9:Step 2: Intent Conflict Detection and Resolution
10:Initialise conflict flag \( conflict\_detected\leftarrow\) False
11:if\(Q\) contains contradictory instructions or sentiment cues then
12:Set \( conflict\_detected\leftarrow\) True
13:Resolve Conflict:
14:Apply predefined rules for intent conflict resolution or prompt user for clarification
15:if clarification received from user then
16:Update \(Q\) based on resolved intent
17:else
18: Proceed with modified query resolution rules (e.g., prioritise primary sentiment)
19:Step 3: Sentiment Classification with Contextual Augmentation
20:Formulate final input \(Q_{final}\gets Q+RAG\_context\)
21:Apply model to \(Q_{final}\) for sentiment classification based on \(P\) parameters
22:Obtain sentiment output \(S\in\{\)positive, negative\(\}\)
23:Step 4: Output Generation and Response
24:Generate final sentiment output \(S\) with relevant insights
25:if\( conflict\_detected\)then
26:Append conflict resolution note to output for transparency
27:return\(S\)
```  
**Algorithm 1** User Input Processing for Sentiment Analysis with Intent Conflict Detection