Spaces:
Running
Running
updateing app.py with sts lora
Browse files
app.py
CHANGED
@@ -1,15 +1,21 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import pipeline, AutoTokenizer
|
3 |
from peft.auto import AutoPeftModelForSequenceClassification
|
4 |
from tensorboard.backend.event_processing import event_accumulator
|
|
|
5 |
import plotly.express as px
|
6 |
import pandas as pd
|
7 |
|
8 |
-
tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
|
9 |
tokenizer1 = AutoTokenizer.from_pretrained("albert-base-v2")
|
10 |
-
|
11 |
loraModel = AutoPeftModelForSequenceClassification.from_pretrained("Intradiction/text_classification_WithLORA")
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
|
15 |
# Handle calls to DistilBERT------------------------------------------
|
@@ -46,16 +52,16 @@ def AlbertUntrained_fn(text1, text2):
|
|
46 |
|
47 |
# Handle calls to Deberta--------------------------------------------
|
48 |
DebertaUntrained_pipe = pipeline("text-classification", model="microsoft/deberta-v3-xsmall")
|
49 |
-
DebertanoLORA_pipe = pipeline(model="rajevan123/STS-Conventional-Fine-Tuning")
|
50 |
-
|
51 |
|
52 |
#STS models
|
53 |
def DebertanoLORA_fn(text1, text2):
|
54 |
return DebertanoLORA_pipe({'text': text1, 'text_pair': text2})
|
55 |
|
56 |
def DebertawithLORA_fn(text1, text2):
|
57 |
-
|
58 |
-
return ("working2")
|
59 |
|
60 |
def DebertaUntrained_fn(text1, text2):
|
61 |
return DebertaUntrained_pipe({'text': text1, 'text_pair': text2})
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline, AutoTokenizer, AutoModel
|
3 |
from peft.auto import AutoPeftModelForSequenceClassification
|
4 |
from tensorboard.backend.event_processing import event_accumulator
|
5 |
+
from peft import PeftModel
|
6 |
import plotly.express as px
|
7 |
import pandas as pd
|
8 |
|
|
|
9 |
tokenizer1 = AutoTokenizer.from_pretrained("albert-base-v2")
|
10 |
+
|
11 |
loraModel = AutoPeftModelForSequenceClassification.from_pretrained("Intradiction/text_classification_WithLORA")
|
12 |
+
tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
|
13 |
+
|
14 |
+
tokenizer2 = AutoTokenizer.from_pretrained("microsoft/deberta-v3-xsmall")
|
15 |
+
base_model = AutoModel.from_pretrained("microsoft/deberta-v3-xsmall")
|
16 |
+
peft_model_id = "rajevan123/STS-Lora-Fine-Tuning-Capstone-Deberta-small"
|
17 |
+
model = PeftModel.from_pretrained(base_model, peft_model_id)
|
18 |
+
#merged_model = model.merge_and_unload()
|
19 |
|
20 |
|
21 |
# Handle calls to DistilBERT------------------------------------------
|
|
|
52 |
|
53 |
# Handle calls to Deberta--------------------------------------------
|
54 |
DebertaUntrained_pipe = pipeline("text-classification", model="microsoft/deberta-v3-xsmall")
|
55 |
+
DebertanoLORA_pipe = pipeline("text-classification", model="rajevan123/STS-Conventional-Fine-Tuning")
|
56 |
+
DebertawithLORA_pipe = pipeline( model=model, tokenizer=tokenizer2)
|
57 |
|
58 |
#STS models
|
59 |
def DebertanoLORA_fn(text1, text2):
|
60 |
return DebertanoLORA_pipe({'text': text1, 'text_pair': text2})
|
61 |
|
62 |
def DebertawithLORA_fn(text1, text2):
|
63 |
+
return DebertawithLORA_pipe({'text': text1, 'text_pair': text2})
|
64 |
+
#return ("working2")
|
65 |
|
66 |
def DebertaUntrained_fn(text1, text2):
|
67 |
return DebertaUntrained_pipe({'text': text1, 'text_pair': text2})
|