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
OpenDAS
ollama
Commits
b599946b
Commit
b599946b
authored
Oct 11, 2023
by
Michael Yang
Browse files
add format bytes
parent
aca2d65b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
20 deletions
+36
-20
api/client.go
api/client.go
+1
-1
format/bytes.go
format/bytes.go
+16
-0
llm/llama.go
llm/llama.go
+1
-1
llm/llm.go
llm/llm.go
+18
-18
No files found.
api/client.go
View file @
b599946b
...
...
@@ -127,7 +127,7 @@ func (c *Client) do(ctx context.Context, method, path string, reqData, respData
return
nil
}
const
maxBufferSize
=
512
*
10
24
// 512KB
const
maxBufferSize
=
512
*
10
00
// 512KB
func
(
c
*
Client
)
stream
(
ctx
context
.
Context
,
method
,
path
string
,
data
any
,
fn
func
([]
byte
)
error
)
error
{
var
buf
*
bytes
.
Buffer
...
...
format/bytes.go
0 → 100644
View file @
b599946b
package
format
import
"fmt"
func
HumanBytes
(
b
int64
)
string
{
switch
{
case
b
>
1000
*
1000
*
1000
:
return
fmt
.
Sprintf
(
"%d GB"
,
b
/
1000
/
1000
/
1000
)
case
b
>
1000
*
1000
:
return
fmt
.
Sprintf
(
"%d MB"
,
b
/
1000
/
1000
)
case
b
>
1000
:
return
fmt
.
Sprintf
(
"%d KB"
,
b
/
1000
)
default
:
return
fmt
.
Sprintf
(
"%d B"
,
b
)
}
}
llm/llama.go
View file @
b599946b
...
...
@@ -454,7 +454,7 @@ type PredictRequest struct {
Stop
[]
string
`json:"stop,omitempty"`
}
const
maxBufferSize
=
512
*
10
24
// 512KB
const
maxBufferSize
=
512
*
10
00
// 512KB
func
(
llm
*
llama
)
Predict
(
ctx
context
.
Context
,
prevContext
[]
int
,
prompt
string
,
fn
func
(
api
.
GenerateResponse
))
error
{
prevConvo
,
err
:=
llm
.
Decode
(
ctx
,
prevContext
)
...
...
llm/llm.go
View file @
b599946b
...
...
@@ -60,33 +60,33 @@ func New(workDir, model string, adapters []string, opts api.Options) (LLM, error
totalResidentMemory
:=
memory
.
TotalMemory
()
switch
ggml
.
ModelType
()
{
case
"3B"
,
"7B"
:
if
ggml
.
FileType
()
==
"F16"
&&
totalResidentMemory
<
16
*
10
24
*
10
24
{
return
nil
,
fmt
.
Errorf
(
"F16 model requires at least 16GB of memory"
)
}
else
if
totalResidentMemory
<
8
*
10
24
*
10
24
{
return
nil
,
fmt
.
Errorf
(
"model requires at least 8GB of memory"
)
if
ggml
.
FileType
()
==
"F16"
&&
totalResidentMemory
<
16
*
10
00
*
10
00
{
return
nil
,
fmt
.
Errorf
(
"F16 model requires at least 16
GB of memory"
)
}
else
if
totalResidentMemory
<
8
*
10
00
*
10
00
{
return
nil
,
fmt
.
Errorf
(
"model requires at least 8
GB of memory"
)
}
case
"13B"
:
if
ggml
.
FileType
()
==
"F16"
&&
totalResidentMemory
<
32
*
10
24
*
10
24
{
return
nil
,
fmt
.
Errorf
(
"F16 model requires at least 32GB of memory"
)
}
else
if
totalResidentMemory
<
16
*
10
24
*
10
24
{
return
nil
,
fmt
.
Errorf
(
"model requires at least 16GB of memory"
)
if
ggml
.
FileType
()
==
"F16"
&&
totalResidentMemory
<
32
*
10
00
*
10
00
{
return
nil
,
fmt
.
Errorf
(
"F16 model requires at least 32
GB of memory"
)
}
else
if
totalResidentMemory
<
16
*
10
00
*
10
00
{
return
nil
,
fmt
.
Errorf
(
"model requires at least 16
GB of memory"
)
}
case
"30B"
,
"34B"
,
"40B"
:
if
ggml
.
FileType
()
==
"F16"
&&
totalResidentMemory
<
64
*
10
24
*
10
24
{
return
nil
,
fmt
.
Errorf
(
"F16 model requires at least 64GB of memory"
)
}
else
if
totalResidentMemory
<
32
*
10
24
*
10
24
{
return
nil
,
fmt
.
Errorf
(
"model requires at least 32GB of memory"
)
if
ggml
.
FileType
()
==
"F16"
&&
totalResidentMemory
<
64
*
10
00
*
10
00
{
return
nil
,
fmt
.
Errorf
(
"F16 model requires at least 64
GB of memory"
)
}
else
if
totalResidentMemory
<
32
*
10
00
*
10
00
{
return
nil
,
fmt
.
Errorf
(
"model requires at least 32
GB of memory"
)
}
case
"65B"
,
"70B"
:
if
ggml
.
FileType
()
==
"F16"
&&
totalResidentMemory
<
128
*
10
24
*
10
24
{
return
nil
,
fmt
.
Errorf
(
"F16 model requires at least 128GB of memory"
)
}
else
if
totalResidentMemory
<
64
*
10
24
*
10
24
{
return
nil
,
fmt
.
Errorf
(
"model requires at least 64GB of memory"
)
if
ggml
.
FileType
()
==
"F16"
&&
totalResidentMemory
<
128
*
10
00
*
10
00
{
return
nil
,
fmt
.
Errorf
(
"F16 model requires at least 128
GB of memory"
)
}
else
if
totalResidentMemory
<
64
*
10
00
*
10
00
{
return
nil
,
fmt
.
Errorf
(
"model requires at least 64
GB of memory"
)
}
case
"180B"
:
if
ggml
.
FileType
()
==
"F16"
&&
totalResidentMemory
<
512
*
10
24
*
10
24
{
if
ggml
.
FileType
()
==
"F16"
&&
totalResidentMemory
<
512
*
10
00
*
10
00
{
return
nil
,
fmt
.
Errorf
(
"F16 model requires at least 512GB of memory"
)
}
else
if
totalResidentMemory
<
128
*
10
24
*
10
24
{
}
else
if
totalResidentMemory
<
128
*
10
00
*
10
00
{
return
nil
,
fmt
.
Errorf
(
"model requires at least 128GB of memory"
)
}
}
...
...
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