File size: 9,499 Bytes
77fb120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5f6a8ee
77fb120
 
 
 
 
 
3bcbf13
 
77fb120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56deacd
77fb120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3bcbf13
77fb120
 
 
 
 
 
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
---
language:
- es
license: cc-by-4.0
task_categories:
- text-retrieval
- text-classification
task_ids:
- document-retrieval
pretty_name: SpanishMicroEvents
size_categories:
- 10K<n<100K
tags:
- news
- events
- multimodal
- spanish
- retrieval
- clip
- bertopic
---

# SpanishMicroEvents

**SpanishMicroEvents** is the first publicly available multimodal dataset for fine-grained news micro-event detection and retrieval in Spanish. It contains 13,831 news articles from a single Spanish outlet (2024-2025), organized into 1,632 micro-events through a two-phase construction pipeline combining neural topic modelling and hybrid temporal segmentation.

Each article is represented by three modalities:
- **Text**: multilingual E5-small embeddings (384d)
- **Image**: CLIP ViT-B/32 embeddings (512d), one per unique MD5 image hash
- **Temporal**: daily publication-density signal per micro-event

> **Paper**: *SpanishMicroEvents: A Multimodal Dataset for Fine-Grained News Event Retrieval in Spanish* — Under review.
> 
---

## Dataset Structure

### Files

| File | Description |
|------|-------------|
| `articles.parquet` | Main article-level dataset (13,831 × 14 columns) |
| `micro_events.csv` | Micro-event summary table (1,632 rows) |
| `embeddings_e5_small.npy` | Text embeddings aligned 1:1 with `articles.parquet` (N × 384) |
| `embeddings_clip_articulos.npy` | CLIP image embeddings aligned 1:1 with `articles.parquet` (N × 512) |
| `validation_sample.csv` | Manually annotated quality sample (50 micro-events) |

### `articles.parquet` — column reference

| Column | Type | Source | Description |
|--------|------|--------|-------------|
| `id` | int | Raw corpus | Unique article identifier |
| `url` | str | Raw corpus | Article URL |
| `publication_date` | datetime | Raw corpus | Publication timestamp |
| `headline` | str | Raw corpus | Article headline |
| `article_body` | str | Raw corpus | Full article body text |
| `description` | str | Raw corpus | Article description/teaser |
| `image_hash` | str | Raw corpus | MD5 hash of the associated image |
| `named_entities` | list[dict] | `phase0_corpus_enrichment` | Named entities extracted with Stanza (fields: `text`, `type`; types: PER, ORG, LOC, MISC) |
| `dbpedia_entities_raw` | list[dict] | `phase0_corpus_enrichment` | Raw DBpedia entity linking output before deduplication (fields: `text`, `uri`, `types`) |
| `named_entities_dbpedia` | list[dict] | `phase0_corpus_enrichment` | Deduplicated DBpedia-linked entities (fields: `text`, `uri`, `types`) |
| `date_mentions` | list[str] | `phase0_corpus_enrichment` | Raw date mentions detected in the text |
| `extracted_dates` | list[str] | `phase0_corpus_enrichment` | Normalised date expressions extracted from text |
| `micro_event_id` | str | `phase2_temporal_segmentation` | Micro-event identifier. Format: `"{topic_id}"` for atomic events, `"{topic_id}_{segment}"` for split clusters. Value `"-1"` indicates the article was not assigned to any valid micro-event (singleton or isolated burst). |
| `event_label` | str | `phase2_temporal_segmentation` | JIT label for the micro-event: top-4 BM25-weighted c-TF-IDF terms, deduplicated by Porter stem (e.g. `"ábalos_fiscal_koldo_corrupción"`). |

### `micro_events.csv` — column reference

| Column | Type | Description |
|--------|------|-------------|
| `micro_event_id` | str | Micro-event identifier (matches `articles.parquet`) |
| `label` | str | JIT event label |
| `start_date` | date | First article date |
| `end_date` | date | Last article date |
| `n_articles` | int | Number of articles in the event |
| `source_cluster_id` | int | Phase 1 cluster of origin |
| `route` | str | `"A"` (temporal segmentation) or `"B"` (atomic, bypass) |
| `duration_days` | int | Duration in days (`end_date − start_date`) |

### `validation_sample.csv` — column reference

| Column | Type | Description |
|--------|------|-------------|
| `micro_event_id` | str | Micro-event identifier |
| `n_articles` | int | Number of articles |
| `duration_days` | int | Duration in days |
| `label` | str | JIT event label |
| `representative_headline` | str | Representative headline |
| `remaining_headlines` | str | Remaining headlines (pipe-separated) |
| `annotation` | str | Manual annotation: `C` = Correct, `P` = Partial, `N` = Non-event |
| `notes` | str | Free-text annotation notes |

---

## Key Statistics

| Statistic | Value |
|-----------|-------|
| Total articles | 13,831 |
| Articles in valid micro-events | 4,418 (31.9%) |
| Total micro-events | 1,632 |
| Articles / micro-event (mean) | 2.71 |
| Articles / micro-event (median) | 2 |
| Median event duration (Phase 1 clusters) | 190 days |
| Median event duration (Phase 2 micro-events) | 3 days |
| Duration reduction factor | 63× |
| Articles with CLIP embedding | 12,713 (91.9%) |
| Unique image hashes | 12,789 |
| Time span | 2024-2025 |
| Language | Spanish |

---

## Construction Pipeline

The dataset was built through a five-stage pipeline, each corresponding to a Jupyter notebook. All notebooks are written in English, except `phase0_corpus_enrichment` which was developed as a prior preprocessing step and is provided in Spanish for reproducibility.

### Phase 0 — Corpus Enrichment (`phase0_corpus_enrichment.ipynb`)
Ingestion and enrichment of the raw corpus: text normalisation, NER with Stanza (→ `named_entities`), temporal expression extraction (→ `date_mentions`, `extracted_dates`), and DBpedia entity linking (→ `named_entities_dbpedia`).

### Phase 1 — Semantic Micro-Clustering (`phase1_semantic_clustering.ipynb`)
BERTopic with HDBSCAN (`min_cluster_size=6`) over multilingual E5-small embeddings projected to 5d via UMAP. Noise articles rescued via Ward agglomerative clustering. Produces 3,577 labelled semantic clusters.

**Quality metrics**: $C_v = 0.62$, Silhouette (raw embeddings) $= 0.006$, intra/inter distance ratio $= 0.637$.

### Phase 2 — Hybrid Temporal Segmentation (`phase2_temporal_segmentation.ipynb`)
Dual routing (Route A: ≥4 articles → temporal segmentation; Route B: <4 → atomic). Gaussian smoothing (σ=0.75) + peak detection. Triple-criterion split validator: temporal gap ≥30 days (70.5% of splits), residual cosine dissimilarity (29.5%), named-entity Jaccard=0 (~0%). Produces 1,632 micro-events and the `micro_event_id` / `event_label` columns.

### Phase 3 — CLIP Embeddings (`phase3_clip_embeddings.ipynb`)
CLIP ViT-B/32 embeddings computed once per unique MD5 image hash and broadcast to all articles sharing that hash. 12,713/13,831 articles have a valid embedding; the remaining 1,118 receive a zero vector and are excluded from image-only evaluations.

### Baseline Retrieval (`baseline_retrieval.ipynb`)
Reproduces BM25, text-only, image-only, concat, and late-fusion retrieval baselines reported in the paper. Evaluation protocol: 500 sampled queries, MAP@5 and MAP@10.

---

## Reproducing the Pipeline

The `notebooks/` folder contains the five pipeline notebooks. The `src/` folder contains the supporting Python modules imported by the notebooks.

**Recommended environment**: Google Colab (notebooks mount Google Drive automatically). To run locally, update the `DATA_DIR` path in Cell 1 of each notebook.

**Dependencies** (installed automatically by the notebooks via `!pip install`):
```
bertopic>=0.16
sentence-transformers>=2.2
gensim>=4.3
umap-learn>=0.5
hdbscan>=0.8
scipy>=1.10
scikit-learn>=1.2
rank-bm25>=0.2
open-clip-torch>=2.20
stanza>=1.6
```

**Execution order**: `fase0``fase1``fase2``fase3``baseline_retrieval`.
`fase0` only needs to be run once to generate the enriched corpus; the remaining notebooks load pre-computed artifacts from Drive.

---

## Loading the Dataset

```python
import pandas as pd
import numpy as np

# Article-level data
articles = pd.read_parquet("articles.parquet")

# Micro-event summary
events = pd.read_csv("micro_events.csv")

# Text embeddings — aligned 1:1 with articles (same row order)
text_emb = np.load("embeddings_e5_small.npy")        # shape: (13831, 384)

# Image embeddings — aligned 1:1 with articles (same row order)
clip_emb = np.load("embeddings_clip_articulos.npy")  # shape: (13831, 512)

# Filter only articles in valid micro-events
valid = articles[articles["micro_event_id"] != "-1"]  # 4,418 articles
```

---

## Retrieval Baseline Results

| System | P@5 | R@5 | MAP@5 | MAP@10 |
|--------|-----|-----|-------|--------|
| Random | .0002 | .0002 | .0002 | .0002 |
| **BM25** | **.1544** | **.3555** | **.2645** | **.2796** |
| Text-only (E5-small) | .0224 | .0416 | .0299 | .0297 |
| Image-only (CLIP) | .0312 | .0678 | .0429 | .0443 |
| **Concat (E5 + CLIP)** | **.0372** | **.0710** | **.0485** | **.0514** |
| Late fusion | .0376 | .0713 | .0481 | .0508 |

---

## Manual Validation

A random sample of 50 micro-events was manually annotated:

| Label | Count | % |
|-------|-------|---|
| Correct | 13 | 26% |
| Partial | 3 | 6% |
| Non-event | 34 | 68% |

The 68% non-event rate reflects the single-outlet nature of the corpus: recurring sections (weather, gastronomy, opinion columns, historical essays) are correctly grouped by topic but do not constitute discrete news events. The true clustering error rate (articles from distinct events merged) is only 14%.

---

## Citation

*Under review.*

---

## License

This dataset is released under the [Creative Commons Attribution 4.0 International (CC BY 4.0)](https://creativecommons.org/licenses/by/4.0/) license.