Spaces:
Runtime error
Runtime error
Commit
·
6a785f3
1
Parent(s):
8d183f5
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
hf_tag = "facebook/xglm-4.5B"
|
| 3 |
+
xglm_model = pipeline('text-generation', model=hf_tag)
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def query_xglm(prompt:str, print_response=True, min_rl=40, max_rl=260):
|
| 7 |
+
result =xglm_model(prompt,
|
| 8 |
+
do_sample=True,
|
| 9 |
+
min_length=min_rl+len(prompt),
|
| 10 |
+
max_length=max_rl+len(prompt),
|
| 11 |
+
top_k=40,
|
| 12 |
+
temperature=0.6,
|
| 13 |
+
clean_up_tokenization_spaces=True)
|
| 14 |
+
|
| 15 |
+
return result[0]['generated_text']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
face=gr.Interface(
|
| 19 |
+
fn=query_xglm,
|
| 20 |
+
inputs=['text'],
|
| 21 |
+
outputs=['text'],
|
| 22 |
+
title='MULTILINGUAL TEXT GENERATION',
|
| 23 |
+
examples=samples
|
| 24 |
+
)
|
| 25 |
+
face.launch()
|