# Large-Language-Model-Enabled Text Semantic Communication Systems
## 3 System Model and Mechanism
### Decoding Algorithm of LLM-SC  
After training, a pre-trained LLM can compute the probability in Equation (14) of a sent sequence \(S=(s_{1},s_{2},\cdots,s_{t})\) given a received sequence \(O=(o_{1},o_{2},\cdots,o_{t})\), representing the likelihood of the sequence \(S\) transforming into \(O\) after transmission through a channel. This decoding process can be applied using any pre-trained LLM, and in this subsection, we delve into the specific decoding algorithm. According to Equation (8), assuming the transmitted sequence length does not exceed the maximum context length of the LLM, the optimal decoding strategy involves  
\[\hat{W} = \operatorname*{argmax}_{w_{i}\in V}\sum_{i=1}^{t}P(w_{i}\mid w_{ i-1},w_{i-2},\cdots,w_{1})P(o_{i}\mid w_{i}) \tag{18}\] \[= \operatorname*{argmax}_{w_{i}\in V}\sum_{i=1}^{t}P(w_{i}\mid w_{ i-1},w_{i-2},\cdots,w_{1})P(o_{i}\mid s_{i})\] \[= \operatorname*{argmax}_{w_{i}\in V}\sum_{i=1}^{t}[\ln(P(w_{i} \mid w_{i-1},w_{i-2},\cdots,w_{1}))+\ln(P(o_{i}\mid s_{i}))],\]  
The first term in Equation (18) reflects the prior probability distribution of transmitted tokens, while the second term quantifies the Euclidean distance between received symbols and constellation points. The direct exploration of all possible sequences to select the one with the highest probability, known as maximum likelihood decoding, poses computational challenges with complexity \(O(V^{t})\), where \(V\) is the number of possible states (sets of transmit symbols) and \(t\) is the sequence length, typically imposing engineering constraints. \[\hat{W} = \operatorname*{argmax}_{w_{i}\in V}\prod_{i=1}^{t}P(w_{i}\mid w_ {i-1},w_{i-2},\cdots,w_{1})P(o_{i}\mid w_{i}) \tag{19}\] \[= \operatorname*{argmax}_{w_{i}\in V}\sum_{i=1}^{t}[N_{0}\ln(P(w_ {i}\mid w_{i-1},w_{i-2},\cdots,w_{1}))-\|o_{i}-h_{i}\otimes s_{i}\|^{2}],\]  
where \(N_{0}\) denotes the noise power spectral density (PSD), typically \(N_{0}=2\sigma^{2}\). Here, \(w_{i}\) represents the \(i\)-th transmitted token that undergoes modulation into \(s_{i}\) and transmission through the channel. Equation (19) represents a typical hidden Markov model prediction problem, commonly addressed using dynamic programming algorithms to find the path with the maximum probability. The Viterbi algorithm provides optimal sequence decoding for hidden Markov models by dynamically tracking maximal-probability paths. However, its \(O(V^{2}\times t)\) complexity is prohibitive for large vocabularies (\(V=\)32,000). To mitigate complexity, beam search, a heuristic algorithm prevalent in NLP, is adapted. Beam search sets up a search tree using breadth-first search, sacrificing optimality for efficiency. In beam search, the beam width \(K\) governs its operation. At each timestep, it retains the top  
Figure 1: The structure of LLM-SC. sequences by score, expanding each to generate \(K\times V\) candidates. From these, the next \(K\) best sequences are selected to continue expansion. Beam search transitions into the Viterbi algorithm when \(K=V\), and into a greedy decoding algorithm when \(K=1\). It strikes a balance between the optimality of Viterbi and the efficiency of greedy decoding, making it suitable for scenarios where minor errors are acceptable given the expansive search space. Our decoding approach is modified using the scoring function described by Equation (20). Specifically, a max heap of size \(K\) is maintained to store high-scoring sequences. Then, \(K\) sequences are used to predict the next symbol and these are added to the heap. Then, we extract the current top \(K\) for the next iteration:  
\[ \begin{split}&\text{\em socre}=N_{0}\ln P(w_{i}|w_{i-1},w_{i-2}, \cdots,w_{1})-\|o_{i}-h_{i}\otimes s\|^{2},\end{split}  \tag{20}\]  
Beam search decoding with a computational complexity of \(O(K\times V\times t)\) facilitates parallelized computation across \(K\) sequences. Algorithm 1 outlines the workflow, designed to demodulate text efficiently. By adjusting \(K\), computational efficiency against decoding accuracy can be balanced.