Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EmbeddingInfo NamedTuple #392

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions fuse/data/tokenizers/modular_tokenizer/inject_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re
from collections import defaultdict
from typing import Dict, List, Optional, Tuple, Union
from typing import Dict, List, NamedTuple, Optional, Tuple, Union
from warnings import warn

import torch
Expand All @@ -13,6 +13,11 @@
from fuse.utils import NDict


class EmbeddingInfo(NamedTuple):
location: int
embedding_input: str


class InjectorToModularTokenizerLib:
"""
InjectorTokenizer builds on top of ModularTokenizer.
Expand Down Expand Up @@ -227,7 +232,10 @@ def build_scalars_and_embeddings(

embedding_input = sample_dict[embeddings_key]
external_embeddings_info[embedding_model_name].append(
(num_tokens_token_so_far, embedding_input)
EmbeddingInfo(
location=num_tokens_token_so_far,
embedding_input=embedding_input,
)
)
elif tokenizer_name.startswith("VECTORS_"):
raise NotImplementedError
Expand Down
Loading