Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
DAN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Automatic Text Recognition
DAN
Commits
48d4aa0d
Commit
48d4aa0d
authored
1 year ago
by
Manon Blanco
Committed by
Solene Tarride
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Catch runtimeError when formatting LM files
parent
a62a2366
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!313
Catch runtimeError when formatting LM files
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dan/datasets/extract/arkindex.py
+3
-0
3 additions, 0 deletions
dan/datasets/extract/arkindex.py
dan/datasets/extract/utils.py
+16
-6
16 additions, 6 deletions
dan/datasets/extract/utils.py
with
19 additions
and
6 deletions
dan/datasets/extract/arkindex.py
+
3
−
0
View file @
48d4aa0d
...
...
@@ -384,6 +384,9 @@ class ArkindexExtractor:
subword_vocab_size
=
self
.
subword_vocab_size
,
)
if
not
tokenizer
.
sentencepiece_model
:
return
for
level
,
tokenize
in
(
(
"
characters
"
,
tokenizer
.
char_tokenize
),
(
"
words
"
,
tokenizer
.
word_tokenize
),
...
...
This diff is collapsed.
Click to expand it.
dan/datasets/extract/utils.py
+
16
−
6
View file @
48d4aa0d
...
...
@@ -186,12 +186,22 @@ class Tokenizer:
with
NamedTemporaryFile
(
dir
=
self
.
outdir
,
suffix
=
"
.txt
"
,
mode
=
"
w
"
)
as
tmp
:
tmp
.
write
(
"
\n
"
.
join
(
self
.
training_corpus
))
tmp
.
flush
()
spm
.
SentencePieceTrainer
.
train
(
input
=
tmp
.
name
,
vocab_size
=
self
.
subword_vocab_size
,
model_prefix
=
self
.
prefix
,
user_defined_symbols
=
self
.
special_tokens
,
)
try
:
spm
.
SentencePieceTrainer
.
train
(
input
=
tmp
.
name
,
vocab_size
=
self
.
subword_vocab_size
,
model_prefix
=
self
.
prefix
,
user_defined_symbols
=
self
.
special_tokens
,
minloglevel
=
1
,
)
except
Exception
as
e
:
logger
.
warning
(
f
"
Failed to train a sentencepiece model for subword tokenization:
{
e
}
"
"
Try again by editing the `--subword-vocab-size` parameter.
"
)
self
.
sentencepiece_model
=
None
return
# Load the model
self
.
sentencepiece_model
=
spm
.
SentencePieceProcessor
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment