Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import faiss
|
|
4 |
import os
|
5 |
import numpy as np
|
6 |
from sentence_transformers import SentenceTransformer
|
7 |
-
from transformers import AutoTokenizer,
|
8 |
|
9 |
# Model paths
|
10 |
sent = "dnzblgn/Sentiment-Analysis-Customer-Reviews"
|
@@ -12,17 +12,23 @@ sarc = "dnzblgn/Sarcasm-Detection-Customer-Reviews"
|
|
12 |
doc = "dnzblgn/Customer-Reviews-Classification"
|
13 |
embedding_model = SentenceTransformer('multi-qa-mpnet-base-dot-v1')
|
14 |
|
|
|
15 |
# Load sentiment, sarcasm, and classification models
|
16 |
-
sentiment_tokenizer = AutoTokenizer.from_pretrained(sent,use_fast=False)
|
17 |
-
sentiment_model = AutoModelForSequenceClassification.from_pretrained(sent)
|
18 |
-
sarcasm_tokenizer = AutoTokenizer.from_pretrained(sarc,use_fast=False)
|
19 |
-
sarcasm_model = AutoModelForSequenceClassification.from_pretrained(sarc)
|
20 |
-
classification_tokenizer = AutoTokenizer.from_pretrained(doc,use_fast=False)
|
21 |
-
classification_model = AutoModelForSequenceClassification.from_pretrained(doc)
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
# Paths and files
|
28 |
UPLOAD_FOLDER = "uploads"
|
|
|
4 |
import os
|
5 |
import numpy as np
|
6 |
from sentence_transformers import SentenceTransformer
|
7 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, AutoModelForSequenceClassification
|
8 |
|
9 |
# Model paths
|
10 |
sent = "dnzblgn/Sentiment-Analysis-Customer-Reviews"
|
|
|
12 |
doc = "dnzblgn/Customer-Reviews-Classification"
|
13 |
embedding_model = SentenceTransformer('multi-qa-mpnet-base-dot-v1')
|
14 |
|
15 |
+
|
16 |
# Load sentiment, sarcasm, and classification models
|
17 |
+
sentiment_tokenizer = AutoTokenizer.from_pretrained(sent, use_fast=False, use_auth_token=HF_TOKEN)
|
18 |
+
sentiment_model = AutoModelForSequenceClassification.from_pretrained(sent, use_auth_token=HF_TOKEN)
|
19 |
+
sarcasm_tokenizer = AutoTokenizer.from_pretrained(sarc, use_fast=False, use_auth_token=HF_TOKEN)
|
20 |
+
sarcasm_model = AutoModelForSequenceClassification.from_pretrained(sarc, use_auth_token=HF_TOKEN)
|
21 |
+
classification_tokenizer = AutoTokenizer.from_pretrained(doc, use_fast=False, use_auth_token=HF_TOKEN)
|
22 |
+
classification_model = AutoModelForSequenceClassification.from_pretrained(doc, use_auth_token=HF_TOKEN)
|
23 |
+
|
24 |
+
import os
|
25 |
+
HF_TOKEN = os.getenv("HUGGINGFACE_TOKEN") # Read token from the environment variable
|
26 |
+
|
27 |
+
# Use the token in the model loading
|
28 |
+
mistral_tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-v0.1", use_auth_token=HF_TOKEN)
|
29 |
+
mistral_model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-v0.1", torch_dtype=torch.float16, use_auth_token=HF_TOKEN)
|
30 |
+
|
31 |
+
|
32 |
|
33 |
# Paths and files
|
34 |
UPLOAD_FOLDER = "uploads"
|