Spaces:
Running
on
Zero
Running
on
Zero
yam-peleg/Hebrew-Mistral-7B-200K
Browse files
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title: Yam-Peleg Hebrew-Mistral-7B
|
3 |
emoji: ๐
|
4 |
colorFrom: blue
|
5 |
colorTo: gray
|
@@ -11,10 +11,9 @@ license: apache-2.0
|
|
11 |
suggested_hardware: a10g-small
|
12 |
---
|
13 |
|
14 |
-
# Yam-Peleg's Hebrew-Mistral-7B
|
15 |
|
16 |
-
Hebrew-Mistral-7B was introduced in [this Facebook post](https://www.facebook.com/groups/MDLI1/posts/
|
17 |
|
18 |
-
Please, check the [original model card](https://huggingface.co/yam-peleg/Hebrew-Mistral-7B) for more details.
|
19 |
You can see the other Hebrew models by Yam [here](https://huggingface.co/collections/yam-peleg/hebrew-models-65e957875324e2b9a4b68f08)
|
20 |
-
|
|
|
1 |
---
|
2 |
+
title: Yam-Peleg Hebrew-Mistral-7B-200K
|
3 |
emoji: ๐
|
4 |
colorFrom: blue
|
5 |
colorTo: gray
|
|
|
11 |
suggested_hardware: a10g-small
|
12 |
---
|
13 |
|
14 |
+
# Yam-Peleg's Hebrew-Mistral-7B-200K
|
15 |
|
16 |
+
Hebrew-Mistral-7B-200K was introduced in [this Facebook post](https://www.facebook.com/groups/MDLI1/posts/2708679492629415/).
|
17 |
|
18 |
+
Please, check the [original model card](https://huggingface.co/yam-peleg/Hebrew-Mistral-7B-200K) for more details.
|
19 |
You can see the other Hebrew models by Yam [here](https://huggingface.co/collections/yam-peleg/hebrew-models-65e957875324e2b9a4b68f08)
|
|
app.py
CHANGED
@@ -3,24 +3,27 @@ from threading import Thread
|
|
3 |
from typing import Iterator
|
4 |
|
5 |
import gradio as gr
|
|
|
|
|
6 |
import spaces
|
7 |
import torch
|
8 |
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
|
|
9 |
|
10 |
MAX_MAX_NEW_TOKENS = 1024
|
11 |
DEFAULT_MAX_NEW_TOKENS = 256
|
12 |
-
MAX_INPUT_TOKEN_LENGTH =
|
13 |
|
14 |
DESCRIPTION = """\
|
15 |
-
# Yam-Peleg's Hebrew-Mistral-7B
|
16 |
|
17 |
-
Hebrew-Mistral-7B was introduced in [this Facebook post](https://www.facebook.com/groups/MDLI1/posts/
|
18 |
|
19 |
-
Please, check the [original model card](https://huggingface.co/yam-peleg/Hebrew-Mistral-7B) for more details.
|
20 |
You can see the other Hebrew models by Yam [here](https://huggingface.co/collections/yam-peleg/hebrew-models-65e957875324e2b9a4b68f08)
|
21 |
|
22 |
# Note: Use this model for only for completing sentences.
|
23 |
-
## While the user interface is of a chatbot for convenience, this is a base model and is not fine-tuned for chatbot tasks or instruction following tasks.
|
24 |
"""
|
25 |
|
26 |
LICENSE = """
|
@@ -38,9 +41,9 @@ if not torch.cuda.is_available():
|
|
38 |
|
39 |
|
40 |
if torch.cuda.is_available():
|
41 |
-
model_id = "yam-peleg/Hebrew-Mistral-7B"
|
42 |
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", torch_dtype=torch.bfloat16, low_cpu_mem_usage=True)
|
43 |
-
tokenizer_id = "yam-peleg/Hebrew-Mistral-7B"
|
44 |
tokenizer = AutoTokenizer.from_pretrained(tokenizer_id)
|
45 |
|
46 |
|
@@ -54,7 +57,14 @@ def generate(
|
|
54 |
top_k: int = 30,
|
55 |
repetition_penalty: float = 1.0,
|
56 |
) -> Iterator[str]:
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
input_ids = tokenizer([message], return_tensors="pt").input_ids
|
59 |
if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
|
60 |
input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
|
@@ -102,28 +112,28 @@ chat_interface = gr.ChatInterface(
|
|
102 |
minimum=0.1,
|
103 |
maximum=4.0,
|
104 |
step=0.1,
|
105 |
-
value=0.
|
106 |
),
|
107 |
gr.Slider(
|
108 |
label="Top-p (nucleus sampling)",
|
109 |
minimum=0.05,
|
110 |
maximum=1.0,
|
111 |
step=0.05,
|
112 |
-
value=0.
|
113 |
),
|
114 |
gr.Slider(
|
115 |
label="Top-k",
|
116 |
minimum=1,
|
117 |
maximum=1000,
|
118 |
step=1,
|
119 |
-
value=
|
120 |
),
|
121 |
],
|
122 |
stop_btn=None,
|
123 |
examples=[
|
124 |
["ืืชืืื ืืขืืืช ืฉืืงืืื:"],
|
125 |
["ืฉืคืช ืืชืื ืืช ืคืืืืื ืืื"],
|
126 |
-
["
|
127 |
["ืฉืืื: ืืื ืขืืจ ืืืืจื ืฉื ืืืื ืช ืืฉืจืื?\nืชืฉืืื:"],
|
128 |
["ืฉืืื: ืื ื ืืืฉ ืขืืืฃ, ืื ืืืื ืื ืืขืฉืืช?\nืชืฉืืื:"],
|
129 |
],
|
@@ -136,4 +146,4 @@ with gr.Blocks(css="style.css") as demo:
|
|
136 |
gr.Markdown(LICENSE)
|
137 |
|
138 |
if __name__ == "__main__":
|
139 |
-
demo.queue(max_size=20).launch()
|
|
|
3 |
from typing import Iterator
|
4 |
|
5 |
import gradio as gr
|
6 |
+
# from gradio import MultimodalTextbox
|
7 |
+
# from gradio.data_classes import FileData
|
8 |
import spaces
|
9 |
import torch
|
10 |
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
11 |
+
from typing_extensions import NotRequired, TypedDict
|
12 |
|
13 |
MAX_MAX_NEW_TOKENS = 1024
|
14 |
DEFAULT_MAX_NEW_TOKENS = 256
|
15 |
+
MAX_INPUT_TOKEN_LENGTH = 50000
|
16 |
|
17 |
DESCRIPTION = """\
|
18 |
+
# Yam-Peleg's Hebrew-Mistral-7B-200K
|
19 |
|
20 |
+
Hebrew-Mistral-7B-200K was introduced in [this Facebook post](https://www.facebook.com/groups/MDLI1/posts/2708679492629415/).
|
21 |
|
22 |
+
Please, check the [original model card](https://huggingface.co/yam-peleg/Hebrew-Mistral-7B-200K) for more details.
|
23 |
You can see the other Hebrew models by Yam [here](https://huggingface.co/collections/yam-peleg/hebrew-models-65e957875324e2b9a4b68f08)
|
24 |
|
25 |
# Note: Use this model for only for completing sentences.
|
26 |
+
## While the user interface is of a chatbot for convenience, this is a base model and is not fine-tuned for chatbot tasks or instruction following tasks.
|
27 |
"""
|
28 |
|
29 |
LICENSE = """
|
|
|
41 |
|
42 |
|
43 |
if torch.cuda.is_available():
|
44 |
+
model_id = "yam-peleg/Hebrew-Mistral-7B-200K"
|
45 |
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", torch_dtype=torch.bfloat16, low_cpu_mem_usage=True)
|
46 |
+
tokenizer_id = "yam-peleg/Hebrew-Mistral-7B-200K"
|
47 |
tokenizer = AutoTokenizer.from_pretrained(tokenizer_id)
|
48 |
|
49 |
|
|
|
57 |
top_k: int = 30,
|
58 |
repetition_penalty: float = 1.0,
|
59 |
) -> Iterator[str]:
|
60 |
+
historical_text = ""
|
61 |
+
#Prepend the entire chat history to the message with new lines between each message
|
62 |
+
for user, assistant in chat_history:
|
63 |
+
historical_text += f"\n{user}\n{assistant}"
|
64 |
+
|
65 |
+
message = historical_text + f"\n{message}"
|
66 |
+
if len(historical_text) > 0:
|
67 |
+
message = historical_text + f"\n{message}"
|
68 |
input_ids = tokenizer([message], return_tensors="pt").input_ids
|
69 |
if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
|
70 |
input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
|
|
|
112 |
minimum=0.1,
|
113 |
maximum=4.0,
|
114 |
step=0.1,
|
115 |
+
value=0.9,
|
116 |
),
|
117 |
gr.Slider(
|
118 |
label="Top-p (nucleus sampling)",
|
119 |
minimum=0.05,
|
120 |
maximum=1.0,
|
121 |
step=0.05,
|
122 |
+
value=0.7,
|
123 |
),
|
124 |
gr.Slider(
|
125 |
label="Top-k",
|
126 |
minimum=1,
|
127 |
maximum=1000,
|
128 |
step=1,
|
129 |
+
value=40,
|
130 |
),
|
131 |
],
|
132 |
stop_btn=None,
|
133 |
examples=[
|
134 |
["ืืชืืื ืืขืืืช ืฉืืงืืื:"],
|
135 |
["ืฉืคืช ืืชืื ืืช ืคืืืืื ืืื"],
|
136 |
+
["ืืืืฉ ืืืืจืื ืืขืืื ืืฉื ืืื ืืืืจื, ืืฉืืคืชืข"],
|
137 |
["ืฉืืื: ืืื ืขืืจ ืืืืจื ืฉื ืืืื ืช ืืฉืจืื?\nืชืฉืืื:"],
|
138 |
["ืฉืืื: ืื ื ืืืฉ ืขืืืฃ, ืื ืืืื ืื ืืขืฉืืช?\nืชืฉืืื:"],
|
139 |
],
|
|
|
146 |
gr.Markdown(LICENSE)
|
147 |
|
148 |
if __name__ == "__main__":
|
149 |
+
demo.queue(max_size=20).launch()
|