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

Commit

Permalink
fixes for next_token_lm (#85)
Browse files Browse the repository at this point in the history
* fixes for next_token_lm

* update CHANGELOG
  • Loading branch information
epwalsh authored Jun 30, 2020
1 parent 37136f8 commit 0ce14da
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- `CopyNetSeq2Seq` model now works with pretrained transformers.
- A bug with `NextTokenLM` that caused simple gradient interpreters to fail.

### Changed

Expand Down
1 change: 0 additions & 1 deletion allennlp_models/lm/models/next_token_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ def make_output_human_readable(
)
output_dict["words"] = top_words
tokens = []
print(output_dict["token_ids"])
for instance_tokens in output_dict["token_ids"]:
tokens.append(
[
Expand Down
5 changes: 4 additions & 1 deletion allennlp_models/lm/predictors/next_token_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ def predictions_to_labeled_instances(
):
new_instance = instance.duplicate()
token_field: TextField = instance["tokens"] # type: ignore
mask_targets = [Token(target_top_k[0]) for target_top_k in outputs["words"]]
mask_targets = [
Token(target_top_k_text[0], text_id=target_top_id_id)
for (target_top_k_text, target_top_id_id) in zip(outputs["words"], outputs["token_ids"])
]

new_instance.add_field(
"target_ids",
Expand Down

0 comments on commit 0ce14da

Please sign in to comment.