Skip to content

Commit

Permalink
better handling or eos tokens, hard limit on vRAM usage (for RX 7900XTX)
Browse files Browse the repository at this point in the history
  • Loading branch information
FontaineRiant committed Mar 21, 2024
1 parent 5bc58ee commit 3d2b0e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion generator/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self,
self.enc = AutoTokenizer.from_pretrained(model_name, add_prefix_space=False)

self.length = length
self.max_history = self.model.config.max_position_embeddings - self.length
self.max_history = min(self.model.config.max_position_embeddings - self.length, 6000)

def __del__(self):
pass
Expand Down
4 changes: 2 additions & 2 deletions story/story.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def clean_input(self, action=''):
return text.strip()

def clean_result(self, result):
result = re.sub(rf'^({self.gen.model.config.prefix})+', '', result) # remove leading endoftext tokens
result = re.sub(rf'{self.gen.model.config.prefix}[\s\S]*$', '', result) # parse endoftext token that end the text
result = re.sub(rf'^({self.gen.enc.eos_token})+', '', result) # remove leading endoftext tokens
result = re.sub(rf'{self.gen.enc.eos_token}[\s\S]*$', '', result) # parse endoftext token that end the text

result = result.replace("’", "'")
result = result.replace("`", "'")
Expand Down

0 comments on commit 3d2b0e5

Please sign in to comment.