mikeee FredZhang7 commited on
Commit
360d9e4
β€’
0 Parent(s):

Duplicate from FredZhang7/chat-test

Browse files

Co-authored-by: Fred Zhang <FredZhang7@users.noreply.huggingface.co>

Files changed (5) hide show
  1. .gitattributes +35 -0
  2. README.md +14 -0
  3. app.py +33 -0
  4. ultrachat-13B-test.py +27 -0
  5. ultrachat-13b-performance.md +7 -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: Chat Test
3
+ emoji: πŸ“š
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: gradio
7
+ sdk_version: 3.36.1
8
+ app_file: app.py
9
+ pinned: false
10
+ license: apache-2.0
11
+ duplicated_from: FredZhang7/chat-test
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ os.system("pip install --upgrade torch transformers sentencepiece scipy cpm_kernels accelerate bitsandbytes")
3
+
4
+
5
+ import gradio as gr
6
+ from transformers import AutoTokenizer, AutoModelForCausalLM
7
+
8
+ # tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm2-6b-int4", trust_remote_code=True)
9
+ # model = AutoModel.from_pretrained("THUDM/chatglm2-6b-int4", trust_remote_code=True)
10
+ tokenizer = AutoTokenizer.from_pretrained("openchat/openchat_v2_w")
11
+ model = AutoModelForCausalLM.from_pretrained("openchat/openchat_v2_w", load_in_8bit_fp32_cpu_offload=True, load_in_8bit=True)
12
+ model.float()
13
+ model = model.eval()
14
+
15
+ model_path = model.config._dict['model_name_or_path']
16
+ model_size_gb = os.path.getsize(model_path) / (1024 * 1024 * 1024)
17
+
18
+ print(f"The model '{model_name}' is taking approximately {model_size_gb:.2f} GB of disk space.")
19
+
20
+ # with gr.Blocks() as demo:
21
+ # chatbot = gr.Chatbot()
22
+ # msg = gr.Textbox()
23
+ # clear = gr.ClearButton([msg, chatbot])
24
+
25
+ # def respond(message, chat_history):
26
+ # response, chat_history = model.chat(tokenizer, message, history=chat_history, temperature=0.7, repetition_penalty=1.2, max_length=128)
27
+ # chat_history.append((message, response))
28
+ # return "", chat_history
29
+
30
+ # msg.submit(respond, [msg, chatbot], [msg, chatbot])
31
+
32
+ # if __name__ == "__main__":
33
+ # demo.launch()
ultrachat-13B-test.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ os.system("pip install llama-cpp-python")
3
+
4
+ from gradio import Interface, Textbox, Slider
5
+ import requests
6
+ from llama_cpp import Llama
7
+
8
+ url = "https://huggingface.co/TheBloke/UltraLM-13B-GGML/resolve/main/ultralm-13b.ggmlv3.q4_0.bin"
9
+
10
+ response = requests.get(url)
11
+ with open("ultralm-13b.ggmlv3.q4_0.bin", "wb") as f:
12
+ f.write(response.content)
13
+
14
+ # os.system("pwd")
15
+ # os.system("ls")
16
+
17
+ llm = Llama(model_path="ultralm-13b.ggmlv3.q4_0.bin", n_ctx=2048)
18
+
19
+ def generate_text(prompt, temperature, max_length):
20
+ prompt_template=f'''USER: {prompt}
21
+ ASSISTANT:'''
22
+ output = llm.create_completion(prompt_template, temperature=temperature, max_tokens=max_length, echo=True, stop=["USER:"])
23
+ print(output)
24
+ return output
25
+
26
+
27
+ Interface(fn=generate_text, inputs=[Textbox(type="text", lines=10), Slider(minimum=0, maximum=2, step=0.1, value=0.7), Slider(minimum=1, maximum=2048, step=2, value=256)], outputs=Textbox(type="text", lines=20), title="UltraChat 13B Text Generation", description="Enter a prompt to generate text.").launch()
ultrachat-13b-performance.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ Default Config, with temperature=0.7 and max_tokens=256
2
+
3
+ | Response Time | Prompt |
4
+ |----------------|------------------------|
5
+ | 350+ seconds | "Hi" |
6
+ | 1000+ seconds | an inappropriate word |
7
+ | N/A | https://flowgpt.com/prompt/af5bcff8-899e-4d79-a968-c4a3b38c5954?isModal=true |