nxmwxm commited on
Commit
e409476
·
verified ·
1 Parent(s): bde0148

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -1,8 +1,18 @@
1
  import streamlit as st
2
  from transformers import pipeline, T5Tokenizer, T5ForConditionalGeneration
3
 
4
- # Replace with your Hugging Face model repository path
5
- model_repo_path = 'nxmwxm/answer_generator'
 
 
 
 
 
 
 
 
 
 
6
 
7
  # Load the pipeline with your model and tokenizer
8
  qa_pipeline = pipeline(
 
1
  import streamlit as st
2
  from transformers import pipeline, T5Tokenizer, T5ForConditionalGeneration
3
 
4
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
5
+
6
+ model_repo_path = 'nxmwxm/correct_answer'
7
+
8
+ # Load tokenizer and model
9
+ tokenizer = AutoTokenizer.from_pretrained(model_repo_path)
10
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_repo_path)
11
+
12
+ # Check and add special tokens if needed
13
+ special_tokens_dict = {'additional_special_tokens': ['<extra_id_99>']}
14
+ num_added_toks = tokenizer.add_special_tokens(special_tokens_dict)
15
+ model.resize_token_embeddings(len(tokenizer))
16
 
17
  # Load the pipeline with your model and tokenizer
18
  qa_pipeline = pipeline(