ShikharLLM commited on
Commit
ed921e2
·
verified ·
1 Parent(s): a1ba27b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -1,11 +1,15 @@
 
1
  import gradio as gr
2
  import torch
3
  from transformers import AutoModelForCausalLM, AutoTokenizer
4
 
5
- # Load the tokenizer and model
 
 
 
6
  model_id = "meta-llama/Llama-3.2-3B-Instruct"
7
- tokenizer = AutoTokenizer.from_pretrained(model_id)
8
- model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
9
 
10
  # Define the prediction function
11
  def generate_text(prompt):
 
1
+ import os
2
  import gradio as gr
3
  import torch
4
  from transformers import AutoModelForCausalLM, AutoTokenizer
5
 
6
+ # Retrieve the Hugging Face token from environment variables
7
+ hf_token = os.getenv("HUGGINGFACE_TOKEN")
8
+
9
+ # Load the tokenizer and model with the token
10
  model_id = "meta-llama/Llama-3.2-3B-Instruct"
11
+ tokenizer = AutoTokenizer.from_pretrained(model_id, use_auth_token=hf_token)
12
+ model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto", use_auth_token=hf_token)
13
 
14
  # Define the prediction function
15
  def generate_text(prompt):