yakine commited on
Commit
c73b72d
·
verified ·
1 Parent(s): 7b590be

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -11
app.py CHANGED
@@ -28,22 +28,14 @@ model_gpt2 = GPT2LMHeadModel.from_pretrained('gpt2')
28
  text_generator = pipeline("text-generation", model=model_gpt2, tokenizer=tokenizer_gpt2)
29
 
30
  # Load the Llama-3 model and tokenizer once during startup
31
- tokenizer_llama = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3-8B", token=hf_token)
32
- # Define the offload directory
33
- offload_dir = "./offload"
34
- os.makedirs(offload_dir, exist_ok=True) # Create the directory if it doesn't exist
35
-
36
- # Load the Llama model with disk offloading
37
- with init_empty_weights():
38
- model_llama = AutoModelForCausalLM.from_pretrained(
39
- "meta-llama/Meta-Llama-3-8B",
40
  torch_dtype='auto',
41
  device_map='auto',
42
  token=hf_token
43
  )
44
 
45
- # Offload the model to the specified directory
46
- disk_offload(model_llama, offload_dir) # Pass the offload directory
47
 
48
  # Define your prompt template
49
  prompt_template = """\
 
28
  text_generator = pipeline("text-generation", model=model_gpt2, tokenizer=tokenizer_gpt2)
29
 
30
  # Load the Llama-3 model and tokenizer once during startup
31
+ tokenizer_llama = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3.1-8B", token=hf_token)
32
+ model_llama = AutoModelForCausalLM.from_pretrained(
33
+ "meta-llama/Meta-Llama-3.1-8B",
 
 
 
 
 
 
34
  torch_dtype='auto',
35
  device_map='auto',
36
  token=hf_token
37
  )
38
 
 
 
39
 
40
  # Define your prompt template
41
  prompt_template = """\