#pragma once
#include "transcribe.h"
#include <cstdint>
#include <string>
#include <vector>
struct gguf_context;
struct ggml_context;
struct ggml_tensor;
namespace transcribe::voxtral_realtime {
struct HParams {
int32_t enc_n_layers = 0;
int32_t enc_d_model = 0;
int32_t enc_n_heads = 0;
int32_t enc_n_kv_heads = 0; int32_t enc_head_dim = 0; int32_t enc_ffn_dim = 0; int32_t enc_num_mel_bins = 0; int32_t enc_max_pos = 0; int32_t enc_sliding_window = 0; float enc_rope_theta = 0.0f;
float enc_rms_norm_eps = 0.0f;
std::string enc_hidden_act;
int32_t proj_downsample = 0; int32_t proj_in = 0; int32_t audio_length_per_tok = 0; std::string proj_hidden_act;
int32_t dec_n_layers = 0; int32_t dec_hidden = 0; int32_t dec_intermediate = 0; int32_t dec_n_heads = 0; int32_t dec_n_kv_heads = 0; int32_t dec_head_dim = 0; std::string dec_hidden_act; float dec_rms_norm_eps = 0.0f;
float dec_rope_theta = 0.0f;
int32_t dec_sliding_window = 0; int32_t dec_max_position = 0; bool dec_tie_word_embeddings = true;
int32_t dec_vocab_size = 0;
int32_t default_num_delay_tokens = 0; float time_embed_theta = 0.0f; int32_t time_embed_dim = 0; int32_t ada_hidden = 0;
int32_t streaming_pad_token_id = 32;
int32_t bos_token_id = -1;
int32_t eos_token_id = -1;
int32_t pad_token_id = -1;
int32_t vocab_size = 0;
std::string fe_type;
int32_t fe_num_mels = 0;
int32_t fe_sample_rate = 0;
int32_t fe_n_fft = 0;
int32_t fe_win_length = 0;
int32_t fe_hop_length = 0;
std::string fe_window;
std::string fe_normalize; float fe_global_log_mel_max = 1.5f;
float fe_dither = 0.0f;
float fe_pre_emphasis = 0.0f;
float fe_f_min = 0.0f;
float fe_f_max = 8000.0f;
std::string fe_pad_mode;
bool fe_center = true;
std::string fe_mel_norm;
int32_t audio_tokens_for(int32_t mel_frames) const {
return (audio_length_per_tok > 0) ? (mel_frames + audio_length_per_tok - 1) / audio_length_per_tok : 0;
}
};
transcribe_status read_hparams(const gguf_context * gguf, HParams & hp);
struct EncStem {
ggml_tensor * conv0_w = nullptr; ggml_tensor * conv0_b = nullptr; ggml_tensor * conv1_w = nullptr; ggml_tensor * conv1_b = nullptr; ggml_tensor * final_norm_w = nullptr; };
struct EncBlock {
ggml_tensor * norm_attn_w = nullptr; ggml_tensor * attn_q_w = nullptr; ggml_tensor * attn_q_b = nullptr; ggml_tensor * attn_k_w = nullptr; ggml_tensor * attn_v_w = nullptr;
ggml_tensor * attn_v_b = nullptr;
ggml_tensor * attn_out_w = nullptr;
ggml_tensor * attn_out_b = nullptr;
ggml_tensor * norm_ffn_w = nullptr; ggml_tensor * ffn_gate_w = nullptr; ggml_tensor * ffn_up_w = nullptr; ggml_tensor * ffn_down_w = nullptr; ggml_tensor * ffn_down_b = nullptr; ggml_tensor * ffn_gate_up_w = nullptr;
};
struct Projector {
ggml_tensor * linear_1_w = nullptr; ggml_tensor * linear_2_w = nullptr; };
struct DecEmbed {
ggml_tensor * token_w = nullptr; };
struct DecBlock {
ggml_tensor * norm_attn_w = nullptr; ggml_tensor * norm_ffn_w = nullptr; ggml_tensor * attn_q_w = nullptr; ggml_tensor * attn_k_w = nullptr; ggml_tensor * attn_v_w = nullptr;
ggml_tensor * attn_o_w = nullptr; ggml_tensor * ffn_gate_w = nullptr; ggml_tensor * ffn_up_w = nullptr; ggml_tensor * ffn_down_w = nullptr; ggml_tensor * ffn_gate_up_w = nullptr; ggml_tensor * ada_linear_1_w = nullptr; ggml_tensor * ada_linear_2_w = nullptr; };
struct DecFinal {
ggml_tensor * norm_w = nullptr; };
struct Weights {
EncStem enc_stem;
std::vector<EncBlock> enc_blocks;
Projector proj;
DecEmbed dec_embed;
std::vector<DecBlock> dec_blocks;
DecFinal dec_final;
ggml_tensor * time_inv_freq = nullptr;
};
transcribe_status build_weights(ggml_context * ctx_meta, const HParams & hp, Weights & weights);
}