hsuwill000 commited on
Commit
f422903
·
verified ·
1 Parent(s): ccb4d99

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -6,6 +6,18 @@ from llama_cpp import Llama
6
  from huggingface_hub import snapshot_download
7
 
8
  # 下载并转换模型
 
 
 
 
 
 
 
 
 
 
 
 
9
  def setup_model(model_id):
10
  local_dir = model_id.split('/')[-1]
11
  if not os.path.exists(local_dir):
@@ -25,6 +37,8 @@ def setup_model(model_id):
25
 
26
  # 设定模型路径
27
  MODEL_ID = "ibm-granite/granite-3.1-2b-instruct"
 
 
28
  MODEL_PATH = setup_model(MODEL_ID)
29
 
30
  # 加载 Llama 模型
 
6
  from huggingface_hub import snapshot_download
7
 
8
  # 下载并转换模型
9
+ def git_llama():
10
+ if not os.path.exists('llama.cpp'):
11
+ run_command('git clone https://github.com/ggml-org/llama.cpp.git')
12
+
13
+ # 进入仓库目录并编译
14
+ os.chdir('llama.cpp')
15
+ run_command('pip install -r requirements.txt')
16
+ run_command('cmake -B build')
17
+ run_command('cmake --build build --config Release -j 8')
18
+ os.chdir('..') # 返回上级目录
19
+
20
+
21
  def setup_model(model_id):
22
  local_dir = model_id.split('/')[-1]
23
  if not os.path.exists(local_dir):
 
37
 
38
  # 设定模型路径
39
  MODEL_ID = "ibm-granite/granite-3.1-2b-instruct"
40
+
41
+ git_llama()
42
  MODEL_PATH = setup_model(MODEL_ID)
43
 
44
  # 加载 Llama 模型