Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

api: deprecate typical_p (#18627)

Daniel Hiltgen7af393188def
diff --git a/api/types.go b/api/types.go
index 2d180840a..30a5990b3 100644
--- a/api/types.go
+++ b/api/types.go
@@ -575,7 +575,7 @@ type Options struct {
TopK int `json:"top_k,omitempty"`
TopP float32 `json:"top_p,omitempty"`
MinP float32 `json:"min_p,omitempty"`
- TypicalP float32 `json:"typical_p,omitempty"` // Deprecated: rejected on new requests and models; still honored from existing model parameters
+ TypicalP float32 `json:"typical_p,omitempty"` // Deprecated: rejected as a model parameter; still accepted per request with a warning
RepeatLastN int `json:"repeat_last_n,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
RepeatPenalty float32 `json:"repeat_penalty,omitempty"`
diff --git a/cmd/cmd.go b/cmd/cmd.go
index 615291f02..af7427d39 100644
--- a/cmd/cmd.go
+++ b/cmd/cmd.go
@@ -292,7 +292,7 @@ func safetensorsCreateOptions(modelfile *parser.Modelfile, filename, modelName s
var (
errAdaptersUnsupported = errors.New("LoRA adapters are no longer supported")
errForceLocalOnly = errors.New("--force is only supported for local MLX safetensors imports")
- errTypicalPUnsupported = errors.New("typical_p is no longer supported")
+ errTypicalPDeprecated = errors.New("typical_p is deprecated and cannot be set as a model parameter; pass it as a request option instead")
)
// createSafetensorsModel imports in-process when the server is local and
@@ -336,7 +336,7 @@ func CreateHandler(cmd *cobra.Command, args []string) error {
return errAdaptersUnsupported
}
if slices.ContainsFunc(modelfile.Commands, func(c parser.Command) bool { return c.Name == "typical_p" }) {
- return errTypicalPUnsupported
+ return errTypicalPDeprecated
}
opts, isSafetensorsCreate, err := safetensorsCreateOptions(modelfile, filename, modelName)
diff --git a/cmd/cmd_test.go b/cmd/cmd_test.go
index 843356774..08e975cec 100644
--- a/cmd/cmd_test.go
+++ b/cmd/cmd_test.go
@@ -1902,8 +1902,8 @@ func TestCreateHandlerRejectsTypicalPBeforeUpload(t *testing.T) {
cmd.Flags().Bool("force", false, "")
cmd.SetContext(t.Context())
- if err := CreateHandler(cmd, []string{"test-model"}); !errors.Is(err, errTypicalPUnsupported) {
- t.Fatalf("error = %v, want %v", err, errTypicalPUnsupported)
+ if err := CreateHandler(cmd, []string{"test-model"}); !errors.Is(err, errTypicalPDeprecated) {
+ t.Fatalf("error = %v, want %v", err, errTypicalPDeprecated)
}
}
diff --git a/cmd/interactive.go b/cmd/interactive.go
index a2eeb5482..5a2f28c33 100644
--- a/cmd/interactive.go
+++ b/cmd/interactive.go
@@ -353,10 +353,6 @@ func generateInteractive(cmd *cobra.Command, opts runOptions) error {
continue
}
params := args[3:]
- if args[2] == "typical_p" {
- fmt.Printf("Couldn't set parameter: %q\n", errTypicalPUnsupported)
- continue
- }
fp, err := api.FormatParams(map[string][]string{args[2]: params})
if err != nil {
fmt.Printf("Couldn't set parameter: %q\n", err)
diff --git a/docs/api.md b/docs/api.md
index b38390bac..7787fcf8b 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -378,6 +378,8 @@ curl http://localhost:11434/api/generate -d '{
If you want to set custom options for the model at runtime rather than in the Modelfile, you can do so with the `options` parameter. This example sets every available option, but you can set any of them individually and omit the ones you do not want to override.
+`typical_p` is deprecated and may be removed in a future release.
+
##### Request
```shell
diff --git a/server/create.go b/server/create.go
index 45c39f139..cb56aa196 100644
--- a/server/create.go
+++ b/server/create.go
@@ -47,6 +47,7 @@ var (
errInvalidSplitGGUF = errors.New("invalid split GGUF")
errMixedModelTypes = errors.New("mixed model file types")
errInvalidCreateInfo = errors.New("invalid create info")
+ errTypicalPDeprecated = errors.New("typical_p is deprecated and cannot be set as a model parameter; pass it as a request option instead")
)
const (
@@ -67,7 +68,7 @@ func (s *Server) CreateHandler(c *gin.Context) {
}
if r.Parameters["typical_p"] != nil {
- c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": errTypicalPUnsupported.Error()})
+ c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": errTypicalPDeprecated.Error()})
return
}
diff --git a/server/routes.go b/server/routes.go
index 99846c1ec..6ca00a2e0 100644
--- a/server/routes.go
+++ b/server/routes.go
@@ -117,10 +117,7 @@ func init() {
renderers.RenderImgTags = true
}
-var (
- errRequired = errors.New("is required")
- errTypicalPUnsupported = errors.New("typical_p is no longer supported")
-)
+var errRequired = errors.New("is required")
func (s *Server) modelOptions(model *Model, requestOpts map[string]any) (api.Options, error) {
return s.modelOptionsWithEmbeddingBatchDefault(model, requestOpts, shouldApplyEmbeddingBatchDefault(model, requestOpts))
@@ -146,6 +143,7 @@ func (s *Server) modelOptionsWithEmbeddingBatchDefault(model *Model, requestOpts
}
}
+ warnDeprecatedOptions(requestOpts)
if err := opts.FromMap(requestOpts); err != nil {
return api.Options{}, err
}
@@ -176,6 +174,18 @@ func hasOption(opts map[string]any, name string) bool {
return ok
}
+// deprecatedOptions may still be set per request, and reach the runner, but
+// cannot be saved as model parameters.
+var deprecatedOptions = []string{"typical_p"}
+
+func warnDeprecatedOptions(opts map[string]any) {
+ for _, name := range deprecatedOptions {
+ if opts[name] != nil {
+ slog.Warn("deprecated option provided", "option", name)
+ }
+ }
+}
+
func usesAutomaticNumCtx(model *Model, requestOpts map[string]any) bool {
if _, ok := requestOpts["num_ctx"]; ok {
return false
@@ -211,11 +221,6 @@ func (s *Server) scheduleRunner(ctx context.Context, model *Model, caps []model.
return nil, nil, nil, fmt.Errorf("'llama3.2-vision' is no longer compatible with your version of Ollama and has been replaced by a newer version. To re-download, run 'ollama pull llama3.2-vision'")
}
- // null is unset, as in Options.FromMap
- if requestOpts["typical_p"] != nil {
- return nil, nil, nil, errTypicalPUnsupported
- }
-
if err := model.CheckCapabilities(caps...); err != nil {
return nil, nil, nil, fmt.Errorf("%s %w", model.Name, err)
}
@@ -3123,7 +3128,7 @@ func countChatImages(msgs []api.Message) int {
func handleScheduleError(c *gin.Context, name string, err error) {
switch {
- case errors.Is(err, errCapabilities), errors.Is(err, errRequired), errors.Is(err, errTypicalPUnsupported):
+ case errors.Is(err, errCapabilities), errors.Is(err, errRequired):
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
case errors.Is(err, context.Canceled):
c.JSON(499, gin.H{"error": "request canceled"})
diff --git a/server/routes_create_test.go b/server/routes_create_test.go
index 2d7ef0654..b382034bc 100644
--- a/server/routes_create_test.go
+++ b/server/routes_create_test.go
@@ -819,7 +819,7 @@ func TestCreateFromBin(t *testing.T) {
}
})
- t.Run("rejected parameter", func(t *testing.T) {
+ t.Run("deprecated parameter is rejected", func(t *testing.T) {
w := createRequest(t, s.CreateHandler, api.CreateRequest{
Name: "my-gguf-model",
Files: map[string]string{"0.gguf": digest},
@@ -828,10 +828,10 @@ func TestCreateFromBin(t *testing.T) {
})
if w.Code != http.StatusBadRequest {
- t.Fatalf("expected status 400, got %d", w.Code)
+ t.Fatalf("expected status 400, got %d: %s", w.Code, w.Body.String())
}
- if !strings.Contains(w.Body.String(), "typical_p is no longer supported") {
- t.Errorf("expected removed parameter error, got:\n%s", w.Body.String())
+ if !strings.Contains(w.Body.String(), errTypicalPDeprecated.Error()) {
+ t.Errorf("expected deprecated parameter error, got:\n%s", w.Body.String())
}
})
}
diff --git a/server/routes_generate_test.go b/server/routes_generate_test.go
index 8b21f8209..da350eead 100644
--- a/server/routes_generate_test.go
+++ b/server/routes_generate_test.go
@@ -224,17 +224,6 @@ func createMinimalGGUFModel(t *testing.T, s *Server, name string, kv gguftest.KV
}
}
-func TestModelOptionsKeepStoredTypicalP(t *testing.T) {
- s := &Server{}
- opts, err := s.modelOptions(&Model{Options: map[string]any{"typical_p": 0.5}}, nil)
- if err != nil {
- t.Fatal(err)
- }
- if opts.TypicalP != 0.5 {
- t.Fatalf("typical_p = %v, want 0.5", opts.TypicalP)
- }
-}
-
func TestChatModeForModel(t *testing.T) {
t.Setenv("OLLAMA_GO_TEMPLATE", "")
if got := chatModeForModel(&Model{HasChatTemplate: true, HasGoTemplate: true}); got != chatExecutionModeRendered {
@@ -1653,33 +1642,20 @@ func TestGenerate(t *testing.T) {
}
})
- t.Run("rejected option", func(t *testing.T) {
+ t.Run("deprecated option passes through", func(t *testing.T) {
w := createRequest(t, s.GenerateHandler, api.GenerateRequest{
Model: "test",
Prompt: "Hello!",
Options: map[string]any{"typical_p": 0.5},
- })
-
- if w.Code != http.StatusBadRequest {
- t.Errorf("expected status 400, got %d", w.Code)
- }
-
- if diff := cmp.Diff(w.Body.String(), `{"error":"typical_p is no longer supported"}`); diff != "" {
- t.Errorf("mismatch (-got +want):\n%s", diff)
- }
- })
-
- t.Run("null option is unset", func(t *testing.T) {
- w := createRequest(t, s.GenerateHandler, api.GenerateRequest{
- Model: "test",
- Prompt: "Hello!",
- Options: map[string]any{"typical_p": nil},
Stream: &stream,
})
if w.Code != http.StatusOK {
t.Errorf("expected status 200, got %d: %s", w.Code, w.Body.String())
}
+ if mock.CompletionRequest.Options.TypicalP != 0.5 {
+ t.Errorf("typical_p = %v, want 0.5", mock.CompletionRequest.Options.TypicalP)
+ }
})
t.Run("load model", func(t *testing.T) {