Dsxir.DemoStrategy.KNN.EmbedText (dsxir v0.2.0)

Copy Markdown

Deterministic input-map rendering for KNN embedding.

Used at both compile (embedding trainset examples) and inference (embedding the live query) so the two representations land in the same vector space.

Rules

  • embed_fields: :all — every key in inputs, sorted alphabetically.
  • embed_fields: [:a, :b] — only those keys, in the declared order.

Each field renders as "<name>: <value>\n". Values render via:

  • to_string/1 for strings, atoms (including booleans), numbers.
  • Jason.encode!/1 for lists and maps.
  • Raise Dsxir.Errors.Invalid.Configuration{reason: :unembeddable_input} for opaque structs that aren't enumerable.

Missing fields render as "<name>: nil\n". The renderer never raises on missing keys — that is by design.

Summary

Functions

Render inputs to the deterministic embed-text string used at both compile time and inference time. See the module doc for the field-selection rules and value-rendering policy.

Types

fields()

@type fields() :: :all | [atom()]

Functions

render(inputs, fields)

@spec render(map(), fields()) :: String.t()

Render inputs to the deterministic embed-text string used at both compile time and inference time. See the module doc for the field-selection rules and value-rendering policy.