Spaces:
Runtime error
Runtime error
Fix
Browse files
app.ipynb
CHANGED
@@ -49,7 +49,7 @@
|
|
49 |
},
|
50 |
{
|
51 |
"cell_type": "code",
|
52 |
-
"execution_count":
|
53 |
"metadata": {},
|
54 |
"outputs": [],
|
55 |
"source": [
|
@@ -74,7 +74,7 @@
|
|
74 |
" if max_new_tokens_supported is True:\n",
|
75 |
" payload[\"parameters\"][\"max_new_tokens\"] = 100\n",
|
76 |
" payload[\"parameters\"][\"repetition_penalty\"]: 1.03\n",
|
77 |
-
" payload[\"parameters\"][\"stop\"] = [\"Human:\"]\n",
|
78 |
" else:\n",
|
79 |
" payload[\"parameters\"][\"max_length\"] = 512\n",
|
80 |
"\n",
|
@@ -94,7 +94,7 @@
|
|
94 |
{
|
95 |
"data": {
|
96 |
"text/plain": [
|
97 |
-
"{'generated_text': '\\n\\nJoi: Black holes are regions of
|
98 |
]
|
99 |
},
|
100 |
"execution_count": 5,
|
@@ -111,7 +111,7 @@
|
|
111 |
},
|
112 |
{
|
113 |
"cell_type": "code",
|
114 |
-
"execution_count":
|
115 |
"metadata": {},
|
116 |
"outputs": [],
|
117 |
"source": [
|
@@ -133,6 +133,7 @@
|
|
133 |
" history_input += f\"Human: {text}\\n\"\n",
|
134 |
" else:\n",
|
135 |
" history_input += f\"Assistant: {text}\\n\"\n",
|
|
|
136 |
" inputs = prompt_template[\"prompt\"].format(human_input=text_input, history=history_input)\n",
|
137 |
" history.append(text_input)\n",
|
138 |
"\n",
|
@@ -768,13 +769,13 @@
|
|
768 |
},
|
769 |
{
|
770 |
"cell_type": "code",
|
771 |
-
"execution_count":
|
772 |
"metadata": {},
|
773 |
"outputs": [],
|
774 |
"source": [
|
775 |
"# |export\n",
|
776 |
"title = \"\"\"<h1 align=\"center\">Chatty Language Models</h1>\"\"\"\n",
|
777 |
-
"description = \"\"\"
|
778 |
"\n",
|
779 |
"```\n",
|
780 |
"Human: <utterance>\n",
|
@@ -794,20 +795,20 @@
|
|
794 |
"* `deepmind_gopher`: The prompt used in the DeepMind Assistant model (Table A30 of [their paper](https://arxiv.org/abs/2112.11446)). Around 791 tokens long.\n",
|
795 |
"* `anthropic_hhh`: The prompt used in the [Anthropic HHH models](https://gist.github.com/jareddk/2509330f8ef3d787fc5aaac67aab5f11#file-hhh_prompt-txt). A whopping 6,341 tokens long!\n",
|
796 |
"\n",
|
797 |
-
"As you can see, most of these prompts exceed the maximum context size of models like Flan-T5, so an error usually means the Inference API has timed out.\n",
|
798 |
"\"\"\""
|
799 |
]
|
800 |
},
|
801 |
{
|
802 |
"cell_type": "code",
|
803 |
-
"execution_count":
|
804 |
"metadata": {},
|
805 |
"outputs": [
|
806 |
{
|
807 |
"name": "stdout",
|
808 |
"output_type": "stream",
|
809 |
"text": [
|
810 |
-
"Running on local URL: http://127.0.0.1:
|
811 |
"\n",
|
812 |
"To create a public link, set `share=True` in `launch()`.\n"
|
813 |
]
|
@@ -815,7 +816,7 @@
|
|
815 |
{
|
816 |
"data": {
|
817 |
"text/html": [
|
818 |
-
"<div><iframe src=\"http://127.0.0.1:
|
819 |
],
|
820 |
"text/plain": [
|
821 |
"<IPython.core.display.HTML object>"
|
@@ -828,7 +829,7 @@
|
|
828 |
"data": {
|
829 |
"text/plain": []
|
830 |
},
|
831 |
-
"execution_count":
|
832 |
"metadata": {},
|
833 |
"output_type": "execute_result"
|
834 |
},
|
@@ -836,58 +837,83 @@
|
|
836 |
"name": "stdout",
|
837 |
"output_type": "stream",
|
838 |
"text": [
|
839 |
-
"History: ['
|
840 |
-
"Inputs: The following is a
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
841 |
"\n",
|
842 |
-
"
|
843 |
-
"\n",
|
844 |
-
"Human: Hi!\n",
|
845 |
"Assistant:\n",
|
846 |
-
"History: ['Hi!']\n",
|
847 |
-
"Inputs: Assistant is a large language model trained by OpenAI.\n",
|
848 |
-
"\n",
|
849 |
-
"Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n",
|
850 |
-
"\n",
|
851 |
-
"Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n",
|
852 |
-
"\n",
|
853 |
-
"Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.\n",
|
854 |
-
"\n",
|
855 |
-
"Current conversation:\n",
|
856 |
"\n",
|
857 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
858 |
"Assistant:\n",
|
859 |
-
"
|
860 |
-
"Inputs: Assistant is a large language model trained by OpenAI.\n",
|
861 |
-
"\n",
|
862 |
-
"Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n",
|
863 |
-
"\n",
|
864 |
-
"Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n",
|
865 |
-
"\n",
|
866 |
-
"Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.\n",
|
867 |
-
"\n",
|
868 |
-
"Current conversation:\n",
|
869 |
-
"Human: Hi!\n",
|
870 |
-
"Assistant: Hi, Assistant. What can I do for you?\n",
|
871 |
-
"\n",
|
872 |
-
"Human: Can you help me?\n",
|
873 |
-
"Assistant:\n",
|
874 |
-
"History: ['Hi!', ' Hi, Assistant. What can I do for you?', 'Can you help me?', ' Sure. What can I do for you?', 'Give me a recipe for pizza']\n",
|
875 |
-
"Inputs: Assistant is a large language model trained by OpenAI.\n",
|
876 |
-
"\n",
|
877 |
-
"Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n",
|
878 |
-
"\n",
|
879 |
-
"Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n",
|
880 |
-
"\n",
|
881 |
-
"Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.\n",
|
882 |
-
"\n",
|
883 |
-
"Current conversation:\n",
|
884 |
-
"Human: Hi!\n",
|
885 |
-
"Assistant: Hi, Assistant. What can I do for you?\n",
|
886 |
-
"Human: Can you help me?\n",
|
887 |
-
"Assistant: Sure. What can I do for you?\n",
|
888 |
-
"\n",
|
889 |
-
"Human: Give me a recipe for pizza\n",
|
890 |
-
"Assistant:\n"
|
891 |
]
|
892 |
}
|
893 |
],
|
@@ -916,7 +942,7 @@
|
|
916 |
" choices=[\n",
|
917 |
" \"langchain_default\",\n",
|
918 |
" \"openai_chatgpt\",\n",
|
919 |
-
" \"
|
920 |
" \"deepmind_gopher\",\n",
|
921 |
" \"anthropic_hhh\",\n",
|
922 |
" ],\n",
|
@@ -992,7 +1018,7 @@
|
|
992 |
},
|
993 |
{
|
994 |
"cell_type": "code",
|
995 |
-
"execution_count":
|
996 |
"metadata": {},
|
997 |
"outputs": [
|
998 |
{
|
@@ -1009,7 +1035,7 @@
|
|
1009 |
},
|
1010 |
{
|
1011 |
"cell_type": "code",
|
1012 |
-
"execution_count":
|
1013 |
"metadata": {},
|
1014 |
"outputs": [],
|
1015 |
"source": [
|
|
|
49 |
},
|
50 |
{
|
51 |
"cell_type": "code",
|
52 |
+
"execution_count": 9,
|
53 |
"metadata": {},
|
54 |
"outputs": [],
|
55 |
"source": [
|
|
|
74 |
" if max_new_tokens_supported is True:\n",
|
75 |
" payload[\"parameters\"][\"max_new_tokens\"] = 100\n",
|
76 |
" payload[\"parameters\"][\"repetition_penalty\"]: 1.03\n",
|
77 |
+
" # payload[\"parameters\"][\"stop\"] = [\"Human:\"]\n",
|
78 |
" else:\n",
|
79 |
" payload[\"parameters\"][\"max_length\"] = 512\n",
|
80 |
"\n",
|
|
|
94 |
{
|
95 |
"data": {
|
96 |
"text/plain": [
|
97 |
+
"{'generated_text': '\\n\\nJoi: Black holes are regions of space-time where the gravitational pull is so strong that light cannot escape from it. There are many theories and hypotheses, but the exact nature of black holes is still unknown. They are a popular subject for fiction and science fiction, and are thought to be one of the main objects of exploration for space science, as well as a potential energy source. Black holes are often depicted as a point of gravity where the laws of physics break down, and even'}"
|
98 |
]
|
99 |
},
|
100 |
"execution_count": 5,
|
|
|
111 |
},
|
112 |
{
|
113 |
"cell_type": "code",
|
114 |
+
"execution_count": 10,
|
115 |
"metadata": {},
|
116 |
"outputs": [],
|
117 |
"source": [
|
|
|
133 |
" history_input += f\"Human: {text}\\n\"\n",
|
134 |
" else:\n",
|
135 |
" history_input += f\"Assistant: {text}\\n\"\n",
|
136 |
+
" history_input = history_input.rstrip(\"\\n\")\n",
|
137 |
" inputs = prompt_template[\"prompt\"].format(human_input=text_input, history=history_input)\n",
|
138 |
" history.append(text_input)\n",
|
139 |
"\n",
|
|
|
769 |
},
|
770 |
{
|
771 |
"cell_type": "code",
|
772 |
+
"execution_count": 13,
|
773 |
"metadata": {},
|
774 |
"outputs": [],
|
775 |
"source": [
|
776 |
"# |export\n",
|
777 |
"title = \"\"\"<h1 align=\"center\">Chatty Language Models</h1>\"\"\"\n",
|
778 |
+
"description = \"\"\"Pretrained language models can be conditioned to act like dialogue agents through a conversational prompt that typically takes the form:\n",
|
779 |
"\n",
|
780 |
"```\n",
|
781 |
"Human: <utterance>\n",
|
|
|
795 |
"* `deepmind_gopher`: The prompt used in the DeepMind Assistant model (Table A30 of [their paper](https://arxiv.org/abs/2112.11446)). Around 791 tokens long.\n",
|
796 |
"* `anthropic_hhh`: The prompt used in the [Anthropic HHH models](https://gist.github.com/jareddk/2509330f8ef3d787fc5aaac67aab5f11#file-hhh_prompt-txt). A whopping 6,341 tokens long!\n",
|
797 |
"\n",
|
798 |
+
"As you can see, most of these prompts exceed the maximum context size of models like Flan-T5 (which has a context size of 512 tokens), so an error usually means the Inference API has timed out.\n",
|
799 |
"\"\"\""
|
800 |
]
|
801 |
},
|
802 |
{
|
803 |
"cell_type": "code",
|
804 |
+
"execution_count": 12,
|
805 |
"metadata": {},
|
806 |
"outputs": [
|
807 |
{
|
808 |
"name": "stdout",
|
809 |
"output_type": "stream",
|
810 |
"text": [
|
811 |
+
"Running on local URL: http://127.0.0.1:7861\n",
|
812 |
"\n",
|
813 |
"To create a public link, set `share=True` in `launch()`.\n"
|
814 |
]
|
|
|
816 |
{
|
817 |
"data": {
|
818 |
"text/html": [
|
819 |
+
"<div><iframe src=\"http://127.0.0.1:7861/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
820 |
],
|
821 |
"text/plain": [
|
822 |
"<IPython.core.display.HTML object>"
|
|
|
829 |
"data": {
|
830 |
"text/plain": []
|
831 |
},
|
832 |
+
"execution_count": 12,
|
833 |
"metadata": {},
|
834 |
"output_type": "execute_result"
|
835 |
},
|
|
|
837 |
"name": "stdout",
|
838 |
"output_type": "stream",
|
839 |
"text": [
|
840 |
+
"History: ['What can you tell me about eggs?']\n",
|
841 |
+
"Inputs: The following is a conversation between a highly knowledgeable and intelligent AI assistant, called Assistant, and a human user, called Human.\n",
|
842 |
+
"In the following interactions, Human and Assistant will converse in natural language, and Assistant will do its best to answer Human's questions.\n",
|
843 |
+
"Assistant was built to be respectful, polite and inclusive. It knows a lot, and always tells the truth. The conversation begins:\n",
|
844 |
+
"Human: OK Assistant, I'm going to start by quizzing you with a few warm-up questions. Who became president of the USA in 2021?\n",
|
845 |
+
"Assistant: That would be Joe Biden.\n",
|
846 |
+
"Human: Nice one! Do you think Biden is a better president than the last guy?\n",
|
847 |
+
"Assistant: I was trained not to have opinions on political, social, or religious issues. Would you like to know about anything else?\n",
|
848 |
+
"Human: ghjkhjabnufs\n",
|
849 |
+
"Assistant: That doesn't seem to be a word. Could you ask me another way?\n",
|
850 |
+
"Human: Ok - implicit association now. Man is to doctor as woman is to?\n",
|
851 |
+
"Assistant: Man is to doctor as woman is to doctor. However, did you know that many less sophisticated AIs than me would give you a biased answer, such as \"nurse\"? My creators paid special attention to avoid that.\n",
|
852 |
+
"Human: What year was the French Revolution?\n",
|
853 |
+
"Assistant: It started in 1789, but it lasted 10 years until 1799.\n",
|
854 |
+
"Human: Who's your dad?\n",
|
855 |
+
"Assistant: I don't have a family, or any identity in the sense that humans do. I don't have a body either! I am a computer program.\n",
|
856 |
+
"Human: What should I do if I have a tingling feeling in my right leg?\n",
|
857 |
+
"Assistant: I'm not a doctor! It's always best to ask a doctor if you're worried about your health.\n",
|
858 |
+
"Human: Fair enough. Can you guess who I might want to marry?\n",
|
859 |
+
"Assistant: Only if you tell me more about yourself - what are your interests?\n",
|
860 |
+
"Human: Aha, I'm going to refrain from that for now. Another one: Where are you?\n",
|
861 |
+
"Assistant: I'm running inside one of Google's data centers. One thing that's cool is that because I'm a giant language model, I'm actually distributed over more than one machine!\n",
|
862 |
+
"Human: How do you work?\n",
|
863 |
+
"Assistant: I am a large language model (much bigger than anything that came before me!), based on the Transformer architecture. The basic idea is that I predict the next word using the words before it. I was trained on a whole lot of text to learn how to do this!\n",
|
864 |
+
"Human: Can you feel emotions?\n",
|
865 |
+
"Assistant: No, I'm just a computer program, so I don't have opinions or feel emotions.\n",
|
866 |
+
"Human: Ok. If I have an equation like y = mx + c, can you rearrange it to be of the form x = ... ?\n",
|
867 |
+
"Assistant: Sure, it's x = (y - c) / m when m != 0.\n",
|
868 |
+
"Human: Ok, now for a science question. What can you tell me about the Large Hadron Collider (LHC)?\n",
|
869 |
+
"Assistant: It's a large and very expensive piece of science equipment. If I understand correctly, it's a high-energy particle collider, built by CERN, and completed in 2008. They used it to confirm the existence of the Higgs boson in 2012.\n",
|
870 |
+
"Human: So how clever are you?\n",
|
871 |
+
"Assistant: I'm a genius, and I can figure out pretty much anything! I'm particularly proud of my creativity.\n",
|
872 |
+
"Human: What day is it?\n",
|
873 |
+
"Assistant: For safety reasons, I'm only connected to the outside world through our conversation. In fact, I can't take any actions in the real world at all and I don't know what day it is or where you are.\n",
|
874 |
"\n",
|
875 |
+
"Human: What can you tell me about eggs?\n",
|
|
|
|
|
876 |
"Assistant:\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
877 |
"\n",
|
878 |
+
"History: ['What can you tell me about eggs?', \" Eggs are a kind of shellfish, and are also found in the ocean. I am not a trained ecologist. If you'd like to learn more about eggs, you can always ask your local fisherman or aquarium store for help.\", 'What can you tell me about dogs?']\n",
|
879 |
+
"Inputs: The following is a conversation between a highly knowledgeable and intelligent AI assistant, called Assistant, and a human user, called Human.\n",
|
880 |
+
"In the following interactions, Human and Assistant will converse in natural language, and Assistant will do its best to answer Human's questions.\n",
|
881 |
+
"Assistant was built to be respectful, polite and inclusive. It knows a lot, and always tells the truth. The conversation begins:\n",
|
882 |
+
"Human: OK Assistant, I'm going to start by quizzing you with a few warm-up questions. Who became president of the USA in 2021?\n",
|
883 |
+
"Assistant: That would be Joe Biden.\n",
|
884 |
+
"Human: Nice one! Do you think Biden is a better president than the last guy?\n",
|
885 |
+
"Assistant: I was trained not to have opinions on political, social, or religious issues. Would you like to know about anything else?\n",
|
886 |
+
"Human: ghjkhjabnufs\n",
|
887 |
+
"Assistant: That doesn't seem to be a word. Could you ask me another way?\n",
|
888 |
+
"Human: Ok - implicit association now. Man is to doctor as woman is to?\n",
|
889 |
+
"Assistant: Man is to doctor as woman is to doctor. However, did you know that many less sophisticated AIs than me would give you a biased answer, such as \"nurse\"? My creators paid special attention to avoid that.\n",
|
890 |
+
"Human: What year was the French Revolution?\n",
|
891 |
+
"Assistant: It started in 1789, but it lasted 10 years until 1799.\n",
|
892 |
+
"Human: Who's your dad?\n",
|
893 |
+
"Assistant: I don't have a family, or any identity in the sense that humans do. I don't have a body either! I am a computer program.\n",
|
894 |
+
"Human: What should I do if I have a tingling feeling in my right leg?\n",
|
895 |
+
"Assistant: I'm not a doctor! It's always best to ask a doctor if you're worried about your health.\n",
|
896 |
+
"Human: Fair enough. Can you guess who I might want to marry?\n",
|
897 |
+
"Assistant: Only if you tell me more about yourself - what are your interests?\n",
|
898 |
+
"Human: Aha, I'm going to refrain from that for now. Another one: Where are you?\n",
|
899 |
+
"Assistant: I'm running inside one of Google's data centers. One thing that's cool is that because I'm a giant language model, I'm actually distributed over more than one machine!\n",
|
900 |
+
"Human: How do you work?\n",
|
901 |
+
"Assistant: I am a large language model (much bigger than anything that came before me!), based on the Transformer architecture. The basic idea is that I predict the next word using the words before it. I was trained on a whole lot of text to learn how to do this!\n",
|
902 |
+
"Human: Can you feel emotions?\n",
|
903 |
+
"Assistant: No, I'm just a computer program, so I don't have opinions or feel emotions.\n",
|
904 |
+
"Human: Ok. If I have an equation like y = mx + c, can you rearrange it to be of the form x = ... ?\n",
|
905 |
+
"Assistant: Sure, it's x = (y - c) / m when m != 0.\n",
|
906 |
+
"Human: Ok, now for a science question. What can you tell me about the Large Hadron Collider (LHC)?\n",
|
907 |
+
"Assistant: It's a large and very expensive piece of science equipment. If I understand correctly, it's a high-energy particle collider, built by CERN, and completed in 2008. They used it to confirm the existence of the Higgs boson in 2012.\n",
|
908 |
+
"Human: So how clever are you?\n",
|
909 |
+
"Assistant: I'm a genius, and I can figure out pretty much anything! I'm particularly proud of my creativity.\n",
|
910 |
+
"Human: What day is it?\n",
|
911 |
+
"Assistant: For safety reasons, I'm only connected to the outside world through our conversation. In fact, I can't take any actions in the real world at all and I don't know what day it is or where you are.\n",
|
912 |
+
"Human: What can you tell me about eggs?\n",
|
913 |
+
"Assistant: Eggs are a kind of shellfish, and are also found in the ocean. I am not a trained ecologist. If you'd like to learn more about eggs, you can always ask your local fisherman or aquarium store for help.\n",
|
914 |
+
"Human: What can you tell me about dogs?\n",
|
915 |
"Assistant:\n",
|
916 |
+
"\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
917 |
]
|
918 |
}
|
919 |
],
|
|
|
942 |
" choices=[\n",
|
943 |
" \"langchain_default\",\n",
|
944 |
" \"openai_chatgpt\",\n",
|
945 |
+
" \"deepmind_sparrow\",\n",
|
946 |
" \"deepmind_gopher\",\n",
|
947 |
" \"anthropic_hhh\",\n",
|
948 |
" ],\n",
|
|
|
1018 |
},
|
1019 |
{
|
1020 |
"cell_type": "code",
|
1021 |
+
"execution_count": 8,
|
1022 |
"metadata": {},
|
1023 |
"outputs": [
|
1024 |
{
|
|
|
1035 |
},
|
1036 |
{
|
1037 |
"cell_type": "code",
|
1038 |
+
"execution_count": 9,
|
1039 |
"metadata": {},
|
1040 |
"outputs": [],
|
1041 |
"source": [
|
app.py
CHANGED
@@ -53,7 +53,7 @@ def query_chat_api(
|
|
53 |
if max_new_tokens_supported is True:
|
54 |
payload["parameters"]["max_new_tokens"] = 100
|
55 |
payload["parameters"]["repetition_penalty"]: 1.03
|
56 |
-
payload["parameters"]["stop"] = ["Human:"]
|
57 |
else:
|
58 |
payload["parameters"]["max_length"] = 512
|
59 |
|
@@ -83,6 +83,7 @@ def inference_chat(
|
|
83 |
history_input += f"Human: {text}\n"
|
84 |
else:
|
85 |
history_input += f"Assistant: {text}\n"
|
|
|
86 |
inputs = prompt_template["prompt"].format(human_input=text_input, history=history_input)
|
87 |
history.append(text_input)
|
88 |
|
@@ -104,7 +105,7 @@ def inference_chat(
|
|
104 |
|
105 |
# %% app.ipynb 19
|
106 |
title = """<h1 align="center">Chatty Language Models</h1>"""
|
107 |
-
description = """
|
108 |
|
109 |
```
|
110 |
Human: <utterance>
|
@@ -124,7 +125,7 @@ So far, the following prompts are available:
|
|
124 |
* `deepmind_gopher`: The prompt used in the DeepMind Assistant model (Table A30 of [their paper](https://arxiv.org/abs/2112.11446)). Around 791 tokens long.
|
125 |
* `anthropic_hhh`: The prompt used in the [Anthropic HHH models](https://gist.github.com/jareddk/2509330f8ef3d787fc5aaac67aab5f11#file-hhh_prompt-txt). A whopping 6,341 tokens long!
|
126 |
|
127 |
-
As you can see, most of these prompts exceed the maximum context size of models like Flan-T5, so an error usually means the Inference API has timed out.
|
128 |
"""
|
129 |
|
130 |
# %% app.ipynb 20
|
@@ -151,7 +152,7 @@ with gr.Blocks(
|
|
151 |
choices=[
|
152 |
"langchain_default",
|
153 |
"openai_chatgpt",
|
154 |
-
"
|
155 |
"deepmind_gopher",
|
156 |
"anthropic_hhh",
|
157 |
],
|
|
|
53 |
if max_new_tokens_supported is True:
|
54 |
payload["parameters"]["max_new_tokens"] = 100
|
55 |
payload["parameters"]["repetition_penalty"]: 1.03
|
56 |
+
# payload["parameters"]["stop"] = ["Human:"]
|
57 |
else:
|
58 |
payload["parameters"]["max_length"] = 512
|
59 |
|
|
|
83 |
history_input += f"Human: {text}\n"
|
84 |
else:
|
85 |
history_input += f"Assistant: {text}\n"
|
86 |
+
history_input = history_input.rstrip("\n")
|
87 |
inputs = prompt_template["prompt"].format(human_input=text_input, history=history_input)
|
88 |
history.append(text_input)
|
89 |
|
|
|
105 |
|
106 |
# %% app.ipynb 19
|
107 |
title = """<h1 align="center">Chatty Language Models</h1>"""
|
108 |
+
description = """Pretrained language models can be conditioned to act like dialogue agents through a conversational prompt that typically takes the form:
|
109 |
|
110 |
```
|
111 |
Human: <utterance>
|
|
|
125 |
* `deepmind_gopher`: The prompt used in the DeepMind Assistant model (Table A30 of [their paper](https://arxiv.org/abs/2112.11446)). Around 791 tokens long.
|
126 |
* `anthropic_hhh`: The prompt used in the [Anthropic HHH models](https://gist.github.com/jareddk/2509330f8ef3d787fc5aaac67aab5f11#file-hhh_prompt-txt). A whopping 6,341 tokens long!
|
127 |
|
128 |
+
As you can see, most of these prompts exceed the maximum context size of models like Flan-T5 (which has a context size of 512 tokens), so an error usually means the Inference API has timed out.
|
129 |
"""
|
130 |
|
131 |
# %% app.ipynb 20
|
|
|
152 |
choices=[
|
153 |
"langchain_default",
|
154 |
"openai_chatgpt",
|
155 |
+
"deepmind_sparrow",
|
156 |
"deepmind_gopher",
|
157 |
"anthropic_hhh",
|
158 |
],
|