Spaces:
Sleeping
Sleeping
name and path fixes
Browse files
app.py
CHANGED
|
@@ -7,19 +7,21 @@ import os
|
|
| 7 |
from model import FFNModule, FeatureNormPredictor, FFNParams, TrainingParams
|
| 8 |
|
| 9 |
|
| 10 |
-
def predict (Word, Sentence,
|
| 11 |
models = {'BERT': 'bert-base-uncased',
|
| 12 |
'ALBERT': 'albert-xxlarge-v2',
|
| 13 |
'roBERTa': 'roberta-base'}
|
| 14 |
if Word not in Sentence: return "invalid input: word not in sentence"
|
| 15 |
-
model_name_hf =
|
| 16 |
-
norm_name_hf =
|
| 17 |
-
lm = cwe.CWE(models[
|
| 18 |
|
| 19 |
-
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
model_path = hf_hub_download(f"{
|
| 22 |
-
label_path = hf_hub_download(f"{
|
| 23 |
|
| 24 |
model = FeatureNormPredictor.load_from_checkpoint(
|
| 25 |
checkpoint_path=model_path,
|
|
|
|
| 7 |
from model import FFNModule, FeatureNormPredictor, FFNParams, TrainingParams
|
| 8 |
|
| 9 |
|
| 10 |
+
def predict (Word, Sentence, LLM, Norm, Layer):
|
| 11 |
models = {'BERT': 'bert-base-uncased',
|
| 12 |
'ALBERT': 'albert-xxlarge-v2',
|
| 13 |
'roBERTa': 'roberta-base'}
|
| 14 |
if Word not in Sentence: return "invalid input: word not in sentence"
|
| 15 |
+
model_name_hf = LLM.lower()
|
| 16 |
+
norm_name_hf = Norm.lower()
|
| 17 |
+
lm = cwe.CWE(models[LLM])
|
| 18 |
|
| 19 |
+
repo_id = "jwalanthi/semantic-feature-classifiers"
|
| 20 |
+
subfolder = "{model_name_hf}_models_all"
|
| 21 |
+
name_hf = f"{model_name_hf}_to_{norm_name_hf}_layer{Layer}"
|
| 22 |
|
| 23 |
+
model_path = hf_hub_download(repo_id = repo_id, subfolder=subfolder, filename=f"{name_hf}.ckpt", use_auth_token=os.environ['TOKEN'])
|
| 24 |
+
label_path = hf_hub_download(repo_id = repo_id, subfolder=subfolder, filename=f"{name_hf}.txt", use_auth_token=os.environ['TOKEN'])
|
| 25 |
|
| 26 |
model = FeatureNormPredictor.load_from_checkpoint(
|
| 27 |
checkpoint_path=model_path,
|