Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,26 @@
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from fastapi.responses import JSONResponse
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
print("Version ---- 1")
|
| 6 |
app = FastAPI()
|
| 7 |
|
| 8 |
-
import torch
|
| 9 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 10 |
-
|
| 11 |
# Load model and tokenizer from Hugging Face
|
| 12 |
model_name = "deepseek-ai/DeepSeek-R1-Distill-Llama-8B"
|
| 13 |
|
| 14 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
|
|
| 15 |
model = AutoModelForCausalLM.from_pretrained(
|
| 16 |
model_name,
|
| 17 |
-
|
| 18 |
-
device_map="auto"
|
|
|
|
| 19 |
)
|
| 20 |
|
|
|
|
| 21 |
class ConflictDetectionRequest(BaseModel):
|
| 22 |
Req1: str
|
| 23 |
Req2: str
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from fastapi.responses import JSONResponse
|
| 4 |
+
import torch
|
| 5 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 6 |
+
from accelerate import init_empty_weights, infer_auto_device_map, dispatch_model
|
| 7 |
|
| 8 |
print("Version ---- 1")
|
| 9 |
app = FastAPI()
|
| 10 |
|
|
|
|
|
|
|
|
|
|
| 11 |
# Load model and tokenizer from Hugging Face
|
| 12 |
model_name = "deepseek-ai/DeepSeek-R1-Distill-Llama-8B"
|
| 13 |
|
| 14 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 15 |
+
|
| 16 |
model = AutoModelForCausalLM.from_pretrained(
|
| 17 |
model_name,
|
| 18 |
+
dtype=torch.bfloat16,
|
| 19 |
+
device_map="auto",
|
| 20 |
+
offload_folder="offload" # folder for disk offload
|
| 21 |
)
|
| 22 |
|
| 23 |
+
|
| 24 |
class ConflictDetectionRequest(BaseModel):
|
| 25 |
Req1: str
|
| 26 |
Req2: str
|