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

How to load an existing trained model and make predictions on the unseen data? #575

Open
emadpres opened this issue Jul 18, 2019 · 1 comment

Comments

@emadpres
Copy link

emadpres commented Jul 18, 2019

Hi everyone,

I'm very fresh in AI field and I'm trying to learn how to use XNMT to create a simple English->German translator. Here's my very basic question:

What I did

I followed the Getting Started page and after reading different YAML files, and modified the 01_standard.yaml file to train a model in the following way:

!Experiment
  name: codecomment
  model: !DefaultTranslator
    src_reader: !PlainTextReader
      vocab: !Vocab {vocab_file: /Users/emadpres/Downloads/toy-ende/src-test.vocab.txt}
    trg_reader: !PlainTextReader
      vocab: !Vocab {vocab_file: /Users/emadpres/Downloads/toy-ende/tgt-test.vocab.txt}
  train: !SimpleTrainingRegimen
    run_for_epochs: 2
    src_file: /Users/emadpres/Downloads/toy-ende/src-test.txt
    trg_file: /Users/emadpres/Downloads/toy-ende/tgt-test.txt
    dev_tasks:
      - !LossEvalTask
        src_file: /Users/emadpres/Downloads/toy-ende/src-test.txt
        ref_file: /Users/emadpres/Downloads/toy-ende/tgt-test.txt
  evaluate:
    - !AccuracyEvalTask
      eval_metrics: bleu
      src_file: /Users/emadpres/Downloads/toy-ende/src-test.txt
      ref_file: /Users/emadpres/Downloads/toy-ende/tgt-test.txt
      hyp_file: examples/output/{EXP}.test_hyp

where src-test.txt and tgt-test.txt are a list of sentences (separated with new line) in English and German, respectively. the corresponding "*.vocab.txt" files include the tokens using nltk.tokenize.

It worked and it created the following model files:

  • xnmt/example/models/codecomment.mod
  • xnmt/example/models/codecomment.mod.data/*

Problem

How can I load and use my trained model to make predictions on the unseen data, like giving an English sentence and see what is the result?

I looked into API and sample config files. They usually show how to load and fine-tune an existing model, not how to use it in practice. Note that I don't want to provide a pair of (input, expected output) as we do for the evaluation step. I want to see get the output for a given input.

Any help or hint is welcome.

@emadpres emadpres changed the title How to load and use an existing trained model? How to load an existing trained model and make predictions on the unseen data? Jul 18, 2019
@philip30
Copy link
Contributor

Hi, you'd probably want to see this: https://github.com/neulab/xnmt/blob/master/examples/08_load_eval_beam.yaml

This is the way of loading pretrained model and doing evaluation.

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

No branches or pull requests

2 participants