ikraamkb commited on
Commit
3a89958
Β·
verified Β·
1 Parent(s): 0878e54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -16,11 +16,12 @@ import easyocr
16
  # Initialize FastAPI
17
  app = FastAPI()
18
 
19
- # Load AI Model for Question Answering on Documents (Mistral-7B)
20
  model_name = "mistralai/Mistral-7B-Instruct"
21
- print(f"πŸ”„ Loading model: {model_name}...")
22
- tokenizer = AutoTokenizer.from_pretrained(model_name)
23
- model = AutoModelForCausalLM.from_pretrained(model_name)
 
24
 
25
  doc_qa_pipeline = pipeline("text-generation", model=model, tokenizer=tokenizer, device=-1)
26
 
 
16
  # Initialize FastAPI
17
  app = FastAPI()
18
 
19
+ print(f"πŸ”„ Loading models")
20
  model_name = "mistralai/Mistral-7B-Instruct"
21
+ hf_token = os.getenv("HUGGINGFACEHUB_API_TOKEN") # Fetch token from environment variable
22
+
23
+ tokenizer = AutoTokenizer.from_pretrained(model_name, token=hf_token)
24
+ model = AutoModelForCausalLM.from_pretrained(model_name, token=hf_token)
25
 
26
  doc_qa_pipeline = pipeline("text-generation", model=model, tokenizer=tokenizer, device=-1)
27