Compare commits
5 Commits
main
...
royh-preci
Author | SHA1 | Date | |
---|---|---|---|
|
e210f8763f | ||
|
3971c2333f | ||
|
c71698426c | ||
|
f93cdfdfae | ||
|
af370ac178 |
@ -657,7 +657,7 @@ func showInfo(resp *api.ShowResponse) {
|
|||||||
|
|
||||||
modelData := [][]string{
|
modelData := [][]string{
|
||||||
{"arch", arch},
|
{"arch", arch},
|
||||||
{"parameters", resp.Details.ParameterSize},
|
{"parameters", format.Parameters(uint64(resp.ModelInfo["general.parameter_count"].(float64)))},
|
||||||
{"quantization", resp.Details.QuantizationLevel},
|
{"quantization", resp.Details.QuantizationLevel},
|
||||||
{"context length", fmt.Sprintf("%v", resp.ModelInfo[fmt.Sprintf("%s.context_length", arch)].(float64))},
|
{"context length", fmt.Sprintf("%v", resp.ModelInfo[fmt.Sprintf("%s.context_length", arch)].(float64))},
|
||||||
{"embedding length", fmt.Sprintf("%v", resp.ModelInfo[fmt.Sprintf("%s.embedding_length", arch)].(float64))},
|
{"embedding length", fmt.Sprintf("%v", resp.ModelInfo[fmt.Sprintf("%s.embedding_length", arch)].(float64))},
|
||||||
@ -671,7 +671,7 @@ func showInfo(resp *api.ShowResponse) {
|
|||||||
if resp.ProjectorInfo != nil {
|
if resp.ProjectorInfo != nil {
|
||||||
projectorData := [][]string{
|
projectorData := [][]string{
|
||||||
{"arch", "clip"},
|
{"arch", "clip"},
|
||||||
{"parameters", format.HumanNumber(uint64(resp.ProjectorInfo["general.parameter_count"].(float64)))},
|
{"parameters", format.Parameters(uint64(resp.ProjectorInfo["general.parameter_count"].(float64)))},
|
||||||
}
|
}
|
||||||
|
|
||||||
if projectorType, ok := resp.ProjectorInfo["clip.projector_type"]; ok {
|
if projectorType, ok := resp.ProjectorInfo["clip.projector_type"]; ok {
|
||||||
|
@ -9,9 +9,10 @@ const (
|
|||||||
Thousand = 1000
|
Thousand = 1000
|
||||||
Million = Thousand * 1000
|
Million = Thousand * 1000
|
||||||
Billion = Million * 1000
|
Billion = Million * 1000
|
||||||
|
Trillion = Billion * 1000
|
||||||
)
|
)
|
||||||
|
|
||||||
func HumanNumber(b uint64) string {
|
func RoundedParameter(b uint64) string {
|
||||||
switch {
|
switch {
|
||||||
case b >= Billion:
|
case b >= Billion:
|
||||||
number := float64(b) / Billion
|
number := float64(b) / Billion
|
||||||
@ -31,3 +32,33 @@ func HumanNumber(b uint64) string {
|
|||||||
return fmt.Sprintf("%d", b)
|
return fmt.Sprintf("%d", b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Parameters(b uint64) string {
|
||||||
|
switch {
|
||||||
|
case b >= Trillion:
|
||||||
|
number := float64(b) / Trillion
|
||||||
|
return fmt.Sprintf("%sT", decimalPlace(number))
|
||||||
|
case b >= Billion:
|
||||||
|
number := float64(b) / Billion
|
||||||
|
return fmt.Sprintf("%sB", decimalPlace(number))
|
||||||
|
case b >= Million:
|
||||||
|
number := float64(b) / Million
|
||||||
|
return fmt.Sprintf("%sM", decimalPlace(number))
|
||||||
|
case b >= Thousand:
|
||||||
|
number := float64(b) / Thousand
|
||||||
|
return fmt.Sprintf("%sK", decimalPlace(number))
|
||||||
|
default:
|
||||||
|
return fmt.Sprintf("%d", b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func decimalPlace(number float64) string {
|
||||||
|
switch {
|
||||||
|
case number >= 100:
|
||||||
|
return fmt.Sprintf("%.0f", number)
|
||||||
|
case number >= 10:
|
||||||
|
return fmt.Sprintf("%.1f", number)
|
||||||
|
default:
|
||||||
|
return fmt.Sprintf("%.2f", number)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestHumanNumber(t *testing.T) {
|
func TestRoundedParameter(t *testing.T) {
|
||||||
type testCase struct {
|
type testCase struct {
|
||||||
input uint64
|
input uint64
|
||||||
expected string
|
expected string
|
||||||
@ -24,7 +24,34 @@ func TestHumanNumber(t *testing.T) {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.expected, func(t *testing.T) {
|
t.Run(tc.expected, func(t *testing.T) {
|
||||||
result := HumanNumber(tc.input)
|
result := RoundedParameter(tc.input)
|
||||||
|
if result != tc.expected {
|
||||||
|
t.Errorf("Expected %s, got %s", tc.expected, result)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestParameters(t *testing.T) {
|
||||||
|
type testCase struct {
|
||||||
|
input uint64
|
||||||
|
expected string
|
||||||
|
}
|
||||||
|
|
||||||
|
testCases := []testCase{
|
||||||
|
{26000000, "26.0M"},
|
||||||
|
{26000000000, "26.0B"},
|
||||||
|
{1000, "1.00K"},
|
||||||
|
{1000000, "1.00M"},
|
||||||
|
{1000000000, "1.00B"},
|
||||||
|
{1000000000000, "1.00T"},
|
||||||
|
{100, "100"},
|
||||||
|
{206000000, "206M"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range testCases {
|
||||||
|
t.Run(tc.expected, func(t *testing.T) {
|
||||||
|
result := Parameters(tc.input)
|
||||||
if result != tc.expected {
|
if result != tc.expected {
|
||||||
t.Errorf("Expected %s, got %s", tc.expected, result)
|
t.Errorf("Expected %s, got %s", tc.expected, result)
|
||||||
}
|
}
|
||||||
|
@ -466,7 +466,7 @@ func CreateModel(ctx context.Context, name model.Name, modelFileDir, quantizatio
|
|||||||
if baseLayer.GGML != nil {
|
if baseLayer.GGML != nil {
|
||||||
config.ModelFormat = cmp.Or(config.ModelFormat, baseLayer.GGML.Name())
|
config.ModelFormat = cmp.Or(config.ModelFormat, baseLayer.GGML.Name())
|
||||||
config.ModelFamily = cmp.Or(config.ModelFamily, baseLayer.GGML.KV().Architecture())
|
config.ModelFamily = cmp.Or(config.ModelFamily, baseLayer.GGML.KV().Architecture())
|
||||||
config.ModelType = cmp.Or(config.ModelType, format.HumanNumber(baseLayer.GGML.KV().ParameterCount()))
|
config.ModelType = cmp.Or(config.ModelType, format.RoundedParameter(baseLayer.GGML.KV().ParameterCount()))
|
||||||
config.FileType = cmp.Or(config.FileType, baseLayer.GGML.KV().FileType().String())
|
config.FileType = cmp.Or(config.FileType, baseLayer.GGML.KV().FileType().String())
|
||||||
config.ModelFamilies = append(config.ModelFamilies, baseLayer.GGML.KV().Architecture())
|
config.ModelFamilies = append(config.ModelFamilies, baseLayer.GGML.KV().Architecture())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user