Skip to content

Commit

Permalink
Rename ReadOnly with Training
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-grella committed Jan 22, 2021
1 parent fdef275 commit 3906c42
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/nlp/transformers/bert/bert.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type Config struct {
TypeVocabSize int `json:"type_vocab_size"`
VocabSize int `json:"vocab_size"`
ID2Label map[string]string `json:"id2label"`
ReadOnly bool `json:"read_only"`
Training bool `json:"training"` // Custom for spaGO
}

func init() {
Expand Down Expand Up @@ -93,7 +93,7 @@ func NewDefaultBERT(config Config, embeddingsStoragePath string) *Model {
MaxPositions: config.MaxPositionEmbeddings,
TokenTypes: config.TypeVocabSize,
WordsMapFilename: embeddingsStoragePath,
WordsMapReadOnly: config.ReadOnly,
WordsMapReadOnly: !config.Training,
DeletePreEmbeddings: false,
}),
Encoder: NewBertEncoder(EncoderConfig{
Expand Down
3 changes: 3 additions & 0 deletions pkg/nlp/transformers/bert/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ func ConvertHuggingFacePreTrained(modelPath string) error {
if err != nil {
return err
}
// Enable training mode, so that we have writing permissions
// (for example, for embeddings storage files).
config.Training = true
vocab, err := vocabulary.NewFromFile(vocabFilename)
if err != nil {
return err
Expand Down

0 comments on commit 3906c42

Please sign in to comment.