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 +7 -3
- tokenizer.json +0 -0
processing_action_tokenizer.py
CHANGED
|
@@ -3,10 +3,11 @@ 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 |
|
| 11 |
|
| 12 |
class UniversalActionProcessor(ProcessorMixin):
|
|
@@ -132,6 +133,7 @@ class UniversalActionProcessor(ProcessorMixin):
|
|
| 132 |
|
| 133 |
# Train BPE tokenizer
|
| 134 |
bpe = ByteLevelBPETokenizer()
|
|
|
|
| 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)]
|
|
@@ -140,14 +142,16 @@ class UniversalActionProcessor(ProcessorMixin):
|
|
| 140 |
min_frequency=8,
|
| 141 |
show_progress=True,
|
| 142 |
special_tokens=[],
|
| 143 |
-
initial_alphabet=alphabet,
|
| 144 |
# max_token_length=10000,
|
| 145 |
max_token_length=100,
|
| 146 |
)
|
| 147 |
|
| 148 |
# Train the inner tokenizer (don't use ByteLevelBPETokenizer.train_from_iterator()
|
| 149 |
# because it doesn't support custom alphabets)
|
| 150 |
-
bpe._tokenizer.train_from_iterator(_token_iter(), trainer=trainer)
|
|
|
|
|
|
|
| 151 |
|
| 152 |
return cls(
|
| 153 |
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, Tokenizer
|
| 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 |
|
| 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)]
|
|
|
|
| 142 |
min_frequency=8,
|
| 143 |
show_progress=True,
|
| 144 |
special_tokens=[],
|
| 145 |
+
# initial_alphabet=alphabet,
|
| 146 |
# max_token_length=10000,
|
| 147 |
max_token_length=100,
|
| 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(_token_iter(), vocab_size=vocab_size,)
|
| 155 |
|
| 156 |
return cls(
|
| 157 |
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
|
|
|