Spaces:
Sleeping
Sleeping
jerukperas
commited on
Commit
•
01a9f90
1
Parent(s):
39f9c9e
wip
Browse files- Dockerfile +40 -0
- app.py +24 -0
Dockerfile
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.10
|
2 |
+
|
3 |
+
RUN apt-get update && \
|
4 |
+
apt-get install -y \
|
5 |
+
build-essential \
|
6 |
+
libssl-dev \
|
7 |
+
libffi-dev \
|
8 |
+
libbz2-dev \
|
9 |
+
liblzma-dev \
|
10 |
+
zlib1g-dev \
|
11 |
+
libsqlite3-dev \
|
12 |
+
wget \
|
13 |
+
curl \
|
14 |
+
git \
|
15 |
+
cmake \
|
16 |
+
libblis64-4 \
|
17 |
+
libblis64-4-openmp \
|
18 |
+
libblis64-4-pthread \
|
19 |
+
libblis64-4-serial \
|
20 |
+
libblis64-dev \
|
21 |
+
libblis64-openmp-dev \
|
22 |
+
libblis64-pthread-dev \
|
23 |
+
libblis64-serial-dev && \
|
24 |
+
apt-get clean && \
|
25 |
+
rm -rf /var/lib/apt/lists/*
|
26 |
+
|
27 |
+
RUN useradd -m -u 1000 user
|
28 |
+
USER user
|
29 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
30 |
+
ENV GOMP_CPU_AFFINITY="0-19"
|
31 |
+
ENV BLIS_NUM_THREADS=14
|
32 |
+
|
33 |
+
WORKDIR /app
|
34 |
+
|
35 |
+
RUN pip install --no-cache-dir --upgrade pip
|
36 |
+
RUN CMAKE_ARGS="-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=FLAME" \
|
37 |
+
pip install llama-cpp-python
|
38 |
+
|
39 |
+
COPY --chown=user ./app.py /app/app.py
|
40 |
+
CMD ["python", "app.py"]
|
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from llama_cpp import Llama
|
3 |
+
|
4 |
+
print("Downloading model")
|
5 |
+
llm = Llama.from_pretrained(
|
6 |
+
repo_id="bartowski/gemma-2-2b-it-abliterated-GGUF",
|
7 |
+
filename="gemma-2-2b-it-abliterated-IQ4_XS.gguf",
|
8 |
+
numa=True,
|
9 |
+
n_ctx=4096,
|
10 |
+
)
|
11 |
+
|
12 |
+
|
13 |
+
def respond(prompt: str):
|
14 |
+
stream = llm.create_chat_completion(stream=True, messages=[{"role": "user", "content": prompt}])
|
15 |
+
|
16 |
+
response = ""
|
17 |
+
for chunk in stream:
|
18 |
+
if "content" in chunk["choices"][0]["delta"]:
|
19 |
+
response += chunk["choices"][0]["delta"]["content"]
|
20 |
+
yield response
|
21 |
+
|
22 |
+
|
23 |
+
demo = gr.Interface(fn=respond, inputs=[gr.TextArea("What is the capital of France?")], outputs=[gr.TextArea()])
|
24 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|