Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,10 +5,14 @@ import io
|
|
5 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
|
6 |
|
7 |
|
8 |
-
# Load fine-tuned
|
9 |
-
|
10 |
-
model = AutoModelForSequenceClassification.from_pretrained(
|
11 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
|
|
|
|
|
|
|
|
12 |
|
13 |
# Initialize pipelines
|
14 |
text_classification_pipeline = pipeline("text-classification", model=model, tokenizer=tokenizer)
|
@@ -68,8 +72,8 @@ question = st.text_input("Ask a question:")
|
|
68 |
context = st.text_area("Provide the news article or content for the Q&A:", height=150)
|
69 |
|
70 |
if question and context.strip():
|
71 |
-
|
72 |
-
qa_pipeline = pipeline("question-answering", model=
|
73 |
result = qa_pipeline(question=question, context=context)
|
74 |
|
75 |
# Check if the result contains an answer
|
|
|
5 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
|
6 |
|
7 |
|
8 |
+
# Load fine-tuned models and tokenizers for both functions
|
9 |
+
model_name_classification = "TAgroup5/news-classification-model" # Replace with the correct model name
|
10 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name_classification)
|
11 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_classification)
|
12 |
+
|
13 |
+
model_name_qa = "distilbert-base-cased-distilled-squad"
|
14 |
+
model_qa = AutoModelForQuestionAnswering.from_pretrained(model_name_qa)
|
15 |
+
tokenizer_qa = AutoTokenizer.from_pretrained(model_name_qa)
|
16 |
|
17 |
# Initialize pipelines
|
18 |
text_classification_pipeline = pipeline("text-classification", model=model, tokenizer=tokenizer)
|
|
|
72 |
context = st.text_area("Provide the news article or content for the Q&A:", height=150)
|
73 |
|
74 |
if question and context.strip():
|
75 |
+
model_name_qa = "distilbert-base-uncased-distilled-squad" # Example of a common Q&A model
|
76 |
+
qa_pipeline = pipeline("question-answering", model=model_name_qa, tokenizer=model_name_qa)
|
77 |
result = qa_pipeline(question=question, context=context)
|
78 |
|
79 |
# Check if the result contains an answer
|