NoaiGPT commited on
Commit
2dd3ae0
1 Parent(s): 0f91720
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -368,6 +368,13 @@ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, AutoModelForSeque
368
  from sentence_splitter import SentenceSplitter
369
  from itertools import product
370
 
 
 
 
 
 
 
 
371
  # Get the Hugging Face token from environment variable
372
  hf_token = os.getenv('HF_TOKEN')
373
 
@@ -377,7 +384,7 @@ print(f"Using device: {device}")
377
 
378
  # Initialize paraphraser model and tokenizer
379
  paraphraser_model_name = "ramsrigouthamg/t5-large-paraphraser-diverse-high-quality"
380
- paraphraser_tokenizer = AutoTokenizer.from_pretrained(paraphraser_model_name)
381
  paraphraser_model = AutoModelForSeq2SeqLM.from_pretrained(paraphraser_model_name).to(device)
382
 
383
  # Initialize classifier model and tokenizer
 
368
  from sentence_splitter import SentenceSplitter
369
  from itertools import product
370
 
371
+ # Ensure sentencepiece is installed
372
+ try:
373
+ import sentencepiece
374
+ except ImportError:
375
+ import subprocess
376
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "sentencepiece"])
377
+
378
  # Get the Hugging Face token from environment variable
379
  hf_token = os.getenv('HF_TOKEN')
380
 
 
384
 
385
  # Initialize paraphraser model and tokenizer
386
  paraphraser_model_name = "ramsrigouthamg/t5-large-paraphraser-diverse-high-quality"
387
+ paraphraser_tokenizer = AutoTokenizer.from_pretrained(paraphraser_model_name, use_fast=False)
388
  paraphraser_model = AutoModelForSeq2SeqLM.from_pretrained(paraphraser_model_name).to(device)
389
 
390
  # Initialize classifier model and tokenizer