## 3 Methodology
### Chunk Rank Based on Vector Correlation  
Most semantic retrieval systems leverage pre-trained language models such as BERT (Bidirectional Encoder Representations from Transformers) [42] or GPT (Generative Pretrained Transformer) [43; 44] for text encoding. Trained on large-scale corpora, these models excel at capturing intricate semantic relationships between words and sentences, significantly enhancing retrieval accuracy and relevance. In the RAG system proposed in this study, both user queries and knowledge base text chunks are mapped into a shared high-dimensional vector space. This alignment enables chunk rank based on vector correlation, where the most relevant top-k chunks are filtered through semantic similarity metrics such as cosine similarity, ensuring precise contextual grounding for downstream generative tasks [45].  
First, both the user query \(q\) and knowledge-associated text chunks \(C\) must be mapped into a unified vector space, ensuring that semantically similar texts reside in proximate regions within this space. Specifically, the query \(q\) and the text chunks \(C\) are encoded into vectors \(v_{\text{q}}\) and \([v_{c_{1}},v_{c_{2}},\dots,v_{c_{i}}]\) through independent pre-trained language models:  
\[v_{\text{q}}=f_{\text{query}}\left(q;\theta_{\text{q}}\right),\;v_{c_{i}}=f_{ \text{chunk}}(c_{i};\theta_{\text{c}}), \tag{5}\]  
where \(f_{\text{query}}\) and \(f_{\text{chunk}}\) represent the query encoder and document encoder, while \(\theta_{\text{q}}\) and \(\theta_{\text{c}}\) are the parameters of the query encoder and document encoder, respectively.  
Subsequently, the most relevant text chunks are efficiently retrieved from the large-scale knowledge base based on vector similarity. This can be measured using cosine similarity, as defined in Equation (6):  
\[\text{sim}(q,c_{i})=\cos\left(v_{\text{q}},v_{c_{i}}\right)=\frac{v_{\text{q} }\cdot v_{c_{i}}}{\|v_{\text{q}}\|\|v_{c_{i}}\|}, \tag{6}\]  
This metric ensures scale-invariant comparison of vector orientations, effectively capturing semantic relevance between queries and chunks.  
Finally, the most relevant text chunks are efficiently retrieved from the large-scale knowledge base based on vector similarity. Specifically, for all candidate text chunks \(c_{i}\in C\)  
Figure 2: Schematic diagram of EDTS.  
the system sorts them in descending order of similarity and returns the IDs of the k vectors with the highest similarity, as shown in Formula (7).  
\[\text{ID}_{\text{stop-k}}=\begin{array}{c}k\\ \text{arg}\;\max\;\text{sim}(q,c_{i}),\\ c_{i}\in C\end{array} \tag{7}\]  
This process ensures that the retrieved chunks are both semantically relevant and contextually aligned with the user query, providing a robust foundation for downstream tasks such as knowledge-augmented generation.  
After completing the top-k retrieval based on vector similarity, the system needs to map the high-dimensional vector indices back to the original text units to achieve semantic reconstruction of the knowledge context. This process is implemented through the establishment of a bidirectional metadata mapping mechanism, the core of which lies in maintaining a strict correspondence between the vector space and the text space [46]. Each text chunk \(c_{i}\) is assigned a globally unique identifier \(id_{i}\) during the process of converting it into \(v_{c_{i}}\), and \(id_{i}\) is stored in a structured database along with the following metadata:  
\[\text{Metadata}(c_{i})=\{id_{i},c_{i},\;\text{source\_doc}\}, \tag{8}\]  
where source_doc provides information about the knowledge document.  
Based on the returned vector indices \(\text{ID}_{\text{stop-k}}=[id_{1},id_{2},\ldots\ldots,id_{k}]\) from the retrieval, the text reconstruction is achieved by looking up these indices in the database. This process involves retrieving the corresponding text chunks associated with each of these unique identifiers [47]. At this point, top-k text chunks most relevant to the query \(q\) are obtained.