Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,56 +1,42 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import requests
|
| 3 |
-
import asyncio
|
| 4 |
import time
|
| 5 |
from ast import literal_eval
|
| 6 |
-
import urllib.parse
|
| 7 |
-
from dacite import from_dict
|
| 8 |
-
from together_web3.computer import LanguageModelInferenceRequest
|
| 9 |
-
from together_web3.together import TogetherWeb3
|
| 10 |
-
|
| 11 |
-
st.title("GPT-JT")
|
| 12 |
-
if 'together_web3' not in st.session_state:
|
| 13 |
-
st.session_state.together_web3 = TogetherWeb3()
|
| 14 |
-
if 'loop' not in st.session_state:
|
| 15 |
-
st.session_state.loop = asyncio.new_event_loop()
|
| 16 |
-
async def _inference(prompt, max_tokens, stop, top_p, temperature, seed):
|
| 17 |
-
result = await st.session_state.together_web3.language_model_inference(
|
| 18 |
-
from_dict(
|
| 19 |
-
data_class=LanguageModelInferenceRequest,
|
| 20 |
-
data={
|
| 21 |
-
"model": "Together-gpt-JT-6B-v1",
|
| 22 |
-
"max_tokens": max_tokens,
|
| 23 |
-
"prompt": prompt,
|
| 24 |
-
"stop": stop,
|
| 25 |
-
"top_p": top_p,
|
| 26 |
-
"temperature": temperature,
|
| 27 |
-
"seed": seed,
|
| 28 |
-
}
|
| 29 |
-
),
|
| 30 |
-
)
|
| 31 |
-
return result
|
| 32 |
|
| 33 |
@st.cache
|
| 34 |
def infer(prompt,
|
| 35 |
model_name,
|
| 36 |
max_new_tokens=10,
|
| 37 |
-
temperature=
|
| 38 |
top_p=1.0,
|
| 39 |
num_completions=1,
|
| 40 |
seed=42,
|
| 41 |
stop="\n"):
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
|
|
|
|
|
|
| 48 |
col1, col2 = st.columns([1, 3])
|
| 49 |
|
| 50 |
with col1:
|
| 51 |
model_name = st.selectbox("Model", ["GPT-JT-6B-v1"])
|
| 52 |
max_new_tokens = st.text_input('Max new tokens', "10")
|
| 53 |
-
temperature = st.text_input('temperature', "
|
| 54 |
top_p = st.text_input('top_p', "1.0")
|
| 55 |
num_completions = st.text_input('num_completions (only the best one will be returend)', "1")
|
| 56 |
stop = st.text_input('stop, split by;', r'\n')
|
|
@@ -76,4 +62,4 @@ with col2:
|
|
| 76 |
prompt, model_name=model_name, max_new_tokens=max_new_tokens, temperature=temperature, top_p=top_p,
|
| 77 |
num_completions=num_completions, seed=seed, stop=literal_eval("'''"+stop+"'''"),
|
| 78 |
)
|
| 79 |
-
generated_area.text(prompt + report_text)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import requests
|
|
|
|
| 3 |
import time
|
| 4 |
from ast import literal_eval
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
@st.cache
|
| 7 |
def infer(prompt,
|
| 8 |
model_name,
|
| 9 |
max_new_tokens=10,
|
| 10 |
+
temperature=0.0,
|
| 11 |
top_p=1.0,
|
| 12 |
num_completions=1,
|
| 13 |
seed=42,
|
| 14 |
stop="\n"):
|
| 15 |
+
|
| 16 |
+
model_name_map = {
|
| 17 |
+
"GPT-JT-6B-v1": "Together-gpt-JT-6B-v1",
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
my_post_dict = {
|
| 21 |
+
"model": "Together-gpt-JT-6B-v1",
|
| 22 |
+
"prompt": prompt,
|
| 23 |
+
"top_p": float(top_p),
|
| 24 |
+
"temperature": float(temperature),
|
| 25 |
+
"max_tokens": int(max_new_tokens),
|
| 26 |
+
"stop": stop.split(";")
|
| 27 |
+
}
|
| 28 |
+
response = requests.get("https://staging.together.xyz/api/inference", params=my_post_dict).json()
|
| 29 |
+
return response['output']['choices'][0]['text']
|
| 30 |
+
|
| 31 |
|
| 32 |
+
st.title("GPT-JT")
|
| 33 |
+
|
| 34 |
col1, col2 = st.columns([1, 3])
|
| 35 |
|
| 36 |
with col1:
|
| 37 |
model_name = st.selectbox("Model", ["GPT-JT-6B-v1"])
|
| 38 |
max_new_tokens = st.text_input('Max new tokens', "10")
|
| 39 |
+
temperature = st.text_input('temperature', "0.0")
|
| 40 |
top_p = st.text_input('top_p', "1.0")
|
| 41 |
num_completions = st.text_input('num_completions (only the best one will be returend)', "1")
|
| 42 |
stop = st.text_input('stop, split by;', r'\n')
|
|
|
|
| 62 |
prompt, model_name=model_name, max_new_tokens=max_new_tokens, temperature=temperature, top_p=top_p,
|
| 63 |
num_completions=num_completions, seed=seed, stop=literal_eval("'''"+stop+"'''"),
|
| 64 |
)
|
| 65 |
+
generated_area.text(prompt + report_text)
|