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
580fe895
Commit
580fe895
authored
Jul 06, 2023
by
Michael Yang
Committed by
Jeffrey Morgan
Jul 06, 2023
Browse files
free llama model
parent
50792821
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
server/routes.go
server/routes.go
+3
-2
No files found.
server/routes.go
View file @
580fe895
...
@@ -33,11 +33,12 @@ func generate(c *gin.Context) {
...
@@ -33,11 +33,12 @@ func generate(c *gin.Context) {
return
return
}
}
l
,
err
:=
llama
.
New
(
req
.
Model
,
llama
.
EnableF16Memory
,
llama
.
SetContext
(
128
),
llama
.
EnableEmbeddings
,
llama
.
SetGPULayers
(
gpulayers
))
mode
l
,
err
:=
llama
.
New
(
req
.
Model
,
llama
.
EnableF16Memory
,
llama
.
SetContext
(
128
),
llama
.
EnableEmbeddings
,
llama
.
SetGPULayers
(
gpulayers
))
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
"Loading the model failed:"
,
err
.
Error
())
fmt
.
Println
(
"Loading the model failed:"
,
err
.
Error
())
return
return
}
}
defer
model
.
Free
()
templateNames
:=
make
([]
string
,
0
,
len
(
templates
.
Templates
()))
templateNames
:=
make
([]
string
,
0
,
len
(
templates
.
Templates
()))
for
_
,
template
:=
range
templates
.
Templates
()
{
for
_
,
template
:=
range
templates
.
Templates
()
{
...
@@ -59,7 +60,7 @@ func generate(c *gin.Context) {
...
@@ -59,7 +60,7 @@ func generate(c *gin.Context) {
go
func
()
{
go
func
()
{
defer
close
(
ch
)
defer
close
(
ch
)
_
,
err
:=
l
.
Predict
(
req
.
Prompt
,
llama
.
Debug
,
llama
.
SetTokenCallback
(
func
(
token
string
)
bool
{
_
,
err
:=
mode
l
.
Predict
(
req
.
Prompt
,
llama
.
Debug
,
llama
.
SetTokenCallback
(
func
(
token
string
)
bool
{
ch
<-
token
ch
<-
token
return
true
return
true
}),
llama
.
SetTokens
(
tokens
),
llama
.
SetThreads
(
threads
),
llama
.
SetTopK
(
90
),
llama
.
SetTopP
(
0.86
),
llama
.
SetStopWords
(
"llama"
))
}),
llama
.
SetTokens
(
tokens
),
llama
.
SetThreads
(
threads
),
llama
.
SetTopK
(
90
),
llama
.
SetTopP
(
0.86
),
llama
.
SetStopWords
(
"llama"
))
...
...
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