TAgroup5 commited on
Commit
ebaf596
·
verified ·
1 Parent(s): 08c83be

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -5,10 +5,14 @@ import io
5
  from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
6
 
7
 
8
- # Load fine-tuned model and tokenizer (adjust the model name)
9
- model_name = "TAgroup5/news-classification-model" # Replace with the correct model name
10
- model = AutoModelForSequenceClassification.from_pretrained(model_name)
11
- tokenizer = AutoTokenizer.from_pretrained(model_name)
 
 
 
 
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
- qa_model_name = "distilbert-base-uncased-distilled-squad" # Example of a common Q&A model
72
- qa_pipeline = pipeline("question-answering", model=qa_model_name, tokenizer=qa_model_name)
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