Skip to content

Simplify tokenizer creation #44

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

Merged
merged 1 commit into from
Apr 5, 2024
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
6 changes: 3 additions & 3 deletions src/chronos/chronos.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from dataclasses import dataclass
from typing import Any, Dict, List, Literal, Optional, Tuple, Union

import chronos
import torch
import torch.nn as nn
from transformers import (
Expand Down Expand Up @@ -45,9 +46,8 @@ def __post_init__(self):
), f"Special token id's must be smaller than {self.n_special_tokens=}"

def create_tokenizer(self) -> "ChronosTokenizer":
if self.tokenizer_class == "MeanScaleUniformBins":
return MeanScaleUniformBins(**self.tokenizer_kwargs, config=self)
raise ValueError
class_ = getattr(chronos, self.tokenizer_class)
return class_(**self.tokenizer_kwargs, config=self)


class ChronosTokenizer:
Expand Down