Spaces:
Build error
Build error
ffreemt
commited on
Commit
Β·
911bd2d
1
Parent(s):
2d4aaee
Update minimal requirements.txt
Browse files- README.md +2 -3
- app.py +17 -9
- requirements.txt +10 -10
README.md
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
emoji: π
|
4 |
colorFrom: yellow
|
5 |
colorTo: gray
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.39.0
|
8 |
app_file: app.py
|
9 |
-
pinned:
|
10 |
-
duplicated_from: AironHeart/llama2
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: gradio-interface-tryout
|
3 |
emoji: π
|
4 |
colorFrom: yellow
|
5 |
colorTo: gray
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.39.0
|
8 |
app_file: app.py
|
9 |
+
pinned: true
|
|
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
@@ -1,14 +1,19 @@
|
|
1 |
-
import torch
|
2 |
import gradio as gr
|
3 |
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoModel
|
4 |
|
5 |
-
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
6 |
# tokenizer = AutoTokenizer.from_pretrained("stabilityai/StableBeluga2", use_fast=False)
|
7 |
# model = AutoModelForCausalLM.from_pretrained("stabilityai/StableBeluga2", torch_dtype=torch.float16, low_cpu_mem_usage=True, device_map="auto")
|
8 |
# system_prompt = "### System:\nYou are Stable Beluga, an AI that follows instructions extremely well. Help as much as you can. Remember, be safe, and don't do anything illegal.\n\n"
|
9 |
# pipeline = pipeline(task="text-generation", model="meta-llama/Llama-2-7b")
|
10 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
11 |
-
|
|
|
|
|
|
|
|
|
12 |
|
13 |
|
14 |
def chat(message, history):
|
@@ -16,11 +21,14 @@ def chat(message, history):
|
|
16 |
# inputs = tokenizer(prompt, return_tensors="pt").to(device=device)
|
17 |
# output = model.generate(**inputs, do_sample=True, top_p=0.95, top_k=0, max_new_tokens=256)
|
18 |
# return tokenizer.decode(output[0], skip_special_tokens=True)
|
19 |
-
for response, history in chat_model.stream_chat(
|
|
|
|
|
20 |
yield response
|
21 |
|
22 |
|
23 |
-
gr.ChatInterface(
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
1 |
+
# import torch
|
2 |
import gradio as gr
|
3 |
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoModel
|
4 |
|
5 |
+
# device = "cuda" if torch.cuda.is_available() else "cpu"
|
6 |
+
|
7 |
# tokenizer = AutoTokenizer.from_pretrained("stabilityai/StableBeluga2", use_fast=False)
|
8 |
# model = AutoModelForCausalLM.from_pretrained("stabilityai/StableBeluga2", torch_dtype=torch.float16, low_cpu_mem_usage=True, device_map="auto")
|
9 |
# system_prompt = "### System:\nYou are Stable Beluga, an AI that follows instructions extremely well. Help as much as you can. Remember, be safe, and don't do anything illegal.\n\n"
|
10 |
# pipeline = pipeline(task="text-generation", model="meta-llama/Llama-2-7b")
|
11 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
12 |
+
"THUDM/chatglm2-6b-int4", trust_remote_code=True
|
13 |
+
)
|
14 |
+
chat_model = AutoModel.from_pretrained(
|
15 |
+
"THUDM/chatglm2-6b-int4", trust_remote_code=True
|
16 |
+
).float()
|
17 |
|
18 |
|
19 |
def chat(message, history):
|
|
|
21 |
# inputs = tokenizer(prompt, return_tensors="pt").to(device=device)
|
22 |
# output = model.generate(**inputs, do_sample=True, top_p=0.95, top_k=0, max_new_tokens=256)
|
23 |
# return tokenizer.decode(output[0], skip_special_tokens=True)
|
24 |
+
for response, history in chat_model.stream_chat(
|
25 |
+
tokenizer, message, history, max_length=2048, top_p=0.7, temperature=0.95
|
26 |
+
):
|
27 |
yield response
|
28 |
|
29 |
|
30 |
+
gr.ChatInterface(
|
31 |
+
chat,
|
32 |
+
title="StableBeluga2 (Enjoy various AI tools and applications at aironheart.com For FREE!)",
|
33 |
+
description="Enjoy various AI tools and applications at aironheart.com/explore For FREE!",
|
34 |
+
).queue(1).launch()
|
requirements.txt
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
transformers
|
2 |
-
diffusers
|
3 |
-
accelerate
|
4 |
-
xformers
|
5 |
-
torch
|
6 |
-
fairscale
|
7 |
-
fire
|
8 |
-
sentencepiece
|
9 |
-
cpm_kernels
|
10 |
-
protobuf
|
11 |
-
mdtex2html
|
|
|
1 |
transformers
|
2 |
+
# diffusers
|
3 |
+
# accelerate
|
4 |
+
# xformers
|
5 |
+
# torch
|
6 |
+
# fairscale
|
7 |
+
# fire
|
8 |
+
# sentencepiece
|
9 |
+
# cpm_kernels
|
10 |
+
# protobuf
|
11 |
+
# mdtex2html
|