paperswithcode / galai

Model API for GALACTICA
Apache License 2.0
2.67k stars 275 forks source link

Convert Model.Generate output to readable file (txt, pdf, doc, etc) ? #46

Closed marcusvinicius178 closed 1 year ago

marcusvinicius178 commented 1 year ago

Hi I am not using a text editor, therefore I cannot visualize the output of the following code:

import galai as gal

#import gc
import torch
torch.cuda.empty_cache()
#gc.collect()

model = gal.load_model("mini", num_gpus = 1)
model.generate("Question: What is the notch signaling pathway?\n\nAnswer:") 

print(model.generate)

I would like to do something such as

model.generate("Question: What is the notch signaling pathway?\n\nAnswer:") > Output.txt

How can I do that?

phineas-pta commented 1 year ago

with very basic python i/o:

with open("output.txt", "w", encoding="utf-8") as  f:
    f.write(model.generate("Question: What is the notch signaling pathway?\n\nAnswer:"))