chengchingwen / Transformers.jl

Julia Implementation of Transformer models
MIT License
523 stars 74 forks source link

Remove const from vocab for AttentionIsAllYouNeed example #47

Closed nmoran closed 3 years ago

nmoran commented 3 years ago

When const is there. the following error results when trying to run the example with tasks other than the task example. Removing the const allows the example to run.

$ julia --project example/AttentionIsAllYouNeed/1-model.jl -g wmt14
ERROR: LoadError: cannot declare vocab constant; it already has a value
Stacktrace:                                       
 [1] top-level scope at .../Transformers.jl/example/AttentionIsAllYouNeed/1-model.jl:19
 [2] include(::Function, ::Module, ::String) at ./Base.jl:380
 [3] include(::Module, ::String) at ./Base.jl:368                                                    
 [4] exec_options(::Base.JLOptions) at ./client.jl:296
 [5] _start() at ./client.jl:506
in expression starting at .../Transformers.jl/example/AttentionIsAllYouNeed/1-model.jl:19
chengchingwen commented 3 years ago

Thanks for finding this bug. However, since the vocab is treated as a Vocabulary type in the rest of code, using Ref will introduce other problems. I think a quick fix for this PR would be simply remove the const keyword.

nmoran commented 3 years ago

Thanks for pointing that out. Have just updated to simply remove the const. This was the first version I tried before looking into using a Ref. Thought I had reverted to the original before committing but looks like I hadn't.