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

[WIP] Add Moonshine #34784

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft

[WIP] Add Moonshine #34784

wants to merge 13 commits into from

Conversation

eustlb
Copy link
Contributor

@eustlb eustlb commented Nov 18, 2024

No description provided.

@eustlb eustlb changed the title Add Moonshine [WIP] Add Moonshine Nov 18, 2024
@HuggingFaceDocBuilderDev

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.

Copy link
Contributor

@xenova xenova left a 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).

Comment on lines +25 to +26
from transformers.models.moonshine.modeling_moonshine import MoonshineConfig
from transformers.models.moonshine.modeling_moonshine import MoonshineDecoder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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"
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants