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
44b466ee
Commit
44b466ee
authored
Apr 28, 2025
by
Devon Rifkin
Browse files
config: update default context length to 4096
parent
a25f3f82
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
5 deletions
+5
-5
docs/faq.md
docs/faq.md
+1
-1
envconfig/config.go
envconfig/config.go
+2
-2
envconfig/config_test.go
envconfig/config_test.go
+2
-2
No files found.
docs/faq.md
View file @
44b466ee
...
@@ -20,7 +20,7 @@ Please refer to the [GPU docs](./gpu.md).
...
@@ -20,7 +20,7 @@ Please refer to the [GPU docs](./gpu.md).
## How can I specify the context window size?
## How can I specify the context window size?
By default, Ollama uses a context window size of
2048
tokens.
By default, Ollama uses a context window size of
4096
tokens.
This can be overridden with the
`OLLAMA_CONTEXT_LENGTH`
environment variable. For example, to set the default context window to 8K, use:
This can be overridden with the
`OLLAMA_CONTEXT_LENGTH`
environment variable. For example, to set the default context window to 8K, use:
...
...
envconfig/config.go
View file @
44b466ee
...
@@ -169,7 +169,7 @@ var (
...
@@ -169,7 +169,7 @@ var (
// Enable the new Ollama engine
// Enable the new Ollama engine
NewEngine
=
Bool
(
"OLLAMA_NEW_ENGINE"
)
NewEngine
=
Bool
(
"OLLAMA_NEW_ENGINE"
)
// ContextLength sets the default context length
// ContextLength sets the default context length
ContextLength
=
Uint
(
"OLLAMA_CONTEXT_LENGTH"
,
2048
)
ContextLength
=
Uint
(
"OLLAMA_CONTEXT_LENGTH"
,
4096
)
)
)
func
String
(
s
string
)
func
()
string
{
func
String
(
s
string
)
func
()
string
{
...
@@ -255,7 +255,7 @@ func AsMap() map[string]EnvVar {
...
@@ -255,7 +255,7 @@ func AsMap() map[string]EnvVar {
"OLLAMA_ORIGINS"
:
{
"OLLAMA_ORIGINS"
,
AllowedOrigins
(),
"A comma separated list of allowed origins"
},
"OLLAMA_ORIGINS"
:
{
"OLLAMA_ORIGINS"
,
AllowedOrigins
(),
"A comma separated list of allowed origins"
},
"OLLAMA_SCHED_SPREAD"
:
{
"OLLAMA_SCHED_SPREAD"
,
SchedSpread
(),
"Always schedule model across all GPUs"
},
"OLLAMA_SCHED_SPREAD"
:
{
"OLLAMA_SCHED_SPREAD"
,
SchedSpread
(),
"Always schedule model across all GPUs"
},
"OLLAMA_MULTIUSER_CACHE"
:
{
"OLLAMA_MULTIUSER_CACHE"
,
MultiUserCache
(),
"Optimize prompt caching for multi-user scenarios"
},
"OLLAMA_MULTIUSER_CACHE"
:
{
"OLLAMA_MULTIUSER_CACHE"
,
MultiUserCache
(),
"Optimize prompt caching for multi-user scenarios"
},
"OLLAMA_CONTEXT_LENGTH"
:
{
"OLLAMA_CONTEXT_LENGTH"
,
ContextLength
(),
"Context length to use unless otherwise specified (default:
2048
)"
},
"OLLAMA_CONTEXT_LENGTH"
:
{
"OLLAMA_CONTEXT_LENGTH"
,
ContextLength
(),
"Context length to use unless otherwise specified (default:
4096
)"
},
"OLLAMA_NEW_ENGINE"
:
{
"OLLAMA_NEW_ENGINE"
,
NewEngine
(),
"Enable the new Ollama engine"
},
"OLLAMA_NEW_ENGINE"
:
{
"OLLAMA_NEW_ENGINE"
,
NewEngine
(),
"Enable the new Ollama engine"
},
// Informational
// Informational
...
...
envconfig/config_test.go
View file @
44b466ee
...
@@ -279,8 +279,8 @@ func TestVar(t *testing.T) {
...
@@ -279,8 +279,8 @@ func TestVar(t *testing.T) {
func
TestContextLength
(
t
*
testing
.
T
)
{
func
TestContextLength
(
t
*
testing
.
T
)
{
cases
:=
map
[
string
]
uint
{
cases
:=
map
[
string
]
uint
{
""
:
2048
,
""
:
4096
,
"
4096"
:
4096
,
"
2048"
:
2048
,
}
}
for
k
,
v
:=
range
cases
{
for
k
,
v
:=
range
cases
{
...
...
xuxzh1
🎱
@xuxzh1
mentioned in commit
4261a3b0
·
Jan 16, 2026
mentioned in commit
4261a3b0
mentioned in commit 4261a3b0b264430489921a1b4a16a6267711d595
Toggle commit list
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