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
Upload processor
Browse files- processing_action_tokenizer.py +19 -17
- tokenizer.json +0 -0
processing_action_tokenizer.py
CHANGED
|
@@ -4,8 +4,9 @@ from typing import ClassVar
|
|
| 4 |
import numpy as np
|
| 5 |
from scipy.fft import dct, idct
|
| 6 |
from tokenizers import ByteLevelBPETokenizer
|
| 7 |
-
from
|
| 8 |
from transformers.processing_utils import ProcessorMixin
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
class UniversalActionProcessor(ProcessorMixin):
|
|
@@ -134,26 +135,27 @@ class UniversalActionProcessor(ProcessorMixin):
|
|
| 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 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
|
| 146 |
# Train the inner tokenizer (don't use ByteLevelBPETokenizer.train_from_iterator()
|
| 147 |
# because it doesn't support custom alphabets)
|
| 148 |
-
|
| 149 |
# trainer.train_from_iterator(_token_iter(), trainer=trainer)
|
| 150 |
-
bpe.train_from_iterator(
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
|
|
|
| 157 |
|
| 158 |
return cls(
|
| 159 |
PreTrainedTokenizerFast(tokenizer_object=bpe, clean_up_tokenization_spaces=False),
|
|
|
|
| 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.processing_utils import ProcessorMixin
|
| 9 |
+
from transformers import PreTrainedTokenizerFast
|
| 10 |
|
| 11 |
|
| 12 |
class UniversalActionProcessor(ProcessorMixin):
|
|
|
|
| 135 |
|
| 136 |
# Set up the entire range of possible tokens as the initial alphabet
|
| 137 |
# alphabet = [chr(i) for i in range(max_token - min_token + 1)]
|
| 138 |
+
trainer = BpeTrainer(
|
| 139 |
+
vocab_size=vocab_size,
|
| 140 |
+
min_frequency=2,
|
| 141 |
+
show_progress=True,
|
| 142 |
+
special_tokens=[],
|
| 143 |
+
# initial_alphabet=alphabet,
|
| 144 |
+
max_token_length=512,
|
| 145 |
+
)
|
| 146 |
|
| 147 |
# Train the inner tokenizer (don't use ByteLevelBPETokenizer.train_from_iterator()
|
| 148 |
# because it doesn't support custom alphabets)
|
| 149 |
+
bpe._tokenizer.train_from_iterator(_token_iter(), trainer=trainer)
|
| 150 |
# trainer.train_from_iterator(_token_iter(), trainer=trainer)
|
| 151 |
+
# bpe.train_from_iterator(
|
| 152 |
+
# _token_iter(),
|
| 153 |
+
# vocab_size=vocab_size,
|
| 154 |
+
# min_frequency=2,
|
| 155 |
+
# special_tokens=[],
|
| 156 |
+
# length=len(dct_tokens),
|
| 157 |
+
# max_token_length=512,
|
| 158 |
+
# )
|
| 159 |
|
| 160 |
return cls(
|
| 161 |
PreTrainedTokenizerFast(tokenizer_object=bpe, clean_up_tokenization_spaces=False),
|
tokenizer.json
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|