Spaces:
Sleeping
Sleeping
Initial probe deploy 2026-06-14 17:36:00
Browse files- requirements.txt +7 -7
- rewriter.py +7 -3
requirements.txt
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
-
fastapi=
|
| 2 |
-
uvicorn[standard]=
|
| 3 |
-
pydantic=
|
| 4 |
transformers>=4.50.0
|
| 5 |
-
torch=
|
| 6 |
-
sentence-transformers=
|
| 7 |
-
numpy<2.0
|
| 8 |
huggingface_hub>=0.25.0
|
| 9 |
-
gradio=
|
|
|
|
|
|
| 1 |
+
fastapi>=0.115.2,<1.0
|
| 2 |
+
uvicorn[standard]>=0.32.0
|
| 3 |
+
pydantic>=2.9
|
| 4 |
transformers>=4.50.0
|
| 5 |
+
torch>=2.4
|
| 6 |
+
sentence-transformers>=3.0
|
|
|
|
| 7 |
huggingface_hub>=0.25.0
|
| 8 |
+
gradio>=5.6.0
|
| 9 |
+
accelerate>=1.0
|
rewriter.py
CHANGED
|
@@ -77,9 +77,13 @@ class Rewriter:
|
|
| 77 |
{"role": "system", "content": SYSTEM_PROMPT},
|
| 78 |
{"role": "user", "content": user_message},
|
| 79 |
]
|
| 80 |
-
|
| 81 |
-
messages, add_generation_prompt=True, return_tensors="pt"
|
| 82 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
input_len = prompt_ids.shape[-1]
|
| 84 |
with torch.no_grad():
|
| 85 |
out = self.model.generate(
|
|
|
|
| 77 |
{"role": "system", "content": SYSTEM_PROMPT},
|
| 78 |
{"role": "user", "content": user_message},
|
| 79 |
]
|
| 80 |
+
encoded = self.tokenizer.apply_chat_template(
|
| 81 |
+
messages, add_generation_prompt=True, return_tensors="pt", return_dict=False
|
| 82 |
+
)
|
| 83 |
+
if hasattr(encoded, "shape"):
|
| 84 |
+
prompt_ids = encoded.to(self.device)
|
| 85 |
+
else:
|
| 86 |
+
prompt_ids = encoded["input_ids"].to(self.device)
|
| 87 |
input_len = prompt_ids.shape[-1]
|
| 88 |
with torch.no_grad():
|
| 89 |
out = self.model.generate(
|