diff --git a/src/learn_to_pick/base.py b/src/learn_to_pick/base.py index dab5e45..a449815 100644 --- a/src/learn_to_pick/base.py +++ b/src/learn_to_pick/base.py @@ -497,10 +497,10 @@ def _embed_string_type( result[namespace] = DenseFeatures(model.encode(item.value)) if item.keep: keep_str = item.value.replace(" ", "_") - result[namespace] = {"raw": re.sub(r"[\t\n\r\f\v]+", " ", keep_str)} + result[namespace] = {"default_ft": re.sub(r"[\t\n\r\f\v]+", " ", keep_str)} elif isinstance(item, str): encoded = item.replace(" ", "_") - result[namespace] = {"raw": re.sub(r"[\t\n\r\f\v]+", " ", encoded)} + result[namespace] = {"default_ft": re.sub(r"[\t\n\r\f\v]+", " ", encoded)} else: raise ValueError(f"Unsupported type {type(item)} for embedding") diff --git a/src/learn_to_pick/pick_best.py b/src/learn_to_pick/pick_best.py index df8c6ac..1682010 100644 --- a/src/learn_to_pick/pick_best.py +++ b/src/learn_to_pick/pick_best.py @@ -123,14 +123,14 @@ def __init__( def _dotproducts(self, context, actions): _context_dense = base.Featurized() for ns in context.sparse.keys(): - if "raw" in context.sparse[ns]: - _context_dense[ns] = self.model.encode(context.sparse[ns]["raw"]) + if "default_ft" in context.sparse[ns]: + _context_dense[ns] = self.model.encode(context.sparse[ns]["default_ft"]) _actions_dense = [base.Featurized() for _ in range(len(actions))] for _action, action in zip(_actions_dense, actions): for ns in action.sparse.keys(): - if "raw" in action.sparse[ns]: - _action[ns] = self.model.encode(action.sparse[ns]["raw"]) + if "default_ft" in action.sparse[ns]: + _action[ns] = self.model.encode(action.sparse[ns]["default_ft"]) context_names = list(_context_dense.dense.keys()) context_matrix = np.stack(list(_context_dense.dense.values())) @@ -146,8 +146,8 @@ def _dotproducts(self, context, actions): def _generic_namespace(self, featurized): result = base.SparseFeatures() for ns in featurized.sparse.keys(): - if "raw" in featurized.sparse[ns]: - result[ns] = featurized.sparse[ns]["raw"] + if "default_ft" in featurized.sparse[ns]: + result[ns] = featurized.sparse[ns]["default_ft"] return result def _generic_namespaces(self, context, actions): diff --git a/tests/unit_tests/test_pick_best_call.py b/tests/unit_tests/test_pick_best_call.py index 24b374b..d35d4b2 100644 --- a/tests/unit_tests/test_pick_best_call.py +++ b/tests/unit_tests/test_pick_best_call.py @@ -169,10 +169,10 @@ def test_everything_embedded() -> None: expected = "\n".join( [ - f"shared |User_dense {encoded_ctx_str_1} |User_sparse raw:={ctx_str_1}", - f"|action_dense {action_dense} |action_sparse raw:={str1}", - f"|action_dense {action_dense} |action_sparse raw:={str2}", - f"|action_dense {action_dense} |action_sparse raw:={str3}", + f"shared |User_dense {encoded_ctx_str_1} |User_sparse default_ft:={ctx_str_1}", + f"|action_dense {action_dense} |action_sparse default_ft:={str1}", + f"|action_dense {action_dense} |action_sparse default_ft:={str2}", + f"|action_dense {action_dense} |action_sparse default_ft:={str3}", ] ) # noqa @@ -198,10 +198,10 @@ def test_default_auto_embedder_is_off() -> None: expected = "\n".join( [ - f"shared |User_sparse raw:={ctx_str_1}", - f"|action_sparse raw:={str1}", - f"|action_sparse raw:={str2}", - f"|action_sparse raw:={str3}", + f"shared |User_sparse default_ft:={ctx_str_1}", + f"|action_sparse default_ft:={str1}", + f"|action_sparse default_ft:={str2}", + f"|action_sparse default_ft:={str3}", ] ) # noqa @@ -227,10 +227,10 @@ def test_default_w_embeddings_off() -> None: expected = "\n".join( [ - f"shared |User_sparse raw:={ctx_str_1}", - f"|action_sparse raw:={str1}", - f"|action_sparse raw:={str2}", - f"|action_sparse raw:={str3}", + f"shared |User_sparse default_ft:={ctx_str_1}", + f"|action_sparse default_ft:={str1}", + f"|action_sparse default_ft:={str2}", + f"|action_sparse default_ft:={str3}", ] ) # noqa @@ -258,9 +258,9 @@ def test_default_w_embeddings_on() -> None: expected = "\n".join( [ - f"shared |User_sparse raw:={ctx_str_1} |@_sparse User:={ctx_str_1}", - f"|action_sparse raw:={str1} |{dot_prod} |#_sparse action:={str1} ", - f"|action_sparse raw:={str2} |{dot_prod} |#_sparse action:={str2} ", + f"shared |User_sparse default_ft:={ctx_str_1} |@_sparse User:={ctx_str_1}", + f"|action_sparse default_ft:={str1} |{dot_prod} |#_sparse action:={str1} ", + f"|action_sparse default_ft:={str2} |{dot_prod} |#_sparse action:={str2} ", ] ) # noqa diff --git a/tests/unit_tests/test_pick_best_text_embedder.py b/tests/unit_tests/test_pick_best_text_embedder.py index 414341a..b5aafd8 100644 --- a/tests/unit_tests/test_pick_best_text_embedder.py +++ b/tests/unit_tests/test_pick_best_text_embedder.py @@ -35,10 +35,10 @@ def test_pickbest_textembedder_no_label_no_emb() -> None: named_actions = {"action": ["0", "1", "2"]} expected = "\n".join( [ - "shared |context_sparse raw:=context", - "|action_sparse raw:=0", - "|action_sparse raw:=1", - "|action_sparse raw:=2", + "shared |context_sparse default_ft:=context", + "|action_sparse default_ft:=0", + "|action_sparse default_ft:=1", + "|action_sparse default_ft:=2", ] ) @@ -56,10 +56,10 @@ def test_pickbest_textembedder_w_label_no_score_no_emb() -> None: named_actions = {"action": ["0", "1", "2"]} expected = "\n".join( [ - "shared |context_sparse raw:=context", - "|action_sparse raw:=0", - "|action_sparse raw:=1", - "|action_sparse raw:=2", + "shared |context_sparse default_ft:=context", + "|action_sparse default_ft:=0", + "|action_sparse default_ft:=1", + "|action_sparse default_ft:=2", ] ) selected = pick_best_chain.PickBestSelected(index=0, probability=1.0) @@ -80,10 +80,10 @@ def test_pickbest_textembedder_w_full_label_no_emb() -> None: named_actions = {"action": ["0", "1", "2"]} expected = "\n".join( [ - "shared |context_sparse raw:=context", - "0:-0.0:1.0 |action_sparse raw:=0", - "|action_sparse raw:=1", - "|action_sparse raw:=2", + "shared |context_sparse default_ft:=context", + "0:-0.0:1.0 |action_sparse default_ft:=0", + "|action_sparse default_ft:=1", + "|action_sparse default_ft:=2", ] ) @@ -142,10 +142,10 @@ def test_pickbest_textembedder_w_full_label_w_embed_and_keep() -> None: context = {"context": rl_chain.EmbedAndKeep(ctx_str)} expected = "\n".join( [ - f"shared |context_dense {encoded_ctx_str} |context_sparse raw:={ctx_str}", - "0:-0.0:1.0 |action_dense 0:1.0 1:0.0 |action_sparse raw:=0", - "|action_dense 0:1.0 1:0.0 |action_sparse raw:=1", - "|action_dense 0:1.0 1:0.0 |action_sparse raw:=2", + f"shared |context_dense {encoded_ctx_str} |context_sparse default_ft:={ctx_str}", + "0:-0.0:1.0 |action_dense 0:1.0 1:0.0 |action_sparse default_ft:=0", + "|action_dense 0:1.0 1:0.0 |action_sparse default_ft:=1", + "|action_dense 0:1.0 1:0.0 |action_sparse default_ft:=2", ] ) # noqa: E501 selected = pick_best_chain.PickBestSelected(index=0, probability=1.0, score=0.0) @@ -164,10 +164,10 @@ def test_pickbest_textembedder_more_namespaces_no_label_no_emb() -> None: context = {"context1": "context1", "context2": "context2"} expected = "\n".join( [ - "shared |context1_sparse raw:=context1 |context2_sparse raw:=context2 ", - "|a_sparse raw:=0 |b_sparse raw:=0", - "|action1_sparse raw:=1", - "|action1_sparse raw:=2", + "shared |context1_sparse default_ft:=context1 |context2_sparse default_ft:=context2 ", + "|a_sparse default_ft:=0 |b_sparse default_ft:=0", + "|action1_sparse default_ft:=1", + "|action1_sparse default_ft:=2", ] ) # noqa: E501 event = pick_best_chain.PickBestEvent( @@ -185,10 +185,10 @@ def test_pickbest_textembedder_more_namespaces_w_label_no_emb() -> None: context = {"context1": "context1", "context2": "context2"} expected = "\n".join( [ - "shared |context1_sparse raw:=context1 |context2_sparse raw:=context2", - "|a_sparse raw:=0 |b_sparse raw:=0", - "|action_sparse raw:=1", - "|action_sparse raw:=2", + "shared |context1_sparse default_ft:=context1 |context2_sparse default_ft:=context2", + "|a_sparse default_ft:=0 |b_sparse default_ft:=0", + "|action_sparse default_ft:=1", + "|action_sparse default_ft:=2", ] ) # noqa: E501 selected = pick_best_chain.PickBestSelected(index=0, probability=1.0) @@ -207,10 +207,10 @@ def test_pickbest_textembedder_more_namespaces_w_full_label_no_emb() -> None: context = {"context1": "context1", "context2": "context2"} expected = "\n".join( [ - "shared |context1_sparse raw:=context1 |context2_sparse raw:=context2", - "0:-0.0:1.0 |a_sparse raw:=0 |b_sparse raw:=0", - "|action_sparse raw:=1", - "|action_sparse raw:=2", + "shared |context1_sparse default_ft:=context1 |context2_sparse default_ft:=context2", + "0:-0.0:1.0 |a_sparse default_ft:=0 |b_sparse default_ft:=0", + "|action_sparse default_ft:=1", + "|action_sparse default_ft:=2", ] ) # noqa: E501 selected = pick_best_chain.PickBestSelected(index=0, probability=1.0, score=0.0) @@ -282,10 +282,10 @@ def test_pickbest_textembedder_more_namespaces_w_full_label_w_full_embed_and_kee } expected = "\n".join( [ - f"shared |context1_dense {encoded_ctx_str_1} |context2_dense {encoded_ctx_str_2} |context1_sparse raw:={ctx_str_1} |context2_sparse raw:={ctx_str_2}", - f"0:-0.0:1.0 |a_dense 0:1.0 1:0.0 |b_dense 0:1.0 1:0.0 |a_sparse raw:=0 |b_sparse raw:=0", - f"|action_dense 0:1.0 1:0.0 |action_sparse raw:=1", - f"|action_dense 0:1.0 1:0.0 |action_sparse raw:=2", + f"shared |context1_dense {encoded_ctx_str_1} |context2_dense {encoded_ctx_str_2} |context1_sparse default_ft:={ctx_str_1} |context2_sparse default_ft:={ctx_str_2}", + f"0:-0.0:1.0 |a_dense 0:1.0 1:0.0 |b_dense 0:1.0 1:0.0 |a_sparse default_ft:=0 |b_sparse default_ft:=0", + f"|action_dense 0:1.0 1:0.0 |action_sparse default_ft:=1", + f"|action_dense 0:1.0 1:0.0 |action_sparse default_ft:=2", ] ) # noqa: E501 @@ -317,9 +317,9 @@ def test_pickbest_textembedder_more_namespaces_w_full_label_w_partial_emb() -> N expected = "\n".join( [ - f"shared |context2_dense {encoded_ctx_str_2} |context1_sparse raw:={ctx_str_1}", - f"0:-0.0:1.0 |b_dense 0:1.0 1:0.0 |a_sparse raw:=0", - f"|action_sparse raw:=1", + f"shared |context2_dense {encoded_ctx_str_2} |context1_sparse default_ft:={ctx_str_1}", + f"0:-0.0:1.0 |b_dense 0:1.0 1:0.0 |a_sparse default_ft:=0", + f"|action_sparse default_ft:=1", f"|action_dense 0:1.0 1:0.0", ] ) # noqa: E501 @@ -355,10 +355,10 @@ def test_pickbest_textembedder_more_namespaces_w_full_label_w_partial_emakeep() context = {"context1": ctx_str_1, "context2": rl_chain.EmbedAndKeep(ctx_str_2)} expected = "\n".join( [ - f"shared |context2_dense {encoded_ctx_str_2} |context1_sparse raw:={ctx_str_1} |context2_sparse raw:={ctx_str_2}", - f"0:-0.0:1.0 |b_dense 0:1.0 1:0.0 |a_sparse raw:=0 |b_sparse raw:=0", - f"|action_sparse raw:=1", - f"|action_dense 0:1.0 1:0.0 |action_sparse raw:=2", + f"shared |context2_dense {encoded_ctx_str_2} |context1_sparse default_ft:={ctx_str_1} |context2_sparse default_ft:={ctx_str_2}", + f"0:-0.0:1.0 |b_dense 0:1.0 1:0.0 |a_sparse default_ft:=0 |b_sparse default_ft:=0", + f"|action_sparse default_ft:=1", + f"|action_dense 0:1.0 1:0.0 |action_sparse default_ft:=2", ] ) # noqa: E501 selected = pick_best_chain.PickBestSelected(index=0, probability=1.0, score=0.0) @@ -386,8 +386,8 @@ def test_raw_features_underscored() -> None: context = {"context": ctx_str} expected_no_embed = "\n".join( [ - f"shared |context_sparse raw:={ctx_str_underscored}", - f"|action_sparse raw:={str1_underscored}", + f"shared |context_sparse default_ft:={ctx_str_underscored}", + f"|action_sparse default_ft:={str1_underscored}", ] ) @@ -414,8 +414,8 @@ def test_raw_features_underscored() -> None: context = {"context": rl_chain.EmbedAndKeep(ctx_str)} expected_embed_and_keep = "\n".join( [ - f"shared |context_dense {encoded_ctx_str} |context_sparse raw:={ctx_str_underscored}", - f"|action_dense {encoded_str1} |action_sparse raw:={str1_underscored}", + f"shared |context_dense {encoded_ctx_str} |context_sparse default_ft:={ctx_str_underscored}", + f"|action_dense {encoded_str1} |action_sparse default_ft:={str1_underscored}", ] ) # noqa: E501 event = pick_best_chain.PickBestEvent( diff --git a/tests/unit_tests/test_rl_loop_base_embedder.py b/tests/unit_tests/test_rl_loop_base_embedder.py index 544d8c5..2bf2bf0 100644 --- a/tests/unit_tests/test_rl_loop_base_embedder.py +++ b/tests/unit_tests/test_rl_loop_base_embedder.py @@ -7,7 +7,7 @@ def test_simple_context_str_no_emb() -> None: - expected = {"a_namespace": {"raw": "test"}} + expected = {"a_namespace": {"default_ft": "test"}} featurized = base.embed("test", MockEncoder(), "a_namespace") assert featurized.sparse == expected @@ -17,7 +17,7 @@ def test_simple_context_str_no_emb() -> None: def test_simple_context_str_w_emb() -> None: str1 = "test" expected_dense = {"a_namespace": [4.0, 0.0]} - expected_sparse = {"a_namespace": {"raw": str1}} + expected_sparse = {"a_namespace": {"default_ft": str1}} featurized = base.embed(base.Embed(str1), MockEncoder(), "a_namespace") assert featurized.dense == expected_dense @@ -32,7 +32,7 @@ def test_simple_context_str_w_nested_emb() -> None: # nested embeddings, innermost wins str1 = "test" expected_dense = {"a_namespace": [4.0, 0.0]} - expected_sparse = {"a_namespace": {"raw": str1}} + expected_sparse = {"a_namespace": {"default_ft": str1}} featurized = base.embed( base.EmbedAndKeep(base.Embed(str1)), MockEncoder(), "a_namespace" @@ -48,7 +48,7 @@ def test_simple_context_str_w_nested_emb() -> None: def test_context_w_namespace_no_emb() -> None: - expected_sparse = {"test_namespace": {"raw": "test"}} + expected_sparse = {"test_namespace": {"default_ft": "test"}} featurized = base.embed({"test_namespace": "test"}, MockEncoder()) assert featurized.sparse == expected_sparse assert featurized.dense == {} @@ -56,7 +56,7 @@ def test_context_w_namespace_no_emb() -> None: def test_context_w_namespace_w_emb() -> None: str1 = "test" - expected_sparse = {"test_namespace": {"raw": str1}} + expected_sparse = {"test_namespace": {"default_ft": str1}} expected_dense = {"test_namespace": [4.0, 0.0]} featurized = base.embed({"test_namespace": base.Embed(str1)}, MockEncoder()) @@ -70,7 +70,7 @@ def test_context_w_namespace_w_emb() -> None: def test_context_w_namespace_w_emb2() -> None: str1 = "test" - expected_sparse = {"test_namespace": {"raw": str1}} + expected_sparse = {"test_namespace": {"default_ft": str1}} expected_dense = {"test_namespace": [4.0, 0.0]} featurized = base.embed(base.Embed({"test_namespace": str1}), MockEncoder()) @@ -85,7 +85,7 @@ def test_context_w_namespace_w_emb2() -> None: def test_context_w_namespace_w_some_emb() -> None: str1 = "test" str2 = "test_" - expected_sparse = {"test_namespace": {"raw": str1}} + expected_sparse = {"test_namespace": {"default_ft": str1}} expected_dense = {"test_namespace2": [5.0, 0.0]} featurized = base.embed( {"test_namespace": str1, "test_namespace2": base.Embed(str2)}, MockEncoder() @@ -94,8 +94,8 @@ def test_context_w_namespace_w_some_emb() -> None: assert featurized.dense == expected_dense expected_sparse = { - "test_namespace": {"raw": str1}, - "test_namespace2": {"raw": str2}, + "test_namespace": {"default_ft": str1}, + "test_namespace2": {"default_ft": str2}, } featurized = base.embed( {"test_namespace": str1, "test_namespace2": base.EmbedAndKeep(str2)}, @@ -110,9 +110,9 @@ def test_simple_action_strlist_no_emb() -> None: str2 = "test2" str3 = "test3" expected_sparse = [ - {"a_namespace": {"raw": str1}}, - {"a_namespace": {"raw": str2}}, - {"a_namespace": {"raw": str3}}, + {"a_namespace": {"default_ft": str1}}, + {"a_namespace": {"default_ft": str2}}, + {"a_namespace": {"default_ft": str3}}, ] to_embed: List[Union[str, base._Embed]] = [str1, str2, str3] featurized = base.embed(to_embed, MockEncoder(), "a_namespace") @@ -128,9 +128,9 @@ def test_simple_action_strlist_w_emb() -> None: str3 = "test__" expected_sparse = [ - {"a_namespace": {"raw": str1}}, - {"a_namespace": {"raw": str2}}, - {"a_namespace": {"raw": str3}}, + {"a_namespace": {"default_ft": str1}}, + {"a_namespace": {"default_ft": str2}}, + {"a_namespace": {"default_ft": str3}}, ] expected_dense = [ {"a_namespace": [4.0, 0.0]}, @@ -158,7 +158,7 @@ def test_simple_action_strlist_w_some_emb() -> None: str2 = "test_" str3 = "test__" - expected_sparse = [{"a_namespace": {"raw": str1}}, {}, {}] + expected_sparse = [{"a_namespace": {"default_ft": str1}}, {}, {}] expected_dense = [{}, {"a_namespace": [5.0, 0.0]}, {"a_namespace": [6.0, 0.0]}] featurized = base.embed( [str1, base.Embed(str2), base.Embed(str3)], MockEncoder(), "a_namespace" @@ -173,9 +173,9 @@ def test_simple_action_strlist_w_some_emb() -> None: "a_namespace", ) expected_sparse = [ - {"a_namespace": {"raw": str1}}, - {"a_namespace": {"raw": str2}}, - {"a_namespace": {"raw": str3}}, + {"a_namespace": {"default_ft": str1}}, + {"a_namespace": {"default_ft": str2}}, + {"a_namespace": {"default_ft": str3}}, ] for i in range(len(featurized)): assert featurized[i].sparse == expected_sparse[i] @@ -187,9 +187,9 @@ def test_action_w_namespace_no_emb() -> None: str2 = "test2" str3 = "test3" expected_sparse = [ - {"test_namespace": {"raw": str1}}, - {"test_namespace": {"raw": str2}}, - {"test_namespace": {"raw": str3}}, + {"test_namespace": {"default_ft": str1}}, + {"test_namespace": {"default_ft": str2}}, + {"test_namespace": {"default_ft": str3}}, ] featurized = base.embed( @@ -210,9 +210,9 @@ def test_action_w_namespace_w_emb() -> None: str2 = "test_" str3 = "test__" expected_sparse = [ - {"test_namespace": {"raw": str1}}, - {"test_namespace": {"raw": str2}}, - {"test_namespace": {"raw": str3}}, + {"test_namespace": {"default_ft": str1}}, + {"test_namespace": {"default_ft": str2}}, + {"test_namespace": {"default_ft": str3}}, ] expected_dense = [ {"test_namespace": [4.0, 0.0]}, @@ -250,9 +250,9 @@ def test_action_w_namespace_w_emb2() -> None: str2 = "test_" str3 = "test__" expected_sparse = [ - {"test_namespace1": {"raw": str1}}, - {"test_namespace2": {"raw": str2}}, - {"test_namespace3": {"raw": str3}}, + {"test_namespace1": {"default_ft": str1}}, + {"test_namespace2": {"default_ft": str2}}, + {"test_namespace3": {"default_ft": str3}}, ] expected_dense = [ {"test_namespace1": [4.0, 0.0]}, @@ -294,7 +294,7 @@ def test_action_w_namespace_w_some_emb() -> None: str2 = "test_" str3 = "test__" expected_sparse = [ - {"test_namespace": {"raw": str1}}, + {"test_namespace": {"default_ft": str1}}, {}, {}, ] @@ -317,9 +317,9 @@ def test_action_w_namespace_w_some_emb() -> None: assert featurized[i].dense == expected_dense[i] expected_sparse = [ - {"test_namespace": {"raw": str1}}, - {"test_namespace": {"raw": str2}}, - {"test_namespace": {"raw": str3}}, + {"test_namespace": {"default_ft": str1}}, + {"test_namespace": {"default_ft": str2}}, + {"test_namespace": {"default_ft": str3}}, ] featurized = base.embed( [ @@ -339,9 +339,9 @@ def test_action_w_namespace_w_emb_w_more_than_one_item_in_first_dict() -> None: str2 = "test_" str3 = "test__" expected_sparse = [ - {"test_namespace2": {"raw": str1}}, - {"test_namespace2": {"raw": str2}}, - {"test_namespace2": {"raw": str3}}, + {"test_namespace2": {"default_ft": str1}}, + {"test_namespace2": {"default_ft": str2}}, + {"test_namespace2": {"default_ft": str3}}, ] expected_dense = [ {"test_namespace": [4.0, 0.0]}, @@ -362,9 +362,9 @@ def test_action_w_namespace_w_emb_w_more_than_one_item_in_first_dict() -> None: assert featurized[i].dense == expected_dense[i] expected_sparse = [ - {"test_namespace": {"raw": str1}, "test_namespace2": {"raw": str1}}, - {"test_namespace": {"raw": str2}, "test_namespace2": {"raw": str2}}, - {"test_namespace": {"raw": str3}, "test_namespace2": {"raw": str3}}, + {"test_namespace": {"default_ft": str1}, "test_namespace2": {"default_ft": str1}}, + {"test_namespace": {"default_ft": str2}, "test_namespace2": {"default_ft": str2}}, + {"test_namespace": {"default_ft": str3}, "test_namespace2": {"default_ft": str3}}, ] featurized = base.embed( [ @@ -383,8 +383,8 @@ def test_one_namespace_w_list_of_features_no_emb() -> None: str1 = "test1" str2 = "test2" expected_sparse = { - "test_namespace_0": {"raw": str1}, - "test_namespace_1": {"raw": str2}, + "test_namespace_0": {"default_ft": str1}, + "test_namespace_1": {"default_ft": str2}, } featurized = base.embed({"test_namespace": [str1, str2]}, MockEncoder()) @@ -395,7 +395,7 @@ def test_one_namespace_w_list_of_features_no_emb() -> None: def test_one_namespace_w_list_of_features_w_some_emb() -> None: str1 = "test" str2 = "test_" - expected_sparse = {"test_namespace_0": {"raw": str1}} + expected_sparse = {"test_namespace_0": {"default_ft": str1}} expected_dense = {"test_namespace_1": [5.0, 0.0]} featurized = base.embed({"test_namespace": [str1, base.Embed(str2)]}, MockEncoder())