Skip to content

Commit d68a6f5

Browse files
committed
dependency update and the overall reanimation
1 parent cf9b7c1 commit d68a6f5

22 files changed

+422
-152
lines changed

.github/workflows/CompatHelper.yml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,48 @@ on:
33
schedule:
44
- cron: 23 23 * * *
55
workflow_dispatch:
6+
permissions:
7+
contents: write
8+
pull-requests: write
69
jobs:
710
CompatHelper:
811
runs-on: ubuntu-latest
912
steps:
10-
- name: Pkg.add("CompatHelper")
11-
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
12-
- name: CompatHelper.main()
13+
- name: Check if Julia is already available in the PATH
14+
id: julia_in_path
15+
run: which julia
16+
continue-on-error: true
17+
- name: Install Julia, but only if it is not already available in the PATH
18+
uses: julia-actions/setup-julia@v2
19+
with:
20+
version: '1'
21+
arch: ${{ runner.arch }}
22+
if: steps.julia_in_path.outcome != 'success'
23+
- name: "Add the General registry via Git"
24+
run: |
25+
import Pkg
26+
ENV["JULIA_PKG_SERVER"] = ""
27+
Pkg.Registry.add("General")
28+
shell: julia --color=yes {0}
29+
- name: "Install CompatHelper"
30+
run: |
31+
import Pkg
32+
name = "CompatHelper"
33+
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
34+
version = "3"
35+
Pkg.add(; name, uuid, version)
36+
shell: julia --color=yes {0}
37+
- name: "Run CompatHelper"
38+
run: |
39+
import CompatHelper
40+
CompatHelper.main()
41+
shell: julia --color=yes {0}
1342
env:
1443
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
# This repo uses Documenter, so we can reuse our [Documenter SSH key](https://documenter.juliadocs.org/stable/man/hosting/walkthrough/).
45+
# If we didn't have one of those setup, we could configure a dedicated ssh deploy key `COMPATHELPER_PRIV` following https://juliaregistries.github.io/CompatHelper.jl/dev/#Creating-SSH-Key.
46+
# Either way, we need an SSH key if we want the PRs that CompatHelper creates to be able to trigger CI workflows themselves.
47+
# That is because GITHUB_TOKEN's can't trigger other workflows (see https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow).
48+
# Check if you have a deploy key setup using these docs: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/reviewing-your-deploy-keys.
1549
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
16-
run: julia -e 'using CompatHelper; CompatHelper.main()'
50+
# COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }}

.github/workflows/TagBot.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@ on:
44
types:
55
- created
66
workflow_dispatch:
7+
inputs:
8+
lookback:
9+
default: 3
10+
permissions:
11+
actions: read
12+
checks: read
13+
contents: write
14+
deployments: read
15+
issues: read
16+
discussions: read
17+
packages: read
18+
pages: read
19+
pull-requests: read
20+
repository-projects: read
21+
security-events: read
22+
statuses: read
723
jobs:
824
TagBot:
925
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
@@ -12,3 +28,5 @@ jobs:
1228
- uses: JuliaRegistries/TagBot@v1
1329
with:
1430
token: ${{ secrets.GITHUB_TOKEN }}
31+
# Edit the following line to reflect the actual name of the GitHub Secret containing your private key
32+
ssh: ${{ secrets.DOCUMENTER_KEY }}

.github/workflows/ci.yml

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ jobs:
1313
strategy:
1414
matrix:
1515
version:
16-
- '1.6'
16+
- '1.10'
17+
- '1'
1718
- 'nightly'
1819
os:
1920
- ubuntu-latest
@@ -28,33 +29,67 @@ jobs:
2829
# MacOS not available on x86
2930
- {os: 'macOS-latest', arch: 'x86'}
3031
# Don't test on all versions
31-
- {os: 'macOS-latest', version: '1.6'}
32+
- {os: 'macOS-latest', version: '1.10'}
3233
- {os: 'macOS-latest', version: 'nightly'}
33-
- {os: 'windows-latest', version: '1.6'}
34+
- {os: 'windows-latest', version: '1.10'}
3435
- {os: 'windows-latest', version: 'nightly'}
3536
- {os: 'windows-latest', arch: 'x86'}
36-
- {arch: 'x86', version: '1.6'}
37+
- {arch: 'x86', version: '1.10'}
3738
- {arch: 'x86', version: 'nightly'}
3839
steps:
39-
- uses: actions/checkout@v1
40+
- uses: actions/checkout@v4
4041
- uses: julia-actions/setup-julia@latest
4142
with:
4243
version: ${{ matrix.version }}
4344
arch: ${{ matrix.arch }}
44-
- uses: julia-actions/julia-buildpkg@latest
45-
- uses: julia-actions/julia-runtest@latest
45+
- uses: julia-actions/cache@v2
46+
- name: Install dependencies
47+
run: |
48+
if [[ "${{ matrix.version }}" == "1" || "${{ matrix.version }}" == "nightly" ]]; then
49+
# Julia 1.11+ - Install dependencies without any precompilation
50+
julia --project=. -e 'using Pkg; Pkg.instantiate(; allow_autoprecomp=false)'
51+
else
52+
# Julia 1.10 and earlier work normally
53+
julia --project=. -e 'using Pkg; Pkg.instantiate()'
54+
fi
55+
env:
56+
JULIA_CUDA_USE_BINARYBUILDER: false
57+
JULIA_PKG_PRECOMPILE_AUTO: 0
58+
shell: bash
59+
- name: Explicit precompilation
60+
run: |
61+
if [[ "${{ matrix.version }}" == "1" || "${{ matrix.version }}" == "nightly" ]]; then
62+
# Julia 1.11+ - Minimal precompilation to avoid world age and segfault issues
63+
echo "Skipping precompilation for Julia 1.11+ to avoid world age issues"
64+
else
65+
# Julia 1.10 - Precompile everything normally
66+
julia --project=. -e 'using Pkg; Pkg.precompile()'
67+
fi
68+
env:
69+
JULIA_CUDA_USE_BINARYBUILDER: false
70+
shell: bash
71+
- name: Run tests
72+
run: |
73+
if [[ "${{ matrix.version }}" == "1" || "${{ matrix.version }}" == "nightly" ]]; then
74+
# Julia 1.11+ - Use minimal compilation and precompilation to avoid world age issues
75+
julia --compiled-modules=no --pkgimages=no --color=yes --project=. -e 'using Pkg; Pkg.test()'
76+
else
77+
# Julia 1.10 and earlier can use normal compiled modules
78+
julia --color=yes --project=. -e 'using Pkg; Pkg.test()'
79+
fi
4680
env:
4781
DATADEPS_ALWAYS_ACCEPT: true
48-
with:
49-
coverage: false
82+
JULIA_CUDA_USE_BINARYBUILDER: false
83+
JULIA_PKG_PRECOMPILE_AUTO: 0
84+
shell: bash
5085
docs:
5186
name: Documentation
5287
runs-on: ubuntu-latest
5388
steps:
54-
- uses: actions/checkout@v1
89+
- uses: actions/checkout@v4
5590
- uses: julia-actions/setup-julia@latest
5691
with:
57-
version: '1.6'
92+
version: '1.11'
5893
- run: julia --project=docs -e '
5994
using Pkg;
6095
Pkg.develop(PackageSpec(; path=pwd()));

Project.toml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name = "TextModels"
22
uuid = "77b9cbda-2a23-51df-82a3-24144d1cd378"
33
license = "MIT"
44
desc = "Practical Neural Network based models for Natural Language Processing"
5-
version = "0.1.1"
5+
version = "0.2.0"
66

77
[deps]
88
BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0"
@@ -12,6 +12,7 @@ DataDeps = "124859b0-ceae-595e-8997-d05f6a7a8dfe"
1212
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
1313
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
1414
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
15+
Functors = "d9f16b24-f501-4c13-a1f2-28368ffc5196"
1516
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
1617
Languages = "8ef0a80b-9436-5d2c-a485-80b904378c43"
1718
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
@@ -24,19 +25,20 @@ WordTokenizers = "796a5d58-b03d-544a-977e-18100b691f6e"
2425
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
2526

2627
[compat]
27-
BSON = "0.3.3"
28-
CUDA = "3"
28+
BSON = "0.3"
29+
CUDA = "3, 4, 5"
2930
CorpusLoaders = "0.3"
3031
DataDeps = "0.7"
31-
DataStructures = "0.18.9"
32-
Flux = "0.12.8"
33-
JSON = "0.21.1"
34-
Languages = "0.4.3"
35-
NNlib = "0.7"
36-
StatsBase = "0.33.6"
37-
TextAnalysis = "0.7.3"
38-
WordTokenizers = "0.5.6"
39-
Zygote = "0.6.10"
32+
DataStructures = "0.18, 0.19, 0.20"
33+
Flux = "0.16, 0.17"
34+
Functors = "0.4, 0.5, 0.6"
35+
JSON = "0.21, 0.22"
36+
Languages = "0.4"
37+
NNlib = "0.7, 0.8, 0.9, 0.10"
38+
StatsBase = "0.33, 0.34, 0.35"
39+
TextAnalysis = "0.8"
40+
WordTokenizers = "0.5, 0.6"
41+
Zygote = "0.7, 0.8"
4042
julia = "1.6"
4143

4244
[extras]

docs/src/crf.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This package currently provides support for Linear Chain Conditional Random Fiel
55
Let us first load the dependencies-
66

77
using Flux
8-
using Flux: onehot, train!, Params, gradient, LSTM, Dense, reset!
8+
using Flux: onehot, LSTM, Dense, reset!
99
using TextModels: CRF, viterbi_decode, crf_loss
1010

1111
Conditional Random Field layer is essentially like a softmax that operates on the top most layer.

docs/src/sentiment.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ A StringDocument{String}
2727
julia> m(d1)
2828
0.5183109f0
2929

30-
julia> d = StringDocument("a horrible thing that everyone hates")
30+
julia> d2 = StringDocument("a horrible thing that everyone hates")
3131
A StringDocument{String}
3232
* Language: Languages.English()
3333
* Title: Untitled Document

docs/src/tagging.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The pretrained model can also be loaded and can be used directly to predict tags
3636

3737
### To train model:
3838
```julia
39-
julia> tagger = PerceptronTagger(false) #we can use tagger = PerceptronTagger()
39+
julia> tagger = TextModels.PerceptronTagger(false) #we can use tagger = TextModels.PerceptronTagger()
4040
julia> fit!(tagger, [[("today","NN"),("is","VBZ"),("good","JJ"),("day","NN")]])
4141
iteration : 1
4242
iteration : 2
@@ -47,7 +47,7 @@ iteration : 5
4747

4848
### To load pretrained model:
4949
```julia
50-
julia> tagger = PerceptronTagger(true)
50+
julia> tagger = TextModels.PerceptronTagger(true)
5151
loaded successfully
5252
PerceptronTagger(AveragePerceptron(Set(Any["JJS", "NNP_VBZ", "NN_NNS", "CC", "NNP_NNS", "EX", "NNP_TO", "VBD_DT", "LS", ("Council", "NNP") … "NNPS", "NNP_LS", "VB", "NNS_NN", "NNP_SYM", "VBZ", "VBZ_JJ", "UH", "SYM", "NNP_NN", "CD"]), Dict{Any,Any}("i+2 word wetlands"=>Dict{Any,Any}("NNS"=>0.0,"JJ"=>0.0,"NN"=>0.0),"i-1 tag+i word NNP basic"=>Dict{Any,Any}("JJ"=>0.0,"IN"=>0.0),"i-1 tag+i word DT chloride"=>Dict{Any,Any}("JJ"=>0.0,"NN"=>0.0),"i-1 tag+i word NN choo"=>Dict{Any,Any}("NNP"=>0.0,"NN"=>0.0),"i+1 word antarctica"=>Dict{Any,Any}("FW"=>0.0,"NN"=>0.0),"i-1 tag+i word -START- appendix"=>Dict{Any,Any}("NNP"=>0.0,"NNPS"=>0.0,"NN"=>0.0),"i-1 word wahoo"=>Dict{Any,Any}("JJ"=>0.0,"VBD"=>0.0),"i-1 tag+i word DT children's"=>Dict{Any,Any}("NNS"=>0.0,"NN"=>0.0),"i word dnipropetrovsk"=>Dict{Any,Any}("NNP"=>0.003,"NN"=>-0.003),"i suffix hla"=>Dict{Any,Any}("JJ"=>0.0,"NN"=>0.0)…), DefaultDict{Any,Any,Int64}(), DefaultDict{Any,Any,Int64}(), 1, ["-START-", "-START2-"]), Dict{Any,Any}("is"=>"VBZ","at"=>"IN","a"=>"DT","and"=>"CC","for"=>"IN","by"=>"IN","Retrieved"=>"VBN","was"=>"VBD","He"=>"PRP","in"=>"IN"…), Set(Any["JJS", "NNP_VBZ", "NN_NNS", "CC", "NNP_NNS", "EX", "NNP_TO", "VBD_DT", "LS", ("Council", "NNP") … "NNPS", "NNP_LS", "VB", "NNS_NN", "NNP_SYM", "VBZ", "VBZ_JJ", "UH", "SYM", "NNP_NN", "CD"]), ["-START-", "-START2-"], ["-END-", "-END2-"], Any[])
5353
```

src/CRF/crf.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ function CRF(n::Integer)
2525
return CRF(W, n)
2626
end
2727

28-
@functor CRF
28+
using Functors
29+
Functors.@functor CRF
2930

3031
function Base.show(io::IO, c::CRF)
3132
print(io, "CRF with ", c.n + 2, " distinct tags (including START and STOP tags).")

src/CRF/loss.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ thereby preventing operation.
2525
eltype(label_seq) = Flux.OneHotVector
2626
"""
2727
function score_sequence(c::CRF, x, label_seq)
28-
score = preds_first(c, label_seq[1]) + onecold(label_seq[1], x[1])
28+
score = preds_first(c, label_seq[1]) + x[1][onecold(label_seq[1])]
2929

3030
for i in 2:length(label_seq)
3131
score += preds_single(c, label_seq[i], label_seq[i-1]) +
32-
onecold(label_seq[i], x[i])
32+
x[i][onecold(label_seq[i])]
3333
end
3434

3535
return score + preds_last(c, label_seq[end])

src/TextModels.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ module TextModels
88

99

1010
using Flux, Zygote
11-
using Flux: identity, onehot, onecold, @functor, onehotbatch
11+
using Flux: identity, onehot, onecold, onehotbatch
12+
using Functors
1213

1314

1415
using TextAnalysis
@@ -47,13 +48,15 @@ module TextModels
4748
using BSON
4849
using CorpusLoaders
4950
using DataDeps
51+
using DelimitedFiles
5052
include("ULMFiT/utils.jl")
5153
include("ULMFiT/datadeps.jl")
5254
include("ULMFiT/data_loaders.jl")
5355
include("ULMFiT/custom_layers.jl")
5456
include("ULMFiT/pretrain_lm.jl")
5557
include("ULMFiT/fine_tune_lm.jl")
5658
include("ULMFiT/train_text_classifier.jl")
59+
include("ULMFiT/sentiment.jl")
5760
end
5861
export ULMFiT
5962

0 commit comments

Comments
 (0)