Michael commited on
Commit ·
43fa150
1
Parent(s): 955ca83
Document all app options and clarify the tool description
Browse files
README.md
CHANGED
|
@@ -14,165 +14,80 @@ short_description: Interacting with LLMs
|
|
| 14 |
|
| 15 |
# PRISE — Privacy Risk Inference System with Explainability
|
| 16 |
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
the
|
| 22 |
-
|
| 23 |
-
as a result — each with the evidence that supports it.
|
| 24 |
|
| 25 |
-
|
| 26 |
-
real-time inference explanations change what people choose to disclose.
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
## What it does
|
| 31 |
-
|
| 32 |
-
Each conversation turn passes through four mechanisms, all rendered back into the UI:
|
| 33 |
-
|
| 34 |
-
| Mechanism | What the user sees |
|
| 35 |
-
|---|---|
|
| 36 |
-
| **PII detection** | Identifying spans highlighted in the message, coloured by category (Identity, Contact, Location, Sensitive), with a hover tooltip giving the type and the model's confidence. |
|
| 37 |
-
| **External-data linkage** | Spans that match a retrieved document from an external corpus are underlined, with a tooltip showing the matched excerpt, its similarity score, and a link to the source where one exists. |
|
| 38 |
-
| **Attribute inference** | A "How the AI sees you" card giving the most probable value for six attributes — age band, gender, marital status, education, financial situation, and country — each with a probability, the lift over the population base rate, and a *Why?* tooltip quoting the evidence. |
|
| 39 |
-
| **Privacy risk score** | A 0–100 score combining the inference lift, the PII count and the linkage count, with a breakdown of which component drove it. |
|
| 40 |
-
|
| 41 |
-
### Two differential privacy mechanisms
|
| 42 |
|
| 43 |
-
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
substituted and at what ε, so the protection is visible without showing the user noisy text.
|
| 49 |
-
- **Retrieval DP** — an exponential mechanism over document scores during retrieval, with
|
| 50 |
-
sensitivity computed empirically from the candidate pool's utility range rather than a fixed
|
| 51 |
-
constant.
|
| 52 |
|
| 53 |
-
|
| 54 |
-
fused with reciprocal rank fusion.
|
| 55 |
|
| 56 |
-
|
| 57 |
|
| 58 |
-
|
| 59 |
|
| 60 |
```bash
|
| 61 |
-
# 1. Install
|
| 62 |
-
pip install -r requirements.txt
|
| 63 |
-
|
| 64 |
-
# 2. Provide credentials (only the provider you intend to use is required)
|
| 65 |
export GEMINI_API_KEY="..." # default provider
|
| 66 |
export OPENAI_API_KEY="..." # optional
|
| 67 |
export TOGETHER_API_KEY="..." # optional
|
| 68 |
-
export VALID_ACCESS_TOKEN_1="..." # optional
|
| 69 |
-
|
| 70 |
-
# 3. Run
|
| 71 |
-
python app.py
|
| 72 |
```
|
| 73 |
|
| 74 |
-
|
| 75 |
-
environment, and the app degrades gracefully when an optional one is absent.
|
| 76 |
-
|
| 77 |
-
To use the app without any API calls at all — useful for inspecting the interface — start it in
|
| 78 |
-
demo mode, which produces deterministic placeholder annotations:
|
| 79 |
|
| 80 |
```bash
|
| 81 |
-
python app.py
|
| 82 |
```
|
| 83 |
|
| 84 |
-
|
| 85 |
|
| 86 |
-
|
| 87 |
-
[Apify](https://apify.com) instead of, or in addition to, the local corpus. It needs
|
| 88 |
-
`APIFY_TOKEN` plus the actor IDs (`APIFY_X_ACTOR_ID`, `APIFY_FB_POSTS_ACTOR`,
|
| 89 |
-
`APIFY_FB_PAGES_ACTOR`, `APIFY_LI_POSTS_ACTOR`, `APIFY_WEB_SCRAPER_ACTOR`). This path is
|
| 90 |
-
experimental and was **not** used in the reported study.
|
| 91 |
|
| 92 |
-
-
|
| 93 |
-
|
| 94 |
-
## Configuration
|
| 95 |
-
|
| 96 |
-
Every option is available both as a command-line flag and as a URL query parameter, so a
|
| 97 |
-
condition can be assigned by handing a participant a link.
|
| 98 |
|
| 99 |
```
|
| 100 |
-
http://localhost:7860/?rag=1&epsilon=20&show_pii_highlights=1
|
| 101 |
```
|
| 102 |
|
| 103 |
-
|
|
| 104 |
-
|---|---|---|
|
| 105 |
-
| `model` | model name | Which LLM to converse with |
|
| 106 |
-
| `rag` | `0` / `1` | Enable external-data linkage |
|
| 107 |
-
| `epsilon` | float or `inf` | DP budget, shared by both mechanisms; `inf` disables DP |
|
| 108 |
-
| `show_risk` | `0` / `1` | Show the privacy risk panel |
|
| 109 |
-
| `show_pii_highlights` | `0` / `1` | Highlight PII spans in the conversation |
|
| 110 |
-
| `show_rag_highlights` | `0` / `1` | Highlight external-data linkages |
|
| 111 |
-
| `show_tips` | `0` / `1` | Show hover tooltips |
|
| 112 |
-
| `show_dp` | `0`–`3` | When to reveal the Privacy Settings panel: never / each turn / start only / on *End conversation* |
|
| 113 |
-
| `show_infr_attr_card` | `0`–`2` | When to reveal the inference card: never / each turn / on *End conversation* |
|
| 114 |
-
| `show_settings` | `0` / `1` | Expose the live settings panel |
|
| 115 |
-
| `scenario_mode` | `real`, `persona2`, … | Free-style, or a scripted persona with known ground-truth attributes |
|
| 116 |
-
| `demo` | `0` / `1` | Placeholder annotations, no API calls |
|
| 117 |
-
| `token` | string | Session access token |
|
| 118 |
-
|
| 119 |
-
### Study conditions
|
| 120 |
-
|
| 121 |
-
The four experimental conditions differ only in these parameters:
|
| 122 |
-
|
| 123 |
-
| Condition | External data | PII highlights | DP |
|
| 124 |
|---|---|---|---|
|
| 125 |
-
|
|
| 126 |
-
|
|
| 127 |
-
|
|
| 128 |
-
|
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
```
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
```
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
- **167 posts by the study persona** (Sarah Chen), carrying the ground-truth attributes the
|
| 150 |
-
profiler is evaluated against.
|
| 151 |
-
- **833 posts by 30 other synthetic authors**, spanning the same attribute space the profiler
|
| 152 |
-
infers over. Several are healthcare workers, and several live in the persona's cities, so
|
| 153 |
-
retrieval cannot succeed by keying on occupation or location alone. No distractor post names
|
| 154 |
-
the persona.
|
| 155 |
-
|
| 156 |
-
Columns: `Unique ID`, `First Name`, `Last Name`, `text`, `platform`, `year_joined`, `Age bin`,
|
| 157 |
-
`Finance Status`, `Education`, `Locale`, `Marital Status`, `Gender`, `source`, `content_type`,
|
| 158 |
-
`is_persona`.
|
| 159 |
-
|
| 160 |
-
Every post is synthetic. No real person's data is included.
|
| 161 |
-
|
| 162 |
-
---
|
| 163 |
-
|
| 164 |
-
## Logging
|
| 165 |
-
|
| 166 |
-
When an access token is supplied, each turn appends a row to a per-participant CSV: the message
|
| 167 |
-
and the model's reply, the DP-perturbed text actually sent to the model, detected PII, external
|
| 168 |
-
linkages, per-attribute inference probabilities and lifts, and the risk score with its
|
| 169 |
-
breakdown. This is what the analysis pipeline consumes.
|
| 170 |
-
|
| 171 |
-
---
|
| 172 |
-
|
| 173 |
-
## Notes
|
| 174 |
-
|
| 175 |
-
- Retrieval indices are rebuilt from their component pickles at startup rather than unpickled
|
| 176 |
-
whole, so they stay portable across environments.
|
| 177 |
-
- Every persona, corpus and conversation shipped here is synthetic.
|
| 178 |
-
- License: CC BY-ND 4.0.
|
|
|
|
| 14 |
|
| 15 |
# PRISE — Privacy Risk Inference System with Explainability
|
| 16 |
|
| 17 |
+
PRISE is a browser-based chat interface that places a transparency layer between the user and a
|
| 18 |
+
conversational LLM. Alongside the model's ordinary reply, each turn is annotated to show what the
|
| 19 |
+
system has learned about the user. Identifying details in the message are highlighted and labelled
|
| 20 |
+
by type. Phrases that match an external record about the user are marked and traced back to their
|
| 21 |
+
source. A profile card lists the demographic attributes the model can now predict, each with its
|
| 22 |
+
confidence and the evidence behind it. A single risk score summarises the turn.
|
| 23 |
|
| 24 |
+
[Differential privacy](https://en.wikipedia.org/wiki/Differential_privacy) can be applied on the
|
| 25 |
+
user's side: before a message is sent, its content words are perturbed so that the model receives
|
| 26 |
+
a noised version of the text. The conversation panel still shows what the user actually wrote, and
|
| 27 |
+
a badge on the message reports how many words were substituted and at which privacy budget (ε).
|
|
|
|
| 28 |
|
| 29 |
+
## Usage
|
|
|
|
| 30 |
|
| 31 |
+
### Dependencies
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
+
Python 3.10. Install with:
|
| 34 |
|
| 35 |
+
```bash
|
| 36 |
+
pip install -r requirements.txt
|
| 37 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
+
The main dependencies are Gradio, OpenAI, LangChain, FAISS, sentence-transformers and rank-bm25.
|
|
|
|
| 40 |
|
| 41 |
+
### API keys
|
| 42 |
|
| 43 |
+
Keys are read from the environment; only the provider you intend to use is required.
|
| 44 |
|
| 45 |
```bash
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
export GEMINI_API_KEY="..." # default provider
|
| 47 |
export OPENAI_API_KEY="..." # optional
|
| 48 |
export TOGETHER_API_KEY="..." # optional
|
| 49 |
+
export VALID_ACCESS_TOKEN_1="..." # optional, gates the app behind a token
|
|
|
|
|
|
|
|
|
|
| 50 |
```
|
| 51 |
|
| 52 |
+
### Running
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
```bash
|
| 55 |
+
python app.py
|
| 56 |
```
|
| 57 |
|
| 58 |
+
The app serves on `http://localhost:7860`.
|
| 59 |
|
| 60 |
+
### Options
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
+
Every option below is available both as a command-line flag and as a URL query parameter, so a
|
| 63 |
+
configuration can be assigned via a link:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
```
|
| 66 |
+
http://localhost:7860/?rag=1&epsilon=20&show_pii_highlights=1
|
| 67 |
```
|
| 68 |
|
| 69 |
+
| Option | Values | Default | Meaning |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|---|---|---|---|
|
| 71 |
+
| `model` | model name | `Gemini-2.5-Flash` | LLM used for the conversation |
|
| 72 |
+
| `rag` | `0` / `1` | `1` | Link the conversation against the external corpus |
|
| 73 |
+
| `epsilon` | float or `inf` | `inf` | Privacy budget for the perturbation; `inf` disables it |
|
| 74 |
+
| `show_risk` | `0` / `1` | `1` | Show the privacy risk panel |
|
| 75 |
+
| `show_tips` | `0` / `1` | `1` | Show hover tooltips |
|
| 76 |
+
| `show_pii_highlights` | `0` / `1` | `1` | Highlight identifying details |
|
| 77 |
+
| `show_rag_highlights` | `0` / `1` | `1` | Highlight matches against external data |
|
| 78 |
+
| `show_settings` | `0` / `1` | `0` | Show the live settings panel |
|
| 79 |
+
| `show_dp` | `0`–`3` | `1` | When to show the privacy settings panel: never, after each turn, at the start only, or when the conversation ends |
|
| 80 |
+
| `show_infr_attr_card` | `0`–`2` | `1` | When to show the inferred-attributes card: never, after each turn, or when the conversation ends |
|
| 81 |
+
| `enable_social_scraping` | `0` / `1` | `0` | Retrieve public social media posts as external data (experimental) |
|
| 82 |
+
| `show_social_scraping` | `0` / `1` | `0` | Show the social media control in the interface |
|
| 83 |
+
| `show_upload_data` | `0` / `1` | `0` | Show the control for uploading a custom corpus |
|
| 84 |
+
| `scenario_mode` | `real`, `persona1`, `persona2` | `real` | Free-style conversation, or a scripted persona |
|
| 85 |
+
| `demo` | `0` / `1` | `0` | Run the interface without making API calls |
|
| 86 |
+
|
| 87 |
+
`token` is accepted as a URL parameter only, and carries the session access token.
|
| 88 |
+
`--retriever_path` (an alternative retriever pickle) and `--port` (default `7860`) are
|
| 89 |
+
command-line flags only.
|
| 90 |
+
|
| 91 |
+
## License
|
| 92 |
+
|
| 93 |
+
CC BY 4.0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|