StevenChen16 commited on
Commit
ab96ee1
1 Parent(s): 8f48aeb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py CHANGED
@@ -1,3 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  from llamafactory.chat import ChatModel
3
  from llamafactory.extras.misc import torch_gc
@@ -5,6 +23,8 @@ import re
5
  import spaces
6
  from threading import Thread
7
 
 
 
8
  def split_into_sentences(text):
9
  sentence_endings = re.compile(r'(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?|\!)\s')
10
  sentences = sentence_endings.split(text)
 
1
+ # 配置环境
2
+ import subprocess
3
+ # 克隆GitHub仓库
4
+ subprocess.run(["git", "clone", "https://github.com/hiyouga/LLaMA-Factory.git"], check=True)
5
+ # 切换到仓库目录
6
+ import os
7
+ os.chdir("LLaMA-Factory")
8
+ # 列出目录内容
9
+ subprocess.run(["ls"], check=True)
10
+ # 安装unsloth
11
+ subprocess.run(["pip", "install", "unsloth[colab-new]@git+https://github.com/unslothai/unsloth.git"], check=True)
12
+ # 安装xformers
13
+ subprocess.run(["pip", "install", "-U", "xformers==0.0.25"], check=True)
14
+ # 安装当前目录下的依赖
15
+ subprocess.run(["pip", "install", ".[torch,bitsandbytes]"], check=True)
16
+
17
+
18
+
19
  import gradio as gr
20
  from llamafactory.chat import ChatModel
21
  from llamafactory.extras.misc import torch_gc
 
23
  import spaces
24
  from threading import Thread
25
 
26
+
27
+
28
  def split_into_sentences(text):
29
  sentence_endings = re.compile(r'(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?|\!)\s')
30
  sentences = sentence_endings.split(text)