shahryarsaeed23 commited on
Commit
61622ee
·
1 Parent(s): 3b593aa

added transformers torch and gradio

Browse files
Files changed (5) hide show
  1. app.py +4 -8
  2. config.json +15 -0
  3. pytorch_model.bin +3 -0
  4. tokenizer_config.json +8 -0
  5. vocab.txt +10 -0
app.py CHANGED
@@ -4,11 +4,11 @@ from transformers import pipeline
4
  # Initialize the sentiment-analysis pipeline
5
  classifier = pipeline("sentiment-analysis", model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")
6
 
7
- def respond(message, history, system_message, max_tokens, temperature, top_p):
8
  # Get the sentiment analysis result
9
  sentiment_result = classifier(message)
10
 
11
- # Process the result to extract the sentiment label
12
  sentiment_label = sentiment_result[0]['label']
13
  sentiment_score = sentiment_result[0]['score']
14
 
@@ -19,12 +19,8 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
19
 
20
  demo = gr.Interface(
21
  fn=respond,
22
- inputs=[gr.Textbox(label="Input Text"),
23
- gr.Textbox(value="You are a friendly chatbot.", label="System message"),
24
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
25
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
26
- gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)")],
27
- outputs=gr.Textbox(label="Response")
28
  )
29
 
30
  if __name__ == "__main__":
 
4
  # Initialize the sentiment-analysis pipeline
5
  classifier = pipeline("sentiment-analysis", model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")
6
 
7
+ def respond(message):
8
  # Get the sentiment analysis result
9
  sentiment_result = classifier(message)
10
 
11
+ # Process the result to extract the sentiment label and score
12
  sentiment_label = sentiment_result[0]['label']
13
  sentiment_score = sentiment_result[0]['score']
14
 
 
19
 
20
  demo = gr.Interface(
21
  fn=respond,
22
+ inputs=gr.Textbox(label="Input Text"),
23
+ outputs=gr.Textbox(label="Sentiment Analysis Result")
 
 
 
 
24
  )
25
 
26
  if __name__ == "__main__":
config.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": ["BertForSequenceClassification"],
3
+ "attention_probs_dropout_prob": 0.1,
4
+ "hidden_dropout_prob": 0.1,
5
+ "hidden_size": 768,
6
+ "intermediate_size": 3072,
7
+ "max_position_embeddings": 512,
8
+ "num_attention_heads": 12,
9
+ "num_hidden_layers": 12,
10
+ "type_vocab_size": 2,
11
+ "vocab_size": 30522,
12
+ "initializer_range": 0.02,
13
+ "layer_norm_eps": 1e-12,
14
+ "hidden_act": "gelu"
15
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:806b777e14642f7a392c8161d352b35fb24d809d50c5a75e09700e91b2267b9f
3
+ size 200
tokenizer_config.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_lower_case": true,
3
+ "unk_token": "[UNK]",
4
+ "pad_token": "[PAD]",
5
+ "cls_token": "[CLS]",
6
+ "sep_token": "[SEP]",
7
+ "mask_token": "[MASK]"
8
+ }
vocab.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ [PAD]
2
+ [UNK]
3
+ [CLS]
4
+ [SEP]
5
+ [MASK]
6
+ the
7
+ of
8
+ and
9
+ to
10
+ a