File tree Expand file tree Collapse file tree 4 files changed +14
-0
lines changed
include/openvino/genai/visual_language Expand file tree Collapse file tree 4 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,9 @@ class OPENVINO_GENAI_EXPORTS VLMPipeline {
8989 // / model chat_template.
9090 // / @param new_template A new template to override with.
9191 void set_chat_template (const std::string& new_template);
92+ // / @brief Get a Tokenizer used to tokenize input and detokenize
93+ // / output.
94+ ov::genai::Tokenizer get_tokenizer () const ;
9295 // / @brief Extract GenerationConfig used to get default values.
9396 // / @return Default values used.
9497 GenerationConfig get_generation_config () const ;
Original file line number Diff line number Diff line change @@ -527,6 +527,10 @@ class ov::genai::VLMPipeline::VLMPipelineImpl {
527527
528528 void finish_chat () {m_is_chat_conversation = false ;}
529529
530+ Tokenizer get_tokenizer () const {
531+ return m_tokenizer;
532+ }
533+
530534 void set_chat_template (const std::string& new_template) {
531535 m_tokenizer.set_chat_template (new_template);
532536 }
@@ -773,6 +777,10 @@ void VLMPipeline::set_chat_template(const std::string& new_template) {
773777 m_pimpl->set_chat_template (new_template);
774778}
775779
780+ Tokenizer VLMPipeline::get_tokenizer () const {
781+ return m_pimpl->get_tokenizer ();
782+ }
783+
776784GenerationConfig VLMPipeline::get_generation_config () const {
777785 return m_pimpl->get_generation_config ();
778786}
Original file line number Diff line number Diff line change @@ -120,6 +120,7 @@ void init_vlm_pipeline(py::module_& m) {
120120
121121 .def (" start_chat" , &ov::genai::VLMPipeline::start_chat, py::arg (" system_message" ) = " " )
122122 .def (" finish_chat" , &ov::genai::VLMPipeline::finish_chat)
123+ .def (" get_tokenizer" , &ov::genai::VLMPipeline::get_tokenizer)
123124 .def (" get_generation_config" , &ov::genai::VLMPipeline::get_generation_config)
124125 .def (" set_generation_config" , &ov::genai::VLMPipeline::set_generation_config)
125126 .def (
Original file line number Diff line number Diff line change @@ -105,6 +105,8 @@ def streamer(word: str) -> bool:
105105
106106 pipe .finish_chat ()
107107 gc .collect ()
108+ tokenizer = pipe .get_tokenizer ()
109+ tokenizer .encode ("" )
108110 del pipe
109111 gc .collect ()
110112
You can’t perform that action at this time.
0 commit comments