Spaces:
Runtime error
Runtime error
liujch1998
commited on
Commit
Β·
f53b36c
1
Parent(s):
89bf924
Debug
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cp
|
|
7 |
|
8 |
class Interactive:
|
9 |
def __init__(self):
|
|
|
10 |
self.tokenizer = transformers.AutoTokenizer.from_pretrained('liujch1998/cd-pi', use_auth_token=os.environ['HF_TOKEN_DOWNLOAD'])
|
11 |
self.model = transformers.AutoModelForSeq2SeqLM.from_pretrained('liujch1998/cd-pi', use_auth_token=os.environ['HF_TOKEN_DOWNLOAD']).to(device)
|
12 |
self.linear = torch.nn.Linear(self.model.shared.embedding_dim, 1).to(device)
|
@@ -14,6 +15,7 @@ class Interactive:
|
|
14 |
# self.linear.bias = torch.nn.Parameter(self.model.shared.weight[32098, 0].unsqueeze(0)) # (1)
|
15 |
self.model.eval()
|
16 |
self.t = 2.2247
|
|
|
17 |
|
18 |
def run(self, statement):
|
19 |
input_ids = self.tokenizer.batch_encode_plus([statement], return_tensors='pt', padding='longest').input_ids.to(device)
|
|
|
7 |
|
8 |
class Interactive:
|
9 |
def __init__(self):
|
10 |
+
print('Init invoked')
|
11 |
self.tokenizer = transformers.AutoTokenizer.from_pretrained('liujch1998/cd-pi', use_auth_token=os.environ['HF_TOKEN_DOWNLOAD'])
|
12 |
self.model = transformers.AutoModelForSeq2SeqLM.from_pretrained('liujch1998/cd-pi', use_auth_token=os.environ['HF_TOKEN_DOWNLOAD']).to(device)
|
13 |
self.linear = torch.nn.Linear(self.model.shared.embedding_dim, 1).to(device)
|
|
|
15 |
# self.linear.bias = torch.nn.Parameter(self.model.shared.weight[32098, 0].unsqueeze(0)) # (1)
|
16 |
self.model.eval()
|
17 |
self.t = 2.2247
|
18 |
+
print('Init finished')
|
19 |
|
20 |
def run(self, statement):
|
21 |
input_ids = self.tokenizer.batch_encode_plus([statement], return_tensors='pt', padding='longest').input_ids.to(device)
|