Skip to content

Instantly share code, notes, and snippets.

@john-adeojo
Last active February 6, 2021 11:57
Show Gist options
  • Select an option

  • Save john-adeojo/fed8247e62600a8ee257d37f4fbcff62 to your computer and use it in GitHub Desktop.

Select an option

Save john-adeojo/fed8247e62600a8ee257d37f4fbcff62 to your computer and use it in GitHub Desktop.
distilbert-base-nli-mean-tokens.py
import sentence_transformers
import torch
from sentence_transformers import SentenceTransformer
# Transform each clean text to 512 dimensional vectors (embeddings)
def embed(data):
model = SentenceTransformer("distilbert-base-nli-mean-tokens")
embeddings = model.encode(data, show_progress_bar=True)
return embeddings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment