nicpopovic commited on
Commit
153e01d
·
verified ·
1 Parent(s): f025491

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -67,10 +67,10 @@ def get_classifiers_for_model(att_size, emb_size, device, config_paths):
67
  layer_id = config["classifier_token"]["layer"]
68
 
69
  classifier_span = MLP(att_size, 2, hidden_dim=config["classifier_span"]["classifier_dim"]).to(device)
70
- classifier_span.load_state_dict(torch.load(os.path.join(config_paths["classifier_span"], "checkpoint.pt"), map_location=device))
71
 
72
  classifier_token = MLP(emb_size, len(config["classifier_token"]["label_map"]), layer_id=layer_id, hidden_dim=config["classifier_token"]["classifier_dim"]).to(device)
73
- classifier_token.load_state_dict(torch.load(os.path.join(config_paths["classifier_token"], "checkpoint.pt"), map_location=device))
74
 
75
  return classifier_span, classifier_token, config["classifier_token"]["label_map"]
76
 
@@ -475,10 +475,7 @@ footer {
475
  height:400px;
476
  }
477
  </style>"""
478
- """
479
- with gr.Blocks(css=css, elem_id="chatbox") as demo:
480
- gr.ChatInterface(generate_text, examples=["Who where the Beatles?", "Whats the GDP of Norway?", "List some fun things to do in Miami", "What do you know about the KIT in Karlsruhe?", "Give me a list of the most iconic 90s songs", "Whats the typical cost of a pizza in New York City?", "Got any suggestions for a day trip from Miami?", "Tell me about the climate in Europe.", "Where can I go scuba diving?", "give me a list of famous people and their years of birth"], type="messages")
481
- """
482
 
483
  example_messages=[{'role': 'user', 'content': 'Who where the Beatles?'}, {'role': 'assistant', 'content': "The <span class='highlight spanhighlight' data-tooltip-text='ORG' style='background-color: #756bb188'> Beatles<span class='small-text'>ORG</span></span> were a <span class='highlight spanhighlight' data-tooltip-text='NORP' style='background-color: #a1d99b88'> British<span class='small-text'>NORP</span></span> rock band formed in <span class='highlight spanhighlight' data-tooltip-text='GPE' style='background-color: #e6550d88'> Liverpool<span class='small-text'>GPE</span></span>, <span class='highlight spanhighlight' data-tooltip-text='GPE' style='background-color: #e6550d88'> England<span class='small-text'>GPE</span></span> in <span class='highlight spanhighlight' data-tooltip-text='DATE' style='background-color: #6baed688'>1960<span class='small-text'>DATE</span></span> that rose to fame with their music and iconic style during the late <span class='highlight spanhighlight' data-tooltip-text='DATE' style='background-color: #6baed688'>1950s<span class='small-text'>DATE</span></span> and <span class='highlight spanhighlight' data-tooltip-text='DATE' style='background-color: #6baed688'> early 1960s<span class='small-text'>DATE</span></span>. The group consisted of <span class='highlight spanhighlight' data-tooltip-text='PERSON' style='background-color: #bcbddc88'> John Lennon<span class='small-text'>PERSON</span></span> ( <span class='highlight spanhighlight' data-tooltip-text='PERSON' style='background-color: #bcbddc88'>Ringo Starr<span class='small-text'>PERSON</span></span>), <span class='highlight spanhighlight' data-tooltip-text='PERSON' style='background-color: #bcbddc88'> Paul McCartney<span class='small-text'>PERSON</span></span>, <span class='highlight spanhighlight' data-tooltip-text='PERSON' style='background-color: #bcbddc88'> George Harrison<span class='small-text'>PERSON</span></span>, and <span class='highlight spanhighlight' data-tooltip-text='PERSON' style='background-color: #bcbddc88'> Ringo Starr<span class='small-text'>PERSON</span></span>. They're widely regarded as one of the most influential and successful bands in popular culture history."}]
484
 
 
67
  layer_id = config["classifier_token"]["layer"]
68
 
69
  classifier_span = MLP(att_size, 2, hidden_dim=config["classifier_span"]["classifier_dim"]).to(device)
70
+ classifier_span.load_state_dict(torch.load(os.path.join(config_paths["classifier_span"], "checkpoint.pt"), map_location=device, weights_only=True))
71
 
72
  classifier_token = MLP(emb_size, len(config["classifier_token"]["label_map"]), layer_id=layer_id, hidden_dim=config["classifier_token"]["classifier_dim"]).to(device)
73
+ classifier_token.load_state_dict(torch.load(os.path.join(config_paths["classifier_token"], "checkpoint.pt"), map_location=device, weights_only=True))
74
 
75
  return classifier_span, classifier_token, config["classifier_token"]["label_map"]
76
 
 
475
  height:400px;
476
  }
477
  </style>"""
478
+
 
 
 
479
 
480
  example_messages=[{'role': 'user', 'content': 'Who where the Beatles?'}, {'role': 'assistant', 'content': "The <span class='highlight spanhighlight' data-tooltip-text='ORG' style='background-color: #756bb188'> Beatles<span class='small-text'>ORG</span></span> were a <span class='highlight spanhighlight' data-tooltip-text='NORP' style='background-color: #a1d99b88'> British<span class='small-text'>NORP</span></span> rock band formed in <span class='highlight spanhighlight' data-tooltip-text='GPE' style='background-color: #e6550d88'> Liverpool<span class='small-text'>GPE</span></span>, <span class='highlight spanhighlight' data-tooltip-text='GPE' style='background-color: #e6550d88'> England<span class='small-text'>GPE</span></span> in <span class='highlight spanhighlight' data-tooltip-text='DATE' style='background-color: #6baed688'>1960<span class='small-text'>DATE</span></span> that rose to fame with their music and iconic style during the late <span class='highlight spanhighlight' data-tooltip-text='DATE' style='background-color: #6baed688'>1950s<span class='small-text'>DATE</span></span> and <span class='highlight spanhighlight' data-tooltip-text='DATE' style='background-color: #6baed688'> early 1960s<span class='small-text'>DATE</span></span>. The group consisted of <span class='highlight spanhighlight' data-tooltip-text='PERSON' style='background-color: #bcbddc88'> John Lennon<span class='small-text'>PERSON</span></span> ( <span class='highlight spanhighlight' data-tooltip-text='PERSON' style='background-color: #bcbddc88'>Ringo Starr<span class='small-text'>PERSON</span></span>), <span class='highlight spanhighlight' data-tooltip-text='PERSON' style='background-color: #bcbddc88'> Paul McCartney<span class='small-text'>PERSON</span></span>, <span class='highlight spanhighlight' data-tooltip-text='PERSON' style='background-color: #bcbddc88'> George Harrison<span class='small-text'>PERSON</span></span>, and <span class='highlight spanhighlight' data-tooltip-text='PERSON' style='background-color: #bcbddc88'> Ringo Starr<span class='small-text'>PERSON</span></span>. They're widely regarded as one of the most influential and successful bands in popular culture history."}]
481