Spaces:
Sleeping
Sleeping
Upload repo-clon-subprces.py
Browse files- repo-clon-subprces.py +59 -0
repo-clon-subprces.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import subprocess
|
2 |
+
import os
|
3 |
+
import urllib.request
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
|
7 |
+
def clone_power_infer():
|
8 |
+
repo_url = "https://github.com/SJTU-IPADS/PowerInfer.git"
|
9 |
+
subprocess.run(["git", "clone", repo_url])
|
10 |
+
|
11 |
+
def install_requirements():
|
12 |
+
subprocess.run(["pip", "install", "-r", "requirements.txt"])
|
13 |
+
|
14 |
+
def cmake_builds():
|
15 |
+
subprocess.run(["cmake", "-S", ".", "-B", "build"])
|
16 |
+
|
17 |
+
# Run cmake --build build --config Release
|
18 |
+
subprocess.run(["cmake", "--build", "build", "--config", "Release"])
|
19 |
+
|
20 |
+
clone_power_infer()
|
21 |
+
os.chdir("PowerInfer")
|
22 |
+
install_requirements()
|
23 |
+
cmake_builds()
|
24 |
+
|
25 |
+
os.mkdir("ReluLLaMA-7B-PowerInfer-GGUF")
|
26 |
+
|
27 |
+
|
28 |
+
# URL to download the file from
|
29 |
+
url = "https://huggingface.co/PowerInfer/ReluLLaMA-7B-PowerInfer-GGUF/resolve/main/llama-7b-relu.powerinfer.gguf"
|
30 |
+
|
31 |
+
# Destination path to save the downloaded file
|
32 |
+
destination_path = "ReluLLaMA-7B-PowerInfer-GGUF/"
|
33 |
+
|
34 |
+
# Download the file
|
35 |
+
urllib.request.urlretrieve(url, destination_path)
|
36 |
+
|
37 |
+
def chat(question):
|
38 |
+
command = [
|
39 |
+
"./build/bin/main",
|
40 |
+
"-m", "./ReluLLaMA-7B-PowerInfer-GGUF/llama-7b-relu.powerinfer.gguf",
|
41 |
+
"-n", "128",
|
42 |
+
"-t", "8",
|
43 |
+
"-p", question
|
44 |
+
]
|
45 |
+
|
46 |
+
# Run the command
|
47 |
+
subprocess.run(command)
|
48 |
+
|
49 |
+
screen = gr.Interface(
|
50 |
+
fn = chat,
|
51 |
+
inputs = gr.Textbox(lines = 10, placeholder = "Enter your question here π"),
|
52 |
+
outputs = gr.Textbox(lines = 10, placeholder = "Your answer will be here soon π"),
|
53 |
+
title="Inference with Powerinfer π©π»βπ»πβπ»π‘",
|
54 |
+
description="This app aims to facilitate the inference of LLMs using Powerinferπ‘",
|
55 |
+
theme="soft",
|
56 |
+
# examples=["Hello", "what is the speed of human nerve impulses?"],
|
57 |
+
)
|
58 |
+
|
59 |
+
screen.launch()
|