# Higgs Audio V2

    
        
        
    

## Genel Bakış

Higgs Audio V2, [Boson AI](https://www.boson.ai/) tarafından geliştirilen güçlü bir ses temel modelidir. Model, 10 milyondan fazla saatlik ses verisi ve çeşitli bir metin veri seti üzerinde ön eğitilmiştir. Post-training veya fine-tuning uygulanmamış olmasına rağmen, Higgs Audio v2, derin dil ve akustik anlayışı sayesinde ifade zengini ses üretiminde üstün performans sergiler.

**Model Mimarisi:**

    

Higgs Audio v2, yukarıdaki mimari şemasında gösterilen "üretim varyantını" benimser. Güçlü performansı üç temel teknik yenilikle sağlanır:

- Birden fazla ASR modeli, ses olayı sınıflandırma modelleri ve kendi geliştirdiğimiz ses anlama modelini kullanan otomatik bir etiketleme hattı geliştirdik. Bu hat sayesinde 10 milyon saatlik ses verisini temizleyip etiketledik; bu veriye AudioVerse adını veriyoruz. Kendi geliştirdiğimiz anlama modeli, mimari şemasında gösterilen "anlama varyantını" benimseyen Higgs Audio v1 Understanding üzerine ince ayarlanmıştır.
- Hem semantik hem de akustik özellikleri yakalayan, sıfırdan eğitilmiş birleşik bir ses tokenleştirici.
- LLM'nin akustik tokenleri modelleme yeteneğini minimal hesaplama maliyetiyle artıran önerilen DualFFN mimarisi.

## Kullanım

Aşağıdaki tüm kod parçacıkları, `test_higgs_audio.py` içindeki entegrasyon testlerini yansıtmakta olup belgenin resmi olarak desteklenen iş akışlarıyla senkronize kalmasını sağlar.

### Tek konuşmacılı akıllı ses

```python
from transformers import AutoProcessor, HiggsAudioV2ForConditionalGeneration

model_id = "eustlb/higgs-audio-v2-generation-3B-base"
processor = AutoProcessor.from_pretrained(model_id, device_map="auto")
model = HiggsAudioV2ForConditionalGeneration.from_pretrained(model_id, device_map="auto")

conversation = [
    {
        "role": "system",
        "content": [
            {
                "type": "text",
                "text": "Generate audio following instruction."
            }
        ],
    },
    {
        "role": "scene",
        "content": [
            {
                "type": "text",
                "text": "Audio is recorded from a quiet room."
            }
        ]
    },
    {
        "role": "user",
        "content": [
            {
                "type": "text",
                "text": "The sun rises in the east and sets in the west. This simple fact has been observed by humans for thousands of years."
            }
        ]
    }
]

inputs = processor.apply_chat_template(
    conversation,
    add_generation_prompt=True,
    tokenize=True,
    return_dict=True,
    sampling_rate=24000,
    return_tensors="pt"
).to(model.device)

outputs = model.generate(**inputs, max_new_tokens=1000, do_sample=False)
decoded = processor.batch_decode(outputs)
processor.save_audio(decoded, "output_single_speaker_smart_voice.wav")
```

### Çok konuşmacılı akıllı ses

```python
from transformers import AutoProcessor, HiggsAudioV2ForConditionalGeneration

model_id = "eustlb/higgs-audio-v2-generation-3B-base"
processor = AutoProcessor.from_pretrained(model_id, device_map="auto")
model = HiggsAudioV2ForConditionalGeneration.from_pretrained(model_id, device_map="auto")

system_message = """You are an AI assistant designed to convert text into speech.
If the user's message includes a [SPEAKER*] tag, do not read out the tag and generate speech for the following text, using the specified voice.
If no speaker tag is present, select a suitable voice on your own."""

user_message = """[SPEAKER0] I can't believe you did that without even asking me first!
[SPEAKER1] Oh, come on! It wasn't a big deal, and I knew you would overreact like this.
[SPEAKER0] Overreact? You made a decision that affects both of us without even considering my opinion!
[SPEAKER1] Because I didn't have time to sit around waiting for you to make up your mind! Someone had to act."""

conversation = [
    {
        "role": "system",
        "content": [
            {
                "type": "text",
                "text": system_message
            }
        ]
    },
    {
        "role": "scene",
        "content": [
            {
                "type": "text",
                "text": "Audio is recorded from a quiet room."
            },
            {
                "type": "text",
                "text": "SPEAKER0: feminine"
            },
            {
                "type": "text",
                "text": "SPEAKER1: masculine"
            },
        ]
    },
    {
        "role": "user",
        "content": [
            {
                "type": "text",
                "text": user_message
            }
        ]
    }
]

inputs = processor.apply_chat_template(
    conversation,
    add_generation_prompt=True,
    tokenize=True,
    return_dict=True,
    sampling_rate=24000,
    return_tensors="pt"
).to(model.device)

outputs = model.generate(**inputs, max_new_tokens=50, do_sample=False)
decoded = processor.batch_decode(outputs)
processor.save_audio(decoded, "output_multi_speaker_smart_voice.wav")
```

### Sıfır atımlı ses klonlama

```python
from transformers import AutoProcessor, HiggsAudioV2ForConditionalGeneration

model_id = "eustlb/higgs-audio-v2-generation-3B-base"
processor = AutoProcessor.from_pretrained(model_id, device_map="auto")
model = HiggsAudioV2ForConditionalGeneration.from_pretrained(model_id, device_map="auto")

conversation = [
    {
        "role": "system",
        "content": [
            {
                "type": "text",
                "text": "Generate audio following instruction."
            }
        ]
    },
    {
        "role": "scene",
        "content": [
            {
                "type": "text",
                "text": "Audio is recorded from a quiet room."
            }
        ]
    },
    {
        "role": "user",
        "content": [
            {
                "type": "text",
                "text": "It was the night before my birthday. Hooray! It's almost here! It may not be a holiday, but it's the best day of the year."
            }
        ]
    },
    {
        "role": "assistant",
        "content": [
            {
                "type": "audio",
                "url": "https://huggingface.co/datasets/eustlb/dummy-audio-samples-higgs/resolve/main/belinda.wav"
            }
        ]
    },
    {
        "role": "user",
        "content": [
            {
                "type": "text",
                "text": "The sun rises in the east and sets in the west. This simple fact has been observed by humans for thousands of years."
            }
        ]
    }
]

inputs = processor.apply_chat_template(
    conversation,
    add_generation_prompt=True,
    tokenize=True,
    return_dict=True,
    sampling_rate=24000,
    return_tensors="pt"
).to(model.device)

outputs = model.generate(**inputs, max_new_tokens=1000, do_sample=False)
decoded = processor.batch_decode(outputs)
processor.save_audio(decoded, "output_zero_shot_voice_cloning.wav")
```

### Çok konuşmacılı ses klonlama

```python
from transformers import AutoProcessor, HiggsAudioV2ForConditionalGeneration

model_id = "eustlb/higgs-audio-v2-generation-3B-base"
processor = AutoProcessor.from_pretrained(model_id, device_map="auto")
model = HiggsAudioV2ForConditionalGeneration.from_pretrained(model_id, device_map="auto")

user_message = """[SPEAKER0] I can't believe you did that without even asking me first!
[SPEAKER1] Oh, come on! It wasn't a big deal, and I knew you would overreact like this.
[SPEAKER0] Overreact? You made a decision that affects both of us without even considering my opinion!
[SPEAKER1] Because I didn't have time to sit around waiting for you to make up your mind! Someone had to act."""

conversation = [
    {
        "role": "system",
        "content": [
            {
                "type": "text",
                "text": "Generate audio following instruction."
            }
        ]
    },
    {
        "role": "scene",
        "content": [
            {
                "type": "text",
                "text": "Audio is recorded from a quiet room."
            },
            {
                "type": "text",
                "text": "SPEAKER0:"
            },
            {
                "type": "audio",
                "url": "https://huggingface.co/datasets/hf-internal-testing/transformers-synthetic-assets/resolve/main/audio/voice_sample.wav"
            },
            {
                "type": "text",
                "text": "SPEAKER1:"
            },
            {
                "type": "audio",
                "url": "https://huggingface.co/datasets/hf-internal-testing/transformers-synthetic-assets/resolve/main/audio/mr_quiller.flac"
            },
        ]
    },
    {
        "role": "user",
        "content": [
            {
                "type": "text",
                "text": user_message
            }
        ]
    },
]

inputs = processor.apply_chat_template(
    conversation,
    add_generation_prompt=True,
    tokenize=True,
    return_dict=True,
    sampling_rate=24000,
    return_tensors="pt"
).to(model.device)

outputs = model.generate(**inputs, max_new_tokens=1000, do_sample=False)
decoded = processor.batch_decode(outputs)
processor.save_audio(decoded, "output_multi_speaker_voice_cloning.wav")
```

### Toplu çıkarım

```python
from transformers import AutoProcessor, HiggsAudioV2ForConditionalGeneration

model_id = "eustlb/higgs-audio-v2-generation-3B-base"
processor = AutoProcessor.from_pretrained(model_id, device_map="auto")
model = HiggsAudioV2ForConditionalGeneration.from_pretrained(model_id, device_map="auto")

conversation1 = [
    {
        "role": "system",
        "content": [
            {
                "type": "text",
                "text": "Generate audio following instruction."
            }
        ]
    },
    {
        "role": "scene",
        "content": [
            {
                "type": "text",
                "text": "Audio is recorded from a quiet room."
            }
        ]
    },
    {
        "role": "user",
        "content": [
            {
                "type": "text",
                "text": "It was the night before my birthday. Hooray! It's almost here! It may not be a holiday, but it's the best day of the year."
            }
        ]
    },
    {
        "role": "assistant",
        "content": [
            {
                "type": "audio",
                "url": "https://huggingface.co/datasets/eustlb/dummy-audio-samples-higgs/resolve/main/belinda.wav"
            }
        ]
    },
    {
        "role": "user",
        "content": [
            {
                "type": "text",
                "text": "The sun rises in the east and sets in the west. This simple fact has been observed by humans for thousands of years."
            }
        ]
    }
]

conversation2 = [
    {
        "role": "system",
        "content": [
            {
                "type": "text",
                "text": "Generate audio following instruction."
            }
        ]
    },
    {
        "role": "scene",
        "content": [
            {
                "type": "text",
                "text": "Audio is recorded from a quiet room."
            }
        ]
    },
    {
        "role": "user",
        "content": [
            {
                "type": "text",
                "text": " It's super important to assess fairly the fact that our former model is over. And this is not a question of adjustment. This is not the same world, 2024, 2025. And on top of that, we are making the same mistakes, on top of the key elements I mentioned. We are over-regulating and under-investing. So just if, in the two to three years to come, if we follow our classical agenda, we will be out of the market. I have no doubts."
            }
        ]
    },
    {
        "role": "assistant",
        "content": [
            {
                "type": "audio",
                "url": "https://huggingface.co/datasets/eustlb/dummy-audio-samples-higgs/resolve/main/macron.wav"
            }
        ]
    },
    {
        "role": "user",
        "content": [
            {
                "type": "text",
                "text": "Hey, here is a clone from the given voice."
            }
        ]
    }
]

inputs = processor.apply_chat_template(
    [conversation1, conversation2],
    add_generation_prompt=True,
    tokenize=True,
    return_dict=True,
    sampling_rate=24000,
    return_tensors="pt"
).to(model.device)

outputs = model.generate(**inputs, max_new_tokens=1000, do_sample=False)
decoded = processor.batch_decode(outputs)
processor.save_audio(decoded, ["output_batched_1.wav", "output_batched_2.wav"])
```

### Eğitim

> [!TIP]
> Varsayılan olarak, model, üretim için gerekli olmadığından bellek tasarrufu sağlamak (~1.5GiB azalma) için metin dil modelleme başlığını yüklemiyor. Ancak modeli eğitirken, metin jetonları üzerinde kaybı hesaplamak için metin başlığına ihtiyacınız var. Bunu etkinleştirmek için, modelin örneklenmesi sırasında `use_text_head=True` değerini ayarlayın (aşağıdaki örneğe bakın).

```python
from transformers import AutoProcessor, HiggsAudioV2ForConditionalGeneration

model_id = "eustlb/higgs-audio-v2-generation-3B-base"
processor = AutoProcessor.from_pretrained(model_id, device_map="auto")
model = HiggsAudioV2ForConditionalGeneration.from_pretrained(model_id, device_map="auto", use_text_head=True)

conversation1 = [
    {
        "role": "system",
        "content": [
            {
                "type": "text",
                "text": "Generate audio following instruction."
            }
        ]
    },
    {
        "role": "scene",
        "content": [
            {
                "type": "text",
                "text": "Audio is recorded from a quiet room."
            }
        ]
    },
    {
        "role": "user",
        "content": [
            {
                "type": "text",
                "text": "It was the night before my birthday. Hooray! It's almost here! It may not be a holiday, but it's the best day of the year."
            }
        ]
    },
    {
        "role": "assistant",
        "content": [
            {
                "type": "audio",
                "url": "https://huggingface.co/datasets/eustlb/dummy-audio-samples-higgs/resolve/main/belinda.wav"
            }
        ]
    }
]

conversation2 = [
    {
        "role": "system",
        "content": [
            {
                "type": "text",
                "text": "Generate audio following instruction."
            }
        ]
    },
    {
        "role": "scene",
        "content": [
            {
                "type": "text",
                "text": "Audio is recorded from a quiet room."
            }
        ]
    },
    {
        "role": "user",
        "content": [
            {
                "type": "text",
                "text": " I would imagine so. A wand with a dragon heartstring core is capable of dazzling magic, and the bond between you and your wand should only grow stronger. Do not be surprised at your new wand's ability to perceive your intentions, particularly in a moment of need"
            }
        ]
    },
    {
        "role": "assistant",
        "content": [
            {
                "type": "audio",
                "url": "https://huggingface.co/datasets/eustlb/dummy-audio-samples-higgs/resolve/main/broom_salesman.wav"
            }
        ]
    }
]

inputs = processor.apply_chat_template(
    [conversation1, conversation2],
    tokenize=True,
    return_dict=True,
    sampling_rate=24000,
    return_tensors="pt",
    output_labels=True,
).to(model.device)

outputs = model(**inputs)
outputs.loss.backward()
```

Bu model [Shuai Zheng](https://huggingface.co/szhengac) ve [Eustache Le Bihan](https://huggingface.co/eustlb) tarafından katkıda bulunmuştur. Orijinal kod [burada](https://github.com/boson-ai/higgs-audio) bulunabilir.

## HiggsAudioV2Config[[transformers.HiggsAudioV2Config]]

#### transformers.HiggsAudioV2Config[[transformers.HiggsAudioV2Config]]

```python
transformers.HiggsAudioV2Config(transformers_version: str | None = None, architectures: list[str] | None = None, output_hidden_states: bool | None = False, return_dict: bool | None = True, dtype: str | torch.dtype | None = None, chunk_size_feed_forward: int = 0, is_encoder_decoder: bool = False, id2label: dict[int, str] | dict[str, str] | None = None, label2id: dict[str, int] | dict[str, str] | None = None, problem_type: Literal['regression', 'single_label_classification', 'multi_label_classification'] | None = None, vocab_size: int = 128256, hidden_size: int = 3072, intermediate_size: int = 8192, num_hidden_layers: int = 28, num_attention_heads: int = 24, num_key_value_heads: int = 8, hidden_act: str = 'silu', max_position_embeddings: int = 2048, initializer_range: float = 0.02, rms_norm_eps: float = 1e-05, use_cache: bool = True, pad_token_id: int | None = 128001, bos_token_id: int | None = 1, eos_token_id: int | list[int] | None = 128009, pretraining_tp: int | None = 1, tie_word_embeddings: bool = False, rope_parameters: transformers.modeling_rope_utils.RopeParameters | dict | None = None, attention_bias: bool = False, attention_dropout: int | float | None = 0.0, mlp_bias: bool = False, head_dim: int | None = 128, num_codebooks: int = 8, codebook_size: int = 1024, audio_token_id: int = 128016, audio_bos_token_id: int = 128013, audio_delay_token_id: int = 128014, audio_stream_bos_id: int = 1024, audio_stream_eos_id: int = 1025)
```

[Kaynak](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/higgs_audio_v2/configuration_higgs_audio_v2.py#L32)

**Parametreler:**

vocab_size (`int`, *isteğe bağlı*, varsayılan `128256`) : Modelin sözlük boyutu. `input_ids` tarafından temsil edilebilecek farklı token sayısını tanımlar.

hidden_size (`int`, *isteğe bağlı*, varsayılan `3072`) : Gizli temsillerin boyutu.

intermediate_size (`int`, *isteğe bağlı*, varsayılan `8192`) : MLP temsillerinin boyutu.

num_hidden_layers (`int`, *isteğe bağlı*, varsayılan `28`) : Transformer decoder'ındaki gizli katman sayısı.

num_attention_heads (`int`, *isteğe bağlı*, varsayılan `24`) : Transformer decoder'ındaki her dikkat katmanı için dikkat başı sayısı.

num_key_value_heads (`int`, *isteğe bağlı*, varsayılan `8`) : Grouped Query Attention'ı uygulamak için kullanılması gereken key_value başlarının sayısıdır. `num_key_value_heads=num_attention_heads` ise model Multi Head Attention (MHA) kullanır, `num_key_value_heads=1` ise model Multi Query Attention (MQA) kullanır, aksi halde GQA kullanılır. Çok başlı bir checkpoint'i GQA checkpoint'ine dönüştürürken, her grup key ve value başı, o gruptaki tüm orijinal başların ortalama havuzlanması (meanpooling) ile oluşturulmalıdır. Daha fazla ayrıntı için [bu makaleye](https://huggingface.co/papers/2305.13245) göz atın. Belirtilmezse, varsayılan olarak `num_attention_heads` kullanılır.

hidden_act (`str`, *isteğe bağlı*, varsayılan `silu`) : Dekoderdeki doğrusal olmayan aktivasyon fonksiyonu (fonksiyon veya dize). Örneğin, `"gelu"`, `"relu"`, `"silu"` vb.

max_position_embeddings (`int`, *isteğe bağlı*, varsayılan `2048`) : Bu modelin kullanılabileceği maksimum dizi uzunluğu.

initializer_range (`float`, *opsiyonel*, varsayılan `0.02`) : Tüm ağırlık matrislerini başlatmak için kullanılan truncated_normal_initializer'ın standart sapması.

rms_norm_eps (`float`, *opsiyonel*, varsayılan `1e-05`) : rms normalizasyon katmanları tarafından kullanılan epsilon.

use_cache (`bool`, *isteğe bağlı*, varsayılan `True`) : Modelin son anahtar/değer dikkatlerini döndürüp döndürmeyeceğini belirtir (tüm modellerde kullanılmaz). Yalnızca `config.is_decoder=True` olduğunda veya model yalnızca çözücü tabanlı üretken bir model olduğunda geçerlidir.

pad_token_id (`int`, *isteğe bağlı*, varsayılan `128001`) : Sözlükte dolgu için kullanılan token kimliği.

bos_token_id (`int`, *isteğe bağlı*, varsayılan `1`) : Sözlükte akış başlangıcı için kullanılan token kimliği.

eos_token_id (`Union[int, list[int]]`, *isteğe bağlı*, varsayılan `128009`) : Sözlükte akış sonu için kullanılan token kimliği.

pretraining_tp (`int`, *isteğe bağlı*, varsayılan `1`) : Deneysel özellik. Ön eğitim sırasında kullanılan tensör paralelliği sırası. Daha fazla bilgi için [bu belgeye](https://huggingface.co/docs/transformers/main/perf_train_gpu_many#tensor-parallelism) bakın. Bu değer, ön eğitim sonuçlarının tam olarak yeniden üretilebilmesini sağlamak için gereklidir. Lütfen [bu soruna](https://github.com/pytorch/pytorch/issues/76232) bakın.

tie_word_embeddings (`bool`, *isteğe bağlı*, varsayılan `False`) : Ağırlık gömme bağlamalarının, modelin `tied_weights_keys` eşlemesine göre yapılıp yapılmayacağını belirtir.

rope_parameters (`Union[~modeling_rope_utils.RopeParameters, dict]`, *isteğe bağlı*) : RoPE gömme yapılandırma parametrelerini içeren sözlük. Sözlük, `rope_theta` için bir değer içermeli ve daha uzun `max_position_embeddings` ile RoPE kullanmak istiyorsanız ölçekleme için kullanılan parametreleri isteğe bağlı olarak içermelidir.

attention_bias (`bool`, *isteğe bağlı*, varsayılan `False`) : Kendi kendine dikkat (self-attention) sırasında sorgu, anahtar, değer ve çıktı projeksiyon katmanlarında sapma (bias) kullanılıp kullanılmayacağı.

attention_dropout (`Union[int, float]`, *isteğe bağlı*, varsayılan `0.0`) : Dikkat olasılıkları için dropout oranı.

mlp_bias (`bool`, *isteğe bağlı*, varsayılan `False`) : MLP katmanlarındaki up_proj, down_proj ve gate_proj katmanlarında bias kullanılıp kullanılmayacağı.

head_dim (`int`, *isteğe bağlı*, varsayılan `128`) : Dikkat başı boyutu. None ise, varsayılan olarak hidden_size // num_attention_heads değerini alır

num_codebooks (`int`, *isteğe bağlı*, varsayılan `8`) : Modelin kullandığı paralel kod kitaplarının sayısı.

codebook_size (`int`, *isteğe bağlı*, varsayılan `1024`) : Modelin kullandığı paralel kod kitaplarının sayısı.

audio_token_id (`int`, *isteğe bağlı*, varsayılan `128016`) : Girdi sesinin yer tutucusu olarak kullanılan ses jetonu indeksi.

audio_bos_token_id (`int`, *isteğe bağlı*, varsayılan 128013) : Ses çıktısı için dizinin başlangıç token'ının token kimliği.

audio_delay_token_id (`int`, *opsiyonel*, varsayılan 128014) : Çoklu kod kitabı üretiminde ses gecikme deseni için kullanılan jeton kimliği.

audio_stream_bos_id (`int`, *isteğe bağlı*, varsayılan 1024) : Ses dizilerinde akış başlangıcı jetonunun kimliği.

audio_stream_eos_id (`int`, *isteğe bağlı*, varsayılan 1025) : Ses dizilerinde akış sonu (end-of-stream) jetonunun kimliği.

Bu, bir HiggsAudioV2ForConditionalGeneration yapılandırmasını depolamak için kullanılan yapılandırma sınıfıdır. Belirtilen argümanlara göre bir Higgs Audio V2 modeli örneklemek ve model mimarisini tanımlamak için kullanılır. Varsayılanlarla bir yapılandırma örneklendiğinde, [bosonai/higgs-audio-v2-generation-3B-base](https://huggingface.co/bosonai/higgs-audio-v2-generation-3B-base) ile benzer bir yapılandırma elde edilir.

Yapılandırma nesneleri [PreTrainedConfig](/docs/transformers/v5.23.0/tr/main_classes/configuration#transformers.PreTrainedConfig) sınıfından türetilir ve model çıktılarını kontrol etmek için kullanılabilir. Daha fazla bilgi için [PreTrainedConfig](/docs/transformers/v5.23.0/tr/main_classes/configuration#transformers.PreTrainedConfig) belgesini okuyun.

Örnek:

```python
>>> from transformers import HiggsAudioV2Model, HiggsAudioV2Config

>>> # Initializing a HiggsAudioV2 style configuration
>>> configuration = HiggsAudioV2Config()

>>> # Initializing a model from the configuration
>>> model = HiggsAudioV2Model(configuration)

>>> # Accessing the model configuration
>>> configuration = model.config
```

## HiggsAudioV2Processor[[transformers.HiggsAudioV2Processor]]

#### transformers.HiggsAudioV2Processor[[transformers.HiggsAudioV2Processor]]

```python
transformers.HiggsAudioV2Processor(feature_extractor, tokenizer, audio_tokenizer, chat_template = None, audio_token = '<|AUDIO_OUT|>', audio_bos_token = '<|audio_out_bos|>', audio_eos_token = '<|audio_eos|>', audio_delay_token = '<|reserved_special_token_6|>', audio_stream_bos_id = 1024, audio_stream_eos_id = 1025)
```

[Kaynak](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/higgs_audio_v2/processing_higgs_audio_v2.py#L41)

**Parametreler:**

feature_extractor (`DacFeatureExtractor`) : [DacFeatureExtractor](/docs/transformers/v5.23.0/tr/model_doc/dac#transformers.DacFeatureExtractor) örneği. Özellik çıkarıcı zorunlu bir girdidir.

tokenizer (`AutoTokenizer`) : [AutoTokenizer](/docs/transformers/v5.23.0/tr/model_doc/auto#transformers.AutoTokenizer) örneği. Tokenizer zorunlu bir girdidir.

audio_tokenizer (`HiggsAudioV2TokenizerModel`) : [HiggsAudioV2TokenizerModel](/docs/transformers/v5.23.0/tr/model_doc/higgs_audio_v2_tokenizer#transformers.HiggsAudioV2TokenizerModel) örneği. Ses tokenizasyonu zorunlu bir girdidir.

chat_template (`str`, *isteğe bağlı*) : Metin ve ses etkileşimlerini birleştirirken sohbet biçimlendirmesi için şablon dizesi.

audio_token (`str`, *isteğe bağlı*, varsayılan `"<|AUDIO_OUT|>"`) : Metin dizisinde ses çıkışını temsil etmek için kullanılan jeton.

audio_bos_token (`str`, *isteğe bağlı*, varsayılan `"<|audio_out_bos|>"`) : Ses çıktısı için dizinin başlangıç jetonu.

audio_eos_token (`str`, *isteğe bağlı*, varsayılan `"<|audio_eos|>"`) : Ses çıktısı için dizin sonu belirteci.

audio_delay_token (`str`, *isteğe bağlı*, varsayılan `"<|reserved_special_token_6|>"`) : Çoklu kod kitabı üretiminde ses gecikme deseni için kullanılan jeton.

audio_stream_bos_id (`int`, *isteğe bağlı*, varsayılan 1024) : Ses dizilerinde akış başlangıcı jetonunun kimliği.

audio_stream_eos_id (`int`, *isteğe bağlı*, varsayılan 1025) : Ses dizilerinde akış sonu (end-of-stream) jetonunun kimliği.

Bir [DacFeatureExtractor](/docs/transformers/v5.23.0/tr/model_doc/dac#transformers.DacFeatureExtractor), bir [AutoTokenizer](/docs/transformers/v5.23.0/tr/model_doc/auto#transformers.AutoTokenizer) ve bir [HiggsAudioV2TokenizerModel](/docs/transformers/v5.23.0/tr/model_doc/higgs_audio_v2_tokenizer#transformers.HiggsAudioV2TokenizerModel)'i tek bir işlemciye sararak bir Higgs Audio işlemcisi oluşturur. Ses özellik çıkarımı, belirteçleyici ve ses kodlama/çözme işlevselliğini devralır. Daha fazla bilgi için [__call__()](/docs/transformers/v5.23.0/tr/model_doc/higgs_audio_v2#transformers.HiggsAudioV2Processor.__call__) ve [decode()](/docs/transformers/v5.23.0/tr/model_doc/higgs_audio_v2#transformers.HiggsAudioV2Processor.decode) yöntemlerine bakın.

#### __call__[[transformers.HiggsAudioV2Processor.__call__]]

```python
__call__(text: str | list[str] | list[list[str]] | None = None, audio: typing.Union[numpy.ndarray, ForwardRef('torch.Tensor'), collections.abc.Sequence[numpy.ndarray], collections.abc.Sequence['torch.Tensor'], NoneType] = None, output_labels: bool | None = False, **kwargs: *<class 'transformers.processing_utils.ProcessingKwargs'>)
```

[Kaynak](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/higgs_audio_v2/processing_higgs_audio_v2.py#L126)

#### decode[[transformers.HiggsAudioV2Processor.decode]]

```python
decode(audio_input_ids)
```

[Kaynak](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/higgs_audio_v2/processing_higgs_audio_v2.py#L283)

## HiggsAudioV2Model[[transformers.HiggsAudioV2Model]]

#### transformers.HiggsAudioV2Model[[transformers.HiggsAudioV2Model]]

```python
transformers.HiggsAudioV2Model(config: HiggsAudioV2Config)
```

[Kaynak](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/higgs_audio_v2/modeling_higgs_audio_v2.py#L381)

**Parametreler:**

config ([HiggsAudioV2Config](/docs/transformers/v5.23.0/tr/model_doc/higgs_audio_v2#transformers.HiggsAudioV2Config)) : Modelin tüm parametrelerini içeren model yapılandırma sınıfı. Bir yapılandırma dosyasıyla başlatmak, modelle ilişkili ağırlıkları yüklemez, yalnızca yapılandırmayı yükler. Model ağırlıklarını yüklemek için [from_pretrained()](/docs/transformers/v5.23.0/tr/main_classes/model#transformers.PreTrainedModel.from_pretrained) yöntemine göz atın.

Üzerinde herhangi bir özel head bulunmayan, ham hidden-states üreten çıplak Higgs Audio V2 Model.

Bu model [PreTrainedModel](/docs/transformers/v5.23.0/tr/main_classes/model#transformers.PreTrainedModel) sınıfından devralır. Kütüphanenin tüm modelleri için uyguladığı genel yöntemler (indirme veya kaydetme, giriş gömme boyutlarını yeniden ayarlama, başları budama vb.) için üst sınıf belgelendirmesine bakın.

Bu model aynı zamanda bir PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) alt sınıfıdır. Bunu standart bir PyTorch Module olarak kullanın ve genel kullanım ve davranışla ilgili tüm konular için PyTorch dokümantasyonuna başvurun.

#### forward[[transformers.HiggsAudioV2Model.forward]]

```python
forward(input_ids: typing.Optional[torch.LongTensor] = None, audio_input_ids: typing.Optional[torch.LongTensor] = None, attention_mask: typing.Optional[torch.LongTensor] = None, audio_input_ids_mask: typing.Optional[torch.BoolTensor] = None, position_ids: typing.Optional[torch.LongTensor] = None, past_key_values: transformers.cache_utils.Cache | None = None, inputs_embeds: typing.Optional[torch.Tensor] = None, use_cache: bool | None = None, **kwargs: *<class 'transformers.utils.generic.TransformersKwargs'>)
```

[Kaynak](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/higgs_audio_v2/modeling_higgs_audio_v2.py#L399)

**Parametreler:**

input_ids (`torch.LongTensor`, şekli `(batch_size, sequence_length)`, *isteğe bağlı*) : Sözlükteki girdi dizisi belirteçlerinin (token) indeksleri. Varsayılan olarak dolgu (padding) yoksayılır. İndeksler [AutoTokenizer](/docs/transformers/v5.23.0/tr/model_doc/auto#transformers.AutoTokenizer) kullanılarak elde edilebilir. Ayrıntılar için [PreTrainedTokenizer.encode()](/docs/transformers/v5.23.0/tr/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode) ve [PreTrainedTokenizer.__call__()](/docs/transformers/v5.23.0/tr/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__) yöntemlerine bakın. [Girdi kimlikları (input IDs) nedir?](../glossary#input-ids)

audio_input_ids (`torch.LongTensor`, şekli `(batch_size, num_audio_frames, num_codebooks)`, *isteğe bağlı*) : Ses kod kitabı belirteçlerinin dizinleri. Dizinler [HiggsAudioV2TokenizerModel.encode()](/docs/transformers/v5.23.0/tr/model_doc/higgs_audio_v2_tokenizer#transformers.HiggsAudioV2TokenizerModel.encode) kullanılarak elde edilebilir.

attention_mask (`torch.LongTensor`, şekli `(batch_size, sequence_length)`, *isteğe bağlı*) : Dolgu (padding) token indekslerinde dikkat (attention) işleminin uygulanmamasını sağlayan maske. `[0, 1]` aralığında seçilen maske değerleri:  - **maske uygulanmayan** tokenlar için 1, - **maske uygulanan** tokenlar için 0.  [Dikkat maskeleri nelerdir?](../glossary#attention-mask)

audio_input_ids_mask (`torch.BoolTensor`, şekli `(batch_size, num_audio_frames)`, *isteğe bağlı*) : `audio_input_ids` içindeki hangi ses karelerinin geçerli olduğunu belirtir.

position_ids (`torch.LongTensor`, şekli `(batch_size, sequence_length)`, *isteğe bağlı*) : Girdi dizisi token'larının konum gömme (position embeddings) içindeki konum indeksleri. `[0, config.n_positions - 1]` aralığında seçilir.  [Konum kimlikleri (position IDs) nedir?](../glossary#position-ids)

past_key_values (`~cache_utils.Cache`, *isteğe bağlı*) : Sıralı çözümlemeyi hızlandırmak için kullanılabilen, önceden hesaplanmış gizli durumlar (self-attention bloklarındaki ve cross-attention bloklarındaki anahtar ve değerler). Bu genellikle, `use_cache=True` veya `config.use_cache=True` olduğunda, çözümlemenin önceki bir aşamasında modelin döndürdüğü `past_key_values` değerlerinden oluşur. Girdi olarak yalnızca [Cache](/docs/transformers/v5.23.0/tr/internal/generation_utils#transformers.Cache) örneği kabul edilir, bkz. [kv cache kılavuzu](https://huggingface.co/docs/transformers/en/kv_cache). `past_key_values` geçirilmezse, varsayılan olarak [DynamicCache](/docs/transformers/v5.23.0/tr/internal/generation_utils#transformers.DynamicCache) başlatılır. Model, girdi olarak verilen aynı önbellek biçimini çıktı olarak verecektir. `past_key_values` kullanılıyorsa, kullanıcının, bu modele geçmiş anahtar-değer durumları verilmemiş olan, yalnızca işlenmemiş `input_ids` değerlerini (şekli `(batch_size, unprocessed_length)` olan) girmesi beklenir; bunun yerine, şekli `(batch_size, sequence_length)` olan tüm `input_ids` değerleri girilmez.

inputs_embeds (`torch.Tensor`, şekli `(batch_size, sequence_length, hidden_size)`, *isteğe bağlı*) : `input_ids` parametresini iletmek yerine, gömülü bir temsil doğrudan iletmeyi tercih edebilirsiniz. Bu, `input_ids` indekslerini ilgili vektörlere dönüştürme biçimi üzerinde modelin dahili gömme arama matrisine kıyasla daha fazla kontrol sahibi olmak istiyorsanız faydalıdır.

use_cache (`bool`, *isteğe bağlı*) : `True` olarak ayarlanırsa, `past_key_values` anahtar değer durumları döndürülür ve çözümlemeyi hızlandırmak için kullanılabilir (bkz. `past_key_values`).

**Dönüş:** `~models.modeling_outputs.BaseModelOutputWithPast`

Yer tutucu konumlar, karşılık gelen ses gömme değerleriyle zaten değiştirilmiş olan standart decoder çıktıları.

[HiggsAudioV2Model](/docs/transformers/v5.23.0/tr/model_doc/higgs_audio_v2#transformers.HiggsAudioV2Model) forward metodu, `__call__` özel metodunu geçersiz kılar.

İleri geçiş tarifi bu fonksiyon içinde tanımlanmalı olsa da, sonrasında bunun yerine `Module` örneğini çağırmak gerekir; çünkü ilki ön ve son işleme adımlarını çalıştırmaktan sorumluyken ikincisi bunları sessizce yok sayar.

Örnek:

```python
>>> from transformers import AutoProcessor, HiggsAudioV2Model
>>> import torch
>>> device = "cuda" if torch.cuda.is_available() else "cpu"
>>> processor = AutoProcessor.from_pretrained("eustlb/higgs-audio-v2-generation-3B-base", device_map=device)
>>> model = HiggsAudioV2Model.from_pretrained("eustlb/higgs-audio-v2-generation-3B-base", device_map=device)
>>> conversation = [
...     {
...         "role": "system",
...         "content": [
...             {
...                 "type": "text",
...                 "text": "Generate audio following instruction."
...             }
...         ]
...     },
...     {
...         "role": "scene",
...         "content": [
...             {
...                 "type": "text",
...                 "text": "Audio is recorded from a quiet room."
...             }
...         ]
...     },
...     {
...         "role": "user",
...         "content": [
...             {
...                 "type": "text",
...                 "text": "It was the night before my birthday. Hooray! It's almost here! It may not be a holiday, but it's the best day of the year."
...             }
...         ]
...     },
...     {
...         "role": "assistant",
...         "content": [
...             {
...                 "type": "audio",
...                 "url": "https://huggingface.co/datasets/eustlb/dummy-audio-samples-higgs/resolve/main/belinda.wav"
...             }
...         ]
...     },
...     {
...         "role": "user",
...         "content": [
...             {
...                 "type": "text",
...                 "text": "The sun rises in the east and sets in the west. This simple fact has been observed by humans for thousands of years."
...             }
...         ]
...     }
... ]
>>> inputs = processor.apply_chat_template(conversation, return_dict=True, tokenize=True, sampling_rate=24000, return_tensors="pt")
>>> inputs = inputs.to(model.device)
>>> outputs = model(**inputs)
```

## HiggsAudioV2ForConditionalGeneration[[transformers.HiggsAudioV2ForConditionalGeneration]]

#### transformers.HiggsAudioV2ForConditionalGeneration[[transformers.HiggsAudioV2ForConditionalGeneration]]

```python
transformers.HiggsAudioV2ForConditionalGeneration(config: HiggsAudioV2Config, use_text_head: bool = False)
```

[Kaynak](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/higgs_audio_v2/modeling_higgs_audio_v2.py#L580)

**Parametreler:**

config ([HiggsAudioV2Config](/docs/transformers/v5.23.0/tr/model_doc/higgs_audio_v2#transformers.HiggsAudioV2Config)) : Modelin tüm parametrelerini içeren model yapılandırma sınıfı. Bir yapılandırma dosyasıyla başlatmak, modelle ilişkili ağırlıkları yüklemez, yalnızca yapılandırmayı yükler. Model ağırlıklarını yüklemek için [from_pretrained()](/docs/transformers/v5.23.0/tr/main_classes/model#transformers.PreTrainedModel.from_pretrained) yöntemine göz atın.

use_text_head (`bool`, *isteğe bağlı*, varsayılan olarak False) : Bir metin dil modeli başlığı kullanılıp kullanılmayacağı. Bu başlık üretim için gerekli değildir, ancak eğitim sırasında metin kaybını hesaplamak için kullanılabilir.

Higgs Audio modeli, çift-FFN'ye sahip, llama benzeri otoregresif bir transformer modelidir.

Bu model [PreTrainedModel](/docs/transformers/v5.23.0/tr/main_classes/model#transformers.PreTrainedModel) sınıfından devralır. Kütüphanenin tüm modelleri için uyguladığı genel yöntemler (indirme veya kaydetme, giriş gömme boyutlarını yeniden ayarlama, başları budama vb.) için üst sınıf belgelendirmesine bakın.

Bu model aynı zamanda bir PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) alt sınıfıdır. Bunu standart bir PyTorch Module olarak kullanın ve genel kullanım ve davranışla ilgili tüm konular için PyTorch dokümantasyonuna başvurun.

#### forward[[transformers.HiggsAudioV2ForConditionalGeneration.forward]]

```python
forward(input_ids: typing.Optional[torch.LongTensor] = None, attention_mask: typing.Optional[torch.BoolTensor] = None, audio_input_ids: typing.Optional[torch.LongTensor] = None, audio_input_ids_mask: typing.Optional[torch.LongTensor] = None, position_ids: typing.Optional[torch.LongTensor] = None, past_key_values: transformers.cache_utils.Cache | None = None, inputs_embeds: typing.Optional[torch.Tensor] = None, labels: typing.Optional[torch.LongTensor] = None, audio_labels: typing.Optional[torch.LongTensor] = None, use_cache: bool | None = None, logits_to_keep: typing.Union[int, torch.Tensor] = 0, **kwargs: *<class 'transformers.utils.generic.TransformersKwargs'>)
```

[Kaynak](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/higgs_audio_v2/modeling_higgs_audio_v2.py#L629)

**Parametreler:**

input_ids (`torch.LongTensor`, şekli `(batch_size, sequence_length)`, *isteğe bağlı*) : Sözlükteki girdi dizisi belirteçlerinin (token) indeksleri. Varsayılan olarak dolgu (padding) yoksayılır. İndeksler [AutoTokenizer](/docs/transformers/v5.23.0/tr/model_doc/auto#transformers.AutoTokenizer) kullanılarak elde edilebilir. Ayrıntılar için [PreTrainedTokenizer.encode()](/docs/transformers/v5.23.0/tr/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode) ve [PreTrainedTokenizer.__call__()](/docs/transformers/v5.23.0/tr/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__) yöntemlerine bakın. [Girdi kimlikları (input IDs) nedir?](../glossary#input-ids)

attention_mask (`torch.BoolTensor`, şekli `(batch_size, sequence_length)`, *isteğe bağlı*) : Dolgu (padding) token indekslerinde dikkat (attention) işleminin uygulanmamasını sağlayan maske. `[0, 1]` aralığında seçilen maske değerleri:  - **maske uygulanmayan** tokenlar için 1, - **maske uygulanan** tokenlar için 0.  [Dikkat maskeleri nelerdir?](../glossary#attention-mask)

audio_input_ids (`torch.LongTensor`, şekli `(batch_size, num_audio_frames, num_codebooks)`, *isteğe bağlı*) : Ses kod kitabı belirteçlerinin dizinleri. Dizinler [HiggsAudioV2TokenizerModel.encode()](/docs/transformers/v5.23.0/tr/model_doc/higgs_audio_v2_tokenizer#transformers.HiggsAudioV2TokenizerModel.encode) kullanılarak elde edilebilir.

audio_input_ids_mask (`torch.BoolTensor`, şekli `(batch_size, num_audio_frames)`, *isteğe bağlı*) : `audio_input_ids` içindeki hangi ses karelerinin geçerli olduğunu belirtir.

position_ids (`torch.LongTensor`, şekli `(batch_size, sequence_length)`, *isteğe bağlı*) : Girdi dizisi token'larının konum gömme (position embeddings) içindeki konum indeksleri. `[0, config.n_positions - 1]` aralığında seçilir.  [Konum kimlikleri (position IDs) nedir?](../glossary#position-ids)

past_key_values (`~cache_utils.Cache`, *isteğe bağlı*) : Sıralı çözümlemeyi hızlandırmak için kullanılabilen, önceden hesaplanmış gizli durumlar (self-attention bloklarındaki ve cross-attention bloklarındaki anahtar ve değerler). Bu genellikle, `use_cache=True` veya `config.use_cache=True` olduğunda, çözümlemenin önceki bir aşamasında modelin döndürdüğü `past_key_values` değerlerinden oluşur. Girdi olarak yalnızca [Cache](/docs/transformers/v5.23.0/tr/internal/generation_utils#transformers.Cache) örneği kabul edilir, bkz. [kv cache kılavuzu](https://huggingface.co/docs/transformers/en/kv_cache). `past_key_values` geçirilmezse, varsayılan olarak [DynamicCache](/docs/transformers/v5.23.0/tr/internal/generation_utils#transformers.DynamicCache) başlatılır. Model, girdi olarak verilen aynı önbellek biçimini çıktı olarak verecektir. `past_key_values` kullanılıyorsa, kullanıcının, bu modele geçmiş anahtar-değer durumları verilmemiş olan, yalnızca işlenmemiş `input_ids` değerlerini (şekli `(batch_size, unprocessed_length)` olan) girmesi beklenir; bunun yerine, şekli `(batch_size, sequence_length)` olan tüm `input_ids` değerleri girilmez.

inputs_embeds (`torch.Tensor`, şekli `(batch_size, sequence_length, hidden_size)`, *isteğe bağlı*) : `input_ids` parametresini iletmek yerine, gömülü bir temsil doğrudan iletmeyi tercih edebilirsiniz. Bu, `input_ids` indekslerini ilgili vektörlere dönüştürme biçimi üzerinde modelin dahili gömme arama matrisine kıyasla daha fazla kontrol sahibi olmak istiyorsanız faydalıdır.

labels (`torch.LongTensor`, şekli `(batch_size, sequence_length)`, *isteğe bağlı*) : Maskeli dil modelleme kaybını hesaplamak için etiketler. Endeksler `[0, ..., config.vocab_size]` aralığında olmalı ya da -100 olmalı (`input_ids` docstring'ine bakın). Endeksleri `-100` olarak ayarlanan tokenlar yok sayılır (maskelenir), kayıp yalnızca `[0, ..., config.vocab_size]` aralığında etiketlere sahip tokenlar için hesaplanır.

audio_labels (`torch.LongTensor` of shape `(batch_size, num_audio_frames, num_codebooks)`, *optional*) : Labels for the audio codebook tokens for computing the masked language modeling loss. Indices should either be in `[0, ..., config.codebook_size]. Token with indices set to `-100` are ignored (masked), the loss is only computed for the tokens with labels in `[0, ..., config.codebook_size]`. Can be obtained using `output_labels=True` when calling [HiggsAudioV2Processor](/docs/transformers/v5.23.0/tr/model_doc/higgs_audio_v2#transformers.HiggsAudioV2Processor).

use_cache (`bool`, *isteğe bağlı*) : `True` olarak ayarlanırsa, `past_key_values` anahtar değer durumları döndürülür ve çözümlemeyi hızlandırmak için kullanılabilir (bkz. `past_key_values`).

logits_to_keep (`Union[int, torch.Tensor]`, *isteğe bağlı*, varsayılan `0`) : `int` ise, son `logits_to_keep` token için logits hesaplanır. `0` ise, tüm `input_ids` için logits hesaplanır (özel durum). Üretim için yalnızca son token'ın logits'ine ihtiyaç duyulur ve bunların yalnızca o token için hesaplanması bellek tasarrufu sağlar; bu, uzun diziler veya büyük sözlük boyutu için oldukça önemli hale gelir. `torch.Tensor` ise, dizi uzunluğu boyutunda tutulacak indekslere karşılık gelen 1B olmalıdır. Bu, paketlenmiş tensor biçimini (batch ve dizi uzunluğu için tek boyut) kullanırken faydalıdır.

**Dönüş:** `~models.modeling_outputs.CausalLMOutputWithPast`

Modelden gelen logitleri, kaybı (etiketler sağlanırsa) ve diğer çıktıları içeren bir `~models.modeling_outputs.CausalLMOutputWithPast`.

[HiggsAudioV2ForConditionalGeneration](/docs/transformers/v5.23.0/tr/model_doc/higgs_audio_v2#transformers.HiggsAudioV2ForConditionalGeneration) forward metodu, `__call__` özel metodunu geçersiz kılar.

İleri geçiş tarifi bu fonksiyon içinde tanımlanmalı olsa da, sonrasında bunun yerine `Module` örneğini çağırmak gerekir; çünkü ilki ön ve son işleme adımlarını çalıştırmaktan sorumluyken ikincisi bunları sessizce yok sayar.

Örnek:

```python
>>> from transformers import AutoProcessor, HiggsAudioV2ForConditionalGeneration
>>> model_id = "eustlb/higgs-audio-v2-generation-3B-base"
>>> processor = AutoProcessor.from_pretrained(model_id, device_map="auto")
>>> model = HiggsAudioV2ForConditionalGeneration.from_pretrained(model_id, device_map="auto")
>>> conversation = [
...     {
...         "role": "system",
...         "content": [
...             {
...                 "type": "text",
...                 "text": "Generate audio following instruction."
...             }
...         ]
...     },
...     {
...         "role": "scene",
...         "content": [
...             {
...                 "type": "text",
...                 "text": "Audio is recorded from a quiet room."
...             }
...         ]
...     },
...     {
...         "role": "user",
...         "content": [
...             {
...                 "type": "text",
...                 "text": "It was the night before my birthday. Hooray! It's almost here! It may not be a holiday, but it's the best day of the year."
...             }
...         ]
...     },
...     {
...         "role": "assistant",
...         "content": [
...             {
...                 "type": "audio",
...                 "url": "https://huggingface.co/datasets/eustlb/dummy-audio-samples-higgs/resolve/main/belinda.wav"
...             }
...         ]
...     },
...     {
...         "role": "user",
...         "content": [
...             {
...                 "type": "text",
...                 "text": "The sun rises in the east and sets in the west. This simple fact has been observed by humans for thousands of years."
...             }
...         ]
...     }
... ]
>>> inputs = processor.apply_chat_template(conversation, return_dict=True, tokenize=True, sampling_rate=24000, return_tensors="pt")
>>> inputs = inputs.to(model.device)
>>> outputs = model(**inputs)
```

#### generate[[transformers.HiggsAudioV2ForConditionalGeneration.generate]]

```python
generate(inputs: typing.Optional[torch.Tensor] = None, generation_config: transformers.generation.configuration_utils.GenerationConfig | None = None, logits_processor: transformers.generation.logits_process.LogitsProcessorList | None = None, stopping_criteria: transformers.generation.stopping_criteria.StoppingCriteriaList | None = None, prefix_allowed_tokens_fn: collections.abc.Callable[[int, torch.Tensor], list[int]] | None = None, synced_gpus: bool | None = None, assistant_model: typing.Optional[ForwardRef('PreTrainedModel')] = None, streamer: typing.Optional[ForwardRef('BaseStreamer')] = None, negative_prompt_ids: typing.Optional[torch.Tensor] = None, negative_prompt_attention_mask: typing.Optional[torch.Tensor] = None, custom_generate: str | collections.abc.Callable | None = None, **kwargs)
```

[Kaynak](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/generation/utils.py#L2581)

**Parametreler:**

inputs (`torch.Tensor`, modaliteye göre değişen şekle sahip, *isteğe bağlı*) : Üretim için istem olarak veya kodlayıcıya model girdisi olarak kullanılan dizi. `None` ise yöntem, `bos_token_id` ve 1 parti boyutu ile başlatır. Sadece çözücü modeller için `inputs`, `input_ids` biçiminde olmalıdır. Kodlayıcı-çözücü modeller için *inputs*, `input_ids`, `input_values`, `input_features` veya `pixel_values`'den herhangi birini temsil edebilir.

generation_config ([GenerationConfig](/docs/transformers/v5.23.0/tr/main_classes/text_generation#transformers.GenerationConfig), *opsiyonel*) : Üretim çağrısı için temel parametrelendirme olarak kullanılacak üretim yapılandırması. `generation_config` öznitelikleriyle eşleşen ve generate'e aktarılan `**kwargs` bunları geçersiz kılar. `generation_config` sağlanmazsa, varsayılan kullanılır ve bunun yükleme önceliği şöyledir: 1) varsa `generation_config.json` model dosyasından; 2) model yapılandırmasından. Belirtilmeyen parametrelerin, üretimi parametrelendirmek için belgelenmesi gereken [GenerationConfig](/docs/transformers/v5.23.0/tr/main_classes/text_generation#transformers.GenerationConfig)'in varsayılan değerlerini devraldığını lütfen unutmayın.

logits_processor (`LogitsProcessorList`, *isteğe bağlı*) : Argümanlardan ve üretim yapılandırmasından oluşturulan varsayılan logits işleyicilerini tamamlayan özel logits işleyicileri. Argümanlarla veya bir üretim yapılandırmasıyla zaten oluşturulmuş bir logits işleyicisi geçirilirse bir hata fırlatılır. Bu özellik ileri düzey kullanıcılar için tasarlanmıştır.

stopping_criteria (`StoppingCriteriaList`, *isteğe bağlı*) : Argümanlardan ve bir üretim yapılandırmasından oluşturulan varsayılan durdurma ölçütlerini tamamlayan özel durdurma ölçütleri. Argümanlarla veya bir üretim yapılandırmasıyla zaten oluşturulmuş bir durdurma ölçütü geçirilirse bir hata fırlatılır. Durdurma ölçütleriniz `scores` girdisine bağlıysa, `generate` fonksiyonuna `return_dict_in_generate=True, output_scores=True` parametrelerini geçmeyi unutmayın. Bu özellik ileri düzey kullanıcılar için tasarlanmıştır.

prefix_allowed_tokens_fn (`Callable[[int, torch.Tensor], list[int]]`, *isteğe bağlı*) : Sağlanırsa, bu fonksiyon her adımda beam search'i yalnızca izin verilen token'lara kısıtlar. Sağlanmazsa hiçbir kısıtlama uygulanmaz. Bu fonksiyon 2 argüman alır: batch kimliği `batch_id` ve `input_ids`. Batch kimliği `batch_id` ve daha önce üretilen token'lara `inputs_ids` bağlı olarak, bir sonraki üretim adımı için izin verilen token'ların listesini döndürmelidir. Bu argüman, [Autoregressive Entity Retrieval](https://huggingface.co/papers/2010.00904) başlıklı bölümde anlatıldığı gibi, önekle (prefix) koşullu kısıtlı üretim için faydalıdır.

synced_gpus (`bool`, *isteğe bağlı*) : while döngüsünün max_length değerine kadar çalışmaya devam edip etmeyeceğini belirtir. Aksi belirtilmedikçe, birden fazla GPU ile `FullyShardedDataParallel` veya DeepSpeed ZeRO Stage 3 kullanılıyorsa, bir GPU diğer GPU'lardan önce üretimi tamamlarsa ölü kilitlenmeyi (deadlock) önlemek için bu bayrak `True` olarak ayarlanır. Aksi halde varsayılan değer `False`'tür.

assistant_model (`PreTrainedModel`, *isteğe bağlı*) : Üretimi hızlandırmak için kullanılabilen bir asistan modelidir. Asistan modelin, tam olarak aynı tokenizer'a sahip olması gerekir. Hızlandırma, asistan model ile aday token'ları tahmin etmenin, generate çağrısını yaptığınız modelle üretim çalıştırmaktan çok daha hızlı olması durumunda elde edilir. Bu nedenle asistan modelin çok daha küçük olması gerekir.

streamer (`BaseStreamer`, *isteğe bağlı*) : Üretilen dizilerin akışını sağlamak için kullanılacak Streamer nesnesi. Üretilen jetonlar `streamer.put(token_ids)` üzerinden geçirilir ve sonraki işlemlerden streamer sorumludur.

negative_prompt_ids (`torch.LongTensor`, şekli `(batch_size, sequence_length)`, *isteğe bağlı*) : CFG gibi bazı işlemciler için gerekli negatif prompt. Batch boyutu, girdi batch boyutuyla eşleşmelidir. Bu deneysel bir özelliktir ve gelecekteki sürümlerde kırıcı API değişikliklerine tabi olabilir.

negative_prompt_attention_mask (`torch.LongTensor`, şekli `(batch_size, sequence_length)`, *isteğe bağlı*) : `negative_prompt_ids` için Attention_mask.

custom_generate (`str` veya `Callable`, *isteğe bağlı*) : Aşağıdakilerden biri: - `str` (Hugging Face Hub deposu adı): standart `generate` yöntemi yerine, o depodaki `custom_generate/generate.py` adresinde tanımlanan özel `generate` işlevini çalıştırır. Depo, üretim mantığını tamamen değiştirir ve dönüş tipi farklı olabilir. - `str` (yerel depo yolu): yukarıdakiyle aynıdır ancak yerel bir yoldan yapılır. Yerel dizinler de, yerel `custom_generate/generate.py` dosyasının çalıştırılması nedeniyle `trust_remote_code=True` gerektirir. - `Callable`: `generate`, olağan girdi hazırlama adımlarını gerçekleştirir, ardından çözümleme döngüsünü çalıştırmak için sağlanan çağrılabilir öğeyi çağırır. Daha fazla bilgi için [belgeleri](../../generation_strategies#custom-generation-methods) inceleyin.

kwargs (`dict[str, Any]`, *isteğe bağlı*) : `generation_config` için ad hoc parametrelendirme ve/veya modelin `forward` fonksiyonuna iletilecek ek model-özel kwargs'lar. Model bir encoder-decoder modeli ise, encoder'a özgü kwargs'lar öneklenmemeli ve decoder'a özgü kwargs'lar *decoder_* önekiyle başlatılmalıdır.

**Dönüş:** [ModelOutput](/docs/transformers/v5.23.0/tr/main_classes/output#transformers.utils.ModelOutput) veya `torch.LongTensor`

Bir [ModelOutput](/docs/transformers/v5.23.0/tr/main_classes/output#transformers.utils.ModelOutput) (`return_dict_in_generate=True` ise veya `config.return_dict_in_generate=True` ise) ya da bir `torch.LongTensor`.

Model bir encoder-decoder modeli *değilse* (`model.config.is_encoder_decoder=False`), olası [ModelOutput](/docs/transformers/v5.23.0/tr/main_classes/output#transformers.utils.ModelOutput) türleri şunlardır:

- [GenerateDecoderOnlyOutput](/docs/transformers/v5.23.0/tr/internal/generation_utils#transformers.generation.GenerateDecoderOnlyOutput),
- [GenerateBeamDecoderOnlyOutput](/docs/transformers/v5.23.0/tr/internal/generation_utils#transformers.generation.GenerateBeamDecoderOnlyOutput)

Model bir kodlayıcı-çözücü modeli (`model.config.is_encoder_decoder=True`) ise, olası [ModelOutput](/docs/transformers/v5.23.0/tr/main_classes/output#transformers.utils.ModelOutput) türleri şunlardır:

- [GenerateEncoderDecoderOutput](/docs/transformers/v5.23.0/tr/internal/generation_utils#transformers.generation.GenerateEncoderDecoderOutput),
- [GenerateBeamEncoderDecoderOutput](/docs/transformers/v5.23.0/tr/internal/generation_utils#transformers.generation.GenerateBeamEncoderDecoderOutput)

Dil modelleme başlığına sahip modeller için token kimliği dizileri üretir.

Çoğu üretim kontrol parametresi, `generation_config` içinde ayarlanır; bu parametre geçirilmezse, modelin varsayılan üretim yapılandırması kullanılır. `generation_config` içindeki herhangi bir değeri, generate() fonksiyonuna ilgili parametreleri geçirerek geçersiz kılabilirsiniz, örneğin `.generate(inputs, num_beams=4, do_sample=True)`.

Üretim stratejileri ve kod örneklerinin genel bakışı için [şu kılavuza](../generation_strategies) göz atın.

