Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,11 +5,13 @@ import torch
|
|
5 |
|
6 |
import bitsandbytes as bnb
|
7 |
|
8 |
-
# 設置模型 ID 和加載 Hugging Face API token
|
9 |
model_id = "dingckc/FineLlama-3.1-8B"
|
10 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id, token=os.getenv(
|
11 |
-
model = AutoModelForCausalLM.from_pretrained(
|
12 |
-
|
|
|
|
|
|
|
13 |
|
14 |
# 定義推理函數
|
15 |
def evaluate_essay(title, essay):
|
|
|
5 |
|
6 |
import bitsandbytes as bnb
|
7 |
|
|
|
8 |
model_id = "dingckc/FineLlama-3.1-8B"
|
9 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, token=os.getenv("ACCESS_KEY"))
|
10 |
+
model = AutoModelForCausalLM.from_pretrained(
|
11 |
+
model_id,
|
12 |
+
device_map="auto", # 自動映射到可用設備(CPU)
|
13 |
+
torch_dtype=torch.float16 # 減少內存占用
|
14 |
+
)
|
15 |
|
16 |
# 定義推理函數
|
17 |
def evaluate_essay(title, essay):
|