Update app_modules/utils.py

This commit is contained in:
Baize 2023-04-05 01:38:37 +00:00 committed by huggingface-web
parent 7edc905c10
commit 3d2cf1ed18
1 changed files with 36 additions and 28 deletions

View File

@ -13,6 +13,7 @@ import html
import markdown2
import torch
import sys
import gc
from pygments.lexers import guess_lexer, ClassNotFound
import gradio as gr
@ -282,6 +283,13 @@ def greedy_search(input_ids: torch.Tensor,
yield text
if any([x in text for x in stop_words]):
del past_key_values
del logits
del probs
del probs_sort
del probs_idx
del probs_sum
gc.collect()
return
def generate_prompt_with_history(text,history,tokenizer,max_length=2048):