import pandas as pd
from tqdm import tqdm
from sentence_transformers import SentenceTransformer
tqdm.pandas()

model = SentenceTransformer('all-MiniLM-L6-v2') #all-MiniLM-L6-v2 #all-mpnet-base-v2

#creates a new column with the encoded text
df['text_vector_'] = df['Text'].progress_apply(lambda x : model.encode(x).tolist())

df

By admin

Leave a Reply

Your email address will not be published.