Spaces:
Runtime error
Runtime error
peter szemraj
commited on
Commit
•
2979040
1
Parent(s):
5b5e54c
reset model back to size L because XL breaks things
Browse files- ai_single_response.py +18 -21
- app.py +3 -0
ai_single_response.py
CHANGED
@@ -16,6 +16,7 @@ import time
|
|
16 |
import warnings
|
17 |
from datetime import datetime
|
18 |
from pathlib import Path
|
|
|
19 |
from utils import print_spacer, cleantxt_wrap
|
20 |
|
21 |
warnings.filterwarnings(action="ignore", message=".*gradient_checkpointing*")
|
@@ -118,27 +119,24 @@ def query_gpt_model(
|
|
118 |
use_gpu=False,
|
119 |
):
|
120 |
"""
|
121 |
-
query_gpt_model
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
Returns:
|
137 |
-
[dict]: [returns a dict with A) just model response as str B) total conversation]
|
138 |
"""
|
139 |
ai = aitextgen(
|
140 |
-
|
141 |
-
model="pszemraj/Ballpark-Trivia-XL",
|
142 |
to_gpu=use_gpu,
|
143 |
)
|
144 |
|
@@ -187,8 +185,7 @@ def query_gpt_model(
|
|
187 |
bot_resp = ", ".join(bot_dialogue)
|
188 |
bot_resp = bot_resp.strip()
|
189 |
# remove the last ',' '.' chars
|
190 |
-
bot_resp = bot_resp
|
191 |
-
bot_resp = bot_resp[:-1] if bot_resp.endswith(",") else bot_resp
|
192 |
if verbose:
|
193 |
print("\n... bot response:\n")
|
194 |
pp.pprint(bot_resp)
|
|
|
16 |
import warnings
|
17 |
from datetime import datetime
|
18 |
from pathlib import Path
|
19 |
+
from grammar_improve import remove_trailing_punctuation
|
20 |
from utils import print_spacer, cleantxt_wrap
|
21 |
|
22 |
warnings.filterwarnings(action="ignore", message=".*gradient_checkpointing*")
|
|
|
119 |
use_gpu=False,
|
120 |
):
|
121 |
"""
|
122 |
+
query_gpt_model - the main function that calls the model.
|
123 |
+
|
124 |
+
Parameters:
|
125 |
+
-----------
|
126 |
+
prompt_msg (str): the prompt to be sent to the model
|
127 |
+
speaker (str, optional): the name of the speaker. Defaults to None.
|
128 |
+
responder (str, optional): the name of the responder. Defaults to None.
|
129 |
+
resp_length (int, optional): the length of the response. Defaults to 128.
|
130 |
+
resp_min (int, optional): the minimum length of the response. Defaults to 4.
|
131 |
+
kparam (int, optional): the k parameter for the top_p. Defaults to 150.
|
132 |
+
temp (float, optional): the temperature for the top_p. Defaults to 0.75.
|
133 |
+
top_p (float, optional): the top_p parameter for the top_p. Defaults to 0.65.
|
134 |
+
verbose (bool, optional): 4 debug. Defaults to False.
|
135 |
+
use_gpu (bool, optional): use gpu. Defaults to False.
|
|
|
|
|
|
|
136 |
"""
|
137 |
ai = aitextgen(
|
138 |
+
model="pszemraj/Ballpark-Trivia-L", # THIS WORKS
|
139 |
+
# model="pszemraj/Ballpark-Trivia-XL", # does not seem to work
|
140 |
to_gpu=use_gpu,
|
141 |
)
|
142 |
|
|
|
185 |
bot_resp = ", ".join(bot_dialogue)
|
186 |
bot_resp = bot_resp.strip()
|
187 |
# remove the last ',' '.' chars
|
188 |
+
bot_resp = remove_trailing_punctuation(bot_resp)
|
|
|
189 |
if verbose:
|
190 |
print("\n... bot response:\n")
|
191 |
pp.pprint(bot_resp)
|
app.py
CHANGED
@@ -153,6 +153,7 @@ if __name__ == "__main__":
|
|
153 |
chat,
|
154 |
inputs=["text"],
|
155 |
outputs="html",
|
|
|
156 |
title=f"Ballpark Trivia: {default_model} Model",
|
157 |
description=f"Are you frequently asked google-able Trivia questions and annoyed by it? Well, this is the app for you! Ballpark Trivia Bot answers any trivia question with something that sounds plausible but is probably not 100% correct. \n\n One might say.. the answers are in the right ballpark.",
|
158 |
article="Further details can be found in the [model card](https://huggingface.co/pszemraj/Ballpark-Trivia-L). If you are interested in a more deceptively incorrect model, there is also [an XL version](https://huggingface.co/pszemraj/Ballpark-Trivia-XL) on my page.\n\n"
|
@@ -165,6 +166,7 @@ if __name__ == "__main__":
|
|
165 |
.user_msg {background-color:cornflowerblue;color:white;align-self:start}
|
166 |
.resp_msg {background-color:lightgray;align-self:self-end}
|
167 |
""",
|
|
|
168 |
allow_screenshot=True,
|
169 |
allow_flagging=False,
|
170 |
enable_queue=True, # allows for dealing with multiple users simultaneously
|
@@ -175,4 +177,5 @@ if __name__ == "__main__":
|
|
175 |
iface.launch(
|
176 |
share=True,
|
177 |
enable_queue=True, # also allows for dealing with multiple users simultaneously (per newer gradio version)
|
|
|
178 |
)
|
|
|
153 |
chat,
|
154 |
inputs=["text"],
|
155 |
outputs="html",
|
156 |
+
examples=["when was Katy Perry born?"],
|
157 |
title=f"Ballpark Trivia: {default_model} Model",
|
158 |
description=f"Are you frequently asked google-able Trivia questions and annoyed by it? Well, this is the app for you! Ballpark Trivia Bot answers any trivia question with something that sounds plausible but is probably not 100% correct. \n\n One might say.. the answers are in the right ballpark.",
|
159 |
article="Further details can be found in the [model card](https://huggingface.co/pszemraj/Ballpark-Trivia-L). If you are interested in a more deceptively incorrect model, there is also [an XL version](https://huggingface.co/pszemraj/Ballpark-Trivia-XL) on my page.\n\n"
|
|
|
166 |
.user_msg {background-color:cornflowerblue;color:white;align-self:start}
|
167 |
.resp_msg {background-color:lightgray;align-self:self-end}
|
168 |
""",
|
169 |
+
live=True,
|
170 |
allow_screenshot=True,
|
171 |
allow_flagging=False,
|
172 |
enable_queue=True, # allows for dealing with multiple users simultaneously
|
|
|
177 |
iface.launch(
|
178 |
share=True,
|
179 |
enable_queue=True, # also allows for dealing with multiple users simultaneously (per newer gradio version)
|
180 |
+
show_tips=True,
|
181 |
)
|