Upload moondream.py
Browse files- moondream.py +3 -1
moondream.py
CHANGED
@@ -321,13 +321,15 @@ class Moondream(PreTrainedModel):
|
|
321 |
**kwargs,
|
322 |
):
|
323 |
prompt = f"<image>\n\n{chat_history}Question: {question}\n\nAnswer:"
|
324 |
-
|
325 |
image_embeds,
|
326 |
prompt,
|
327 |
tokenizer=tokenizer,
|
328 |
max_new_tokens=512,
|
329 |
**kwargs,
|
330 |
)
|
|
|
|
|
331 |
|
332 |
def batch_answer(
|
333 |
self,
|
|
|
321 |
**kwargs,
|
322 |
):
|
323 |
prompt = f"<image>\n\n{chat_history}Question: {question}\n\nAnswer:"
|
324 |
+
generator = self.generate(
|
325 |
image_embeds,
|
326 |
prompt,
|
327 |
tokenizer=tokenizer,
|
328 |
max_new_tokens=512,
|
329 |
**kwargs,
|
330 |
)
|
331 |
+
async for token in generator:
|
332 |
+
yield token
|
333 |
|
334 |
def batch_answer(
|
335 |
self,
|