MCPcopy
hub / github.com/MaartenGr/BERTopic / embed

Method embed

bertopic/backend/_sklearn.py:50–68  ·  view source on GitHub ↗

Embed a list of n documents/words into an n-dimensional matrix of embeddings. Arguments: documents: A list of documents or words to be embedded verbose: No-op variable that's kept around to keep the API consistent. If you want to get feedback on training time

(self, documents, verbose=False)

Source from the content-addressed store, hash-verified

48 self.pipe = pipe
49
50 def embed(self, documents, verbose=False):
51 """Embed a list of n documents/words into an n-dimensional
52 matrix of embeddings.
53
54 Arguments:
55 documents: A list of documents or words to be embedded
56 verbose: No-op variable that's kept around to keep the API consistent. If you want to get feedback on training times, you should use the sklearn API.
57
58 Returns:
59 Document/words embeddings with shape (n, m) with `n` documents/words
60 that each have an embeddings size of `m`
61 """
62 try:
63 check_is_fitted(self.pipe)
64 embeddings = self.pipe.transform(documents)
65 except NotFittedError:
66 embeddings = self.pipe.fit_transform(documents)
67
68 return embeddings

Callers

nothing calls this directly

Calls 3

check_is_fittedFunction · 0.85
fit_transformMethod · 0.80
transformMethod · 0.45

Tested by

no test coverage detected