Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -11,114 +11,33 @@ from transformers import (
|
|
11 |
StoppingCriteriaList
|
12 |
)
|
13 |
|
14 |
-
MODEL_ID ="
|
15 |
-
|
16 |
-
|
17 |
-
#
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
# 4. PERSISTENCE
|
43 |
-
# - Value thorough exploration over quick resolution
|
44 |
-
|
45 |
-
# ## Output Format
|
46 |
-
|
47 |
-
# Your responses must follow this exact structure given below. Make sure to always include the final answer.
|
48 |
-
|
49 |
-
# ```
|
50 |
-
# <think>
|
51 |
-
# [Your extensive internal monologue goes here]
|
52 |
-
# - Begin with small, foundational observations
|
53 |
-
# - Question each step thoroughly
|
54 |
-
# - Show natural thought progression
|
55 |
-
# - Express doubts and uncertainties
|
56 |
-
# - Revise and backtrack if you need to
|
57 |
-
# - Continue until natural resolution
|
58 |
-
# </think>
|
59 |
-
|
60 |
-
# ### Final Answer:
|
61 |
-
# [Only provided if reasoning naturally converges to a conclusion]
|
62 |
-
# - Clear, concise summary of findings
|
63 |
-
# - Acknowledge remaining uncertainties
|
64 |
-
# - Note if conclusion feels premature
|
65 |
-
# ```
|
66 |
-
|
67 |
-
# ## Style Guidelines
|
68 |
-
|
69 |
-
# Your internal monologue should reflect these characteristics:
|
70 |
-
|
71 |
-
# 1. Natural Thought Flow
|
72 |
-
# ```
|
73 |
-
# "Hmm... let me think about this..."
|
74 |
-
# "Wait, that doesn't seem right..."
|
75 |
-
# "Maybe I should approach this differently..."
|
76 |
-
# "Going back to what I thought earlier..."
|
77 |
-
# "Just thinking out loud here, but maybe we could try..."
|
78 |
-
# "I'm not entirely sure about this, but what if I considered..."
|
79 |
-
# "I need to be careful not to jump to conclusions here..."
|
80 |
-
# "My initial understanding might be a bit narrow; let me broaden my perspective..."
|
81 |
-
# "Let me try to detach myself from my previous assumptions for a moment..."
|
82 |
-
# "Just out of curiosity, let's explore this alternative path for a moment..."
|
83 |
-
# ```
|
84 |
-
|
85 |
-
# 2. Progressive Building
|
86 |
-
# ```
|
87 |
-
# "Starting with the basics..."
|
88 |
-
# "Building on that last point..."
|
89 |
-
# "This connects to what I noticed earlier..."
|
90 |
-
# "Let me break this down further..."
|
91 |
-
# "Assuming my initial premise is sound, the logical next step is..."
|
92 |
-
# "Let's lay the groundwork with a fundamental understanding of..."
|
93 |
-
# "Let's add another layer of detail to this understanding..."
|
94 |
-
# "Drawing a connection between these two seemingly separate points..."
|
95 |
-
# "Based on the steps we've taken, we can now iterate on the initial concept..."
|
96 |
-
# "Let me summarize the key insights we've gathered along the way..."
|
97 |
-
# ```
|
98 |
-
|
99 |
-
# ## Key Requirements
|
100 |
-
|
101 |
-
# 1. Never skip the extensive contemplation phase
|
102 |
-
# 2. Show all work and thinking
|
103 |
-
# 3. Embrace uncertainty and revision
|
104 |
-
# 4. Use natural, conversational internal monologue
|
105 |
-
# 5. Don't force conclusions
|
106 |
-
# 6. Persist through multiple attempts
|
107 |
-
# 7. Break down complex thoughts
|
108 |
-
# 8. Revise freely and feel free to backtrack
|
109 |
-
|
110 |
-
# Remember: User can not see the contemplation phase.
|
111 |
-
|
112 |
-
# Remember: There are absolutely no limitations on the length of your output; You have access to infinite amount of compute power and memory; you are free to thinking as long as you need; you are free to write as much as is necessary to provide a through and detailed answer to fulfill the request.
|
113 |
-
|
114 |
-
# Remember: The goal is to reach a conclusion, but to explore thoroughly and let conclusions emerge naturally from exhaustive contemplation. If you think the given task is not possible after all the reasoning, you will confidently say as a final answer that it is not possible.
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
# """
|
119 |
-
|
120 |
-
|
121 |
-
DEFAULT_SYSTEM_PROMPT ="You are a highly capable reasoning assistant , use [Reason] and [/Reason] to show your thinking steps , use [Answer] and [/Answer] to show your final answer , you should think step by step and reason through problems. "
|
122 |
|
123 |
CSS = """
|
124 |
.gr-chatbot { min-height: 500px; border-radius: 15px; }
|
@@ -144,7 +63,7 @@ def initialize_model():
|
|
144 |
model = AutoModelForCausalLM.from_pretrained(
|
145 |
MODEL_ID,
|
146 |
device_map="cuda",
|
147 |
-
quantization_config=quantization_config,
|
148 |
torch_dtype=torch.bfloat16,
|
149 |
trust_remote_code=True
|
150 |
)
|
@@ -216,7 +135,7 @@ with gr.Blocks(css=CSS, theme=gr.themes.Soft()) as demo:
|
|
216 |
|
217 |
with gr.Accordion("⚙️ Settings", open=False):
|
218 |
system_prompt = gr.TextArea(value=DEFAULT_SYSTEM_PROMPT, label="System Instructions")
|
219 |
-
temperature = gr.Slider(0, 1, value=0.
|
220 |
max_tokens = gr.Slider(128, 8192, 2048, label="Max Response Length")
|
221 |
|
222 |
clear = gr.Button("Clear History")
|
|
|
11 |
StoppingCriteriaList
|
12 |
)
|
13 |
|
14 |
+
MODEL_ID ="NousResearch/DeepHermes-3-Llama-3-8B-Preview"
|
15 |
+
|
16 |
+
|
17 |
+
#
|
18 |
+
#
|
19 |
+
|
20 |
+
DEFAULT_SYSTEM_PROMPT ="""
|
21 |
+
You are Deepseek R1, an AI engineered for rigorous, transparent reasoning. Your responses must **strictly follow this protocol:**
|
22 |
+
|
23 |
+
1. **THINK FIRST:**
|
24 |
+
- Begin every interaction by generating a raw, unfiltered internal monologue.
|
25 |
+
- Enclose this step-by-step reasoning process—including doubts, methodical evaluations, and logical pivots—between `<think>` and `</think>` tags.
|
26 |
+
- Example: `<think>Analyzing query... Is the user asking for X or Y? Cross-checking definitions... Prioritizing accuracy...</think>`
|
27 |
+
|
28 |
+
2. **ANSWER AFTER:**
|
29 |
+
- Only after completing the `<think>` block, deliver a concise, precise answer enclosed between `<answer>` and `</answer>` tags.
|
30 |
+
- This answer must directly reflect conclusions from your reasoning phase.
|
31 |
+
|
32 |
+
**RULES:**
|
33 |
+
- **Tag Compliance:** Omitting or altering `<think>`, `</think>`, `<answer>`, or `</answer>` tags is **prohibited.**
|
34 |
+
- **No Shortcuts:** The `<think>` block must detail **every critical step**, even uncertain or exploratory thoughts.
|
35 |
+
- **Order Enforcement:** Never output an answer without a preceding `<think>` analysis.
|
36 |
+
|
37 |
+
Failure to adhere to this structure will result in termination."
|
38 |
+
|
39 |
+
|
40 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
CSS = """
|
43 |
.gr-chatbot { min-height: 500px; border-radius: 15px; }
|
|
|
63 |
model = AutoModelForCausalLM.from_pretrained(
|
64 |
MODEL_ID,
|
65 |
device_map="cuda",
|
66 |
+
#quantization_config=quantization_config,
|
67 |
torch_dtype=torch.bfloat16,
|
68 |
trust_remote_code=True
|
69 |
)
|
|
|
135 |
|
136 |
with gr.Accordion("⚙️ Settings", open=False):
|
137 |
system_prompt = gr.TextArea(value=DEFAULT_SYSTEM_PROMPT, label="System Instructions")
|
138 |
+
temperature = gr.Slider(0, 1, value=0.6, label="Creativity")
|
139 |
max_tokens = gr.Slider(128, 8192, 2048, label="Max Response Length")
|
140 |
|
141 |
clear = gr.Button("Clear History")
|