hbsanaweb commited on
Commit
fc171bf
·
verified ·
1 Parent(s): 0f3dc88

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -1
app.py CHANGED
@@ -2,4 +2,36 @@ import gradio as gr
2
  # gr.load("models/unsloth/Qwen2.5-7B-Instruct-bnb-4bit").launch()
3
  #models/tarfandoon/adabi
4
  # gr.load("models/unsloth/Qwen2-0.5B").launch()
5
- gr.load("models/tarfandoon/adabi").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  # gr.load("models/unsloth/Qwen2.5-7B-Instruct-bnb-4bit").launch()
3
  #models/tarfandoon/adabi
4
  # gr.load("models/unsloth/Qwen2-0.5B").launch()
5
+ #gr.load("models/tarfandoon/adabi").launch()
6
+
7
+ import transformers
8
+ import torch
9
+
10
+ model_id = "hbsanaweb/sana-lama"
11
+
12
+ pipeline = transformers.pipeline(
13
+ "text-generation",
14
+ model=model_id,
15
+ model_kwargs={"torch_dtype": torch.bfloat16},
16
+ device_map="auto",
17
+ )
18
+
19
+ messages = [
20
+ {"role": "system", "content": "تو یک چت بات به زبان فارسی هستی"},
21
+ {"role": "user", "content": "شما کی هستی؟"},
22
+ ]
23
+
24
+ terminators = [
25
+ pipeline.tokenizer.eos_token_id,
26
+ pipeline.tokenizer.convert_tokens_to_ids("<|eot_id|>")
27
+ ]
28
+
29
+ outputs = pipeline(
30
+ messages,
31
+ max_new_tokens=256,
32
+ eos_token_id=terminators,
33
+ do_sample=True,
34
+ temperature=0.6,
35
+ top_p=0.9,
36
+ )
37
+ print(outputs[0]["generated_text"][-1])