Skip to content

Commit 9e1a0fc

Browse files
committed
Add nilRAG to docs
1 parent 1340855 commit 9e1a0fc

File tree

4 files changed

+109
-0
lines changed

4 files changed

+109
-0
lines changed

docs/build/nilRAG.md

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# nilRAG
2+
3+
Retrieval Augmented Generation (RAG) is a technique that grants large language
4+
models (LLMs) information retrieval capabilities and context that they might be
5+
missing. Nillion's RAG (nilRAG) uses [nilAI
6+
(SecretLLM)](https://docs.nillion.com/build/secretLLM/quickstart), [nilDB
7+
(SecretVault)](https://docs.nillion.com/build/secret-vault-quickstart), and
8+
[nilQL](https://docs.nillion.com/build/nilQL).
9+
10+
:::info
11+
In simple terms, nilRAG allows you to store information in SecretVault and then use it as context when you query SecretLLM!
12+
:::
13+
14+
15+
## Library Overview
16+
Data owners often possess valuable files that clients wish to query to enhance
17+
their LLM-based inferences. However, ensuring privacy is a key challenge: data
18+
owners want to keep their data confidential, and clients are equally concerned
19+
about safeguarding their queries. nilRAG addresses this challenge by enabling
20+
secure data sharing and querying. It allows data owners to store their data
21+
securely in SecretVault while allowing clients to query the data without
22+
exposing their queries or compromising the data's privacy. The process involves
23+
leveraging a SecretLLM for secure computation through nilAI. Data owners upload
24+
their information to SecretVault, while SecretLLM processes client queries and
25+
retrieves the most relevant results (top-k) without revealing sensitive
26+
information from either party.
27+
28+
29+
Let us deep dive into the entities and their roles in the system.
30+
31+
1. **Data Owners:** Securely upload files to SecretVault. Before sending the
32+
files to SecretVault, they are processed into multiple chunks of data and
33+
their corresponding embeddings. The embeddings are used for similarity
34+
search, while the chunks are used to retrieve the actual uploaded files. Once
35+
the files are encoded into chunks and embeddings, they are blinded before
36+
being uploaded to SecretVault, where each chunk and embedding is
37+
secret-shared.
38+
39+
For instance, a data owner, wishes to upload the following file to SecretVault and later use it to provide context to SecretLLM:
40+
:::note Employees Example
41+
```
42+
Kyle Moore works at Jackson, Gray and Lewis as a Economist. Kyle Moore was born on 1915-09-27 and lives at 6206 Caroline Point, Bishopland, MI 34522.
43+
44+
Charles Anderson works at Evans, Parker and Ramirez as a Surveyor, insurance. Charles Anderson was born on 2016-12-13 and lives at 0527 William Walk Suite 976, Lake Jason, MS 97840.
45+
46+
Danielle Miller works at Bailey and Sons as a Engineer, mining. Danielle Miller was born on 2007-10-22 and lives at 61586 Michael Greens, New Holly, CO 29872.
47+
...
48+
```
49+
:::
50+
51+
52+
2. **Client:** The client submits a query to search against the data owners'
53+
uploaded files in SecretVault, retrieve the most relevant data, and use the
54+
top-k results for privacy-preserving inference in SecretLLM. Similar to the
55+
encoding by data owners, the query is processed into its corresponding
56+
embeddings.
57+
58+
Going back to our example, the client can query SecretLLM asking about Danielle:
59+
:::note Employees Example
60+
```
61+
Who is Danielle Miller?
62+
```
63+
:::
64+
65+
66+
3. **SecretVault:** SecretVault stores the blinded chunks and embeddings
67+
provided by data owners. When a client submits a query, SecretVault computes
68+
the differences between the query's embeddings and each stored embedding in a
69+
privacy-preserving manner.
70+
71+
72+
4. **SecretLLM:** SecretLLM connects to SecretVault to fetch the blinded
73+
differences between the query and the stored embeddings and then compute the
74+
closest matches. Finally, it uses the top k matches for inference.
75+
76+
Lastly, the client can query SecretLLM asking about Danielle:
77+
:::note Employees Example
78+
```
79+
Danielle Miller is an engineer who works at Bailey and Sons, specializing in mining. She was born on October 22, 2007, and lives at 61586 Michael Greens, New Holly, CO 29872.
80+
```
81+
:::
82+
83+
84+
You can reproduce the example above by following the [README](https://github.com/NillionNetwork/nilrag).
85+
86+
## Implementation
87+
88+
nilRAG is not a standalone library available through
89+
[PyPI](https://pypi.org/project/nilrag) and open-source on
90+
[GitHub](https://github.com/NillionNetwork/nilrag). Developers can use nilRAG as
91+
a feature of [SecretLLM](https://docs.nillion.com/build/secretLLM/quickstart) to
92+
enhance the inference with context that has been uploaded to [SecretVault](https://docs.nillion.com/build/secret-vault).
93+

docs/build/secretLLM/overview.md

+5
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,8 @@ SecretLLM provides two layers of cryptographic proof:
4646
2. Use your API key to check the `/models` endpoint for available models
4747
3. Start running private AI using your chosen model
4848
4. Optionally, verify your environment using the attestation API
49+
50+
51+
### Enhance SecretLLM by providing context from SecretVault and nilRAG
52+
Optionally, you can use nilRAG to allow SecretLLM to access SecretVault and retrieve relevant context!
53+
See our [nilRAG documentation](https://docs.nillion.com/build/nilQL) for details.

sidebar-build.js

+5
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ const buildSidebar = [
163163
},
164164
],
165165
},
166+
{
167+
type: 'doc',
168+
label: 'nilRAG',
169+
id: 'build/nilRAG',
170+
},
166171
],
167172
},
168173

src/utils/FeatureCards.js

+6
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,10 @@ export const Libraries = [
2929
icon: '🔐',
3030
href: './build/nilQL',
3131
},
32+
{
33+
title: 'nilRAG',
34+
description: 'Provide context to SecretLLM from SecretVault with nilRAG library.',
35+
icon: '🔍',
36+
href: './build/nilRAG',
37+
},
3238
];

0 commit comments

Comments
 (0)