aberbossio commited on
Commit
887e87f
·
verified ·
1 Parent(s): 0f8139c

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +26 -12
  2. app.py +50 -0
  3. requirements.txt +3 -0
README.md CHANGED
@@ -1,12 +1,26 @@
1
- ---
2
- title: Ai2
3
- emoji: 📚
4
- colorFrom: green
5
- colorTo: yellow
6
- sdk: gradio
7
- sdk_version: 6.9.0
8
- app_file: app.py
9
- pinned: false
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Qwen3.5 Reasoning Chat (Claude Distilled)
3
+ emoji: 🧠
4
+ colorFrom: blue
5
+ colorTo: indigo
6
+ sdk: gradio
7
+ app_file: app.py
8
+ pinned: false
9
+ license: apache-2.0
10
+ ---
11
+
12
+ # Qwen3.5 Reasoning Chat (Claude 4.6 Distilled)
13
+
14
+ This project runs the **Jackrong/Qwen3.5-9B-Claude-4.6-Opus-Reasoning-Distilled-v2-GGUF** model using `llama-cpp-python`.
15
+
16
+ It is specifically tuned to follow a **Chain-of-Thought (CoT)** reasoning process using `<think>` tags, distilled from Claude 4.6 Opus trajectories.
17
+
18
+ ## Features
19
+ - **GGUF Optimized:** Runs efficiently on CPU.
20
+ - **Reasoning First:** Designed to "think" before answering.
21
+ - **No API Key Required:** Runs the model directly within the Space environment.
22
+
23
+ ## Deployment
24
+ 1. Log in: `huggingface-cli login`
25
+ 2. Create Space: `huggingface-cli repo create qwen3.5-reasoning --repo-type space --sdk gradio`
26
+ 3. Upload: `huggingface-cli upload <username>/qwen3.5-reasoning . --repo-type space`
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from huggingface_hub import hf_hub_download
3
+ from llama_cpp import Llama
4
+ import os
5
+
6
+ # 1. Configuration - Specify the model and the specific GGUF file
7
+ model_id = "Jackrong/Qwen3.5-9B-Claude-4.6-Opus-Reasoning-Distilled-v2-GGUF"
8
+ filename = "Qwen3.5-9B-Claude-4.6-Opus-Reasoning-Distilled-v2-Q4_K_M.gguf"
9
+
10
+ print(f"Downloading model: {filename}...")
11
+ model_path = hf_hub_download(repo_id=model_id, filename=filename)
12
+
13
+ # 2. Initialize the model
14
+ # n_ctx is the context window. 2048 is a safe starting point for free Hugging Face Spaces.
15
+ llm = Llama(model_path=model_path, n_ctx=2048, n_threads=os.cpu_count())
16
+
17
+ def generate_response(message, history):
18
+ # Construct the prompt for reasoning models
19
+ # They typically look for a specific structure to trigger <think> tags.
20
+ prompt = f"<|im_start|>system\nYou are a helpful assistant with advanced reasoning capabilities. Use <think> tags for your internal logic.<|im_end|>\n"
21
+
22
+ for user_msg, assistant_msg in history:
23
+ prompt += f"<|im_start|>user\n{user_msg}<|im_end|>\n"
24
+ prompt += f"<|im_start|>assistant\n{assistant_msg}<|im_end|>\n"
25
+
26
+ prompt += f"<|im_start|>user\n{message}<|im_end|>\n<|im_start|>assistant\n<think>\n"
27
+
28
+ output = llm(
29
+ prompt,
30
+ max_tokens=1024,
31
+ stop=["<|im_end|>"],
32
+ stream=True
33
+ )
34
+
35
+ response = ""
36
+ for chunk in output:
37
+ delta = chunk['choices'][0]['text']
38
+ response += delta
39
+ yield response
40
+
41
+ # 3. Create the UI
42
+ demo = gr.ChatInterface(
43
+ generate_response,
44
+ title="Qwen 3.5 Reasoning Chat (Claude Distilled)",
45
+ description="This Space runs the Qwen3.5-9B reasoning model distilled from Claude 4.6 Opus logic.",
46
+ examples=["Solve the riddle: What has keys but can't open locks?", "Explain quantum entanglement in simple terms."],
47
+ )
48
+
49
+ if __name__ == "__main__":
50
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ huggingface_hub
3
+ llama-cpp-python