Instructions to use tobiges/behavior_fast with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tobiges/behavior_fast with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("tobiges/behavior_fast", device_map="auto") - Notebooks
- Google Colab
- Kaggle
fix processor
Browse files- processing_action_tokenizer.py +17 -15
processing_action_tokenizer.py
CHANGED
|
@@ -3,11 +3,9 @@ from typing import ClassVar
|
|
| 3 |
|
| 4 |
import numpy as np
|
| 5 |
from scipy.fft import dct, idct
|
| 6 |
-
from tokenizers import ByteLevelBPETokenizer
|
| 7 |
-
from tokenizers.trainers import BpeTrainer
|
| 8 |
from transformers import PreTrainedTokenizerFast
|
| 9 |
from transformers.processing_utils import ProcessorMixin
|
| 10 |
-
from tokenizers.models import BPE
|
| 11 |
|
| 12 |
|
| 13 |
class UniversalActionProcessor(ProcessorMixin):
|
|
@@ -133,25 +131,29 @@ class UniversalActionProcessor(ProcessorMixin):
|
|
| 133 |
|
| 134 |
# Train BPE tokenizer
|
| 135 |
bpe = ByteLevelBPETokenizer()
|
| 136 |
-
# tokenizer = Tokenizer(BPE())
|
| 137 |
|
| 138 |
# Set up the entire range of possible tokens as the initial alphabet
|
| 139 |
-
alphabet = [chr(i) for i in range(max_token - min_token + 1)]
|
| 140 |
-
trainer = BpeTrainer(
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
)
|
| 149 |
|
| 150 |
# Train the inner tokenizer (don't use ByteLevelBPETokenizer.train_from_iterator()
|
| 151 |
# because it doesn't support custom alphabets)
|
| 152 |
# bpe._tokenizer.train_from_iterator(_token_iter(), trainer=trainer)
|
| 153 |
# trainer.train_from_iterator(_token_iter(), trainer=trainer)
|
| 154 |
-
bpe.train_from_iterator(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
return cls(
|
| 157 |
PreTrainedTokenizerFast(tokenizer_object=bpe, clean_up_tokenization_spaces=False),
|
|
|
|
| 3 |
|
| 4 |
import numpy as np
|
| 5 |
from scipy.fft import dct, idct
|
| 6 |
+
from tokenizers import ByteLevelBPETokenizer
|
|
|
|
| 7 |
from transformers import PreTrainedTokenizerFast
|
| 8 |
from transformers.processing_utils import ProcessorMixin
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
class UniversalActionProcessor(ProcessorMixin):
|
|
|
|
| 131 |
|
| 132 |
# Train BPE tokenizer
|
| 133 |
bpe = ByteLevelBPETokenizer()
|
|
|
|
| 134 |
|
| 135 |
# Set up the entire range of possible tokens as the initial alphabet
|
| 136 |
+
# alphabet = [chr(i) for i in range(max_token - min_token + 1)]
|
| 137 |
+
# trainer = BpeTrainer(
|
| 138 |
+
# vocab_size=vocab_size,
|
| 139 |
+
# min_frequency=2,
|
| 140 |
+
# show_progress=True,
|
| 141 |
+
# special_tokens=[],
|
| 142 |
+
# initial_alphabet=alphabet,
|
| 143 |
+
# max_token_length=10000,
|
| 144 |
+
# )
|
|
|
|
| 145 |
|
| 146 |
# Train the inner tokenizer (don't use ByteLevelBPETokenizer.train_from_iterator()
|
| 147 |
# because it doesn't support custom alphabets)
|
| 148 |
# bpe._tokenizer.train_from_iterator(_token_iter(), trainer=trainer)
|
| 149 |
# trainer.train_from_iterator(_token_iter(), trainer=trainer)
|
| 150 |
+
bpe.train_from_iterator(
|
| 151 |
+
_token_iter(),
|
| 152 |
+
vocab_size=vocab_size,
|
| 153 |
+
min_frequency=2,
|
| 154 |
+
special_tokens=[],
|
| 155 |
+
length=len(dct_tokens)
|
| 156 |
+
)
|
| 157 |
|
| 158 |
return cls(
|
| 159 |
PreTrainedTokenizerFast(tokenizer_object=bpe, clean_up_tokenization_spaces=False),
|