Skip to content

Commit c703f53

Browse files
authored
Merge pull request #224 from NillionNetwork/feat/nilrag
Add nilRAG to docs
2 parents 1340855 + a8351e6 commit c703f53

File tree

6 files changed

+1232
-1702
lines changed

6 files changed

+1232
-1702
lines changed

docs/build/nilRAG.md

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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 [SecretLLM)](/build/secretLLM/overview), [SecretVault](/build/secret-vault), and the
6+
[nilQL](/build/nilQL) encryption library.
7+
8+
:::info
9+
nilRAG lets you to store private information in [SecretVault](/build/secret-vault) and then use it as context when you use the [SecretLLM](/build/secretLLM/overview) chat endpoint.
10+
:::
11+
12+
13+
## Library Overview
14+
Data owners often possess valuable files that clients wish to query to enhance
15+
their LLM-based inferences. However, ensuring privacy is a key challenge: data
16+
owners want to keep their data confidential, and clients are equally concerned
17+
about safeguarding their queries. nilRAG addresses this challenge by enabling
18+
secure data sharing and querying. It allows data owners to store their data
19+
securely in SecretVault while allowing clients to query the data without
20+
exposing their queries or compromising the data's privacy. The process involves
21+
leveraging a SecretLLM for secure computation through nilAI. Data owners upload
22+
their information to SecretVault, while SecretLLM processes client queries and
23+
retrieves the most relevant results (top-k) without revealing sensitive
24+
information from either party.
25+
26+
27+
Let us deep dive into the entities and their roles in the system.
28+
29+
1. **Data Owners:** Securely upload files to SecretVault. Before sending the
30+
files to SecretVault, they are processed into multiple chunks of data and
31+
their corresponding embeddings. The embeddings are used for similarity
32+
search, while the chunks are used to retrieve the actual uploaded files. Once
33+
the files are encoded into chunks and embeddings, they are blinded before
34+
being uploaded to SecretVault, where each chunk and embedding is
35+
secret-shared.
36+
37+
For instance, a data owner, wishes to upload the following file to SecretVault and later use it to provide context to SecretLLM:
38+
:::note Employees Example
39+
```
40+
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.
41+
42+
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.
43+
44+
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.
45+
...
46+
```
47+
:::
48+
49+
50+
2. **Client:** The client submits a query to search against the data owners'
51+
uploaded files in SecretVault, retrieve the most relevant data, and use the
52+
top-k results for privacy-preserving inference in SecretLLM. Similar to the
53+
encoding by data owners, the query is processed into its corresponding
54+
embeddings.
55+
56+
Going back to our example, the client can query SecretLLM asking about Danielle:
57+
:::note Employees Example
58+
```
59+
Who is Danielle Miller?
60+
```
61+
:::
62+
63+
64+
3. **SecretVault:** SecretVault stores the blinded chunks and embeddings
65+
provided by data owners. When a client submits a query, SecretVault computes
66+
the differences between the query's embeddings and each stored embedding in a
67+
privacy-preserving manner.
68+
69+
70+
4. **SecretLLM:** SecretLLM connects to SecretVault to fetch the blinded
71+
differences between the query and the stored embeddings and then compute the
72+
closest matches. Finally, it uses the top k matches for inference.
73+
74+
Lastly, the client can query SecretLLM asking about Danielle:
75+
:::note Employees Example
76+
```
77+
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.
78+
```
79+
:::
80+
81+
82+
You can reproduce the example above by following the [README](https://github.com/NillionNetwork/nilrag).
83+
84+
## Implementation
85+
86+
nilRAG is a standalone library available through
87+
[PyPI](https://pypi.org/project/nilrag) and open-source on
88+
[GitHub](https://github.com/NillionNetwork/nilrag). Developers can use nilRAG as
89+
a feature of [SecretLLM](https://docs.nillion.com/build/secretLLM/quickstart) to
90+
enhance the inference with context that has been uploaded to [SecretVault](https://docs.nillion.com/build/secret-vault).
91+

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.

package-lock.json

+47-38
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sidebar-build.js

+20
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,26 @@ const buildSidebar = [
163163
},
164164
],
165165
},
166+
{
167+
type: 'category',
168+
label: 'nilRAG',
169+
link: {
170+
type: 'doc',
171+
id: 'build/nilRAG',
172+
},
173+
items: [
174+
{
175+
type: 'link',
176+
label: 'nilrag-py',
177+
href: 'https://github.com/NillionNetwork/nilrag',
178+
},
179+
{
180+
type: 'link',
181+
label: 'Examples',
182+
href: 'https://github.com/NillionNetwork/nilrag/tree/main/examples',
183+
},
184+
],
185+
},
166186
],
167187
},
168188

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)