sandz7 commited on
Commit
aaf89eb
Β·
1 Parent(s): 9078da1

added streamer in the generate_kwargs and placed params in streamer

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -16,7 +16,7 @@ API_KEY = os.getenv('OPEN_AI_API_KEY')
16
  DESCRIPTION = '''
17
  <div>
18
  <h1 style="text-align: center;">Amphisbeana 🐍</h1>
19
- <p>This uses Llama 3 and GPT-4o as generation, both of these make the final generation. <a href="https://huggingface.co/meta-llama/Meta-Llama-3-8B"><b>Llama3-8b</b></a>and <a href="https://platform.openai.com/docs/models/gpt-4o"><b>GPT-4o</b></a></p>
20
  </div>
21
  '''
22
 
@@ -54,11 +54,12 @@ def llama_generation(input_text: str,
54
 
55
  input_ids = llama_tokenizer.apply_chat_template(conversation, return_tensors='pt').to(llama_model.device)
56
 
57
- streamer = TextIteratorStreamer(llama_tokenizer, skip_prompt=True, timeout=10.0)
58
 
59
  # generation arguments to pass in llm generate() eventually
60
  generate_kwargs = dict(
61
  input_ids=input_ids,
 
62
  max_new_tokens=max_new_tokens,
63
  do_sample=True,
64
  temperature=temperature,
 
16
  DESCRIPTION = '''
17
  <div>
18
  <h1 style="text-align: center;">Amphisbeana 🐍</h1>
19
+ <p>This uses Llama 3 and GPT-4o as generation, both of these make the final generation. <a href="https://huggingface.co/meta-llama/Meta-Llama-3-8B"><b>Llama3-8b</b></a> and <a href="https://platform.openai.com/docs/models/gpt-4o"><b>GPT-4o</b></a></p>
20
  </div>
21
  '''
22
 
 
54
 
55
  input_ids = llama_tokenizer.apply_chat_template(conversation, return_tensors='pt').to(llama_model.device)
56
 
57
+ streamer = TextIteratorStreamer(llama_tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
58
 
59
  # generation arguments to pass in llm generate() eventually
60
  generate_kwargs = dict(
61
  input_ids=input_ids,
62
+ streamer=streamer,
63
  max_new_tokens=max_new_tokens,
64
  do_sample=True,
65
  temperature=temperature,