DocWire SDK
DocWire SDK: Award-winning modern data processing in C++20. SourceForge Community Choice & Microsoft support. AI-driven processing. Supports nearly 100 data formats, including email boxes and OCR. Boost efficiency in text extraction, web data extraction, data mining, document analysis. Offline processing possible for security and confidentiality
docwire::ai::ct2::ct2_runner Class Reference

Class representing the CTranslate2 AI model loaded to memory. More...

#include <ct2_runner.h>

Inheritance diagram for docwire::ai::ct2::ct2_runner:
docwire::ai::ai_runner docwire::with_pimpl< ct2_runner > docwire::with_pimpl_base

Public Member Functions

 ct2_runner (const std::filesystem::path &model_data_path)
 Constructor. Loads model to memory. More...
 
std::string process (const std::string &input) override
 Process input text using the model. More...
 
std::vector< double > embed (const std::string &input) override
 Create embedding for the input text using the model. More...
 
virtual void unload () override
 Unload the model and free associated resources. –!Must be thread-safe!– and safe to call concurrently with process()/embed().
 
- Public Member Functions inherited from docwire::ai::ai_runner
virtual ~ai_runner ()=default
 Virtual destructor. More...
 

Additional Inherited Members

- Protected Types inherited from docwire::with_pimpl< ct2_runner >
using impl_type = pimpl_impl< ct2_runner >
 
- Protected Member Functions inherited from docwire::with_pimpl< ct2_runner >
impl_typecreate_impl (Args &&... args)
 
 with_pimpl (Args &&... args)
 
 with_pimpl (with_pimpl< ct2_runner > &&other) noexcept
 
 with_pimpl (std::nullptr_t)
 
with_pimploperator= (with_pimpl &&other) noexcept
 
impl_typeimpl ()
 
const impl_typeimpl () const
 

Detailed Description

Class representing the CTranslate2 AI model loaded to memory.

Constructor loads model to memory and makes it ready for usage. Destructor frees memory used by model. It is important not to duplicate the object because memory consumption can be high.

Definition at line 32 of file ct2_runner.h.

Constructor & Destructor Documentation

◆ ct2_runner()

docwire::ai::ct2::ct2_runner::ct2_runner ( const std::filesystem::path &  model_data_path)

Constructor. Loads model to memory.

Parameters
model_data_pathPath to the folder containing model files.

Member Function Documentation

◆ embed()

std::vector<double> docwire::ai::ct2::ct2_runner::embed ( const std::string &  input)
overridevirtual

Create embedding for the input text using the model.

Parameters
inputText to process.
Returns
Vector of embedding values.

Implements docwire::ai::ai_runner.

◆ process()

std::string docwire::ai::ct2::ct2_runner::process ( const std::string &  input)
overridevirtual

Process input text using the model.

Parameters
inputText to process.
Returns
Processed text.

Implements docwire::ai::ai_runner.


The documentation for this class was generated from the following file: