Aspik101 commited on
Commit
e7670d2
0 Parent(s):

Duplicate from Aspik101/trurl-2-7b-pl-instruct_GGML

Browse files
Files changed (4) hide show
  1. .gitattributes +35 -0
  2. README.md +14 -0
  3. app.py +56 -0
  4. requirements.txt +4 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: trurl-2-7b-pl-instruct_GGML
3
+ emoji: 📚
4
+ colorFrom: indigo
5
+ colorTo: red
6
+ sdk: gradio
7
+ sdk_version: 3.38.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: other
11
+ duplicated_from: Aspik101/trurl-2-7b-pl-instruct_GGML
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random
3
+ import time
4
+ from ctransformers import AutoModelForCausalLM
5
+ from datetime import datetime
6
+
7
+ params = {
8
+ "max_new_tokens":512,
9
+ "stop":["<end>" ,"<|endoftext|>","[", "<user>"],
10
+ "temperature":0.7,
11
+ "top_p":0.8,
12
+ "stream":True,
13
+ "batch_size": 8}
14
+
15
+
16
+ llm = AutoModelForCausalLM.from_pretrained("Aspik101/trurl-2-7b-pl-instruct_GGML", model_type="llama")
17
+
18
+ with gr.Blocks() as demo:
19
+ chatbot = gr.Chatbot()
20
+ msg = gr.Textbox()
21
+ clear = gr.Button("Clear")
22
+
23
+ def user(user_message, history):
24
+ return "", history + [[user_message, None]]
25
+
26
+ def parse_history(hist):
27
+ history_ = ""
28
+ for q, a in hist:
29
+ history_ += f"<user>: {q } \n"
30
+ if a:
31
+ history_ += f"<assistant>: {a} \n"
32
+ return history_
33
+
34
+ def bot(history):
35
+ print(f"When: {datetime.today().strftime('%Y-%m-%d %H:%M:%S')}")
36
+ print("history: ",history)
37
+ prompt = f"Jesteś AI assystentem. Odpowiadaj po polsku. {parse_history(history)}. <assistant>:"
38
+ print("prompt: ",prompt)
39
+ stream = llm(prompt, **params)
40
+ history[-1][1] = ""
41
+ answer_save = ""
42
+ for character in stream:
43
+ history[-1][1] += character
44
+ answer_save += character
45
+ time.sleep(0.005)
46
+ yield history
47
+
48
+ print("answer_save: ",answer_save)
49
+ msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
50
+ bot, chatbot, chatbot
51
+ )
52
+ clear.click(lambda: None, None, chatbot, queue=False)
53
+
54
+
55
+ demo.queue()
56
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ torch
2
+ ctransformers
3
+ gradio
4
+ dl-hf-model