Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,6 @@ model = AutoModelForSequenceClassification.from_pretrained(
|
|
13 |
model_path,
|
14 |
num_labels=1,
|
15 |
load_in_8bit=True,
|
16 |
-
device_map={'': device(type='cuda', index=0)}
|
17 |
)
|
18 |
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
19 |
model.eval()
|
@@ -22,6 +21,12 @@ model.eval()
|
|
22 |
|
23 |
@spaces.GPU(duration=60, enable_queue=True)
|
24 |
def predict(title, abstract):
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
text = f'''Given a certain paper, Title: {title}\n Abstract: {abstract}. \n Predict its normalized academic impact (between 0 and 1):'''
|
26 |
inputs = tokenizer(text, return_tensors="pt").to(device)
|
27 |
with torch.no_grad():
|
|
|
13 |
model_path,
|
14 |
num_labels=1,
|
15 |
load_in_8bit=True,
|
|
|
16 |
)
|
17 |
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
18 |
model.eval()
|
|
|
21 |
|
22 |
@spaces.GPU(duration=60, enable_queue=True)
|
23 |
def predict(title, abstract):
|
24 |
+
model = AutoModelForSequenceClassification.from_pretrained(
|
25 |
+
model_path,
|
26 |
+
num_labels=1,
|
27 |
+
load_in_8bit=True,
|
28 |
+
device_map={'': device(type='cuda', index=0)}
|
29 |
+
)
|
30 |
text = f'''Given a certain paper, Title: {title}\n Abstract: {abstract}. \n Predict its normalized academic impact (between 0 and 1):'''
|
31 |
inputs = tokenizer(text, return_tensors="pt").to(device)
|
32 |
with torch.no_grad():
|