sadit commited on
Commit
a87d450
·
verified ·
1 Parent(s): 48b86e3

Upload encode-redpajamas.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. encode-redpajamas.py +21 -0
encode-redpajamas.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import h5py as h5
2
+ import json
3
+ import pandas as pd
4
+ import torch
5
+ from sentence_transformers import SentenceTransformer
6
+
7
+ torch.set_num_threads(60)
8
+
9
+ D = pd.read_json("red-pajamas-es.json.gz", lines=True)
10
+ #modelname = 'sentence-transformers/all-MiniLM-L6-v2'
11
+ modelname = "hiiamsid/sentence_similarity_spanish_es"
12
+ model = SentenceTransformer(modelname)
13
+
14
+ print(D.columns)
15
+
16
+
17
+ print("embeddings article")
18
+ embeddings = model.encode(D.text)
19
+
20
+ with h5.File("red-pajamas-es.h5", "a") as f:
21
+ f["text"] = embeddings