From 1b5df97522d4e13a8581836d514e37c5f8c5a31c Mon Sep 17 00:00:00 2001 From: Benedikt Fuchs Date: Fri, 28 Jun 2024 16:34:18 +0200 Subject: [PATCH 1/2] character embeddings store their embedding name too --- .gitignore | 2 ++ flair/embeddings/token.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 53e248b6d..cbd5be92d 100644 --- a/.gitignore +++ b/.gitignore @@ -109,3 +109,5 @@ venv.bak/ resources/taggers/ regression_train/ /doc_build/ + +scripts/ \ No newline at end of file diff --git a/flair/embeddings/token.py b/flair/embeddings/token.py index 76173bac8..669d3162a 100644 --- a/flair/embeddings/token.py +++ b/flair/embeddings/token.py @@ -454,13 +454,14 @@ def __init__( path_to_char_dict: Optional[Union[str, Dictionary]] = None, char_embedding_dim: int = 25, hidden_size_char: int = 25, + name: str = "Char" ) -> None: """Instantiates a bidirectional lstm layer toi encode words by their character representation. Uses the default character dictionary if none provided. """ super().__init__() - self.name = "Char" + self.name = name self.static_embeddings = False self.instance_parameters = self.get_instance_parameters(locals=locals()) @@ -556,6 +557,7 @@ def to_params(self) -> Dict[str, Any]: "path_to_char_dict": self.char_dictionary, "char_embedding_dim": self.char_embedding_dim, "hidden_size_char": self.hidden_size_char, + "name": self.name, } From 90479f547f4593c7aa7a1c9c938205791bb13eb7 Mon Sep 17 00:00:00 2001 From: Benedikt Fuchs Date: Fri, 28 Jun 2024 18:55:19 +0200 Subject: [PATCH 2/2] black --- flair/embeddings/token.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flair/embeddings/token.py b/flair/embeddings/token.py index 669d3162a..7cfbd73b9 100644 --- a/flair/embeddings/token.py +++ b/flair/embeddings/token.py @@ -454,7 +454,7 @@ def __init__( path_to_char_dict: Optional[Union[str, Dictionary]] = None, char_embedding_dim: int = 25, hidden_size_char: int = 25, - name: str = "Char" + name: str = "Char", ) -> None: """Instantiates a bidirectional lstm layer toi encode words by their character representation.