-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
[WIP] Add Moonshine #34784
base: main
Are you sure you want to change the base?
[WIP] Add Moonshine #34784
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
bac9c9f
to
d0ed917
Compare
d4864c7
to
22dbaae
Compare
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.
(just some notes in the meantime).
from transformers.models.moonshine.modeling_moonshine import MoonshineConfig | ||
from transformers.models.moonshine.modeling_moonshine import MoonshineDecoder |
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.
from transformers.models.moonshine.modeling_moonshine import MoonshineConfig | |
from transformers.models.moonshine.modeling_moonshine import MoonshineDecoder | |
from transformers.models.moonshine.modeling_moonshine import ( | |
MoonshineConfig, | |
MoonshineForConditionalGeneration, | |
) |
|
||
converted_decoder_weights = _convert_weights(loaded_decoder_weights, encoder=False) | ||
converted_decoder_weights['embed_tokens.weight'] = converted_decoder_weights['embed_tokens.weight'].T | ||
|
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.
final_weights = {} | |
for k, v in encoder_state_dict.items(): | |
final_weights[f"model.encoder.{k}"] = v | |
for k, v in converted_decoder_weights.items(): | |
final_weights[f"model.decoder.{k}"] = v | |
if model_name == 'tiny': | |
config = MoonshineConfig() | |
elif model_name == 'base': | |
config = MoonshineConfig( | |
hidden_size=416, | |
num_hidden_layers=8, | |
num_attention_heads=8, | |
) | |
else: | |
raise ValueError(f"Unknown model name {model_name}") | |
final_weights['proj_out.weight'] = converted_decoder_weights['embed_tokens.weight'] | |
model = MoonshineForConditionalGeneration(config) | |
model.load_state_dict(final_weights) | |
model.save_pretrained(pytorch_dump_folder_path) |
config: MoonshineConfig | ||
""" | ||
|
||
main_input_name = "input_features" |
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.
To align with other parts of the library, it might be better to use "input_values" instead of "input _features", since "input_features" are typically for models that perform feature extraction, whereas for moonshine, we use the raw audio values instead.
No description provided.