Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Compute a sentence embedding for a piece of text
ResourceFunction["SentenceBERTEmbedding"][string] embeds a string into a NumericArray. | |
ResourceFunction["SentenceBERTEmbedding"][list] embeds the list of strings into a two dimensional array. |
Generate sentence embeddings for a few strings:
| In[1]:= |
| Out[1]= |
| In[2]:= |
| Out[2]= |
| In[3]:= |
| Out[3]= |
Note that these are positively correlated (cosine distances are positive):
| In[4]:= |
| Out[4]= |
Compute the embeddings for a list of strings:
| In[5]:= |
| Out[6]= |
Create an plot of the cosine distances, comparing each embedding to the others:
| In[7]:= |
| Out[7]= | ![]() |
Implement a simple semantic search:
| In[8]:= | ![]() |
Find sentences in "Alice" that most closely match the query:
| In[9]:= | ![]() |
| Out[9]= | ![]() |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License