Spaces:
Runtime error
Runtime error
Younes Belkada
commited on
Commit
路
c3dc4f2
1
Parent(s):
2c122c8
fix small errors
Browse files
app.py
CHANGED
|
@@ -14,9 +14,9 @@ hf_writer = gr.HuggingFaceDatasetSaver(HF_API_TOKEN, "huggingface/bloom_internal
|
|
| 14 |
|
| 15 |
|
| 16 |
examples = [
|
| 17 |
-
['A "whatpu" is a small, furry animal native to Tanzania. An example of a sentence that uses the word whatpu is: We were traveling in Africa and we saw these very cute whatpus. To do a "farduddle" means to jump up and down really fast. An example of a sentence that uses the word farduddle is:', 8, 0.1, 0, 0.9, False],
|
| 18 |
-
['def quicksort(l):', 8, 0.1, 0, 0.9, False],
|
| 19 |
-
['Q: 驴C贸mo te llamas? A: What is your name? Q: 驴Qu茅 edad tienes? A: How old are you? Q: 驴D贸nde vives?', 8, 0.1, 0, 0.9, False]
|
| 20 |
]
|
| 21 |
|
| 22 |
def safe_text(text):
|
|
@@ -37,10 +37,16 @@ def query(payload):
|
|
| 37 |
|
| 38 |
def inference(input_sentence, max_length, no_repeat_ngram_size, num_beams, temperature,top_k, top_p, greedy_decoding, seed=42):
|
| 39 |
top_k = None if top_k == 0 else top_k
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
payload = {"inputs": input_sentence,
|
| 42 |
"parameters": {"max_new_tokens": max_length, "top_k": top_k, "top_p": top_p, "temperature": temperature,
|
| 43 |
-
"do_sample":
|
| 44 |
data = query(
|
| 45 |
payload
|
| 46 |
)
|
|
|
|
| 14 |
|
| 15 |
|
| 16 |
examples = [
|
| 17 |
+
['A "whatpu" is a small, furry animal native to Tanzania. An example of a sentence that uses the word whatpu is: We were traveling in Africa and we saw these very cute whatpus. To do a "farduddle" means to jump up and down really fast. An example of a sentence that uses the word farduddle is:', 8, 0, 0, 0.1, 0, 0.9, False],
|
| 18 |
+
['def quicksort(l):', 8, 0, 0, 0.1, 0, 0.9, False],
|
| 19 |
+
['Q: 驴C贸mo te llamas? A: What is your name? Q: 驴Qu茅 edad tienes? A: How old are you? Q: 驴D贸nde vives?', 8, 0, 0, 0.1, 0, 0.9, False]
|
| 20 |
]
|
| 21 |
|
| 22 |
def safe_text(text):
|
|
|
|
| 37 |
|
| 38 |
def inference(input_sentence, max_length, no_repeat_ngram_size, num_beams, temperature,top_k, top_p, greedy_decoding, seed=42):
|
| 39 |
top_k = None if top_k == 0 else top_k
|
| 40 |
+
do_sample = False if num_beams > 0 else not greedy_decoding
|
| 41 |
+
num_beams = None if (greedy_decoding or num_beams == 0) else num_beams
|
| 42 |
+
no_repeat_ngram_size = None if num_beams is None else no_repeat_ngram_size
|
| 43 |
+
top_p = None if num_beams else top_p
|
| 44 |
+
|
| 45 |
+
early_stopping = None if num_beams is None else num_beams > 0
|
| 46 |
+
|
| 47 |
payload = {"inputs": input_sentence,
|
| 48 |
"parameters": {"max_new_tokens": max_length, "top_k": top_k, "top_p": top_p, "temperature": temperature,
|
| 49 |
+
"do_sample": do_sample, "seed": seed, "early_stopping":early_stopping, "no_repeat_ngram_size":no_repeat_ngram_size, "num_beams":num_beams}}
|
| 50 |
data = query(
|
| 51 |
payload
|
| 52 |
)
|