Skip to content

Commit 6db8592

Browse files
Renamed to late
1 parent b47eda8 commit 6db8592

2 files changed

Lines changed: 1 addition & 48 deletions

File tree

turftopic/encoders/contextual.py

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,54 +18,7 @@ def is_contextual(encoder):
1818
Lengths = list[int]
1919

2020

21-
def flatten_embeddings(
22-
embeddings: list[np.ndarray],
23-
) -> tuple[np.ndarray, Lengths]:
24-
"""Flattens ragged array to normal array.
25-
26-
Parameters
27-
----------
28-
embeddings: list[ndarray]
29-
Ragged embedding array.
30-
31-
Returns
32-
-------
33-
flat_embeddings: ndarray
34-
Flattened embedding array.
35-
lengths: list[int]
36-
Length of each document in the corpus.
37-
"""
38-
lengths = [emb.shape[0] for emb in embeddings]
39-
return np.concatenate(embeddings, axis=0), lengths
40-
41-
42-
def unflatten_embeddings(
43-
flat_embeddings: np.ndarray, lengths: Lengths
44-
) -> list[np.ndarray]:
45-
"""Unflattens flat array to ragged array.
46-
47-
Parameters
48-
----------
49-
flat_embeddings: ndarray
50-
Flattened embedding array.
51-
lengths: list[int]
52-
Length of each document in the corpus.
53-
54-
Returns
55-
-------
56-
embeddings: list[ndarray]
57-
Ragged embedding array.
58-
59-
"""
60-
embeddings = []
61-
start_index = 0
62-
for length in lengths:
63-
embeddings.append(flat_embeddings[start_index:length])
64-
start_index += length
65-
return embeddings
66-
67-
68-
class ContextTransformer(SentenceTransformer):
21+
class LateTransformer(SentenceTransformer):
6922
def encode(
7023
self, sentences: Union[str, list[str], np.ndarray], *args, **kwargs
7124
):
File renamed without changes.

0 commit comments

Comments
 (0)