Skip to content

Commit

Permalink
docs: changed function description for encoder
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexwang8 committed Jul 18, 2024
1 parent dc33bf9 commit d260b08
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions resources/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,9 @@ func ResolveHFFromResources(resources *Resources, hfConfig *HFConfig) (*HFConfig
// resolveTokenIds
// Resolve token ids for eos, bos, and pad tokens from resources.
func resolveTokenIds(resources *Resources, hfConfig *HFConfig) (*HFConfig, error) {
// Use interfaces to unmarshal the vocab file from resources
// Vocab is stored in either the vocab.json or encoder.json file
// We want to unmarshal the vocab file into an interface to work with
// We attempt to unmarshal under the vocab.json key first, then encoder.json if it fails
var vocab interface{}
if _, err := resources.GetFile("vocab.json"); err == nil {
if err := json.Unmarshal(*((*resources)["vocab.json"]).Data, &vocab); err != nil {
Expand Down Expand Up @@ -859,10 +861,10 @@ func resolveTokenIds(resources *Resources, hfConfig *HFConfig) (*HFConfig, error
// Used to be able to resolve both embedded and local resources.
// Continuation of ResolveHFFromResources.
func resolveVocabSize(resources *Resources, hfConfig *HFConfig) (*HFConfig, error) {
// Use interfaces to unmarshal the vocab file
var vocab interface{}
// If exists, unmarshal vocab.json, else
// use GetFile to get the file, then unmarshal it
// Vocab is stored in either the vocab.json or encoder.json file
// We want to unmarshal the vocab file into an interface to work with
// We attempt to unmarshal under the vocab.json key first, then encoder.json if it fails
if _, err := resources.GetFile("vocab.json"); err == nil {
if err := json.Unmarshal(*((*resources)["vocab.json"]).Data, &vocab); err != nil {
fmt.Errorf("Error unmarshalling vocab.json: %s", err)
Expand Down

0 comments on commit d260b08

Please sign in to comment.