-
Notifications
You must be signed in to change notification settings - Fork 36
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
Added new model support Cohere/Command-R #154
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,18 +199,23 @@ def export_kvstyle_transformed_model_to_onnx( | |
raise ValueError(f"Need seq_len to be greater than zero, got seq_len={seq_len}") | ||
|
||
# Preprocess inputs | ||
embeds = None | ||
if model_name == "CohereForAI/c4ai-command-r-v01": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we want to do this for all the versions of cohere and not specific to this model_name, then we need to do it as torch level? not a good practice to do at model_name level There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay sure, I have changed it to those architecture with |
||
embeds = transformed_model.get_input_embeddings() | ||
# inputs['inputs_embeds']=embeds(inputs.pop('input_ids')) | ||
# Build inputs for prefill | ||
input_handler = InputHandler( | ||
batch_size=len(Constants.INPUT_STR), | ||
tokenizer=tokenizer, | ||
embeddings=embeds, | ||
config=transformed_model.config, | ||
prompt=Constants.INPUT_STR, | ||
prompt_len=Constants.PROMPT_LEN, | ||
ctx_len=seq_len, | ||
full_batch_size=full_batch_size, | ||
) | ||
|
||
inputs = input_handler.prepare_pytorch_inputs() | ||
|
||
pt_outputs = transformed_model(**inputs) | ||
output_names = list(pt_outputs.keys()) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# ----------------------------------------------------------------------------- | ||
# | ||
# Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
# ----------------------------------------------------------------------------- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to generalize this? I don't this is accessible for all the model categories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes right, we can make this conditional, fetch embeddings only for Cohere.