Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import torch
|
2 |
from transformers import GPT2LMHeadModel, GPT2Tokenizer
|
3 |
import gradio as gr
|
@@ -24,6 +25,7 @@ model.to(device)
|
|
24 |
os.system('python -m spacy download en_core_web_sm')
|
25 |
nlp = spacy.load("en_core_web_sm")
|
26 |
|
|
|
27 |
def historical_generation(prompt, max_new_tokens=600, top_k=50, temperature=0.7, top_p=0.95, repetition_penalty=1.0):
|
28 |
# with torch.no_grad():
|
29 |
prompt = f"### Text ###\n{prompt}"
|
@@ -63,6 +65,7 @@ def historical_generation(prompt, max_new_tokens=600, top_k=50, temperature=0.7,
|
|
63 |
|
64 |
return highlighted_text, generated_text
|
65 |
|
|
|
66 |
def text_analysis(text):
|
67 |
doc = nlp(text)
|
68 |
html = displacy.render(doc, style="dep", page=True)
|
|
|
1 |
+
import spaces
|
2 |
import torch
|
3 |
from transformers import GPT2LMHeadModel, GPT2Tokenizer
|
4 |
import gradio as gr
|
|
|
25 |
os.system('python -m spacy download en_core_web_sm')
|
26 |
nlp = spacy.load("en_core_web_sm")
|
27 |
|
28 |
+
@spaces.GPU
|
29 |
def historical_generation(prompt, max_new_tokens=600, top_k=50, temperature=0.7, top_p=0.95, repetition_penalty=1.0):
|
30 |
# with torch.no_grad():
|
31 |
prompt = f"### Text ###\n{prompt}"
|
|
|
65 |
|
66 |
return highlighted_text, generated_text
|
67 |
|
68 |
+
@spaces.GPU
|
69 |
def text_analysis(text):
|
70 |
doc = nlp(text)
|
71 |
html = displacy.render(doc, style="dep", page=True)
|