Class: Mindee::Input::InferenceParameters
- Inherits:
-
BaseParameters
- Object
- BaseParameters
- Mindee::Input::InferenceParameters
- Defined in:
- lib/mindee/input/inference_parameters.rb
Overview
Parameters to set when sending a file for inference.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#confidence ⇒ Boolean?
readonly
Boost the precision and accuracy of all extractions.
- #data_schema ⇒ DataSchemaField readonly
-
#polygon ⇒ Boolean?
readonly
Calculate bounding box polygons for all fields, and fill their
locationsattribute. -
#rag ⇒ Boolean?
readonly
Enhance extraction accuracy with Retrieval-Augmented Generation.
-
#raw_text ⇒ Boolean?
readonly
Extract the full text content from the document as strings, and fill the raw_text` attribute.
-
#text_context ⇒ String?
readonly
Additional text context used by the model during inference.
Attributes inherited from BaseParameters
#close_file, #file_alias, #model_id, #polling_options, #webhook_ids
Class Method Summary collapse
-
.from_hash(params: {}) ⇒ InferenceParameters
Loads a prediction from a Hash.
-
.slug ⇒ String
Slug for the endpoint.
Instance Method Summary collapse
-
#append_form_data(form_data) ⇒ Array
Appends inference-specific form data to the provided array.
-
#initialize(model_id, rag: nil, raw_text: nil, polygon: nil, confidence: nil, file_alias: nil, webhook_ids: nil, text_context: nil, polling_options: nil, close_file: true, data_schema: nil) ⇒ InferenceParameters
constructor
rubocop:disable Metrics/ParameterLists.
Methods inherited from BaseParameters
load_from_hash, #slug, #validate_async_params
Constructor Details
#initialize(model_id, rag: nil, raw_text: nil, polygon: nil, confidence: nil, file_alias: nil, webhook_ids: nil, text_context: nil, polling_options: nil, close_file: true, data_schema: nil) ⇒ InferenceParameters
rubocop:disable Metrics/ParameterLists
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/mindee/input/inference_parameters.rb', line 49 def initialize( model_id, rag: nil, raw_text: nil, polygon: nil, confidence: nil, file_alias: nil, webhook_ids: nil, text_context: nil, polling_options: nil, close_file: true, data_schema: nil ) super( model_id, file_alias: file_alias, webhook_ids: webhook_ids, polling_options: , close_file: close_file ) @rag = rag @raw_text = raw_text @polygon = polygon @confidence = confidence @text_context = text_context @data_schema = DataSchema.new(data_schema) unless data_schema.nil? # rubocop:enable Metrics/ParameterLists end |
Instance Attribute Details
#confidence ⇒ Boolean? (readonly)
Returns Boost the precision and accuracy of all extractions. Calculate confidence scores for all fields, and fill their confidence attribute.
23 24 25 |
# File 'lib/mindee/input/inference_parameters.rb', line 23 def confidence @confidence end |
#data_schema ⇒ DataSchemaField (readonly)
30 31 32 |
# File 'lib/mindee/input/inference_parameters.rb', line 30 def data_schema @data_schema end |
#polygon ⇒ Boolean? (readonly)
Returns Calculate bounding box polygons for all fields,
and fill their locations attribute.
19 20 21 |
# File 'lib/mindee/input/inference_parameters.rb', line 19 def polygon @polygon end |
#rag ⇒ Boolean? (readonly)
Returns Enhance extraction accuracy with Retrieval-Augmented Generation.
11 12 13 |
# File 'lib/mindee/input/inference_parameters.rb', line 11 def rag @rag end |
#raw_text ⇒ Boolean? (readonly)
Returns Extract the full text content from the document as strings, and fill the raw_text` attribute.
15 16 17 |
# File 'lib/mindee/input/inference_parameters.rb', line 15 def raw_text @raw_text end |
#text_context ⇒ String? (readonly)
Returns Additional text context used by the model during inference. Not recommended, for specific use only.
27 28 29 |
# File 'lib/mindee/input/inference_parameters.rb', line 27 def text_context @text_context end |
Class Method Details
.from_hash(params: {}) ⇒ InferenceParameters
Loads a prediction from a Hash.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/mindee/input/inference_parameters.rb', line 98 def self.from_hash(params: {}) rag = params.fetch(:rag, nil) raw_text = params.fetch(:raw_text, nil) polygon = params.fetch(:polygon, nil) confidence = params.fetch(:confidence, nil) base_params = load_from_hash(params: params) new_params = base_params.merge(rag: rag, raw_text: raw_text, polygon: polygon, confidence: confidence) model_id = new_params.fetch(:model_id) InferenceParameters.new( model_id, rag: rag, raw_text: raw_text, polygon: polygon, confidence: confidence, file_alias: params.fetch(:file_alias, nil), webhook_ids: params.fetch(:webhook_ids, nil), close_file: params.fetch(:close_file, true) ) end |
.slug ⇒ String
Returns Slug for the endpoint.
33 34 35 |
# File 'lib/mindee/input/inference_parameters.rb', line 33 def self.slug 'extraction' end |
Instance Method Details
#append_form_data(form_data) ⇒ Array
Appends inference-specific form data to the provided array.
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/mindee/input/inference_parameters.rb', line 82 def append_form_data(form_data) new_form_data = super new_form_data.push(['rag', @rag.to_s]) unless @rag.nil? new_form_data.push(['raw_text', @raw_text.to_s]) unless @raw_text.nil? new_form_data.push(['polygon', @polygon.to_s]) unless @polygon.nil? new_form_data.push(['confidence', @confidence.to_s]) unless @confidence.nil? new_form_data.push(['text_context', @text_context]) if @text_context new_form_data.push(['data_schema', @data_schema.to_s]) if @data_schema new_form_data end |