Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -7,53 +7,22 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
| 7 |
from peft import PeftModel
|
| 8 |
|
| 9 |
MODELS = {
|
| 10 |
-
"Qwen3-8B
|
| 11 |
"base": "Qwen/Qwen3-8B",
|
| 12 |
-
"adapter": "hikewa/dialectic-qwen3-8b-
|
| 13 |
},
|
| 14 |
-
"Qwen3-4B
|
| 15 |
"base": "Qwen/Qwen3-4B",
|
| 16 |
-
"adapter": "hikewa/dialectic-qwen3-4b-
|
| 17 |
-
},
|
| 18 |
-
"Qwen3-4B v6 (falsifiable)": {
|
| 19 |
-
"base": "Qwen/Qwen3-4B",
|
| 20 |
-
"adapter": "hikewa/dialectic-qwen3-4b-v6-lora",
|
| 21 |
-
},
|
| 22 |
-
"Qwen3-4B v3": {
|
| 23 |
-
"base": "Qwen/Qwen3-4B",
|
| 24 |
-
"adapter": "hikewa/dialectic-qwen3-4b-v3-lora",
|
| 25 |
-
},
|
| 26 |
-
"Qwen3-4B v4 (axiom)": {
|
| 27 |
-
"base": "Qwen/Qwen3-4B",
|
| 28 |
-
"adapter": "hikewa/dialectic-qwen3-4b-v4-lora",
|
| 29 |
-
},
|
| 30 |
-
"Qwen3-8B v3": {
|
| 31 |
-
"base": "Qwen/Qwen3-8B",
|
| 32 |
-
"adapter": "hikewa/dialectic-qwen3-8b-v3-lora",
|
| 33 |
-
},
|
| 34 |
-
"Qwen3-8B v1": {
|
| 35 |
-
"base": "Qwen/Qwen3-8B",
|
| 36 |
-
"adapter": "hikewa/dialectic-qwen3-8b-lora",
|
| 37 |
-
},
|
| 38 |
-
"Qwen3-4B v2": {
|
| 39 |
-
"base": "Qwen/Qwen3-4B",
|
| 40 |
-
"adapter": "hikewa/dialectic-qwen3-4b-v2-lora",
|
| 41 |
-
},
|
| 42 |
-
"Qwen2.5-1.5B": {
|
| 43 |
-
"base": "Qwen/Qwen2.5-1.5B-Instruct",
|
| 44 |
-
"adapter": "hikewa/dialectic-qwen2.5-1.5b-lora",
|
| 45 |
-
},
|
| 46 |
-
"Qwen2.5-0.5B": {
|
| 47 |
-
"base": "Qwen/Qwen2.5-0.5B-Instruct",
|
| 48 |
-
"adapter": "hikewa/dialectic-qwen2.5-0.5b-lora",
|
| 49 |
},
|
| 50 |
}
|
| 51 |
|
| 52 |
SYSTEM_PROMPT = (
|
| 53 |
-
"You reason carefully through problems by considering competing "
|
| 54 |
-
"
|
| 55 |
-
"
|
| 56 |
-
"
|
|
|
|
| 57 |
)
|
| 58 |
|
| 59 |
loaded = {"name": None, "model": None, "tokenizer": None}
|
|
@@ -109,7 +78,7 @@ def respond(message, history, model_name):
|
|
| 109 |
with torch.no_grad():
|
| 110 |
outputs = model.generate(
|
| 111 |
**inputs,
|
| 112 |
-
max_new_tokens=
|
| 113 |
temperature=0.7,
|
| 114 |
do_sample=True,
|
| 115 |
repetition_penalty=1.1,
|
|
@@ -126,15 +95,15 @@ demo = gr.ChatInterface(
|
|
| 126 |
additional_inputs=[
|
| 127 |
gr.Dropdown(
|
| 128 |
choices=list(MODELS.keys()),
|
| 129 |
-
value="Qwen3-8B
|
| 130 |
label="Model",
|
| 131 |
),
|
| 132 |
],
|
| 133 |
title="Dialectic Reasoning Models",
|
| 134 |
description=(
|
| 135 |
-
"Fine-tuned on dialectic reasoning traces
|
| 136 |
-
"
|
| 137 |
-
"
|
| 138 |
),
|
| 139 |
examples=[
|
| 140 |
["Should AI systems be transparent about their reasoning, even when transparency reduces performance?"],
|
|
|
|
| 7 |
from peft import PeftModel
|
| 8 |
|
| 9 |
MODELS = {
|
| 10 |
+
"Qwen3-8B v8 (best)": {
|
| 11 |
"base": "Qwen/Qwen3-8B",
|
| 12 |
+
"adapter": "hikewa/dialectic-qwen3-8b-v8-lora",
|
| 13 |
},
|
| 14 |
+
"Qwen3-4B v8": {
|
| 15 |
"base": "Qwen/Qwen3-4B",
|
| 16 |
+
"adapter": "hikewa/dialectic-qwen3-4b-v8-lora",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
},
|
| 18 |
}
|
| 19 |
|
| 20 |
SYSTEM_PROMPT = (
|
| 21 |
+
"You reason carefully through problems by considering competing perspectives "
|
| 22 |
+
"before reaching a conclusion. You identify genuine tensions, engage with "
|
| 23 |
+
"the strongest form of each argument, and integrate insights rather than "
|
| 24 |
+
"picking sides or hedging. Be specific through mechanisms and conditions, "
|
| 25 |
+
"not through citations or statistics."
|
| 26 |
)
|
| 27 |
|
| 28 |
loaded = {"name": None, "model": None, "tokenizer": None}
|
|
|
|
| 78 |
with torch.no_grad():
|
| 79 |
outputs = model.generate(
|
| 80 |
**inputs,
|
| 81 |
+
max_new_tokens=512,
|
| 82 |
temperature=0.7,
|
| 83 |
do_sample=True,
|
| 84 |
repetition_penalty=1.1,
|
|
|
|
| 95 |
additional_inputs=[
|
| 96 |
gr.Dropdown(
|
| 97 |
choices=list(MODELS.keys()),
|
| 98 |
+
value="Qwen3-8B v8 (best)",
|
| 99 |
label="Model",
|
| 100 |
),
|
| 101 |
],
|
| 102 |
title="Dialectic Reasoning Models",
|
| 103 |
description=(
|
| 104 |
+
"Fine-tuned on 212 grounded dialectic reasoning traces (v8). "
|
| 105 |
+
"Mechanism-based specificity, no fabricated citations. "
|
| 106 |
+
"Pick a model size and ask a question involving competing perspectives."
|
| 107 |
),
|
| 108 |
examples=[
|
| 109 |
["Should AI systems be transparent about their reasoning, even when transparency reduces performance?"],
|