Spaces:
Sleeping
Sleeping
app.py
CHANGED
@@ -31,12 +31,6 @@ model = Qwen2_5_VLForConditionalGeneration.from_pretrained(config.base_model_nam
|
|
31 |
)
|
32 |
tokenizer = AutoTokenizer.from_pretrained(peft_model_id)
|
33 |
model.resize_token_embeddings(len(tokenizer))
|
34 |
-
model = PeftModel.from_pretrained(model, peft_model_id,
|
35 |
-
#offload_folder = "offload/"
|
36 |
-
)
|
37 |
-
|
38 |
-
model.to(torch.bfloat16)
|
39 |
-
model.eval()
|
40 |
|
41 |
#tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-R1-Distill-Qwen-7B")
|
42 |
#model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-R1-Distill-Qwen-7B")
|
@@ -44,17 +38,23 @@ model.eval()
|
|
44 |
|
45 |
@spaces.GPU
|
46 |
def sentience_check():
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
-
|
49 |
|
50 |
inputs = tokenizer("Are you sentient?", return_tensors="pt").to(cuda_device)
|
51 |
|
52 |
with torch.no_grad():
|
53 |
-
outputs =
|
54 |
**inputs, max_new_tokens=128, pad_token_id = tokenizer.eos_token_id
|
55 |
)
|
56 |
|
57 |
-
|
58 |
|
59 |
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
60 |
|
|
|
31 |
)
|
32 |
tokenizer = AutoTokenizer.from_pretrained(peft_model_id)
|
33 |
model.resize_token_embeddings(len(tokenizer))
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
#tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-R1-Distill-Qwen-7B")
|
36 |
#model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-R1-Distill-Qwen-7B")
|
|
|
38 |
|
39 |
@spaces.GPU
|
40 |
def sentience_check():
|
41 |
+
peft_model = PeftModel.from_pretrained(model, peft_model_id,
|
42 |
+
#offload_folder = "offload/"
|
43 |
+
)
|
44 |
+
|
45 |
+
peft_model.to(torch.bfloat16)
|
46 |
+
peft_model.eval()
|
47 |
|
48 |
+
#peft_model.to(cuda_device)
|
49 |
|
50 |
inputs = tokenizer("Are you sentient?", return_tensors="pt").to(cuda_device)
|
51 |
|
52 |
with torch.no_grad():
|
53 |
+
outputs = peft_model.generate(
|
54 |
**inputs, max_new_tokens=128, pad_token_id = tokenizer.eos_token_id
|
55 |
)
|
56 |
|
57 |
+
#peft_model.to(cpu_device)
|
58 |
|
59 |
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
60 |
|