Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

add a new PyText get_num_examples_from_batch function in model #1319

Closed

Conversation

psuzhanhy
Copy link
Contributor

Summary:
Usually in PyText dataloader, each row (sentence) is read as an example, i.e. create List[sentences], and the number of examples in the batch is simply len(List[data]).

This is not correct for language model: in LM, each word is considered as an example.

Reviewed By: kmalik22

Differential Revision: D21032297

@facebook-github-bot facebook-github-bot added CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported labels Apr 15, 2020
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D21032297

psuzhanhy added a commit to psuzhanhy/pytext that referenced this pull request Apr 15, 2020
…ookresearch#1319)

Summary:
Pull Request resolved: facebookresearch#1319

Usually in PyText dataloader, each row (sentence) is read as an example, i.e. create List[sentences], and the number of examples in the batch is simply len(List[data]).

This is not correct for language model: in LM, each word is considered as an example.

Reviewed By: kmalik22

Differential Revision: D21032297

fbshipit-source-id: f04d98b1f1a1ef1a5e50c57c825633f484e1c725
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D21032297

…ookresearch#1319)

Summary:
Pull Request resolved: facebookresearch#1319

Provide a get_num_examples_from_batch() function to model.

It is not enforce to be overriden, nor used often except for federated learning training setting. But it is used, pytext developers need to override them for their model. We override it for LMLSTM, DocModel, and QueryDocPairwiseRankingModel in this diff.

Reviewed By: kmalik22

Differential Revision: D21032297

fbshipit-source-id: 2086dcb81101ffbd36debf37b38debee509cf8fc
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D21032297

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 522e079.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants