# Empowering LLMs with Toolkits: An Open-Source Intelligence Acquisition Method
## 3 Method Description and Implementation
### Memory Module  
The memory module consists of two parts: the local intelligence base and the external knowledge base. Its main purpose is to provide knowledge supplementation for the agent. The local intelligence base is used to store the OSINT obtained by the agent through previous tool usage, in order to improve the information reuse and query efficiency. When the agent encounters a problem that exceeds its own knowledge scope, it first checks whether the required knowledge is available within this module. If not, it then uses the tools in the toolkit to perform queries. The role of the external knowledge base is to provide the agent with domain-specific knowledge. Since this study focuses on the method of obtaining OSINT based on LLMs, we have included license-related information in the external knowledge base for testing purposes. In the development of this module, we employed retrieval-augmented generation (RAG) technology. This technology aims to enhance the generation capabilities and generalization of LLMs. Its core idea is to leverage retrieval techniques to obtain relevant knowledge from an external knowledge base and integrate it into the generation process of the LLM. Formally, given an input \(x\), the process can be described as follows: \(y=G(x,R(x;K))\), where \(y\) is the generated output, \(x\) is the input text or query, \(R(x;K)\) is the retrieval function that retrieves relevant information \(r\) from the knowledge base \(K\), and \(G(x,r)\) is the generation model that produces the output \(y\) based on the input \(x\) and the retrieved information \(r\). Consequently, when generating responses, the model can not only draw on existing knowledge but also dynamically incorporate relevant domain information based on specific task requirements, thereby reducing the likelihood of model hallucinations. Vector databases play a critical role in retrieval-augmented generation (RAG) by facilitating efficient information retrieval and dynamic knowledge augmentation. Specifically, vector databases enable the rapid retrieval of the most relevant documents or information snippets by converting input text into vectors and computing the similarity with vectors stored in the database. Given an input \(x\), this process involves converting the input into a vector representation \(v_{x}\) using an embedding model \(E\). The similarity between \(v_{x}\) and the vectors \(V\) stored in the database is computed using a distance metric \(D\). Mathematically, this can be represented as \(r=\arg\max_{v\in V}D(v_{x},v)\), where \(r\) represents the most relevant information snippet retrieved from the database \(V\). Once the relevant information \(r\) is retrieved, it is integrated into the generation process of the LLM. Vector databases support different types of similarity metrics, such as the Euclidean distance, inner product, and cosine similarity. For two vectors \(\mathbf{a}=[a_{1},a_{2},\ldots,a_{n}]\) and \(\mathbf{b}=[b_{1},b_{2},\ldots,b_{n}]\), their definitions are summarized in Table 1.  
To provide the agent with OSINT information, we utilize vector retrieval technology to swiftly obtain the required information in this module. Given that user queries may involve both Chinese and English simultaneously, we opted to use the bilingual text vector model jina-embeddings-v2-base-zh for the generation of textual feature vectors. This model performs better in monolingual and cross-lingual applications and is trained specifically to support mixed Chinese-English inputs without bias [21]. The information from the local intelligence base and the external knowledge base is then vectorized and stored in a vector database, with an index table established to link the vectorized information to the vector database. When the agent queries license information, it retrieves the data from the vector database \(V\). To achieve this process, we defined a function \(f(\mathbf{q})\) to implement the retrieval of license information.