Bryan Bimantaka (Monash University) commited on
Commit
4a8bc5a
·
1 Parent(s): 00cb685

fixing error

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -91,6 +91,14 @@ model = AutoModelForCausalLM.from_pretrained(
91
  cache_dir=CACHE_DIR
92
  )
93
 
 
 
 
 
 
 
 
 
94
  def format_prompt(prompt, retrieved_documents, k):
95
  """using the retrieved documents we will prompt the model to generate our responses"""
96
  PROMPT = f"Pertanyaan:{prompt}\nKonteks:"
@@ -104,10 +112,11 @@ def chat_function(message, history, max_new_tokens=256, temperature=0.6):
104
 
105
  messages = [{"role":"system","content":SYS_MSG},
106
  {"role":"user", "content":formatted_prompt}]
107
- prompt = pipeline.tokenizer.apply_chat_template(
108
- messages,
109
- tokenize=False,
110
- add_generation_prompt=True,)
 
111
  print(f"Prompt: {prompt}\n")
112
  terminators = [
113
  pipeline.tokenizer.eos_token_id,
 
91
  cache_dir=CACHE_DIR
92
  )
93
 
94
+ pipeline = transformers.pipeline(
95
+ "text-generation",
96
+ model=model,
97
+ tokenizer=tokenizer,
98
+ model_kwargs={"torch_dtype": torch.bfloat16},
99
+ # device="cuda",
100
+ )
101
+
102
  def format_prompt(prompt, retrieved_documents, k):
103
  """using the retrieved documents we will prompt the model to generate our responses"""
104
  PROMPT = f"Pertanyaan:{prompt}\nKonteks:"
 
112
 
113
  messages = [{"role":"system","content":SYS_MSG},
114
  {"role":"user", "content":formatted_prompt}]
115
+ # prompt = pipeline.tokenizer.apply_chat_template(
116
+ # messages,
117
+ # tokenize=False,
118
+ # add_generation_prompt=True,)
119
+ prompt = tokenizer(formatted_prompt, return_tensors="pt")
120
  print(f"Prompt: {prompt}\n")
121
  terminators = [
122
  pipeline.tokenizer.eos_token_id,