## 3 Materials and Methods
### Implementation of Key Technologies
#### 3.2.2 Construction of the Project Knowledge Base  
In order to support the context-aware reasoning of the expert model and the hallucination of answer results, we built a knowledge base based on the collected data. The construction process is shown in Figure 2, where the input data of the knowledge base comes from multi-dimensional behavioral information, such as project documents, codes and related description information. After slicing the input data, the segmented data are vectorized through different embedding models, and then the project knowledge base is built by constructing an index mechanism. When the user query is received, the hybrid retrieval method is used to calculate the similarity between the vectors obtained after the user query input into the embedding model and the vectors in the project knowledge base, and the retrieval results based on keyword search are input into the expert model as candidate results as information supplements to support the expert model to generate more accurate responses.  
Specifically, based on the BGE embedding model, the knowledge document is sliced into blocks and vectorized, and stored in the text vector database. At the same time, the function description of the developed code is extracted and the code's semantic knowledge base is constructed. The embedded representation of the code slice is generated based on CodeBERT and stored in the code vector database. In the retrieval stage, a hybrid retrieval approach is constructed [39]. By designing a multi-way recall strategy, that is, semantic retrieval by calculating the cosine similarity between the user query (user intention) and the text or code vector (Equation (1)). Given the query vector \(Q\), the semantic similarity with the vector \(S\) in the knowledge base is calculated to support the demand for deep semantic retrieval. And keyword retrieval is based on the BM25 algorithm [40] to support the retrieval needs of ambiguous query semantics (Equation (2)). These two kinds of methods can complement each other's shortcomings, and then return the retrieved candidate information based on the retrieval fusion module (Equation (4)), where the semantic retrieval threshold is set to 0.75, according to practical application experience and the actual use effect to balance the recall rate and accuracy. Finally, the retrieved information participates in the reasoning of the expert model to obtain together the corresponding model.  
\[smi_{\textit{cos}}(Q,S)=\frac{Q\cdot S}{\|Q\|\|S\|} \tag{1}\]  
\[Score(Q,E)=\sum_{i=1}^{n}IDF(q_{i})\cdot\frac{f(q_{i},E)\cdot(k_{1}+1)}{f(q_{ i},E)+k_{1}\cdot\left(1-b+b\cdot\frac{|E|}{\textit{len}_{\textit{reg}}}\right)} \tag{2}\]  
where \(Q\) is the query input; \(Score(Q,E)\) is the relevance score between the current query \(Q\) and the knowledge document \(E\). \(q_{i}\) is the ith word in \(Q\), and \(f(q_{i},E)\) is the frequency of \(q_{i}\) in  
Figure 2: Knowledge base construction process.  
\(E\). \(|E|\) is its corresponding length; \(lenE_{avg}\) is the average length of different documents. \(k_{1}\) and \(b\) are adjustable parameters and are usually set to 1.2 and 0.75, respectively, referring to the default parameters of related research [41] and ElasticSearch implementation. \(IDF(q_{i})\) is the inverse document frequency corresponding to \(q_{i}\) (Equation (3)).  
\[IDF(q_{i})=log\bigg{(}\frac{N-n(q_{i})+0.5}{n(q_{i})+0.5}+1\bigg{)} \tag{3}\]  
where \(N\) is the number of documents; \(n(q_{i})\) is the number of documents containing \(q_{i}\).  
\[Score=0.75*smic_{cos}(Q,S)+0.25*Score(Q,E) \tag{4}\]