【问题标题】:AllenNLP) Is there a way to set config for evaluation, epeicially for reader?AllenNLP)有没有办法为评估设置配置,特别是为读者?
【发布时间】:2021-07-01 07:48:59
【问题描述】:

我是 allenNLP 库的新手。 为了为dataset_reader 设置参数,我想设置用于评估的配置,例如火车 (https://github.com/allenai/allennlp-template-config-files/blob/master/training_config/my_model_trained_on_my_dataset.jsonnet)

但我不确定是否有用于评估的配置文件模板,例如火车,并且下面的配置文件有效(其中 train_data_pathtrainer 部分被删除。)

{
    "dataset_reader" : {
        // This name needs to match the name that you used to register your dataset reader, with
        // the call to `@DatasetReader.register()`.
        "type": "classification-tsv",
        // These other parameters exactly match the constructor parameters of your dataset reader class.
        "token_indexers": {
            "tokens": {
                "type": "single_id"
            }
        }
    },
    "validation_data_path": "/path/to/your/validation/data/here.tsv",
    "model": {
        // This name needs to match the name that you used to register your model, with
        // the call to `@Model.register()`.
        "type": "simple_classifier",
        // These other parameters exactly match the constructor parameters of your model class.
        "embedder": {
            "token_embedders": {
                "tokens": {
                    "type": "embedding",
                    "embedding_dim": 10
                }
            }
        },
        "encoder": {
            "type": "bag_of_embeddings",
            "embedding_dim": 10
        }
    },
    "data_loader": {
        // See http://docs.allennlp.org/master/api/data/dataloader/ for more info on acceptable
        // parameters here.
        "batch_size": 8,
        "shuffle": true
    },
}

提前致谢。

【问题讨论】:

  • 您可以使用完全相同的配置文件进行训练和评估。如果您确实需要在数据集阅读器中使用不同的参数进行 eval,除了“dataset_reader”之外,您还可以设置“validation_dataset_reader”字段。

标签: allennlp


【解决方案1】:

@petew 的回答是正确的。 allennlp evaluate 不读取配置文件。它使用与模型一起存储的配置文件。运行allennlp evaluate -h 以获取更多信息。

如果您需要数据集读取器在评估时表现不同,请使用配置文件中的 validation_dataset_reader 字段。这将在训练期间(用于 epoch 结束时的评估)以及稍后运行 allennlp evaluate 时生效。

【讨论】:

  • 我明白了,看来如果我想使用预训练模型,那么没有办法单独更改配置文件。
  • 我猜你想在模型已经训练好之后设置一个validation_dataset_reader?您可以解压缩模型存档,更改配置,然后将其压缩备份。
  • 或者你想做的是使用allennlp predict
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-06-06
  • 2013-02-01
  • 2011-10-19
  • 1970-01-01
  • 2012-08-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多