Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
asv-ml
mlmc
Commits
83761a81
Commit
83761a81
authored
Mar 11, 2020
by
Janos Borst
Browse files
method
parent
673a6c8c
Pipeline
#37018
canceled with stages
in 23 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
mlmc/representation/embedder.py
View file @
83761a81
...
...
@@ -18,7 +18,7 @@ class Embedder:
"""
A class for embedding lists of sentences.
"""
def
__init__
(
self
,
representation
,
device
=
"cpu"
,
return_device
=
"cpu"
):
def
__init__
(
self
,
representation
,
method
=
"first_token"
,
device
=
"cpu"
,
return_device
=
"cpu"
):
"""
Holding an embedding to embed lists of sentences with huggingface or glove.
...
...
@@ -28,6 +28,7 @@ class Embedder:
ToDo:
- Support Pooling method
- Averaging Method
:param representation: Name of the representation (language model or glove vectors)
:param device: The device to use for the computation of the embeddings
...
...
@@ -39,6 +40,8 @@ class Embedder:
self
.
device
=
device
self
.
emb
=
self
.
emb
.
to
(
self
.
device
)
self
.
return_device
=
return_device
assert
method
in
(
"first_token"
,)
self
.
method
=
method
def
embed
(
self
,
sentences
:
List
,
pad
=
None
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment