Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
orangecat
ollama
Commits
d88582df
"vscode:/vscode.git/clone" did not exist on "625654057facd16fc9d797f61b478708cd56d35f"
Commit
d88582df
authored
Apr 18, 2024
by
Patrick Devine
Committed by
Michael Yang
May 20, 2024
Browse files
some changes for llama3
parent
2f81b3dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
convert/convert.go
convert/convert.go
+2
-1
convert/torch.go
convert/torch.go
+4
-2
No files found.
convert/convert.go
View file @
d88582df
...
@@ -77,7 +77,8 @@ func GetModelFormat(dirname string) (ModelFormat, error) {
...
@@ -77,7 +77,8 @@ func GetModelFormat(dirname string) (ModelFormat, error) {
slog
.
Debug
(
fmt
.
Sprintf
(
"file = %s"
,
fn
))
slog
.
Debug
(
fmt
.
Sprintf
(
"file = %s"
,
fn
))
if
strings
.
HasSuffix
(
fn
,
".safetensors"
)
{
if
strings
.
HasSuffix
(
fn
,
".safetensors"
)
{
return
&
SafetensorFormat
{},
nil
return
&
SafetensorFormat
{},
nil
}
else
if
strings
.
HasSuffix
(
fn
,
".bin"
)
{
//} else if strings.HasSuffix(fn, ".bin") {
}
else
if
strings
.
HasSuffix
(
fn
,
".pth"
)
{
slog
.
Debug
(
"model is torch"
)
slog
.
Debug
(
"model is torch"
)
return
&
TorchFormat
{},
nil
return
&
TorchFormat
{},
nil
}
}
...
...
convert/torch.go
View file @
d88582df
...
@@ -33,7 +33,8 @@ type TorchFormat struct{}
...
@@ -33,7 +33,8 @@ type TorchFormat struct{}
func
(
tf
*
TorchFormat
)
GetTensors
(
dirpath
string
,
params
*
Params
)
([]
llm
.
Tensor
,
error
)
{
func
(
tf
*
TorchFormat
)
GetTensors
(
dirpath
string
,
params
*
Params
)
([]
llm
.
Tensor
,
error
)
{
slog
.
Debug
(
"getting torch tensors"
)
slog
.
Debug
(
"getting torch tensors"
)
files
,
err
:=
filepath
.
Glob
(
filepath
.
Join
(
dirpath
,
"pytorch_model-*.bin"
))
//files, err := filepath.Glob(filepath.Join(dirpath, "pytorch_model-*.bin"))
files
,
err
:=
filepath
.
Glob
(
filepath
.
Join
(
dirpath
,
"consolidatedr.*.pth"
))
if
err
!=
nil
{
if
err
!=
nil
{
slog
.
Error
(
"didn't find any torch files"
)
slog
.
Error
(
"didn't find any torch files"
)
return
nil
,
err
return
nil
,
err
...
@@ -120,7 +121,7 @@ func getAltParams(dirpath string) (*Params, error) {
...
@@ -120,7 +121,7 @@ func getAltParams(dirpath string) (*Params, error) {
AttentionHeads
int
`json:"n_heads"`
AttentionHeads
int
`json:"n_heads"`
KeyValHeads
int
`json:"n_kv_heads"`
KeyValHeads
int
`json:"n_kv_heads"`
HiddenLayers
int
`json:"n_layers"`
HiddenLayers
int
`json:"n_layers"`
RopeTheta
int
`json:"rope_theta"`
RopeTheta
float64
`json:"rope_theta"`
NormEPS
float64
`json:"norm_eps"`
NormEPS
float64
`json:"norm_eps"`
}
}
...
@@ -133,6 +134,7 @@ func getAltParams(dirpath string) (*Params, error) {
...
@@ -133,6 +134,7 @@ func getAltParams(dirpath string) (*Params, error) {
}
}
params
:=
&
Params
{
params
:=
&
Params
{
Architectures
:
[]
string
{
"LlamaForCausalLM"
},
HiddenSize
:
tparams
.
HiddenSize
,
HiddenSize
:
tparams
.
HiddenSize
,
AttentionHeads
:
tparams
.
AttentionHeads
,
AttentionHeads
:
tparams
.
AttentionHeads
,
KeyValHeads
:
tparams
.
KeyValHeads
,
KeyValHeads
:
tparams
.
KeyValHeads
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment