Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use unified approach for exporting text generation models #2982

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions demos/common/export_models/export_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,9 @@ def export_text_generation_model(model_repository_path, source_model, model_name
llm_model_path = os.path.join(model_repository_path, model_name)
print("Exporting LLM model to ", llm_model_path)
if not os.path.isdir(llm_model_path) or args['overwrite_models']:
optimum_command = "optimum-cli export openvino --disable-convert-tokenizer --model {} --weight-format {} --trust-remote-code {}".format(source_model, precision, llm_model_path)
optimum_command = "optimum-cli export openvino --model {} --weight-format {} --trust-remote-code {}".format(source_model, precision, llm_model_path)
if os.system(optimum_command):
raise ValueError("Failed to export llm model", source_model)
print("Exporting tokenizer to ", llm_model_path)
convert_tokenizer_command = "convert_tokenizer --utf8_replace_mode replace --with-detokenizer --skip-special-tokens --streaming-detokenizer -o {} {}".format(llm_model_path, source_model)
if (os.system(convert_tokenizer_command)):
raise ValueError("Failed to export tokenizer model", source_model)
os.makedirs(os.path.join(model_repository_path, model_name), exist_ok=True)
gtemplate = jinja2.Environment(loader=jinja2.BaseLoader).from_string(text_generation_graph_template)
graph_content = gtemplate.render(tokenizer_model="{}_tokenizer_model".format(model_name), embeddings_model="{}_embeddings_model".format(model_name), model_path=model_path, **task_parameters)
Expand Down