romybeaute commited on
Commit
b5e5cc2
·
1 Parent(s): a6c6479

Expand README: clear step-by-step Hugging Face token setup for LLM labelling

Browse files
Files changed (1) hide show
  1. README.md +38 -9
README.md CHANGED
@@ -99,23 +99,52 @@ to use the new, extended version, with zero-shot and comparison between datasets
99
  CSV file with a text column. The app auto-detects columns named `text`, `report`, `reflection_answer`, or `reflection_answer_english`. Any column can also be selected manually.
100
 
101
 
102
- ### LLM Setup (Optional)
103
- To use the Automated Topic Labelling feature (Llama-3), you must provide a Hugging Face Access Token. The app uses this token to access the inference API.
104
 
105
- 1. Get a Token: Log in to Hugging Face and create a token with "Read" permissions.
 
 
 
106
 
107
- 2. Configure Local App:
108
 
109
- - Create a folder named .streamlit in your root directory.
110
 
111
- - Inside it, create a file named secrets.toml.
112
 
113
- - Add your token in TOML file:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  ```
115
- HF_TOKEN = "hf_..."
 
 
 
 
 
 
116
  ```
117
 
118
- - Note: This file is ignored by Git to protect your credentials.
 
 
 
 
119
 
120
 
121
  ---
 
99
  CSV file with a text column. The app auto-detects columns named `text`, `report`, `reflection_answer`, or `reflection_answer_english`. Any column can also be selected manually.
100
 
101
 
102
+ ### LLM Topic Labelling — Hugging Face token setup (optional)
 
103
 
104
+ The **Automated Topic Labelling** feature turns each topic's keywords into a
105
+ readable label using a hosted Llama-3 model via the Hugging Face Inference API.
106
+ This is the **only** feature that needs a token — embedding, topic modelling,
107
+ zero-shot classification and condition comparison all work **without** one.
108
 
109
+ If you try to label topics without a token you'll see:
110
 
111
+ > `LLM labelling failed: No HF_TOKEN found in env/secrets.`
112
 
113
+ To enable it:
114
 
115
+ **Step 1 Create a free Hugging Face token**
116
+ 1. Sign in (or sign up) at <https://huggingface.co>.
117
+ 2. Open **Settings → Access Tokens**: <https://huggingface.co/settings/tokens>.
118
+ 3. Click **Create new token**, give it a name, select the **Read** role, and copy
119
+ the value (it starts with `hf_...`).
120
+ *If you create a fine-grained token instead, also tick
121
+ "Make calls to Inference Providers" so the labelling API works.*
122
+
123
+ **Step 2 — Give the token to the app** (pick ONE option)
124
+
125
+ *Option A — secrets file (recommended). From the repo root:*
126
+ ```bash
127
+ mkdir -p .streamlit
128
+ printf 'HF_TOKEN = "hf_xxxxxxxxxxxxxxxxxxxx"\n' > .streamlit/secrets.toml
129
+ ```
130
+ This creates `.streamlit/secrets.toml` containing a single line:
131
+ ```toml
132
+ HF_TOKEN = "hf_xxxxxxxxxxxxxxxxxxxx"
133
  ```
134
+ The file lives inside your repo folder but is already listed in `.gitignore`,
135
+ so it is **never committed**.
136
+
137
+ *Option B — environment variable (good for a one-off session):*
138
+ ```bash
139
+ export HF_TOKEN="hf_xxxxxxxxxxxxxxxxxxxx" # add to ~/.zshrc or ~/.bashrc to persist
140
+ streamlit run app2.py
141
  ```
142
 
143
+ **Step 3 Restart the app** (`streamlit run app2.py`). Topic labelling now works.
144
+
145
+ > ⚠️ **Never paste your token into code, notebooks, or any committed file.**
146
+ > If a token is ever exposed, revoke it on the
147
+ > [tokens page](https://huggingface.co/settings/tokens) and create a new one.
148
 
149
 
150
  ---