ekinnk commited on
Commit
0f2f7ca
1 Parent(s): dd953cb

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +7 -1
main.py CHANGED
@@ -1,14 +1,20 @@
1
  #Imporing required libraries
2
  from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
3
  import gradio as gr
 
4
 
5
  # Defining the pipeline and the model
6
 
 
 
7
  tokenizer = AutoTokenizer.from_pretrained("huggyllama/llama-7b")
8
- model = AutoModelForCausalLM.from_pretrained("huggyllama/llama-7b")
 
 
9
 
10
  print("***")
11
  print("Loaded tokenizer and model")
 
12
  print("***")
13
 
14
  pipe_flan = pipeline("text-generation", model=model, tokenizer=tokenizer)
 
1
  #Imporing required libraries
2
  from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
3
  import gradio as gr
4
+ import torch
5
 
6
  # Defining the pipeline and the model
7
 
8
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
9
+
10
  tokenizer = AutoTokenizer.from_pretrained("huggyllama/llama-7b")
11
+ model = AutoModelForCausalLM.from_pretrained("huggyllama/llama-7b", device_map="auto", torch_dtype=torch.float16)
12
+
13
+ #model = model.to(device)
14
 
15
  print("***")
16
  print("Loaded tokenizer and model")
17
+ print(device)
18
  print("***")
19
 
20
  pipe_flan = pipeline("text-generation", model=model, tokenizer=tokenizer)