IDEAS home Printed from https://ideas.repec.org/a/gam/jmathe/v13y2025i13p2199-d1695471.html
   My bibliography  Save this article

NNG-Based Secure Approximate k-Nearest Neighbor Query for Large Language Models

Author

Listed:
  • Heng Zhou

    (School of Computer Science and Technology, Xidian University, Xi’an 710071, China)

  • Yuchao Wang

    (School of Computer Science and Technology, Xidian University, Xi’an 710071, China)

  • Yi Qiao

    (School of Computer Science and Technology, Xidian University, Xi’an 710071, China)

  • Jin Huang

    (Beijing Academy of Blockchain and Edge Computing, Beijing 100080, China)

Abstract

Large language models (LLMs) have driven transformative progress in artificial intelligence, yet critical challenges persist in data management and privacy protection during model deployment and training. The approximate nearest neighbor (ANN) search, a core operation in LLMs, faces inherent trade-offs between efficiency and security when implemented through conventional locality-sensitive hashing (LSH)-based secure ANN (SANN) methods, which often compromise either query accuracy due to false positives. To address these limitations, this paper proposes a novel secure ANN scheme based on nearest neighbor graph (NNG-SANN), which is designed to ensure the security of approximate k-nearest neighbor queries for vector data commonly used in LLMs. Specifically, a secure indexing structure and subset partitioning method are proposed based on LSH and NNG. The approach utilizes neighborhood information stored in the NNG to supplement subset data, significantly reducing the impact of false positive points generated by LSH on query results, thereby effectively improving query accuracy. To ensure data privacy, we incorporate a symmetric encryption algorithm that encrypts the data subsets obtained through greedy partitioning before storing them on the server, providing robust security guarantees. Furthermore, we construct a secure index table that enables complete candidate set retrieval through a single query, ensuring our solution completes the search process in one interaction while minimizing communication costs. Comprehensive experiments conducted on two datasets of different scales demonstrate that our proposed method outperforms existing state-of-the-art algorithms in terms of both query accuracy and security, effectively meeting the precision and security requirements for nearest neighbor queries in LLMs.

Suggested Citation

  • Heng Zhou & Yuchao Wang & Yi Qiao & Jin Huang, 2025. "NNG-Based Secure Approximate k-Nearest Neighbor Query for Large Language Models," Mathematics, MDPI, vol. 13(13), pages 1-27, July.
  • Handle: RePEc:gam:jmathe:v:13:y:2025:i:13:p:2199-:d:1695471
    as

    Download full text from publisher

    File URL: https://www.mdpi.com/2227-7390/13/13/2199/pdf
    Download Restriction: no

    File URL: https://www.mdpi.com/2227-7390/13/13/2199/
    Download Restriction: no
    ---><---

    More about this item

    Keywords

    ;
    ;
    ;
    ;

    Statistics

    Access and download statistics

    Corrections

    All material on this site has been provided by the respective publishers and authors. You can help correct errors and omissions. When requesting a correction, please mention this item's handle: RePEc:gam:jmathe:v:13:y:2025:i:13:p:2199-:d:1695471. See general information about how to correct material in RePEc.

    If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.

    We have no bibliographic references for this item. You can help adding them by using this form .

    If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your RePEc Author Service profile, as there may be some citations waiting for confirmation.

    For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: MDPI Indexing Manager (email available below). General contact details of provider: https://www.mdpi.com .

    Please note that corrections may take a couple of weeks to filter through the various RePEc services.

    IDEAS is a RePEc service. RePEc uses bibliographic data supplied by the respective publishers.