omniverse1 commited on
Commit
5009c8a
·
verified ·
1 Parent(s): 513e51c

update app

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -3,7 +3,7 @@ import yfinance as yf
3
  import pandas as pd
4
  import numpy as np
5
  import torch
6
- from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
7
  from datetime import datetime, timedelta
8
  import plotly.graph_objects as go
9
  import plotly.express as px
@@ -30,16 +30,16 @@ from config import IDX_STOCKS, TECHNICAL_INDICATORS, PREDICTION_CONFIG
30
  @spaces.GPU(duration=120)
31
  def load_model():
32
  """Load the Amazon Chronos-Bolt model for time series forecasting"""
33
- # Fix: Use AutoModelForSeq2SeqLM and trust_remote_code=True for the T5-based model
34
  model = AutoModelForSeq2SeqLM.from_pretrained(
35
  "amazon/chronos-bolt-base",
36
  torch_dtype=torch.bfloat16,
37
  device_map="auto",
38
  trust_remote_code=True
39
  )
40
- # Fix: Reverting to AutoTokenizer with ONLY trust_remote_code=True
41
- # This should correctly invoke the custom ChronosTokenizer class and resolve model files.
42
- tokenizer = AutoTokenizer.from_pretrained(
43
  "amazon/chronos-bolt-base",
44
  trust_remote_code=True
45
  )
 
3
  import pandas as pd
4
  import numpy as np
5
  import torch
6
+ from transformers import AutoModelForSeq2SeqLM, AutoTokenizer, T5TokenizerFast
7
  from datetime import datetime, timedelta
8
  import plotly.graph_objects as go
9
  import plotly.express as px
 
30
  @spaces.GPU(duration=120)
31
  def load_model():
32
  """Load the Amazon Chronos-Bolt model for time series forecasting"""
33
+ # FIX: Use AutoModelForSeq2SeqLM and trust_remote_code=True (correct for T5-based model)
34
  model = AutoModelForSeq2SeqLM.from_pretrained(
35
  "amazon/chronos-bolt-base",
36
  torch_dtype=torch.bfloat16,
37
  device_map="auto",
38
  trust_remote_code=True
39
  )
40
+ # FINAL FIX: Explicitly use T5TokenizerFast (Fast Tokenizer) with trust_remote_code=True.
41
+ # This bypasses the T5Tokenizer (Slow Tokenizer) fallback logic that caused the TypeError: not a string.
42
+ tokenizer = T5TokenizerFast.from_pretrained(
43
  "amazon/chronos-bolt-base",
44
  trust_remote_code=True
45
  )