Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,13 @@ import os
|
|
| 7 |
from typing import List, Optional
|
| 8 |
from datetime import datetime # 需在文件开头导入
|
| 9 |
from fastapi.responses import MarkdownResponse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# 1. 初始化FastAPI应用
|
| 12 |
app = FastAPI(
|
|
|
|
| 7 |
from typing import List, Optional
|
| 8 |
from datetime import datetime # 需在文件开头导入
|
| 9 |
from fastapi.responses import MarkdownResponse
|
| 10 |
+
import os
|
| 11 |
+
os.environ["TRANSFORMERS_CACHE"] = "/tmp/huggingface_cache"
|
| 12 |
+
class CrossEncoderWrapper:
|
| 13 |
+
def __init__(self):
|
| 14 |
+
self.model_name = "cross-encoder/ms-marco-MiniLM-L-6-v2"
|
| 15 |
+
self.tokenizer = AutoTokenizer.from_pretrained(self.model_name)
|
| 16 |
+
self.model = AutoModelForSequenceClassification.from_pretrained(self.model_name)
|
| 17 |
|
| 18 |
# 1. 初始化FastAPI应用
|
| 19 |
app = FastAPI(
|