ThomasSimonini HF staff commited on
Commit
66dc5cd
·
verified ·
1 Parent(s): 16e549d

Upload moondream.py

Browse files
Files changed (1) hide show
  1. 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
- return self.generate(
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,