Spaces:
Build error
Build error
Commit
·
e898e49
1
Parent(s):
dfed4d6
Update app.py
Browse files
app.py
CHANGED
@@ -18,10 +18,10 @@ sentiment_model = pipeline("text-classification", model="AhmedTaha012/managersFe
|
|
18 |
increase_decrease_model = pipeline("text-classification", model="AhmedTaha012/nextQuarter-status-V1.1.9")
|
19 |
tokenizerTopic = AutoTokenizer.from_pretrained("nickmuchi/finbert-tone-finetuned-finance-topic-classification",use_fast=True,token="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")
|
20 |
modelTopic = AutoModelForSequenceClassification.from_pretrained("nickmuchi/finbert-tone-finetuned-finance-topic-classification",token="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")
|
21 |
-
torch.compile(modelTopic)
|
22 |
tokenizer = AutoTokenizer.from_pretrained("AhmedTaha012/finance-ner-v0.0.9-finetuned-ner")
|
23 |
model = AutoModelForTokenClassification.from_pretrained("AhmedTaha012/finance-ner-v0.0.9-finetuned-ner")
|
24 |
-
torch.compile(model)
|
25 |
# torch.compile(model)
|
26 |
nlpPipe = pipeline("ner", model=model, tokenizer=tokenizer, grouped_entities=True)
|
27 |
def getSpeakers(data):
|
@@ -190,7 +190,7 @@ def convert_amount_to_number(amount_str):
|
|
190 |
except ValueError:
|
191 |
return 0 # Return 0 if the conversion fails
|
192 |
def getTopic(encoded_input):
|
193 |
-
modelTopic.to("cuda")
|
194 |
with torch.no_grad():
|
195 |
logits = modelTopic(**encoded_input).logits
|
196 |
predicted_class_id = logits.argmax().item()
|
@@ -220,7 +220,7 @@ def selectedCorpusForNextQuarterModel(x,quarter,year):
|
|
220 |
result=[x for x in result if len(x)>10]
|
221 |
des=f"the {number_word_dict[str(quarter)]} quarter results of the {year}"
|
222 |
courpus=result
|
223 |
-
embeddings_1 = similarityModel.encode([des]+courpus, normalize_embeddings=True,
|
224 |
sents=[des]+courpus
|
225 |
rest=[sents[f] for f in [list(cosine_similarity(embeddings_1)[0][1:]).index(value)+1 for value in sorted(list(cosine_similarity(embeddings_1)[0][1:]),reverse=True)][:3]]
|
226 |
return ",".join(rest)
|
|
|
18 |
increase_decrease_model = pipeline("text-classification", model="AhmedTaha012/nextQuarter-status-V1.1.9")
|
19 |
tokenizerTopic = AutoTokenizer.from_pretrained("nickmuchi/finbert-tone-finetuned-finance-topic-classification",use_fast=True,token="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")
|
20 |
modelTopic = AutoModelForSequenceClassification.from_pretrained("nickmuchi/finbert-tone-finetuned-finance-topic-classification",token="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")
|
21 |
+
# torch.compile(modelTopic)
|
22 |
tokenizer = AutoTokenizer.from_pretrained("AhmedTaha012/finance-ner-v0.0.9-finetuned-ner")
|
23 |
model = AutoModelForTokenClassification.from_pretrained("AhmedTaha012/finance-ner-v0.0.9-finetuned-ner")
|
24 |
+
# torch.compile(model)
|
25 |
# torch.compile(model)
|
26 |
nlpPipe = pipeline("ner", model=model, tokenizer=tokenizer, grouped_entities=True)
|
27 |
def getSpeakers(data):
|
|
|
190 |
except ValueError:
|
191 |
return 0 # Return 0 if the conversion fails
|
192 |
def getTopic(encoded_input):
|
193 |
+
# modelTopic.to("cuda")
|
194 |
with torch.no_grad():
|
195 |
logits = modelTopic(**encoded_input).logits
|
196 |
predicted_class_id = logits.argmax().item()
|
|
|
220 |
result=[x for x in result if len(x)>10]
|
221 |
des=f"the {number_word_dict[str(quarter)]} quarter results of the {year}"
|
222 |
courpus=result
|
223 |
+
embeddings_1 = similarityModel.encode([des]+courpus, normalize_embeddings=True,show_progress_bar=False)
|
224 |
sents=[des]+courpus
|
225 |
rest=[sents[f] for f in [list(cosine_similarity(embeddings_1)[0][1:]).index(value)+1 for value in sorted(list(cosine_similarity(embeddings_1)[0][1:]),reverse=True)][:3]]
|
226 |
return ",".join(rest)
|