Intradiction commited on
Commit
9a7561b
1 Parent(s): fe93989

Add STS pipe, fix text pair pipes, fix scale should be int, more specific peft import

Browse files
Files changed (1) hide show
  1. app.py +17 -17
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import gradio as gr
2
  from transformers import pipeline, AutoTokenizer
3
- from peft import AutoPeftModelForSequenceClassification
4
 
5
  tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
6
  loraModel = AutoPeftModelForSequenceClassification.from_pretrained("Intradiction/text_classification_WithLORA")
@@ -36,17 +36,17 @@ AlbertnoLORA_pipe = pipeline(model="Intradiction/NLI-Conventional-Fine-Tuning")
36
 
37
  #NLI models
38
  def AlbertnoLORA_fn(text1, text2):
39
- return AlbertnoLORA_pipe(text1, text2)
40
 
41
  def AlbertwithLORA_fn(text1, text2):
42
  return ("working2")
43
 
44
  def AlbertUntrained_fn(text1, text2):
45
- return ALbertUntrained_pipe(text1,text2)
46
 
47
 
48
  # Handle calls to Deberta
49
- #DebertaUntrained_pipe = pipeline()
50
  #DebertanoLORA_pipe = pipeline()
51
  #DebertawithLORA_pipe = pipeline()
52
 
@@ -58,7 +58,7 @@ def DebertawithLORA_fn(text1, text2):
58
  return ("working2")
59
 
60
  def DebertaUntrained_fn(text1, text2):
61
- return ("working3")
62
 
63
 
64
  #placeholder
@@ -81,7 +81,7 @@ with gr.Blocks(
81
  gr.Markdown("""
82
  <div style="overflow: hidden;color:#fff;display: flex;flex-direction: column;align-items: center; position: relative; width: 100%; height: 180px;background-size: cover; background-image: url(https://www.grssigns.co.uk/wp-content/uploads/web-Header-Background.jpg);">
83
  <img style="width: 130px;height: 60px;position: absolute;top:10px;left:10px" src="https://www.torontomu.ca/content/dam/tmumobile/images/TMU-Mobile-AppIcon.png"/>
84
- <span style="margin-top: 40px;font-size: 36px ;font-family:fantasy;">Efficient Fine tuning Of Large Language Models</span>
85
  <span style="margin-top: 10px;font-size: 14px;">By: Rahul Adams, Greylyn Gao, Rajevan Logarajah & Mahir Faisal</span>
86
  <span style="margin-top: 5px;font-size: 14px;">Group Id: AR06 FLC: Alice Reuda</span>
87
  </div>
@@ -90,7 +90,7 @@ with gr.Blocks(
90
  with gr.Row():
91
  gr.Markdown("<h1>Efficient Fine Tuning for Text Classification</h1>")
92
  with gr.Row():
93
- with gr.Column(scale=0.3,variant="panel"):
94
  gr.Markdown("""
95
  <h2>Specifications</h2>
96
  <p><b>Model:</b> Tiny Bert <br>
@@ -99,7 +99,7 @@ with gr.Blocks(
99
  <p>Text classification is an NLP task that focuses on automatically ascribing a predefined category or labels to an input prompt. In this demonstration the Tiny Bert model has been used to classify the text on the basis of sentiment analysis, where the labels (negative and positive) will indicate the emotional state expressed by the input prompt. The tiny bert model was chosen as in its base state its ability to perform sentiment analysis is quite poor, displayed by the untrained model, which often fails to correctly ascribe the label to the sentiment. The models were trained on the IMDB dataset which includes over 100k sentiment pairs pulled from IMDB movie reviews. We can see that when training is performed over [XX] of epochs we see an increase in X% of training time for the LoRA trained model.</p>
100
  """)
101
 
102
- with gr.Column(scale=0.3,variant="panel"):
103
  inp = gr.Textbox(placeholder="Prompt",label= "Enter Query")
104
  btn = gr.Button("Run")
105
  gr.Examples(
@@ -112,7 +112,7 @@ with gr.Blocks(
112
  label="Try asking",
113
  )
114
 
115
- with gr.Column():
116
  with gr.Row(variant="panel"):
117
  TextClassOut = gr.Textbox(label= "Untrained Base Model")
118
  gr.Markdown("""<div>
@@ -143,7 +143,7 @@ with gr.Blocks(
143
  with gr.Row():
144
  gr.Markdown("<h1>Efficient Fine Tuning for Natural Language Inferencing</h1>")
145
  with gr.Row():
146
- with gr.Column(scale=0.3, variant="panel"):
147
  gr.Markdown("""
148
  <h2>Specifications</h2>
149
  <p><b>Model:</b> Albert <br>
@@ -151,7 +151,7 @@ with gr.Blocks(
151
  <b>NLP Task:</b> Natual Languae Infrencing</p>
152
  <p>Natural Language Inference (NLI) which can also be referred to as Textual Entailment is an NLP task with the objective of determining the relationship between two pieces of text. In this demonstration the Albert model has been used to determine textual similarity ascribing a correlation score by the comparison of the two input prompts to determine if. Albert was chosen due to its substandard level of performance in its base state allowing room for improvement during training. The models were trained on the Stanford Natural Language Inference Dataset is a collection of 570k human-written English sentence pairs manually labeled for balanced classification, listed as positive, negative or neutral. We can see that when training is performed over [XX] epochs we see an increase in X% of training time for the LoRA trained model compared to a conventionally tuned model. </p>
153
  """)
154
- with gr.Column(scale=0.3,variant="panel"):
155
  nli_p1 = gr.Textbox(placeholder="Prompt One",label= "Enter Query")
156
  nli_p2 = gr.Textbox(placeholder="Prompt Two",label= "Enter Query")
157
  nli_btn = gr.Button("Run")
@@ -174,7 +174,7 @@ with gr.Blocks(
174
  label="Try asking",
175
  )
176
 
177
- with gr.Column():
178
  with gr.Row(variant="panel"):
179
  NLIOut = gr.Textbox(label= "Untrained Base Model")
180
  gr.Markdown("""<div>
@@ -204,7 +204,7 @@ with gr.Blocks(
204
  with gr.Row():
205
  gr.Markdown("<h1>Efficient Fine Tuning for Semantic Text Similarity</h1>")
206
  with gr.Row():
207
- with gr.Column(scale=0.3,variant="panel"):
208
  gr.Markdown("""
209
  <h2>Specifications</h2>
210
  <p><b>Model:</b> DeBERTa-v3-xsmall <br>
@@ -212,7 +212,7 @@ with gr.Blocks(
212
  <b>NLP Task:</b> Semantic Text Similarity</p>
213
  <p>Semantic text similarity measures the closeness in meaning of two pieces of text despite differences in their wording or structure. This task involves two input prompts which can be sentences, phrases or entire documents and assessing them for similarity. In our implementation we compare phrases represented by a score that can range between zero and one. A score of zero implies completely different phrases, while one indicates identical meaning between the text pair. This implementation uses a DeBERTa-v3-xsmall and training was performed on the semantic text similarity benchmark dataset which contains over 86k semantic pairs and their scores. We can see that when training is performed over [XX] epochs we see an increase in X% of training time for the LoRA trained model compared to a conventionally tuned model.</p>
214
  """)
215
- with gr.Column(scale=0.3,variant="panel"):
216
  sts_p1 = gr.Textbox(placeholder="Prompt One",label= "Enter Query")
217
  sts_p2 = gr.Textbox(placeholder="Prompt Two",label= "Enter Query")
218
  sts_btn = gr.Button("Run")
@@ -235,7 +235,7 @@ with gr.Blocks(
235
  label="Try asking",
236
  )
237
 
238
- with gr.Column():
239
  with gr.Row(variant="panel"):
240
  sts_out = gr.Textbox(label= "Untrained Base Model")
241
  gr.Markdown("""<div>
@@ -253,7 +253,7 @@ with gr.Blocks(
253
  with gr.Row(variant="panel"):
254
  sts_out2 = gr.Textbox(label= "LoRA Fine Tuned Model")
255
  gr.Markdown("""<div>
256
- <span><center><B>Training Information</B><center></span>
257
  <span><br><br><br><br><br></span>
258
  </div>""")
259
 
@@ -261,7 +261,7 @@ with gr.Blocks(
261
  sts_btn.click(fn=DebertanoLORA_fn, inputs=[sts_p1,sts_p2], outputs=sts_out1)
262
  sts_btn.click(fn=DebertawithLORA_fn, inputs=[sts_p1,sts_p2], outputs=sts_out2)
263
 
264
- with gr.Tab("More information"):
265
  gr.Markdown("stuff to add")
266
 
267
 
 
1
  import gradio as gr
2
  from transformers import pipeline, AutoTokenizer
3
+ from peft.auto import AutoPeftModelForSequenceClassification
4
 
5
  tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
6
  loraModel = AutoPeftModelForSequenceClassification.from_pretrained("Intradiction/text_classification_WithLORA")
 
36
 
37
  #NLI models
38
  def AlbertnoLORA_fn(text1, text2):
39
+ return AlbertnoLORA_pipe({'text': text1, 'text_pair': text2})
40
 
41
  def AlbertwithLORA_fn(text1, text2):
42
  return ("working2")
43
 
44
  def AlbertUntrained_fn(text1, text2):
45
+ return ALbertUntrained_pipe({'text': text1, 'text_pair': text2})
46
 
47
 
48
  # Handle calls to Deberta
49
+ DebertaUntrained_pipe = pipeline("text-classification", model="microsoft/deberta-v3-xsmall")
50
  #DebertanoLORA_pipe = pipeline()
51
  #DebertawithLORA_pipe = pipeline()
52
 
 
58
  return ("working2")
59
 
60
  def DebertaUntrained_fn(text1, text2):
61
+ return DebertaUntrained_pipe({'text': text1, 'text_pair': text2})
62
 
63
 
64
  #placeholder
 
81
  gr.Markdown("""
82
  <div style="overflow: hidden;color:#fff;display: flex;flex-direction: column;align-items: center; position: relative; width: 100%; height: 180px;background-size: cover; background-image: url(https://www.grssigns.co.uk/wp-content/uploads/web-Header-Background.jpg);">
83
  <img style="width: 130px;height: 60px;position: absolute;top:10px;left:10px" src="https://www.torontomu.ca/content/dam/tmumobile/images/TMU-Mobile-AppIcon.png"/>
84
+ <span style="margin-top: 40px;font-size: 36px ;font-family:fantasy;">Efficient Fine Tuning Offf Large Language Models</span>
85
  <span style="margin-top: 10px;font-size: 14px;">By: Rahul Adams, Greylyn Gao, Rajevan Logarajah & Mahir Faisal</span>
86
  <span style="margin-top: 5px;font-size: 14px;">Group Id: AR06 FLC: Alice Reuda</span>
87
  </div>
 
90
  with gr.Row():
91
  gr.Markdown("<h1>Efficient Fine Tuning for Text Classification</h1>")
92
  with gr.Row():
93
+ with gr.Column(variant="panel"):
94
  gr.Markdown("""
95
  <h2>Specifications</h2>
96
  <p><b>Model:</b> Tiny Bert <br>
 
99
  <p>Text classification is an NLP task that focuses on automatically ascribing a predefined category or labels to an input prompt. In this demonstration the Tiny Bert model has been used to classify the text on the basis of sentiment analysis, where the labels (negative and positive) will indicate the emotional state expressed by the input prompt. The tiny bert model was chosen as in its base state its ability to perform sentiment analysis is quite poor, displayed by the untrained model, which often fails to correctly ascribe the label to the sentiment. The models were trained on the IMDB dataset which includes over 100k sentiment pairs pulled from IMDB movie reviews. We can see that when training is performed over [XX] of epochs we see an increase in X% of training time for the LoRA trained model.</p>
100
  """)
101
 
102
+ with gr.Column(variant="panel"):
103
  inp = gr.Textbox(placeholder="Prompt",label= "Enter Query")
104
  btn = gr.Button("Run")
105
  gr.Examples(
 
112
  label="Try asking",
113
  )
114
 
115
+ with gr.Column(scale=3):
116
  with gr.Row(variant="panel"):
117
  TextClassOut = gr.Textbox(label= "Untrained Base Model")
118
  gr.Markdown("""<div>
 
143
  with gr.Row():
144
  gr.Markdown("<h1>Efficient Fine Tuning for Natural Language Inferencing</h1>")
145
  with gr.Row():
146
+ with gr.Column(variant="panel"):
147
  gr.Markdown("""
148
  <h2>Specifications</h2>
149
  <p><b>Model:</b> Albert <br>
 
151
  <b>NLP Task:</b> Natual Languae Infrencing</p>
152
  <p>Natural Language Inference (NLI) which can also be referred to as Textual Entailment is an NLP task with the objective of determining the relationship between two pieces of text. In this demonstration the Albert model has been used to determine textual similarity ascribing a correlation score by the comparison of the two input prompts to determine if. Albert was chosen due to its substandard level of performance in its base state allowing room for improvement during training. The models were trained on the Stanford Natural Language Inference Dataset is a collection of 570k human-written English sentence pairs manually labeled for balanced classification, listed as positive, negative or neutral. We can see that when training is performed over [XX] epochs we see an increase in X% of training time for the LoRA trained model compared to a conventionally tuned model. </p>
153
  """)
154
+ with gr.Column(variant="panel"):
155
  nli_p1 = gr.Textbox(placeholder="Prompt One",label= "Enter Query")
156
  nli_p2 = gr.Textbox(placeholder="Prompt Two",label= "Enter Query")
157
  nli_btn = gr.Button("Run")
 
174
  label="Try asking",
175
  )
176
 
177
+ with gr.Column(scale=3):
178
  with gr.Row(variant="panel"):
179
  NLIOut = gr.Textbox(label= "Untrained Base Model")
180
  gr.Markdown("""<div>
 
204
  with gr.Row():
205
  gr.Markdown("<h1>Efficient Fine Tuning for Semantic Text Similarity</h1>")
206
  with gr.Row():
207
+ with gr.Column(variant="panel"):
208
  gr.Markdown("""
209
  <h2>Specifications</h2>
210
  <p><b>Model:</b> DeBERTa-v3-xsmall <br>
 
212
  <b>NLP Task:</b> Semantic Text Similarity</p>
213
  <p>Semantic text similarity measures the closeness in meaning of two pieces of text despite differences in their wording or structure. This task involves two input prompts which can be sentences, phrases or entire documents and assessing them for similarity. In our implementation we compare phrases represented by a score that can range between zero and one. A score of zero implies completely different phrases, while one indicates identical meaning between the text pair. This implementation uses a DeBERTa-v3-xsmall and training was performed on the semantic text similarity benchmark dataset which contains over 86k semantic pairs and their scores. We can see that when training is performed over [XX] epochs we see an increase in X% of training time for the LoRA trained model compared to a conventionally tuned model.</p>
214
  """)
215
+ with gr.Column(variant="panel"):
216
  sts_p1 = gr.Textbox(placeholder="Prompt One",label= "Enter Query")
217
  sts_p2 = gr.Textbox(placeholder="Prompt Two",label= "Enter Query")
218
  sts_btn = gr.Button("Run")
 
235
  label="Try asking",
236
  )
237
 
238
+ with gr.Column(scale=3):
239
  with gr.Row(variant="panel"):
240
  sts_out = gr.Textbox(label= "Untrained Base Model")
241
  gr.Markdown("""<div>
 
253
  with gr.Row(variant="panel"):
254
  sts_out2 = gr.Textbox(label= "LoRA Fine Tuned Model")
255
  gr.Markdown("""<div>
256
+ <span><center><B>Training Informadtion</B><center></span>
257
  <span><br><br><br><br><br></span>
258
  </div>""")
259
 
 
261
  sts_btn.click(fn=DebertanoLORA_fn, inputs=[sts_p1,sts_p2], outputs=sts_out1)
262
  sts_btn.click(fn=DebertawithLORA_fn, inputs=[sts_p1,sts_p2], outputs=sts_out2)
263
 
264
+ with gr.Tab("More informatioen"):
265
  gr.Markdown("stuff to add")
266
 
267