-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(util): add util command to print GGUF informations
Signed-off-by: Ettore Di Giacinto <[email protected]>
- Loading branch information
Showing
4 changed files
with
45 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/rs/zerolog/log" | ||
|
||
cliContext "github.com/go-skynet/LocalAI/core/cli/context" | ||
gguf "github.com/thxcode/gguf-parser-go" | ||
) | ||
|
||
type UtilCMD struct { | ||
GGUFInfo GGUFInfoCMD `cmd:"" name:"gguf-info" help:"Get information about a GGUF file"` | ||
} | ||
|
||
type GGUFInfoCMD struct { | ||
Args []string `arg:"" optional:"" name:"args" help:"Arguments to pass to the utility command"` | ||
} | ||
|
||
func (u *GGUFInfoCMD) Run(ctx *cliContext.Context) error { | ||
if u.Args == nil || len(u.Args) == 0 { | ||
return fmt.Errorf("no GGUF file provided") | ||
} | ||
// We try to guess only if we don't have a template defined already | ||
f, err := gguf.ParseGGUFFile(u.Args[0]) | ||
if err != nil { | ||
// Only valid for gguf files | ||
log.Error().Msgf("guessDefaultsFromFile: %s", "not a GGUF file") | ||
return err | ||
} | ||
|
||
log.Info(). | ||
Any("eosTokenID", f.Tokenizer().EOSTokenID). | ||
Any("bosTokenID", f.Tokenizer().BOSTokenID). | ||
Any("modelName", f.Model().Name). | ||
Any("architecture", f.Architecture().Architecture).Msgf("GGUF file loaded: %s", u.Args[0]) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters