weaviate/weaviate · error

Wrong frequencyPenalty configuration, values are between -2.

Error message

Wrong frequencyPenalty configuration, values are between -2.0 and 2.0

What it means

Weaviate's generative-deepseek module validates the per-collection frequencyPenalty setting in class_settings.go Validate(). The DeepSeek chat API only accepts frequencyPenalty in the range [-2.0, 2.0], so any configured value outside that range (or a non-numeric value that fails to parse, yielding nil) is rejected at schema configuration time. This is a client-side guard so bad settings fail fast instead of erroring on every generation request.

Source

Thrown at modules/generative-deepseek/config/class_settings.go:96

	if err := ic.propertyValuesHelper.ValidateBaseURL(ic.BaseURL()); err != nil {
		return err
	}

	temperature := ic.Temperature()
	if temperature != nil && (*temperature < 0 || *temperature > 2) {
		return errors.Errorf("Wrong temperature configuration, values are between 0.0 and 2.0")
	}

	model := ic.getStringProperty(modelProperty, DefaultDeepSeekModel)
	maxTokens := ic.MaxTokens()
	maxTokensForModel := GetMaxTokensForModel(*model)
	if maxTokens != nil && (*maxTokens < 0 || (maxTokensForModel != nil && *maxTokens > *maxTokensForModel)) {
		return errors.Errorf("Wrong maxTokens configuration, values are should have a minimal value of 1 and max is dependant on the model used")
	}

	frequencyPenalty := ic.getFloatProperty(frequencyPenaltyProperty, &DefaultDeepSeekFrequencyPenalty)
	if frequencyPenalty == nil || (*frequencyPenalty < -2 || *frequencyPenalty > 2) {
		return errors.Errorf("Wrong frequencyPenalty configuration, values are between -2.0 and 2.0")
	}

	presencePenalty := ic.getFloatProperty(presencePenaltyProperty, &DefaultDeepSeekPresencePenalty)
	if presencePenalty == nil || (*presencePenalty < -2 || *presencePenalty > 2) {
		return errors.Errorf("Wrong presencePenalty configuration, values are between -2.0 and 2.0")
	}

	topP := ic.getFloatProperty(topPProperty, &DefaultDeepSeekTopP)
	if topP == nil || (*topP < 0 || *topP > 1) {
		return errors.Errorf("Wrong topP configuration, values are should have a minimal value of 0 and max of 1")
	}

	return nil
}

func (ic *classSettings) getStringProperty(name, defaultValue string) *string {
	asString := ic.propertyValuesHelper.GetPropertyAsStringWithNotExists(ic.cfg, name, "", defaultValue)
	return &asString

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. Set frequencyPenalty to a number within [-2.0, 2.0] (default is 0) in moduleConfig.generative-deepseek
  2. Ensure the value is a JSON number, not a string
  3. Remove the frequencyPenalty field entirely to use DefaultDeepSeekFrequencyPenalty
  4. Re-apply the collection schema after correcting the value

Example fix

// before
"moduleConfig": {"generative-deepseek": {"frequencyPenalty": 3.5}}
// after
"moduleConfig": {"generative-deepseek": {"frequencyPenalty": 0.5}}
Defensive patterns

Strategy: validation

Validate before calling

func validFrequencyPenalty(v any) bool {
	n, ok := v.(float64)
	return ok && n >= -2 && n <= 2
}
// use before building moduleConfig
if !validFrequencyPenalty(cfg.FrequencyPenalty) { return errors.New("frequencyPenalty must be in [-2, 2]") }

Type guard

func asRange(v any, lo, hi float64) (float64, bool) {
	n, ok := v.(float64)
	if !ok || n < lo || n > hi { return 0, false }
	return n, true
}

Prevention

When it happens

Trigger: Creating or updating a collection with generative-deepseek configured where moduleConfig.generative-deepseek.frequencyPenalty is < -2, > 2, or is not a valid number (causing getFloatProperty to return nil).

Common situations: Copy-pasting a frequencyPenalty like 5 or -3 from another provider's docs; passing a string value ('0.5') that fails float parsing; typos in the JSON type when defining the collection schema.

Related errors


AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04). Data as JSON: /api/errors/21e6728cc79f83d1. Report an issue: GitHub.