Spaces:
Sleeping
Sleeping
Commit
·
bb86659
1
Parent(s):
4526b2c
first version
Browse files
app.py
CHANGED
@@ -33,14 +33,14 @@ if not torch.cuda.is_available():
|
|
33 |
DESCRIPTION += "\n<p>Running on CPU 🥶 This demo does not work on CPU.</p>"
|
34 |
|
35 |
|
36 |
-
|
37 |
-
model_id = "meta-llama/Llama-2-7b-chat-hf"
|
38 |
-
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")
|
39 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
40 |
-
tokenizer.use_default_system_prompt = False
|
41 |
|
42 |
|
43 |
-
|
44 |
def generate(
|
45 |
message: str,
|
46 |
chat_history: list[tuple[str, str]],
|
|
|
33 |
DESCRIPTION += "\n<p>Running on CPU 🥶 This demo does not work on CPU.</p>"
|
34 |
|
35 |
|
36 |
+
if torch.cuda.is_available():
|
37 |
+
model_id = "meta-llama/Llama-2-7b-chat-hf"
|
38 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")
|
39 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
40 |
+
tokenizer.use_default_system_prompt = False
|
41 |
|
42 |
|
43 |
+
@spaces.GPU
|
44 |
def generate(
|
45 |
message: str,
|
46 |
chat_history: list[tuple[str, str]],
|