Registry / ai-ml / conformer

conformer

JSON →
library0.3.2pypypi✓ verified 87d ago

This library provides a PyTorch implementation of the Conformer model, an architecture that combines convolutional neural networks and transformers. It is designed to efficiently model both local and global dependencies in sequences, primarily for tasks like speech recognition. The library is currently at version 0.3.2.

pip install conformer
INSTALL
IMPORT
SIG · CONFORMER
C
conformer
ai-mlpythonv0.3.2
Install
66.5s avg
Import
5325ms
Disk
4787MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 74.5s
py 3.11
✕ build_error
✓ 68.88s
py 3.12
✕ build_error
✓ 64.4s
py 3.13
✕ build_error
✓ 58.08s
py 3.9
✕ build_error
✕ timeout
4787MB installed
● package 4787MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Conformer
from conformer import Conformer

Demonstrates how to instantiate the `Conformer` model and perform a basic forward pass with dummy input data, illustrating its tensor input and output signatures.

import torch from conformer import Conformer # Define model parameters (example values) batch_size, sequence_length, input_dim = 3, 12345, 80 num_classes = 10 encoder_dim = 32 num_encoder_layers = 3 depthwise_conv_kernel_size = 31 # Common kernel size for Conformer # Instantiate the Conformer model model = Conformer( num_classes=num_classes, input_dim=input_dim, encoder_dim=encoder_dim, num_encoder_layers=num_encoder_layers, depthwise_conv_kernel_size=depthwise_conv_kernel_size ) # Create dummy input data (e.g., mel spectrograms and their lengths) inputs = torch.rand(batch_size, sequence_length, input_dim) # (batch, sequence_length, input_dim) input_lengths = torch.LongTensor([12345, 12300, 12000]) # Actual lengths for each item in batch # Perform a forward pass outputs, output_lengths = model(inputs, input_lengths) print(f"Output features shape: {outputs.shape}") print(f"Output lengths: {output_lengths}")
Debug
Known issues
breakingThe original GitHub repository for this library (https://github.com/lucidrains/conformer) has disappeared, and the author's account associated with it is no longer active. The library is effectively unmaintained, meaning no further updates, bug fixes, or official support are expected.
fix
Users are strongly advised to migrate to actively maintained Conformer implementations. Notable alternatives include `torchaudio.models.Conformer` for PyTorch users, or implementations found in libraries like Hugging Face Transformers.
affects: 0.1.0a - 0.3.2
gotchaDue to the popularity of the Conformer architecture, there are multiple Python libraries and repositories that implement it. This specific PyPI package `conformer` corresponds to the implementation originally by 'lucidrains'. Be cautious to distinguish it from other implementations (e.g., `torchaudio.models.Conformer`, `conformer-tf`) when referencing documentation or examples to avoid compatibility issues.
fix
Always verify the specific library and import path (e.g., `from conformer import Conformer` vs. `from torchaudio.models import Conformer`) to ensure you are using the intended Conformer implementation.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'conformer'
The `conformer` library is not installed in the current Python environment or the environment is not correctly activated.
fix
Install the library using pip: `pip install conformer`.
ImportError: cannot import name 'Conformer' from 'conformer'
The main `Conformer` class is not directly exposed under the top-level `conformer` package but is nested within a submodule, typically `conformer.model` or `conformer.encoder`.
fix
Import the `Conformer` class from its specific submodule, for example: `from conformer.model import Conformer`.
RuntimeError: Expected object of scalar type Float but got Double for argument #2 'mat2'
Input tensors provided to the Conformer model have a different data type (e.g., `torch.double`, often from NumPy defaults) than what the model expects (typically `torch.float32` for PyTorch models).
fix
Ensure all input tensors are explicitly cast to the expected PyTorch data type, typically `torch.float32`: `input_tensor = input_tensor.to(torch.float32)`.
RuntimeError: The size of tensor a (X) must match the size of tensor b (Y) at non-singleton dimension Z
The dimensions of the input tensor (e.g., batch size, sequence length, feature dimension) do not match the dimensions expected by the Conformer model's layers, or sequence length tensors are inconsistent with the input data.
fix
Reshape the input tensor to `(batch_size, sequence_length, feature_dimension)` and ensure any accompanying `lengths` tensor correctly reflects the batch size and valid sequence lengths for each element in the batch, adhering to the model's input expectations.
Upgrade
Version history
0.3.2latest on PyPI · released May 17, 2023
Audit
Dependencies
torchrequiredCore deep learning framework for PyTorch models
Agent activity
26 hits · last 30 days
node
20
OpenAI (training)
1
Resources
conformer — pip install conformer · libregistry