Reputation: 11
How to actually produce text from a trained model? Any sample code I find online is just model training and printing out embeddings. I don't understand the significance of the embeddings. My goal is to print out text. So for example I have this sample code below. Can I use the model created by this code to actually paraphrase input text rather than just print the embeddings?
from sentence_transformers import SentenceTransformer
sentences = ["This is an example sentence", "Each sentence is converted"]
model = SentenceTransformer('sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2')
embeddings = model.encode(sentences)
print(embeddings)
For Example I would love to achieve something like this:
"This is an example sentence"
Gets converted to
"This sentence is an example"
or
"Jack was going to school"
to
"Jack was on his way to school"
Or something similar.
Upvotes: 0
Views: 938
Reputation: 11488
The point of the embeddings (and training objective of the sentence-transformer
models, generally) is to recognize paraphrased sentences. Note that these are discriminative models, not generative ones!
This means, a model will be able to tell you when two sentences are likely paraphrased (which can be done by looking at the similarity of the two embeddings), but you are not able to actually generate a paraphrase given a singular input. For that, you will have to look at sequence-to-sequence models, which are not part of sentence-transformers
. In particular, their documentation states even states on their page that
SentenceTransformers is a Python framework for state-of-the-art sentence, text and image embeddings. [...]
To directly answer your question then: No, you cannot use this model (or framework) to actually paraphrase an input text.
Upvotes: 1