added streamer in the generate_kwargs and placed params in streamer
Browse files
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,
|
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,
|