Spaces:
Runtime error
Runtime error
first
Browse files- .idea/Gemma_2B_DataScience_RAFT_QA.iml +3 -1
- .idea/misc.xml +7 -0
- app.py +7 -13
.idea/Gemma_2B_DataScience_RAFT_QA.iml
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<module type="PYTHON_MODULE" version="4">
|
3 |
<component name="NewModuleRootManager">
|
4 |
-
<content url="file://$MODULE_DIR$"
|
|
|
|
|
5 |
<orderEntry type="inheritedJdk" />
|
6 |
<orderEntry type="sourceFolder" forTests="false" />
|
7 |
</component>
|
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<module type="PYTHON_MODULE" version="4">
|
3 |
<component name="NewModuleRootManager">
|
4 |
+
<content url="file://$MODULE_DIR$">
|
5 |
+
<excludeFolder url="file://$MODULE_DIR$/.venv_custom_v" />
|
6 |
+
</content>
|
7 |
<orderEntry type="inheritedJdk" />
|
8 |
<orderEntry type="sourceFolder" forTests="false" />
|
9 |
</component>
|
.idea/misc.xml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="Black">
|
4 |
+
<option name="sdkName" value="Python 3.12 (Gemma_2B_DataScience_RAFT_QA)" />
|
5 |
+
</component>
|
6 |
+
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (Gemma_2B_DataScience_RAFT_QA)" project-jdk-type="Python SDK" />
|
7 |
+
</project>
|
app.py
CHANGED
@@ -15,17 +15,11 @@ pipeline = transformers.pipeline(
|
|
15 |
device="cuda",
|
16 |
)
|
17 |
|
|
|
|
|
18 |
@spaces.GPU
|
19 |
-
def chat_function(message, history,
|
20 |
-
|
21 |
-
{"role": "system", "content": system_prompt},
|
22 |
-
{"role": "user", "content": message},
|
23 |
-
]
|
24 |
-
prompt = pipeline.tokenizer.apply_chat_template(
|
25 |
-
messages,
|
26 |
-
tokenize=False,
|
27 |
-
add_generation_prompt=True
|
28 |
-
)
|
29 |
print(prompt)
|
30 |
temp = temperature + 0.1
|
31 |
outputs = pipeline(
|
@@ -41,14 +35,14 @@ gr.ChatInterface(
|
|
41 |
chat_function,
|
42 |
chatbot=gr.Chatbot(height=400),
|
43 |
textbox=gr.Textbox(placeholder="Enter message here", container=False, scale=7),
|
44 |
-
title="
|
45 |
description="""
|
46 |
This space is dedicated for chatting with Gemma 2B Finetuned for Data Science QA using RAFT. Find this model here: https://huggingface.co/ModularityAI/gemma-2b-datascience-it-raft
|
47 |
Feel free to play with customization in the "Additional Inputs".
|
|
|
48 |
""",
|
49 |
-
theme="
|
50 |
additional_inputs=[
|
51 |
-
gr.Textbox("You are helpful AI.", label="System Prompt"),
|
52 |
gr.Slider(512, 4096, label="Max New Tokens"),
|
53 |
gr.Slider(0, 1, label="Temperature")
|
54 |
]
|
|
|
15 |
device="cuda",
|
16 |
)
|
17 |
|
18 |
+
def format_test_question(q):
|
19 |
+
return f"<bos><start_of_turn>user {q} <end_of_turn>model "
|
20 |
@spaces.GPU
|
21 |
+
def chat_function(message, history,max_new_tokens,temperature):
|
22 |
+
prompt = format_test_question(message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
print(prompt)
|
24 |
temp = temperature + 0.1
|
25 |
outputs = pipeline(
|
|
|
35 |
chat_function,
|
36 |
chatbot=gr.Chatbot(height=400),
|
37 |
textbox=gr.Textbox(placeholder="Enter message here", container=False, scale=7),
|
38 |
+
title="Gemma 2B Data Science QA RAFT Demo",
|
39 |
description="""
|
40 |
This space is dedicated for chatting with Gemma 2B Finetuned for Data Science QA using RAFT. Find this model here: https://huggingface.co/ModularityAI/gemma-2b-datascience-it-raft
|
41 |
Feel free to play with customization in the "Additional Inputs".
|
42 |
+
Fine tune Notebook: https://www.kaggle.com/code/hanzlajavaid/gemma-finetuning-raft-technique
|
43 |
""",
|
44 |
+
theme="Monochrome",
|
45 |
additional_inputs=[
|
|
|
46 |
gr.Slider(512, 4096, label="Max New Tokens"),
|
47 |
gr.Slider(0, 1, label="Temperature")
|
48 |
]
|