Spaces:
Sleeping
Sleeping
first commit
Browse files
app.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import requests
|
3 |
+
import json
|
4 |
+
def greet(data):
|
5 |
+
headers = {
|
6 |
+
"Authorization": "Bearer 325618b3f00d46a3bdb01340",
|
7 |
+
"Content-Type": "application/json"
|
8 |
+
}
|
9 |
+
|
10 |
+
body = {
|
11 |
+
"text": data,
|
12 |
+
|
13 |
+
"message" : "",
|
14 |
+
"top_p": 0.7, #DEFAULT 0.8 Top-P is an alternative way of controlling the randomness and creativity of the generated text. We recommend that only one of Temperature or Top P are used,
|
15 |
+
#so when using one of them, make sure that the other is set to 1. A rough rule of thumb is that Top-P provides better control for applications in which GPT-J is expected to generate text with accuracy and correctness,
|
16 |
+
#while Temperature works best for those applications in which original, creative or even amusing responses are sought.
|
17 |
+
"top_k": 60, #DEFAULT 40 Top-K sampling means sorting by probability and zero-ing out the probabilities for anything below the k'th token. A lower value improves quality by removing the tail and making it less likely to go off topic.
|
18 |
+
"temperature": 0.5, #DEFAULT 0.0, Temperature controls the randomness of the generated text. A value of 0 makes the engine deterministic, which means that it will always generate the same output for a given input text. A value of 1 makes the engine take the most risks and use a lot of creativity.
|
19 |
+
#As a frame of reference, it is common for story completion or idea generation to see temperature values between 0.7 to 0.9.
|
20 |
+
"repetition_penalty": 1.0, #DEFAULT 1.0 Repetition penalty works by lowering the chances of a word being selected again the more times that word has already been used. In other words, it works to prevent repetitive word usage.
|
21 |
+
"length": 300
|
22 |
+
}
|
23 |
+
|
24 |
+
res = requests.post(
|
25 |
+
"https://shared-api.forefront.link/organization/GuejzaCOIXGT/codegen-16b-nl/completions/Gu6OxnDd8Tur",
|
26 |
+
json=body,
|
27 |
+
headers=headers
|
28 |
+
)
|
29 |
+
|
30 |
+
data = res.json()
|
31 |
+
return data['result']
|
32 |
+
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
33 |
+
iface.launch()
|