Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any tutorial for using the pretrained model for predicting new sentence pair? #157

Open
anbo724 opened this issue Dec 23, 2020 · 1 comment
Labels
question Further information is requested

Comments

@anbo724
Copy link

anbo724 commented Dec 23, 2020

I have trained the Esim and Bert model.
However, I can not found any code for predicting new sentence pair?
Is anyone can help?

@anbo724 anbo724 added the question Further information is requested label Dec 23, 2020
@cuter44
Copy link

cuter44 commented Jul 31, 2021

Here's one:

import torch
import matchzoo as mz

from anmm_train import *

test_pack = mz.datasets.wiki_qa.load_data('test', task=ranking_task)
test_processed = preprocessor.transform(test_pack, verbose=0)
testset = mz.dataloader.Dataset(
    data_pack=test_processed,
    mode='point',
    batch_size=32
)
testloader = mz.dataloader.DataLoader(
    dataset=testset,
    device=device,
    stage='test',
    callback=padding_callback
)

if __name__ == "__main__":

    trainer.restore_model("./save/model.pt")
    prediction = trainer.predict(testloader)

    pass

# end main

, where anmm_train is the code copied from repo's README, except Trainer.run(). Though you're in predict stage, the train/test dataset is still required as Trainer takes them as required parameter to construct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants