Update README.md
Browse files
README.md
CHANGED
|
@@ -25,24 +25,31 @@ You can find **DialoguePrompts** here: https://huggingface.co/datasets/XD-MU/Dia
|
|
| 25 |
```bash
|
| 26 |
import os
|
| 27 |
from huggingface_hub import snapshot_download
|
| 28 |
-
|
| 29 |
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
|
| 30 |
|
| 31 |
model_name = "XD-MU/ScriptAgent"
|
| 32 |
local_path = "./models/ScriptAgent"
|
| 33 |
|
|
|
|
|
|
|
| 34 |
snapshot_download(
|
| 35 |
repo_id=model_name,
|
| 36 |
local_dir=local_path,
|
| 37 |
-
local_dir_use_symlinks=False,
|
| 38 |
-
resume_download=True
|
| 39 |
)
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
engine = PtEngine(local_path, max_batch_size=1)
|
| 42 |
request_config = RequestConfig(max_tokens=8192, temperature=0.7)
|
| 43 |
|
| 44 |
infer_request = InferRequest(messages=[
|
| 45 |
-
{"role": "user", "content": "Your Dialogue"}
|
| 46 |
])
|
| 47 |
response = engine.infer([infer_request], request_config)[0]
|
| 48 |
|
|
|
|
| 25 |
```bash
|
| 26 |
import os
|
| 27 |
from huggingface_hub import snapshot_download
|
| 28 |
+
|
| 29 |
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
|
| 30 |
|
| 31 |
model_name = "XD-MU/ScriptAgent"
|
| 32 |
local_path = "./models/ScriptAgent"
|
| 33 |
|
| 34 |
+
# 下载整个仓库的所有文件
|
| 35 |
+
print("下载模型所有文件...")
|
| 36 |
snapshot_download(
|
| 37 |
repo_id=model_name,
|
| 38 |
local_dir=local_path,
|
| 39 |
+
local_dir_use_symlinks=False,
|
| 40 |
+
resume_download=True
|
| 41 |
)
|
| 42 |
|
| 43 |
+
print(f"模型已完整下载到: {local_path}")
|
| 44 |
+
|
| 45 |
+
# 使用 SWIFT 加载
|
| 46 |
+
from swift.llm import PtEngine, RequestConfig, InferRequest
|
| 47 |
+
|
| 48 |
engine = PtEngine(local_path, max_batch_size=1)
|
| 49 |
request_config = RequestConfig(max_tokens=8192, temperature=0.7)
|
| 50 |
|
| 51 |
infer_request = InferRequest(messages=[
|
| 52 |
+
{"role": "user", "content": "你的对话上下文(Your Dialogue)"}
|
| 53 |
])
|
| 54 |
response = engine.infer([infer_request], request_config)[0]
|
| 55 |
|