Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -21,8 +21,18 @@ vectordb = FAISS.from_documents(split_docs, embeddings)
|
|
21 |
|
22 |
# Load model and create pipeline
|
23 |
model_name = "01-ai/Yi-Coder-9B-Chat"
|
|
|
|
|
|
|
|
|
24 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
25 |
-
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
qa_pipeline = pipeline(
|
27 |
"text-generation",
|
28 |
model=model,
|
|
|
21 |
|
22 |
# Load model and create pipeline
|
23 |
model_name = "01-ai/Yi-Coder-9B-Chat"
|
24 |
+
|
25 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
26 |
+
print(f"Using device: {device}")
|
27 |
+
|
28 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
29 |
+
#model = AutoModelForCausalLM.from_pretrained(model_name, device_map="cuda", torch_dtype="auto")
|
30 |
+
model = AutoModelForCausalLM.from_pretrained(
|
31 |
+
model_name,
|
32 |
+
device_map=device,
|
33 |
+
torch_dtype=torch.float16 if device == "cuda" else torch.float32
|
34 |
+
)
|
35 |
+
#model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto", torch_dtype="auto")
|
36 |
qa_pipeline = pipeline(
|
37 |
"text-generation",
|
38 |
model=model,
|