From 6ee43a642a17d0650a626298aaf5ebd9b8d36b33 Mon Sep 17 00:00:00 2001 From: ekinakyurek Date: Tue, 5 Nov 2019 11:23:12 +0800 Subject: [PATCH 1/3] loading from array --- src/util.jl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/util.jl b/src/util.jl index 787774b..8085389 100644 --- a/src/util.jl +++ b/src/util.jl @@ -76,7 +76,13 @@ end """ function loadModel(fname::AbstractString) f = KnetLayers.load(fname) - return f["model"], f["opts"], f["vocab"], f["parser"] + prms,opts,vocab,parser = f["model"], f["opts"], f["vocab"], f["parser"] + ModelType = eval(Meta.parse(opts[:modelType])) + model = ModelType(opts,vocab) + for (wm,wl) in zip(params(model),prms) + copyto!(wm.value,wl) + end + return model,opts,vocab,parser end """ From 222bc4e28447a0d5f6eb24f097aad4314dd97fbb Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Tue, 5 Nov 2019 04:20:29 +0000 Subject: [PATCH 2/3] new load --- README.md | 16 ++++++++++++++-- src/util.jl | 6 +++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 78edc7b..c5ee4d4 100644 --- a/README.md +++ b/README.md @@ -40,12 +40,24 @@ Detailed information about experiments can be found in [scripts/](scripts/README **Note**: An Nvidia GPU is required to train the models in a reasonable amount of time. ## Tagging +Available Pre-Trained Models -Note: Limited Support +```JULIA +trained(MorseModel, TRDataSet); +trained(MorseModel, UDDataSet, lang="ru"); +trained(MorseModel, UDDataSet, lang="da"); +trained(MorseModel, UDDataSet, lang="fi"); +trained(MorseModel, UDDataSet, lang="pt"); +trained(MorseModel, UDDataSet, lang="es"); +trained(MorseModel, UDDataSet, lang="hu"); +trained(MorseModel, UDDataSet, lang="bg"); +trained(MorseModel, UDDataSet, lang="sv"); +``` +How To Use ```Julia julia> using Knet, KnetLayers, Morse - julia> model, vocabulary, parser = trained(MorseModel, TRDataSet, vers="2018"); + julia> model, vocabulary, parser = trained(MorseModel, TRDataSet); julia> predictions = model("annem sana yardım edemez .", v=vocabulary, p=parser) annem anne+Noun+A3sg+P1sg+Nom sana sen+Pron+Pers+A2sg+Pnon+Dat diff --git a/src/util.jl b/src/util.jl index 8085389..7852b87 100644 --- a/src/util.jl +++ b/src/util.jl @@ -50,11 +50,11 @@ function download(dataset::Type{TRDataSet}; path=dir("data","TrMor2018")) end end -const server_url ="ai.ku.edu.tr/models/morse/" +const server_url ="people.csail.mit.edu/deniz/models/morse/" -function download(model::Type{T}, format::Type{TRDataSet}; vers="2018", lemma=true, lang="tr") where T +function download(model::Type{T}, format; vers="2018", lemma=true, lang="tr") where T flang = format===TRDataSet ? string("TR-tr",vers) : string("UD-",lang) - mname = string(T,"_lemma_",lemma,"_lang_",flang,"_size_full",".jld2") + mname = string("bestModel.",T,"_lemma_",lemma,"_lang_",flang,"_size_full","_params.jld2") lpath = dir("checkpoints",mname) if !isfile(lpath) mpath = string(server_url, mname) From 1bb3b093dff62ffb2cc85fefcd1e533e55ce98bf Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Tue, 5 Nov 2019 04:28:13 +0000 Subject: [PATCH 3/3] update readme --- README.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c5ee4d4..e1879e7 100644 --- a/README.md +++ b/README.md @@ -40,20 +40,24 @@ Detailed information about experiments can be found in [scripts/](scripts/README **Note**: An Nvidia GPU is required to train the models in a reasonable amount of time. ## Tagging + Available Pre-Trained Models ```JULIA trained(MorseModel, TRDataSet); -trained(MorseModel, UDDataSet, lang="ru"); -trained(MorseModel, UDDataSet, lang="da"); -trained(MorseModel, UDDataSet, lang="fi"); -trained(MorseModel, UDDataSet, lang="pt"); -trained(MorseModel, UDDataSet, lang="es"); -trained(MorseModel, UDDataSet, lang="hu"); -trained(MorseModel, UDDataSet, lang="bg"); -trained(MorseModel, UDDataSet, lang="sv"); +trained(MorseModel, UDDataSet, lang="ru"); # Russian +trained(MorseModel, UDDataSet, lang="da"); # Danish +trained(MorseModel, UDDataSet, lang="fi"); # Finnish +trained(MorseModel, UDDataSet, lang="pt"); # Portuguese +trained(MorseModel, UDDataSet, lang="es"); # Español +trained(MorseModel, UDDataSet, lang="hu"); # Hungarian +trained(MorseModel, UDDataSet, lang="bg"); # Bulgarian +trained(MorseModel, UDDataSet, lang="sv"); # Swedish ``` -How To Use + +### How To Use + +Note: Please use lowercased and tokenized inputs. ```Julia julia> using Knet, KnetLayers, Morse