Update README.md
Browse files
README.md
CHANGED
@@ -4,9 +4,12 @@ language:
|
|
4 |
- en
|
5 |
size_categories:
|
6 |
- 100K<n<1M
|
|
|
|
|
7 |
---
|
8 |
|
9 |
-
English entries only of https://huggingface.co/datasets/EuropeanParliament/Eurovoc.
|
|
|
10 |
|
11 |
Last update 16.05.2024: 352011 entries.
|
12 |
|
@@ -29,4 +32,27 @@ df = ds["train"].to_pandas()
|
|
29 |
df
|
30 |
```
|
31 |
|
32 |
-
![image/png](https://cdn-uploads.huggingface.co/production/uploads/64c4da8719565937fb268b32/eAINKZ8HvQuCHI7WxD-HQ.png)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
- en
|
5 |
size_categories:
|
6 |
- 100K<n<1M
|
7 |
+
task_categories:
|
8 |
+
- feature-extraction
|
9 |
---
|
10 |
|
11 |
+
European legislation from CELLAR/EUROVOC, English entries only of https://huggingface.co/datasets/EuropeanParliament/Eurovoc.
|
12 |
+
This data is enriched with embeddings, ready for semantic search.
|
13 |
|
14 |
Last update 16.05.2024: 352011 entries.
|
15 |
|
|
|
32 |
df
|
33 |
```
|
34 |
|
35 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/64c4da8719565937fb268b32/eAINKZ8HvQuCHI7WxD-HQ.png)
|
36 |
+
|
37 |
+
## Semantic Search
|
38 |
+
Every text has been inferenced with the model2vec library and https://huggingface.co/minishlab/M2V_base_output model from @minishlab.
|
39 |
+
After loading the dataset, use the column `embeddings` for semantic search in this way. See the Jupyter notebook for the full processing script.
|
40 |
+
You can re-run it on consumer-grade hardware without GPU. Inferencing took `Wall time: 1min 36s` on an M3 Max.
|
41 |
+
|
42 |
+
```python
|
43 |
+
from model2vec import StaticModel
|
44 |
+
import numpy as np
|
45 |
+
from sklearn.metrics.pairwise import cosine_similarity
|
46 |
+
|
47 |
+
model = StaticModel.from_pretrained("minishlab/M2V_base_output")
|
48 |
+
|
49 |
+
query = "social democracy"
|
50 |
+
quer_emb = model.encode(query)
|
51 |
+
|
52 |
+
embeddings_matrix = np.stack(df['embeddings'].to_numpy())
|
53 |
+
df["cos_sim"] = cosine_similarity(embeddings_matrix, quer_emb.reshape(1, -1))[:, 0]
|
54 |
+
df = df.sort_values("cos_sim", ascending=False)
|
55 |
+
df
|
56 |
+
```
|
57 |
+
|
58 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/64c4da8719565937fb268b32/wTvM35qwFcn5lw__JyVli.png)
|