forked from comfyanonymous/ComfyUI
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better tokenizing code for AuraFlow.
- Loading branch information
1 parent
b6f09cf
commit 29c2e26
Showing
5 changed files
with
25 additions
and
1,175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import os | ||
|
||
class LLAMATokenizer: | ||
@staticmethod | ||
def from_pretrained(path): | ||
return LLAMATokenizer(path) | ||
|
||
def __init__(self, tokenizer_path): | ||
import sentencepiece | ||
self.tokenizer = sentencepiece.SentencePieceProcessor(model_file=tokenizer_path) | ||
self.end = self.tokenizer.eos_id() | ||
|
||
def get_vocab(self): | ||
out = {} | ||
for i in range(self.tokenizer.get_piece_size()): | ||
out[self.tokenizer.id_to_piece(i)] = i | ||
return out | ||
|
||
def __call__(self, string): | ||
out = self.tokenizer.encode(string) | ||
out += [self.end] | ||
return {"input_ids": out} |
102 changes: 0 additions & 102 deletions
102
comfy/text_encoders/t5_pile_tokenizer/added_tokens.json
This file was deleted.
Oops, something went wrong.
125 changes: 0 additions & 125 deletions
125
comfy/text_encoders/t5_pile_tokenizer/special_tokens_map.json
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.