Spaces:
Sleeping
Sleeping
Nitzantry1
commited on
Commit
โข
4da81f8
1
Parent(s):
a550788
Update app.py
Browse files
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)
|
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.
|
20 |
-
max_length=
|
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()
|