rasyosef commited on
Commit
39012bc
1 Parent(s): a65c505

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -36,7 +36,7 @@ QA_PROMPT = PromptTemplate(
36
  model_id = "microsoft/phi-2"
37
 
38
  tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
39
- model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float32, device_map="cpu", trust_remote_code=True)
40
 
41
  # Returns a faiss vector store retriever given a txt file
42
  def prepare_vector_store_retriever(filename):
@@ -79,7 +79,7 @@ def generate(question, answer, text_file, max_new_tokens):
79
  phi2_pipeline = pipeline(
80
  "text-generation", tokenizer=tokenizer, model=model, max_new_tokens=max_new_tokens,
81
  pad_token_id=tokenizer.eos_token_id, eos_token_id=tokenizer.eos_token_id,
82
- device_map="cpu", streamer=streamer
83
  )
84
 
85
  hf_model = HuggingFacePipeline(pipeline=phi2_pipeline)
 
36
  model_id = "microsoft/phi-2"
37
 
38
  tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
39
+ model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float32, device_map="auto", trust_remote_code=True)
40
 
41
  # Returns a faiss vector store retriever given a txt file
42
  def prepare_vector_store_retriever(filename):
 
79
  phi2_pipeline = pipeline(
80
  "text-generation", tokenizer=tokenizer, model=model, max_new_tokens=max_new_tokens,
81
  pad_token_id=tokenizer.eos_token_id, eos_token_id=tokenizer.eos_token_id,
82
+ device_map="auto", streamer=streamer
83
  )
84
 
85
  hf_model = HuggingFacePipeline(pipeline=phi2_pipeline)