header with user input, and grabbed the first response of output_ids[0]
Browse files
app.py
CHANGED
@@ -34,14 +34,18 @@ def llama_generation(input_text: str,
|
|
34 |
Pass input texts, tokenize, output and back to text.
|
35 |
"""
|
36 |
|
37 |
-
|
|
|
|
|
|
|
|
|
38 |
return_tensors='pt').to('cuda')
|
39 |
|
40 |
# llama generation looks for the numeric vectors not the tensors so there is no need for **input_ids rather just input_ids
|
41 |
output_ids = llama_model.generate(input_ids=input_ids)
|
42 |
|
43 |
# Decode
|
44 |
-
output_text = llama_tokenizer.decode(output_ids,
|
45 |
skip_special_tokens=True)
|
46 |
|
47 |
return output_text
|
|
|
34 |
Pass input texts, tokenize, output and back to text.
|
35 |
"""
|
36 |
|
37 |
+
# Header prompt
|
38 |
+
header = '''Your are a helpful AI called amphisbeana.
|
39 |
+
You will help the user, by giving accurate but creative response'''
|
40 |
+
|
41 |
+
input_ids = llama_tokenizer.encode(input_text + header,
|
42 |
return_tensors='pt').to('cuda')
|
43 |
|
44 |
# llama generation looks for the numeric vectors not the tensors so there is no need for **input_ids rather just input_ids
|
45 |
output_ids = llama_model.generate(input_ids=input_ids)
|
46 |
|
47 |
# Decode
|
48 |
+
output_text = llama_tokenizer.decode(output_ids[0],
|
49 |
skip_special_tokens=True)
|
50 |
|
51 |
return output_text
|