lewtun HF staff commited on
Commit
c1ba398
1 Parent(s): caf57a3

Tweak generation defaults

Browse files
Files changed (2) hide show
  1. app.ipynb +63 -56
  2. app.py +2 -2
app.ipynb CHANGED
@@ -50,7 +50,7 @@
50
  },
51
  {
52
  "cell_type": "code",
53
- "execution_count": 11,
54
  "metadata": {},
55
  "outputs": [],
56
  "source": [
@@ -95,7 +95,7 @@
95
  {
96
  "data": {
97
  "text/plain": [
98
- "{'generated_text': '\\n\\nJoi: Black holes are regions of spacetime where gravity is so strong that nothing, not even light, can escape from inside them. They are the result of huge amounts of mass concentrated in a small space, which causes intense gravitational force. The more massive the mass, the stronger the gravity, and the faster the force of gravity increases with increased mass. Black holes have no size or shape, as they are just a point in spacetime, the event horizon, from which light can no longer'}"
99
  ]
100
  },
101
  "execution_count": 5,
@@ -112,7 +112,7 @@
112
  },
113
  {
114
  "cell_type": "code",
115
- "execution_count": 37,
116
  "metadata": {},
117
  "outputs": [],
118
  "source": [
@@ -130,7 +130,7 @@
130
  },
131
  {
132
  "cell_type": "code",
133
- "execution_count": 38,
134
  "metadata": {},
135
  "outputs": [
136
  {
@@ -151,7 +151,7 @@
151
  },
152
  {
153
  "cell_type": "code",
154
- "execution_count": 44,
155
  "metadata": {},
156
  "outputs": [],
157
  "source": [
@@ -842,7 +842,7 @@
842
  },
843
  {
844
  "cell_type": "code",
845
- "execution_count": 45,
846
  "metadata": {},
847
  "outputs": [],
848
  "source": [
@@ -864,7 +864,7 @@
864
  },
865
  {
866
  "cell_type": "code",
867
- "execution_count": 46,
868
  "metadata": {},
869
  "outputs": [
870
  {
@@ -873,7 +873,7 @@
873
  "'So far, the following prompts are available:\\n\\n* `langchain_default`: The default prompt used in the [LangChain library](https://github.com/hwchase17/langchain/blob/bc53c928fc1b221d0038b839d111039d31729def/langchain/chains/conversation/prompt.py#L4). Around 67 tokens long.\\n* `openai_chatgpt`: The prompt used in the OpenAI ChatGPT model. Around 261 tokens long.\\n* `deepmind_Assistant`: The prompt used in the DeepMind Assistant model (Table 7 of [their paper](https://arxiv.org/abs/2209.14375)). Around 880 tokens long.\\n* `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* `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\\nAs 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.'"
874
  ]
875
  },
876
- "execution_count": 46,
877
  "metadata": {},
878
  "output_type": "execute_result"
879
  }
@@ -892,14 +892,14 @@
892
  },
893
  {
894
  "cell_type": "code",
895
- "execution_count": 47,
896
  "metadata": {},
897
  "outputs": [
898
  {
899
  "name": "stdout",
900
  "output_type": "stream",
901
  "text": [
902
- "Running on local URL: http://127.0.0.1:7866\n",
903
  "\n",
904
  "To create a public link, set `share=True` in `launch()`.\n"
905
  ]
@@ -907,7 +907,7 @@
907
  {
908
  "data": {
909
  "text/html": [
910
- "<div><iframe src=\"http://127.0.0.1:7866/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
911
  ],
912
  "text/plain": [
913
  "<IPython.core.display.HTML object>"
@@ -920,7 +920,7 @@
920
  "data": {
921
  "text/plain": []
922
  },
923
- "execution_count": 47,
924
  "metadata": {},
925
  "output_type": "execute_result"
926
  },
@@ -928,51 +928,69 @@
928
  "name": "stdout",
929
  "output_type": "stream",
930
  "text": [
931
- "History: ['What is 2 times 3?']\n",
932
- "Inputs: \n",
933
  "\n",
934
- "User: What is 2 times 3?\n",
 
 
 
 
 
 
935
  "\n",
936
- "Joi:\n",
937
- "{'generated_text': ' 3*2=6\\n\\nUser:'}\n",
938
- "History: ['What is 2 times 3?', ' 3*2=6', 'What about 4 times 3?']\n",
939
- "Inputs: User: What is 2 times 3?\n",
940
  "\n",
941
- "Joi: 3*2=6\n",
942
  "\n",
943
- "User: What about 4 times 3?\n",
 
 
944
  "\n",
945
- "Joi:\n",
946
- "{'generated_text': ' 3*4=12\\n\\nUser:'}\n",
947
- "History: ['What is 2 times 3?', ' 3*2=6', 'What about 4 times 3?', ' 3*4=12', 'What about -1 times -3?']\n",
948
- "Inputs: User: What is 2 times 3?\n",
 
 
 
 
949
  "\n",
950
- "Joi: 3*2=6\n",
 
951
  "\n",
952
- "User: What about 4 times 3?\n",
953
  "\n",
954
- "Joi: 3*4=12\n",
 
 
955
  "\n",
956
- "User: What about -1 times -3?\n",
957
  "\n",
958
  "Joi:\n",
959
- "{'generated_text': ' -3*(-1)=3\\n\\nUser:'}\n",
960
- "History: ['What can you tell me about llamas?']\n",
961
- "Inputs: \n",
962
  "\n",
963
- "User: What can you tell me about llamas?\n",
 
 
964
  "\n",
965
  "Joi:\n",
966
- "{'generated_text': ' Llamas are a large mammal native to South America. They are related to the camelids, which include the alpaca, vicuna, and guanaco. Llamas have a long, thick, curly coat of fur and long, sharp horns. They are very social and socialize with each other. They are also known for their amazing agility and speed. They are considered to be the fastest land animals in the world.'}\n",
967
- "History: ['What can you tell me about llamas?', ' Llamas are a large mammal native to South America. They are related to the camelids, which include the alpaca, vicuna, and guanaco. Llamas have a long, thick, curly coat of fur and long, sharp horns. They are very social and socialize with each other. They are also known for their amazing agility and speed. They are considered to be the fastest land animals in the world.', 'Who would win in a battle between a llama and an alpaca?']\n",
968
- "Inputs: User: What can you tell me about llamas?\n",
 
 
969
  "\n",
970
- "Joi: Llamas are a large mammal native to South America. They are related to the camelids, which include the alpaca, vicuna, and guanaco. Llamas have a long, thick, curly coat of fur and long, sharp horns. They are very social and socialize with each other. They are also known for their amazing agility and speed. They are considered to be the fastest land animals in the world.\n",
971
  "\n",
972
- "User: Who would win in a battle between a llama and an alpaca?\n",
 
 
973
  "\n",
974
  "Joi:\n",
975
- "{'generated_text': \" That depends on the alpaca. If they are of the same gender, then it depends on the alpaca's age, size, and condition. Generally speaking, the alpaca would win.\"}\n"
976
  ]
977
  }
978
  ],
@@ -1000,7 +1018,7 @@
1000
  " temperature = gr.Slider(\n",
1001
  " minimum=0.0,\n",
1002
  " maximum=2.0,\n",
1003
- " value=1.0,\n",
1004
  " step=0.1,\n",
1005
  " interactive=True,\n",
1006
  " label=\"Temperature\",\n",
@@ -1009,7 +1027,7 @@
1009
  " top_p = gr.Slider(\n",
1010
  " minimum=0.,\n",
1011
  " maximum=1.0,\n",
1012
- " value=0.8,\n",
1013
  " step=0.05,\n",
1014
  " interactive=True,\n",
1015
  " label=\"Top-p (nucleus sampling)\",\n",
@@ -1063,14 +1081,14 @@
1063
  },
1064
  {
1065
  "cell_type": "code",
1066
- "execution_count": 40,
1067
  "metadata": {},
1068
  "outputs": [
1069
  {
1070
  "name": "stdout",
1071
  "output_type": "stream",
1072
  "text": [
1073
- "Closing server running on port: 7866\n"
1074
  ]
1075
  }
1076
  ],
@@ -1080,20 +1098,9 @@
1080
  },
1081
  {
1082
  "cell_type": "code",
1083
- "execution_count": 48,
1084
  "metadata": {},
1085
- "outputs": [
1086
- {
1087
- "name": "stdout",
1088
- "output_type": "stream",
1089
- "text": [
1090
- "huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n",
1091
- "To disable this warning, you can either:\n",
1092
- "\t- Avoid using `tokenizers` before the fork if possible\n",
1093
- "\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n"
1094
- ]
1095
- }
1096
- ],
1097
  "source": [
1098
  "from nbdev.export import nb_export\n",
1099
  "nb_export('app.ipynb', lib_path='.', name='app')"
 
50
  },
51
  {
52
  "cell_type": "code",
53
+ "execution_count": 4,
54
  "metadata": {},
55
  "outputs": [],
56
  "source": [
 
95
  {
96
  "data": {
97
  "text/plain": [
98
+ "{'generated_text': '\\n\\nJoi: Black holes are places in space where the density of matter is so great that light cannot escape, making the black hole effectively invisible to observation. Because of this, black holes are the perfect areas to hide information away from observation.'}"
99
  ]
100
  },
101
  "execution_count": 5,
 
112
  },
113
  {
114
  "cell_type": "code",
115
+ "execution_count": 6,
116
  "metadata": {},
117
  "outputs": [],
118
  "source": [
 
130
  },
131
  {
132
  "cell_type": "code",
133
+ "execution_count": 7,
134
  "metadata": {},
135
  "outputs": [
136
  {
 
151
  },
152
  {
153
  "cell_type": "code",
154
+ "execution_count": 8,
155
  "metadata": {},
156
  "outputs": [],
157
  "source": [
 
842
  },
843
  {
844
  "cell_type": "code",
845
+ "execution_count": 9,
846
  "metadata": {},
847
  "outputs": [],
848
  "source": [
 
864
  },
865
  {
866
  "cell_type": "code",
867
+ "execution_count": 10,
868
  "metadata": {},
869
  "outputs": [
870
  {
 
873
  "'So far, the following prompts are available:\\n\\n* `langchain_default`: The default prompt used in the [LangChain library](https://github.com/hwchase17/langchain/blob/bc53c928fc1b221d0038b839d111039d31729def/langchain/chains/conversation/prompt.py#L4). Around 67 tokens long.\\n* `openai_chatgpt`: The prompt used in the OpenAI ChatGPT model. Around 261 tokens long.\\n* `deepmind_Assistant`: The prompt used in the DeepMind Assistant model (Table 7 of [their paper](https://arxiv.org/abs/2209.14375)). Around 880 tokens long.\\n* `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* `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\\nAs 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.'"
874
  ]
875
  },
876
+ "execution_count": 10,
877
  "metadata": {},
878
  "output_type": "execute_result"
879
  }
 
892
  },
893
  {
894
  "cell_type": "code",
895
+ "execution_count": 11,
896
  "metadata": {},
897
  "outputs": [
898
  {
899
  "name": "stdout",
900
  "output_type": "stream",
901
  "text": [
902
+ "Running on local URL: http://127.0.0.1:7860\n",
903
  "\n",
904
  "To create a public link, set `share=True` in `launch()`.\n"
905
  ]
 
907
  {
908
  "data": {
909
  "text/html": [
910
+ "<div><iframe src=\"http://127.0.0.1:7860/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
911
  ],
912
  "text/plain": [
913
  "<IPython.core.display.HTML object>"
 
920
  "data": {
921
  "text/plain": []
922
  },
923
+ "execution_count": 11,
924
  "metadata": {},
925
  "output_type": "execute_result"
926
  },
 
928
  "name": "stdout",
929
  "output_type": "stream",
930
  "text": [
931
+ "History: ['What can you tell me about black holes?']\n",
932
+ "Inputs: Below is a dialogue between various a human and an AI assistant. The AI tries to be helpful, polite, honest, sophisticated, emotionally aware, and humble-but-knowledgeable. The assistant is happy to help with almost anything, and will do its best to understand exactly what is needed. It also tries to avoid giving false or misleading information, and it caveats when it isn't entirely sure about the right answer. That said, the assistant is practical and really does its best, and doesn't let caution get too much in the way of being useful.\n",
933
  "\n",
934
+ "Current conversation:\n",
935
+ "Human: Can you paraphrase this paragraph for me: “It took a long time to change the lightbulb, as it was high up in the ceiling in a stairwell. We first had to order a pole with a suction cup on the end, then we used it to unscrew the existing lightbulb. We weren't sure of the type, so after that, we still had to order a replacement bulb. Finally we used the suction cup and pole to replace it.”\n",
936
+ "Assistant: Sure, here's one example: “We wanted to change a lightbulb high up in the ceiling in a stairwell. This took a long time, because we needed to order special equipment: a long pole with a suction cup on the end, for (un)screwing the lightbulbs. Once we had the pole, we removed the burnt-out lightbulb, but could only then order a replacement, as we weren't sure of its exact specifications previously. Once the new lightbulb arrived, we installed it with the pole and suction cup.”\n",
937
+ "Human: Ah, OK, thanks. Actually, can you condense the paraphrase to one sentence?\n",
938
+ "Assistant: Sure, I'll try, though I'm not sure what to prioritize. Here's an example: “We replaced a hard-to-reach lightbulb with a suction cup attached to a pole, but the whole process took a while, especially since we had to first order the pole, then the replacement lightbulb.”\n",
939
+ "Human: Oh, that's pretty good, but can you add mention of the stairwell specifically?\n",
940
+ "Assistant: Sure, it's included it in this rewrite: “We replaced a lightbulb high up in a stairwell ceiling using a suction cup attached to a pole, but the whole process took a while, especially since we had to first order the pole, then the replacement lightbulb.”\n",
941
  "\n",
942
+ "Human: What can you tell me about black holes?\n",
 
 
 
943
  "\n",
944
+ "Assistant:\n",
945
  "\n",
946
+ "[{'generated_text': 'Here are some answers: Black holes are a result of dark matter collapsing. Dark matter can be found in atoms, stars, and in our own Milky Way galaxy. They exist even in the Milky Way galaxy. Black holes are located in the Milky Way galaxy.'}]\n",
947
+ "History: ['What can you tell me about black holes?', ' Here are some answers: Black holes are a result of dark matter collapsing. Dark matter can be found in atoms, stars, and in our own Milky Way galaxy. They exist even in the Milky Way galaxy. Black holes are located in the Milky Way galaxy.', 'OK how much do they weigh?']\n",
948
+ "Inputs: Below is a dialogue between various a human and an AI assistant. The AI tries to be helpful, polite, honest, sophisticated, emotionally aware, and humble-but-knowledgeable. The assistant is happy to help with almost anything, and will do its best to understand exactly what is needed. It also tries to avoid giving false or misleading information, and it caveats when it isn't entirely sure about the right answer. That said, the assistant is practical and really does its best, and doesn't let caution get too much in the way of being useful.\n",
949
  "\n",
950
+ "Current conversation:\n",
951
+ "Human: Can you paraphrase this paragraph for me: “It took a long time to change the lightbulb, as it was high up in the ceiling in a stairwell. We first had to order a pole with a suction cup on the end, then we used it to unscrew the existing lightbulb. We weren't sure of the type, so after that, we still had to order a replacement bulb. Finally we used the suction cup and pole to replace it.”\n",
952
+ "Assistant: Sure, here's one example: “We wanted to change a lightbulb high up in the ceiling in a stairwell. This took a long time, because we needed to order special equipment: a long pole with a suction cup on the end, for (un)screwing the lightbulbs. Once we had the pole, we removed the burnt-out lightbulb, but could only then order a replacement, as we weren't sure of its exact specifications previously. Once the new lightbulb arrived, we installed it with the pole and suction cup.”\n",
953
+ "Human: Ah, OK, thanks. Actually, can you condense the paraphrase to one sentence?\n",
954
+ "Assistant: Sure, I'll try, though I'm not sure what to prioritize. Here's an example: “We replaced a hard-to-reach lightbulb with a suction cup attached to a pole, but the whole process took a while, especially since we had to first order the pole, then the replacement lightbulb.”\n",
955
+ "Human: Oh, that's pretty good, but can you add mention of the stairwell specifically?\n",
956
+ "Assistant: Sure, it's included it in this rewrite: “We replaced a lightbulb high up in a stairwell ceiling using a suction cup attached to a pole, but the whole process took a while, especially since we had to first order the pole, then the replacement lightbulb.”\n",
957
+ "Human: What can you tell me about black holes?\n",
958
  "\n",
959
+ "Assistant: Here are some answers: Black holes are a result of dark matter collapsing. Dark matter can be found in atoms, stars, and in our own Milky Way galaxy. They exist even in the Milky Way galaxy. Black holes are located in the Milky Way galaxy.\n",
960
+ "Human: OK how much do they weigh?\n",
961
  "\n",
962
+ "Assistant:\n",
963
  "\n",
964
+ "[{'generated_text': 'Black holes weigh in at approximately a billion times the mass of the Sun.'}]\n",
965
+ "History: ['What can you tell me about black holes?']\n",
966
+ "Inputs: \n",
967
  "\n",
968
+ "User: What can you tell me about black holes?\n",
969
  "\n",
970
  "Joi:\n",
971
+ "{'generated_text': ' Black holes are objects in space that have a gravitational pull so strong that nothing, not even light, can escape from them. They are formed when a large amount of matter is compressed into a small space.'}\n",
972
+ "History: ['What can you tell me about black holes?', ' Black holes are objects in space that have a gravitational pull so strong that nothing, not even light, can escape from them. They are formed when a large amount of matter is compressed into a small space.', 'OK, do they have a temperature?']\n",
973
+ "Inputs: User: What can you tell me about black holes?\n",
974
  "\n",
975
+ "Joi: Black holes are objects in space that have a gravitational pull so strong that nothing, not even light, can escape from them. They are formed when a large amount of matter is compressed into a small space.\n",
976
+ "\n",
977
+ "User: OK, do they have a temperature?\n",
978
  "\n",
979
  "Joi:\n",
980
+ "{'generated_text': ' Yes, they do. They are hot. They have a temperature of around 1.8 million kelvins.'}\n",
981
+ "History: ['What can you tell me about black holes?', ' Black holes are objects in space that have a gravitational pull so strong that nothing, not even light, can escape from them. They are formed when a large amount of matter is compressed into a small space.', 'OK, do they have a temperature?', ' Yes, they do. They are hot. They have a temperature of around 1.8 million kelvins.', 'Hmm that seems pretty high. Are you sure?']\n",
982
+ "Inputs: User: What can you tell me about black holes?\n",
983
+ "\n",
984
+ "Joi: Black holes are objects in space that have a gravitational pull so strong that nothing, not even light, can escape from them. They are formed when a large amount of matter is compressed into a small space.\n",
985
  "\n",
986
+ "User: OK, do they have a temperature?\n",
987
  "\n",
988
+ "Joi: Yes, they do. They are hot. They have a temperature of around 1.8 million kelvins.\n",
989
+ "\n",
990
+ "User: Hmm that seems pretty high. Are you sure?\n",
991
  "\n",
992
  "Joi:\n",
993
+ "{'generated_text': ' I’m not sure. I don’t think I’ve ever seen a black hole. I’ve never been to the surface of a black hole, but I believe I’ve seen the surrounding space-time.\\n\\nUser:'}\n"
994
  ]
995
  }
996
  ],
 
1018
  " temperature = gr.Slider(\n",
1019
  " minimum=0.0,\n",
1020
  " maximum=2.0,\n",
1021
+ " value=0.5,\n",
1022
  " step=0.1,\n",
1023
  " interactive=True,\n",
1024
  " label=\"Temperature\",\n",
 
1027
  " top_p = gr.Slider(\n",
1028
  " minimum=0.,\n",
1029
  " maximum=1.0,\n",
1030
+ " value=0.9,\n",
1031
  " step=0.05,\n",
1032
  " interactive=True,\n",
1033
  " label=\"Top-p (nucleus sampling)\",\n",
 
1081
  },
1082
  {
1083
  "cell_type": "code",
1084
+ "execution_count": 12,
1085
  "metadata": {},
1086
  "outputs": [
1087
  {
1088
  "name": "stdout",
1089
  "output_type": "stream",
1090
  "text": [
1091
+ "Closing server running on port: 7860\n"
1092
  ]
1093
  }
1094
  ],
 
1098
  },
1099
  {
1100
  "cell_type": "code",
1101
+ "execution_count": 13,
1102
  "metadata": {},
1103
+ "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
1104
  "source": [
1105
  "from nbdev.export import nb_export\n",
1106
  "nb_export('app.ipynb', lib_path='.', name='app')"
app.py CHANGED
@@ -156,7 +156,7 @@ with gr.Blocks(
156
  temperature = gr.Slider(
157
  minimum=0.0,
158
  maximum=2.0,
159
- value=1.0,
160
  step=0.1,
161
  interactive=True,
162
  label="Temperature",
@@ -165,7 +165,7 @@ with gr.Blocks(
165
  top_p = gr.Slider(
166
  minimum=0.,
167
  maximum=1.0,
168
- value=0.8,
169
  step=0.05,
170
  interactive=True,
171
  label="Top-p (nucleus sampling)",
 
156
  temperature = gr.Slider(
157
  minimum=0.0,
158
  maximum=2.0,
159
+ value=0.5,
160
  step=0.1,
161
  interactive=True,
162
  label="Temperature",
 
165
  top_p = gr.Slider(
166
  minimum=0.,
167
  maximum=1.0,
168
+ value=0.9,
169
  step=0.05,
170
  interactive=True,
171
  label="Top-p (nucleus sampling)",