Spaces:
Runtime error
Runtime error
michailroussos
commited on
Commit
·
78146c4
1
Parent(s):
3bc8976
more
Browse files
app.py
CHANGED
@@ -38,14 +38,30 @@ def respond(message, max_new_tokens, temperature, system_message=""):
|
|
38 |
).to("cuda")
|
39 |
|
40 |
# Debug: Inspect input tensors
|
41 |
-
print("[DEBUG] Tokenized
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
# Stream response
|
45 |
text_streamer = TextStreamer(tokenizer, skip_prompt=True)
|
46 |
response = model.generate(
|
47 |
-
input_ids=
|
48 |
-
attention_mask=
|
49 |
max_new_tokens=max_new_tokens,
|
50 |
temperature=temperature,
|
51 |
use_cache=True,
|
|
|
38 |
).to("cuda")
|
39 |
|
40 |
# Debug: Inspect input tensors
|
41 |
+
print("[DEBUG] Tokenized inputs:", inputs)
|
42 |
+
|
43 |
+
# Extract `input_ids` and `attention_mask`
|
44 |
+
input_ids = inputs.get("input_ids", None)
|
45 |
+
attention_mask = inputs.get("attention_mask", None)
|
46 |
+
|
47 |
+
# Ensure tensors are present and properly shaped
|
48 |
+
if input_ids is None or attention_mask is None:
|
49 |
+
raise ValueError("Tokenized input is missing `input_ids` or `attention_mask`.")
|
50 |
+
if input_ids.dim() != 2 or attention_mask.dim() != 2:
|
51 |
+
raise ValueError(
|
52 |
+
f"`input_ids` and `attention_mask` must be 2D tensors. "
|
53 |
+
f"Found shapes: input_ids={input_ids.shape}, attention_mask={attention_mask.shape}"
|
54 |
+
)
|
55 |
+
|
56 |
+
# Debug: Shapes of tensors
|
57 |
+
print(f"[DEBUG] input_ids shape: {input_ids.shape}")
|
58 |
+
print(f"[DEBUG] attention_mask shape: {attention_mask.shape}")
|
59 |
|
60 |
# Stream response
|
61 |
text_streamer = TextStreamer(tokenizer, skip_prompt=True)
|
62 |
response = model.generate(
|
63 |
+
input_ids=input_ids,
|
64 |
+
attention_mask=attention_mask,
|
65 |
max_new_tokens=max_new_tokens,
|
66 |
temperature=temperature,
|
67 |
use_cache=True,
|