-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
Optimize weighted embedding extraction with pyannote 3.1 #214
Comments
num_speakers
After a quick run of the diarization pipeline with 5s latency, it seems that pyannote 3.1 is hurting performance: DER=27.3 -> DER=29.1 with the exact same models and hyper-parameters. This is most certainly due to the new API for embedding models compatible with weighted stats pooling, so contrary to my initial idea of leaving this for v0.10, I think it's more a compatibility issue and less a matter of latency optimization. |
cc @hbredin, in case you can think of any other changes that could have caused this |
I can't think of any. I did not witness any change of performance in offline speaker diarization when switching from |
@hbredin I narrowed it down to a change in the interpolation method for the weights: - weights = F.interpolate(
- weights, size=num_frames, mode="linear", align_corners=False
- )
+ weights = F.interpolate(weights, size=num_frames, mode="nearest") Any particular reason for this change? I guess interpolating before calling the model should do the trick but I'm curious. |
MPS support. |
@hbredin MPS is needed for training though, right? Any way we can make it apply a different strategy? Because to interpolate before calling the model I actually need to know the number of frames that the model will produce internally right before the stats pooling. I suggest something like: model = Model.from_pretrained("pyannote/embedding")
model.set_interpolation_method("linear")
embeddings = model(waveform, weights) Inside the outputs = self.stats_pool(outputs, weights=weights, method=self.interpolation_method) And to call the interpolation: def forward(..., interpolation_method: str = "nearest"):
...
weights = F.interpolate(weights, size=num_frames, mode=interpolation_method)
... Notice that the interpolation method would need to be changed with a setter because Also, the same thing could be implemented for the masks in other embedding models (i.e. speechbrain and nemo). Right now I can't take advantage of this optimization because I would need to keep track of which model is compatible with it, and the rule may very easily change in the future, leading to compatibility hell. I'm willing to open PRs for both features. |
Since everything is working fine except for that performance loss on AMI, I think I'd prefer not to wait for this fix to release v0.9. I'll add a note to the reproducibility section of the README to indicate that pyannote<3.1 should be used to get the exact same results and link this issue. In any case, probably re-tuning hyper-parameters for this new interpolation method will give similar results. |
Hi, I'm raising this issue to note that as far as I can tell, the missing functionality has been implemented in the On my Macbook pro M1, using PyTorch 2.4.0:
so there should be no obstacle to returning to the original behavior, right? |
@shenberg have you checked whether using |
With pyannote 3.1, we could do only 1 forward pass of the audio instead of
num_speakers
when extracting embeddings with weights. This is probably at least one of the causes behind the pytorch version of the wespeaker embedding model being that much slower.This optimization would also reduce the latency of
pyannote/embedding
so both would need to be re-computed in the README table.Important: we should verify that this method is also compatible with masking (e.g. in speechbrain embeddings)
The text was updated successfully, but these errors were encountered: