File size: 502 Bytes
a87d450
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import h5py as h5
import json
import pandas as pd
import torch
from sentence_transformers import SentenceTransformer

torch.set_num_threads(60)

D = pd.read_json("red-pajamas-es.json.gz", lines=True)
#modelname = 'sentence-transformers/all-MiniLM-L6-v2'
modelname = "hiiamsid/sentence_similarity_spanish_es"
model = SentenceTransformer(modelname)

print(D.columns)


print("embeddings article")
embeddings = model.encode(D.text)

with h5.File("red-pajamas-es.h5", "a") as f:
    f["text"] = embeddings