Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -731,6 +731,17 @@ def llama_chat_sys_input_seq_constructor(text, sys_prompt=SYSTEM_PROMPT_1, bos_t
|
|
| 731 |
return f"{bos_token}{B_INST} {B_SYS} {sys_prompt} {E_SYS} {text} {E_INST}"
|
| 732 |
|
| 733 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 734 |
def llama_chat_multiturn_sys_input_seq_constructor(
|
| 735 |
message: str,
|
| 736 |
history: List[Tuple[str, str]],
|
|
@@ -1561,9 +1572,10 @@ def batch_inference(
|
|
| 1561 |
prompt_format_fn = llama_chat_multiturn_sys_input_seq_constructor
|
| 1562 |
elif prompt_mode == 'few-shot':
|
| 1563 |
from functools import partial
|
| 1564 |
-
prompt_format_fn = partial(
|
| 1565 |
-
|
| 1566 |
-
)
|
|
|
|
| 1567 |
else:
|
| 1568 |
raise gr.Error(f'Wrong mode {prompt_mode}')
|
| 1569 |
|
|
@@ -1739,7 +1751,7 @@ def launch():
|
|
| 1739 |
["upload_chat.json", "chat", 0.2, 1024, 0.5, 0, "[STOP],[END],<s>,</s>"],
|
| 1740 |
["upload_few_shot.json", "few-shot", 0.2, 128, 0.5, 0, "[STOP],[END],<s>,</s>,\\n"]
|
| 1741 |
],
|
| 1742 |
-
|
| 1743 |
)
|
| 1744 |
|
| 1745 |
demo_chat = gr.ChatInterface(
|
|
|
|
| 731 |
return f"{bos_token}{B_INST} {B_SYS} {sys_prompt} {E_SYS} {text} {E_INST}"
|
| 732 |
|
| 733 |
|
| 734 |
+
def few_shot_prompt(
|
| 735 |
+
message: str,
|
| 736 |
+
history: List[Tuple[str, str]],
|
| 737 |
+
sys_prompt=SYSTEM_PROMPT_1,
|
| 738 |
+
bos_token=BOS_TOKEN,
|
| 739 |
+
eos_token=EOS_TOKEN,
|
| 740 |
+
include_end_instruct=True,
|
| 741 |
+
):
|
| 742 |
+
return f"{bos_token} {message}"
|
| 743 |
+
|
| 744 |
+
|
| 745 |
def llama_chat_multiturn_sys_input_seq_constructor(
|
| 746 |
message: str,
|
| 747 |
history: List[Tuple[str, str]],
|
|
|
|
| 1572 |
prompt_format_fn = llama_chat_multiturn_sys_input_seq_constructor
|
| 1573 |
elif prompt_mode == 'few-shot':
|
| 1574 |
from functools import partial
|
| 1575 |
+
# prompt_format_fn = partial(
|
| 1576 |
+
# llama_chat_multiturn_sys_input_seq_constructor, include_end_instruct=False
|
| 1577 |
+
# )
|
| 1578 |
+
prompt_format_fn = few_shot_prompt
|
| 1579 |
else:
|
| 1580 |
raise gr.Error(f'Wrong mode {prompt_mode}')
|
| 1581 |
|
|
|
|
| 1751 |
["upload_chat.json", "chat", 0.2, 1024, 0.5, 0, "[STOP],[END],<s>,</s>"],
|
| 1752 |
["upload_few_shot.json", "few-shot", 0.2, 128, 0.5, 0, "[STOP],[END],<s>,</s>,\\n"]
|
| 1753 |
],
|
| 1754 |
+
cache_examples=False,
|
| 1755 |
)
|
| 1756 |
|
| 1757 |
demo_chat = gr.ChatInterface(
|