Nitzantry1 commited on
Commit
4da81f8
โ€ข
1 Parent(s): a550788

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -5,19 +5,19 @@ import torch
5
 
6
  # ื˜ื•ืขืŸ ืืช ื”ืžื•ื“ืœ ื•ื”-tokenizer
7
  tokenizer = AutoTokenizer.from_pretrained('dicta-il/dictalm-7b-instruct')
8
- model = AutoModelForCausalLM.from_pretrained('dicta-il/dictalm-7b-instruct', trust_remote_code=True).cuda()
9
 
10
  # ื”ื’ื“ืจืช ื”ืคื•ื ืงืฆื™ื” ืœืฆ'ืื˜ ืขื ื”ืžื•ื“ืœ
11
  def chat_with_model(prompt):
12
  model.eval()
13
  with torch.inference_mode():
14
  kwargs = dict(
15
- inputs=tokenizer(prompt, return_tensors='pt').input_ids.to(model.device),
16
  do_sample=True,
17
  top_k=50,
18
  top_p=0.95,
19
- temperature=0.75,
20
- max_length=100,
21
  min_new_tokens=5
22
  )
23
  output = model.generate(**kwargs)
@@ -26,4 +26,4 @@ def chat_with_model(prompt):
26
 
27
  # ื™ืฆื™ืจืช ืžืžืฉืง ืขื Gradio
28
  interface = gr.Interface(fn=chat_with_model, inputs="text", outputs="text", title="Chat with DictaLM Model")
29
- interface.launch()
 
5
 
6
  # ื˜ื•ืขืŸ ืืช ื”ืžื•ื“ืœ ื•ื”-tokenizer
7
  tokenizer = AutoTokenizer.from_pretrained('dicta-il/dictalm-7b-instruct')
8
+ model = AutoModelForCausalLM.from_pretrained('dicta-il/dictalm-7b-instruct', trust_remote_code=True)
9
 
10
  # ื”ื’ื“ืจืช ื”ืคื•ื ืงืฆื™ื” ืœืฆ'ืื˜ ืขื ื”ืžื•ื“ืœ
11
  def chat_with_model(prompt):
12
  model.eval()
13
  with torch.inference_mode():
14
  kwargs = dict(
15
+ inputs=tokenizer(prompt, return_tensors='pt').input_ids,
16
  do_sample=True,
17
  top_k=50,
18
  top_p=0.95,
19
+ temperature=0.5, # ื”ื•ืจื“ืช ื”ื˜ืžืคืจื˜ื•ืจื” ืœื”ืงื˜ื ืช ื”ืืงืจืื™ื•ืช
20
+ max_length=50, # ื”ืงื˜ื ืช ื”ืžืงืกื™ืžื•ื ืœืžืกืคืจ ืงื˜ืŸ ื™ื•ืชืจ
21
  min_new_tokens=5
22
  )
23
  output = model.generate(**kwargs)
 
26
 
27
  # ื™ืฆื™ืจืช ืžืžืฉืง ืขื Gradio
28
  interface = gr.Interface(fn=chat_with_model, inputs="text", outputs="text", title="Chat with DictaLM Model")
29
+ interface.launch()