Upload 4 files
Browse files
Dockerfile
CHANGED
|
@@ -4,26 +4,33 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 4 |
python3 python3-pip curl ca-certificates \
|
| 5 |
&& rm -rf /var/lib/apt/lists/*
|
| 6 |
|
| 7 |
-
# Download llama.cpp pre-built binary
|
| 8 |
RUN curl -L https://github.com/ggml-org/llama.cpp/releases/download/b8468/llama-b8468-bin-ubuntu-x64.tar.gz \
|
| 9 |
-o /tmp/llama.tar.gz \
|
| 10 |
&& mkdir -p /opt/llama \
|
| 11 |
-
&& tar xzf /tmp/llama.tar.gz -C /opt/llama
|
| 12 |
-
&& rm /tmp/llama.tar.gz
|
|
|
|
|
|
|
| 13 |
|
|
|
|
| 14 |
ENV PATH="/opt/llama/build/bin:/opt/llama/bin:$PATH" \
|
| 15 |
-
LD_LIBRARY_PATH="/opt/llama/build/bin:/opt/llama/lib:$LD_LIBRARY_PATH"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
RUN useradd -m -u 1000 user
|
| 18 |
USER user
|
| 19 |
-
ENV HOME=/home/user PATH="/home/user/.local/bin:/
|
| 20 |
WORKDIR /home/user/app
|
| 21 |
|
| 22 |
-
RUN pip3 install --no-cache-dir --user
|
| 23 |
-
gradio huggingface_hub openai
|
| 24 |
|
| 25 |
COPY --chown=user app.py .
|
| 26 |
COPY --chown=user start.sh .
|
|
|
|
| 27 |
|
| 28 |
EXPOSE 7860
|
| 29 |
-
CMD ["bash", "start.sh"]
|
|
|
|
| 4 |
python3 python3-pip curl ca-certificates \
|
| 5 |
&& rm -rf /var/lib/apt/lists/*
|
| 6 |
|
| 7 |
+
# Download llama.cpp pre-built binary (latest ubuntu x64)
|
| 8 |
RUN curl -L https://github.com/ggml-org/llama.cpp/releases/download/b8468/llama-b8468-bin-ubuntu-x64.tar.gz \
|
| 9 |
-o /tmp/llama.tar.gz \
|
| 10 |
&& mkdir -p /opt/llama \
|
| 11 |
+
&& tar xzf /tmp/llama.tar.gz -C /opt/llama \
|
| 12 |
+
&& rm /tmp/llama.tar.gz \
|
| 13 |
+
&& find /opt/llama -name "llama-server" -exec dirname {} \; > /tmp/bindir.txt \
|
| 14 |
+
&& echo "Binary dir: $(cat /tmp/bindir.txt)"
|
| 15 |
|
| 16 |
+
# Make all llama binaries accessible
|
| 17 |
ENV PATH="/opt/llama/build/bin:/opt/llama/bin:$PATH" \
|
| 18 |
+
LD_LIBRARY_PATH="/opt/llama/build/bin:/opt/llama/lib:/opt/llama:$LD_LIBRARY_PATH"
|
| 19 |
+
|
| 20 |
+
# Add symlinks so llama-server is always found
|
| 21 |
+
RUN find /opt/llama -name "llama-server" -exec ln -sf {} /usr/local/bin/llama-server \; \
|
| 22 |
+
&& find /opt/llama -name "*.so*" -exec cp {} /usr/local/lib/ \; 2>/dev/null; ldconfig || true
|
| 23 |
|
| 24 |
RUN useradd -m -u 1000 user
|
| 25 |
USER user
|
| 26 |
+
ENV HOME=/home/user PATH="/home/user/.local/bin:/usr/local/bin:$PATH"
|
| 27 |
WORKDIR /home/user/app
|
| 28 |
|
| 29 |
+
RUN pip3 install --no-cache-dir --user gradio huggingface_hub openai
|
|
|
|
| 30 |
|
| 31 |
COPY --chown=user app.py .
|
| 32 |
COPY --chown=user start.sh .
|
| 33 |
+
RUN chmod +x start.sh
|
| 34 |
|
| 35 |
EXPOSE 7860
|
| 36 |
+
CMD ["bash", "start.sh"]
|
README.md
CHANGED
|
@@ -11,9 +11,4 @@ license: apache-2.0
|
|
| 11 |
|
| 12 |
# Qwen3.5-9B Claude 4.6 Opus Reasoning Distilled v2
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
- Claude 4.6 Opus reasoning patterns distilled into Qwen3.5-9B
|
| 17 |
-
- Optimized for coding, math, and logical reasoning tasks
|
| 18 |
-
- Supports Myanmar/Burmese language
|
| 19 |
-
- Running on CPU with llama-cpp-python
|
|
|
|
| 11 |
|
| 12 |
# Qwen3.5-9B Claude 4.6 Opus Reasoning Distilled v2
|
| 13 |
|
| 14 |
+
Powered by **Qwen3.5-9B-Claude-4.6-Opus-Reasoning-Distilled-v2** (Q4_K_M GGUF) + llama.cpp server.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
|
@@ -18,27 +18,50 @@ def chat(message, history, system_prompt, max_tokens, temperature, show_thinking
|
|
| 18 |
messages.append({"role": "assistant", "content": h["content"]})
|
| 19 |
messages.append({"role": "user", "content": message})
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
-
with gr.Blocks(title="Qwen3.5-9B Claude Reasoning") as demo:
|
| 36 |
-
gr.Markdown(
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
with gr.Row():
|
| 39 |
max_tokens = gr.Slider(64, 2048, 512, step=64, label="Max Tokens")
|
| 40 |
temperature = gr.Slider(0.1, 1.5, 0.7, step=0.1, label="Temperature")
|
| 41 |
show_thinking = gr.Checkbox(label="Show thinking", value=False)
|
| 42 |
-
gr.ChatInterface(fn=chat, additional_inputs=[system_prompt, max_tokens, temperature, show_thinking])
|
| 43 |
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
messages.append({"role": "assistant", "content": h["content"]})
|
| 19 |
messages.append({"role": "user", "content": message})
|
| 20 |
|
| 21 |
+
try:
|
| 22 |
+
stream = client.chat.completions.create(
|
| 23 |
+
model="local",
|
| 24 |
+
messages=messages,
|
| 25 |
+
max_tokens=int(max_tokens),
|
| 26 |
+
temperature=float(temperature),
|
| 27 |
+
stream=True,
|
| 28 |
+
)
|
| 29 |
+
partial = ""
|
| 30 |
+
for chunk in stream:
|
| 31 |
+
delta = chunk.choices[0].delta.content or ""
|
| 32 |
+
partial += delta
|
| 33 |
+
if show_thinking:
|
| 34 |
+
yield partial
|
| 35 |
+
else:
|
| 36 |
+
yield strip_think_tags(partial)
|
| 37 |
+
except Exception as e:
|
| 38 |
+
yield f"Error: {str(e)} - llama-server is still loading, please wait and try again."
|
| 39 |
|
| 40 |
+
with gr.Blocks(title="Qwen3.5-9B Claude Reasoning", theme=gr.themes.Soft()) as demo:
|
| 41 |
+
gr.Markdown(
|
| 42 |
+
"""
|
| 43 |
+
# Qwen3.5-9B Claude 4.6 Opus Reasoning Distilled v2
|
| 44 |
+
CPU inference ααΌα
αΊαα²α·α‘αα½ααΊ response 30s-2min ααΌα¬ααα―ααΊαα«αααΊα ααΌααΊαα¬ααα―αααΊαΈ αα±αΈααα―α·ααα«αααΊα
|
| 45 |
+
"""
|
| 46 |
+
)
|
| 47 |
+
system_prompt = gr.Textbox(
|
| 48 |
+
label="System Prompt",
|
| 49 |
+
value="You are a helpful coding and reasoning assistant. Respond in the same language the user uses.",
|
| 50 |
+
lines=2,
|
| 51 |
+
)
|
| 52 |
with gr.Row():
|
| 53 |
max_tokens = gr.Slider(64, 2048, 512, step=64, label="Max Tokens")
|
| 54 |
temperature = gr.Slider(0.1, 1.5, 0.7, step=0.1, label="Temperature")
|
| 55 |
show_thinking = gr.Checkbox(label="Show thinking", value=False)
|
|
|
|
| 56 |
|
| 57 |
+
gr.ChatInterface(
|
| 58 |
+
fn=chat,
|
| 59 |
+
additional_inputs=[system_prompt, max_tokens, temperature, show_thinking],
|
| 60 |
+
examples=[
|
| 61 |
+
["Python ααΎα¬ decorator αααΊααα―αα―αΆαΈααα²"],
|
| 62 |
+
["Write a Flask REST API with JWT auth"],
|
| 63 |
+
["FizzBuzz ααα― recursive function αα²α· αα±αΈααΌαα«"],
|
| 64 |
+
],
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
start.sh
CHANGED
|
@@ -1,28 +1,38 @@
|
|
| 1 |
#!/bin/bash
|
|
|
|
| 2 |
|
| 3 |
-
echo "Downloading model
|
| 4 |
-
python3 -c "
|
| 5 |
from huggingface_hub import hf_hub_download
|
| 6 |
path = hf_hub_download(
|
| 7 |
repo_id='Jackrong/Qwen3.5-9B-Claude-4.6-Opus-Reasoning-Distilled-v2-GGUF',
|
| 8 |
-
filename='Qwen3.5-9B
|
| 9 |
)
|
| 10 |
-
print(
|
| 11 |
-
"
|
| 12 |
|
| 13 |
-
|
| 14 |
|
| 15 |
-
echo "Starting llama-server
|
| 16 |
llama-server \
|
| 17 |
--model "$MODEL_PATH" \
|
| 18 |
--host 127.0.0.1 \
|
| 19 |
--port 8080 \
|
| 20 |
--ctx-size 2048 \
|
| 21 |
--threads 2 \
|
| 22 |
-
--batch-size 256
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
echo "Starting Gradio app
|
| 28 |
-
python3 app.py
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
+
set -e
|
| 3 |
|
| 4 |
+
echo "=== Downloading model ==="
|
| 5 |
+
MODEL_PATH=$(python3 -c "
|
| 6 |
from huggingface_hub import hf_hub_download
|
| 7 |
path = hf_hub_download(
|
| 8 |
repo_id='Jackrong/Qwen3.5-9B-Claude-4.6-Opus-Reasoning-Distilled-v2-GGUF',
|
| 9 |
+
filename='Qwen3.5-9B.Q4_K_M.gguf',
|
| 10 |
)
|
| 11 |
+
print(path)
|
| 12 |
+
")
|
| 13 |
|
| 14 |
+
echo "Model path: $MODEL_PATH"
|
| 15 |
|
| 16 |
+
echo "=== Starting llama-server ==="
|
| 17 |
llama-server \
|
| 18 |
--model "$MODEL_PATH" \
|
| 19 |
--host 127.0.0.1 \
|
| 20 |
--port 8080 \
|
| 21 |
--ctx-size 2048 \
|
| 22 |
--threads 2 \
|
| 23 |
+
--batch-size 256 \
|
| 24 |
+
--log-disable &
|
| 25 |
|
| 26 |
+
# Wait for server to be ready
|
| 27 |
+
echo "Waiting for llama-server to start..."
|
| 28 |
+
for i in $(seq 1 30); do
|
| 29 |
+
if curl -s http://127.0.0.1:8080/health > /dev/null 2>&1; then
|
| 30 |
+
echo "llama-server is ready!"
|
| 31 |
+
break
|
| 32 |
+
fi
|
| 33 |
+
echo " attempt $i/30..."
|
| 34 |
+
sleep 2
|
| 35 |
+
done
|
| 36 |
|
| 37 |
+
echo "=== Starting Gradio app ==="
|
| 38 |
+
exec python3 app.py
|