File size: 6,508 Bytes
1d8c2e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# Guide de Démarrage Rapide

Configuration en 5 minutes pour déployer l'application d'annotation sécurisée.

## Prérequis

- Un compte HuggingFace
- Accès à votre Space `matis35/feedbacks-scoring-app`
- Le dataset à annoter (format JSONL ou sur HF Hub)

## Étape 1 : Créer le Dataset de Stockage (2 min)

1. Allez sur https://huggingface.co/new-dataset
2. Nom : `ffgen-annotations-storage`
3. Visibilité : **Private** (très important!)
4. Cliquez sur "Create dataset"
5. Laissez-le vide, ne chargez rien

✅ Vous avez maintenant : `matis35/ffgen-annotations-storage`

## Étape 2 : Créer un Token HF (1 min)

1. Allez sur https://huggingface.co/settings/tokens
2. Cliquez "New token"
3. Nom : `annotation-app-write`
4. Type : **Write** (important!)
5. Cliquez "Generate token"
6. **Copiez le token** (format `hf_xxxxxxxxxxxx`)

⚠️ Gardez ce token en sécurité, ne le partagez pas!

## Étape 3 : Configurer les Secrets (2 min)

1. Allez sur votre Space : https://huggingface.co/spaces/matis35/feedbacks-scoring-app
2. Cliquez sur **Settings** (en haut)
3. Scrollez vers "Variables and secrets"
4. Ajoutez ces 3 secrets :

### Secret 1 : APP_PASSWORD
- Nom : `APP_PASSWORD`
- Valeur : Choisissez un mot de passe fort (ex: `Annotator2025!`)
- Type : Secret

### Secret 2 : HF_TOKEN
- Nom : `HF_TOKEN`
- Valeur : Le token copié à l'étape 2 (`hf_xxxxx`)
- Type : Secret

### Secret 3 : HF_DATASET_REPO
- Nom : `HF_DATASET_REPO`
- Valeur : `matis35/ffgen-annotations-storage`
- Type : Secret

✅ Les 3 secrets doivent être visibles dans la liste

## Étape 4 : Configurer les Annotateurs (2 min)

### Option A : Configuration basique (3 annotateurs)

Copiez le fichier exemple :
```bash
cd feedbacks-scoring-app
cp data/annotators.json.example data/annotators.json
```

Éditez `data/annotators.json` selon votre dataset :
```json
{
  "annotator_1": {
    "name": "Alice",
    "start_idx": 0,
    "end_idx": 100
  },
  "annotator_2": {
    "name": "Bob",
    "start_idx": 100,
    "end_idx": 200
  },
  "annotator_3": {
    "name": "Charlie",
    "start_idx": 200,
    "end_idx": 300
  }
}
```

### Option B : Utiliser vos subsets FFGen

Si vous avez utilisé `create_annotation_study.py` :

```bash
# Vous avez créé 10 subsets avec create_annotation_study.py
# Configurez 10 annotateurs correspondants

# Exemple pour 10 annotateurs, 40 items chacun
python -c "
import json

config = {}
for i in range(10):
    config[f'annotator_{i+1}'] = {
        'name': f'Annotateur {i+1}',
        'start_idx': i * 40,
        'end_idx': (i + 1) * 40,
        'description': f'Subset {i+1}/10'
    }

with open('data/annotators.json', 'w') as f:
    json.dump(config, f, indent=2)

print('✅ Config créée pour 10 annotateurs')
"
```

## Étape 5 : Pousser sur HF (1 min)

```bash
cd feedbacks-scoring-app

# Vérifier les changements
git status

# Commiter
git add .
git commit -m "Add secure authentication and HF persistence"

# Pousser vers HF Spaces
git push origin main
```

Le Space va rebuilder automatiquement (3-5 minutes).

## Étape 6 : Tester (2 min)

1. Attendez que le Space soit "Running" (vert)
2. Ouvrez l'app : https://huggingface.co/spaces/matis35/feedbacks-scoring-app
3. Testez la connexion :
   - Entrez le mot de passe (`APP_PASSWORD`)
   - Sélectionnez un annotateur
   - Vérifiez que ça fonctionne

## Étape 7 : Distribuer aux Annotateurs

Envoyez ce message à vos annotateurs :

```
Bonjour,

Voici les informations pour accéder à l'outil d'annotation :

URL : https://huggingface.co/spaces/matis35/feedbacks-scoring-app
Mot de passe : [VOTRE_APP_PASSWORD]
Votre identifiant : [annotator_X]

Instructions :
1. Ouvrez l'URL et entrez le mot de passe
2. Sélectionnez votre identifiant dans la liste
3. Chargez le dataset (je vous enverrai le lien/fichier)
4. Annotez les feedbacks selon les critères ci-dessous
5. IMPORTANT : Cliquez sur "☁️ Sauvegarder sur HF" toutes les 30-60 minutes
6. Vous pouvez fermer et reprendre plus tard

Critères d'annotation :
- Score 1 : [DÉFINIR]
- Score 2 : [DÉFINIR]
- Score 3 : [DÉFINIR]
- Score 4 : [DÉFINIR]
- Score 5 : [DÉFINIR]

Questions ? Contactez-moi : [VOTRE_EMAIL]
```

## Vérification Post-Déploiement

✅ Checklist de vérification :

- [ ] Le Space démarre sans erreur
- [ ] L'authentification fonctionne
- [ ] La sélection d'annotateur fonctionne
- [ ] Le chargement de dataset fonctionne
- [ ] Le filtrage par portion fonctionne (vérifier les nombres)
- [ ] La sauvegarde HF fonctionne (vérifier dans le dataset)
- [ ] L'export JSONL fonctionne
- [ ] Les annotateurs peuvent se connecter

## Commandes Utiles

### Voir les logs du Space
```bash
# Via l'interface web : Settings > Logs
# Ou regarder en temps réel depuis l'onglet "Logs"
```

### Vérifier les annotations sauvegardées
```bash
# Allez sur : https://huggingface.co/datasets/matis35/ffgen-annotations-storage
# Vous devriez voir un dossier annotations/ avec des fichiers .json
```

### Télécharger toutes les annotations
```bash
huggingface-cli download \
    matis35/ffgen-annotations-storage \
    --repo-type dataset \
    --local-dir ./collected_annotations
```

### Analyser l'accord inter-annotateurs (si gold items)
```bash
cd FFGen/3_data_processing

python analyze_agreement.py \
    ../../collected_annotations/annotations/*.json \
    --gold-file annotation_study/gold_standard.json
```

## Dépannage Express

### Le Space ne démarre pas
```bash
# Vérifiez les logs
# Problème courant : secret mal configuré
# Solution : Vérifiez Settings > Variables and secrets
```

### "HF Storage not configured"
```bash
# Il manque HF_TOKEN ou HF_DATASET_REPO
# Ajoutez-les dans Settings > Secrets
```

### "Authentication failed"
```bash
# APP_PASSWORD incorrect ou manquant
# Vérifiez Settings > Secrets
```

### Un annotateur voit tout le dataset
```bash
# Problème dans annotators.json
# Vérifiez start_idx et end_idx
# Rechargez le dataset après correction
```

### Les annotations disparaissent
```bash
# Les annotateurs n'ont pas sauvegardé sur HF
# Rappelez-leur de cliquer sur "☁️ Sauvegarder sur HF"
# La sauvegarde locale est perdue tous les 48h
```

## Support

Documentation complète : [CONFIGURATION.md](CONFIGURATION.md)

Problèmes ?
- Vérifiez d'abord les logs du Space
- Consultez la section Dépannage de CONFIGURATION.md
- Ouvrez une issue GitHub si nécessaire

---

**Temps total : ~15 minutes**

Prochain fichier à lire : [CONFIGURATION.md](CONFIGURATION.md) pour les détails complets.