Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions kimia_infer/utils/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ def sample_audio_logits(
logits.scatter_(dim=0, index=recent_window, src=scores)
logits = logits.unsqueeze(0) # Add batch dimension back

# Apply temperature scaling if not greedy
if self.audio_temperature > 1e-6:
logits = logits / self.audio_temperature

# Convert to probabilities with softmax
logprobs = torch.log_softmax(logits, dim=-1, dtype=torch.float)

# Apply temperature scaling if not greedy
if self.audio_temperature > 1e-6:
logprobs = logprobs / self.audio_temperature

# Apply top-k sampling
if self.audio_top_k > 0:
# Get probabilities from logprobs
Expand Down Expand Up @@ -134,13 +135,14 @@ def sample_text_logits(
logits.scatter_(dim=0, index=recent_window, src=scores)
logits = logits.unsqueeze(0) # Add batch dimension back

# Apply temperature scaling if not greedy
if self.text_temperature > 1e-6:
logits = logits / self.text_temperature

# Convert to probabilities with softmax
logprobs = torch.log_softmax(logits, dim=-1, dtype=torch.float)

# Apply temperature scaling if not greedy
if self.text_temperature > 1e-6:
logprobs = logprobs / self.text_temperature

# Apply top-k sampling
if self.text_top_k > 0:
# Get probabilities from logprobs
Expand Down