Obscura.PrivacyFilter.Serving (obscura v0.1.0)

Copy Markdown View Source

Reusable native privacy-filter serving runtime.

build/1 loads checkpoint-local config, weights, label info, and model parameters once. run/3 tokenizes input text, executes the native model, and converts privacy-filter BIOES logits into normal Obscura analyzer results.

Summary

Types

t()

@type t() :: %Obscura.PrivacyFilter.Serving{
  backend: term(),
  backend_metadata: term(),
  checkpoint: term(),
  config: term(),
  decoder: term(),
  discard_overlapping_spans: term(),
  dtypes: term(),
  label_info: term(),
  label_map: term(),
  layout: term(),
  logprob_conversion: term(),
  min_span_logprob: term(),
  model_fun: term(),
  n_ctx: term(),
  pad_windows: term(),
  params: term(),
  sequence_length_bucket_threshold: term(),
  sequence_length_buckets: term(),
  trim_span_whitespace: term(),
  viterbi_biases: term(),
  viterbi_calibration: term(),
  weights: term()
}

Functions

build(opts)

@spec build(keyword()) :: {:ok, t()} | {:error, term()}

postprocess(serving, tokenization, logits, opts \\ [])

@spec postprocess(t(), map(), Nx.Tensor.t(), keyword()) ::
  {:ok, [Obscura.Analyzer.Result.t()]} | {:error, term()}

postprocess_logprobs(serving, tokenization, logprob_rows, opts \\ [])

@spec postprocess_logprobs(t(), map(), [[float()]], keyword()) ::
  {:ok, [Obscura.Analyzer.Result.t()]} | {:error, term()}

run(serving, text, opts \\ [])

@spec run(t(), String.t(), keyword()) ::
  {:ok, [Obscura.Analyzer.Result.t()]} | {:error, term()}

run_with_timings(serving, text, opts \\ [])

@spec run_with_timings(t(), String.t(), keyword()) ::
  {:ok, [Obscura.Analyzer.Result.t()], map()} | {:error, term(), map()}