Downloads · 30 days
5
5% of all-time downloads
ShuaiAnwo/pore-codec-rsq742c36a-519
pore-codec-rsq742c36a-519 is a feature extraction model from ShuaiAnwo. Use it when you need embeddings to search or compare text. It is set up for transformers. The card lists the license as apache-2.0.
Downloads · 30 days
5
5% of all-time downloads
All-time downloads
111
Public
Parameters
972K
3.9 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors3.9 MB · 99%
From the Hugging Face model README

PoreCodec-RSQ742C36A is a lightweight neural codec for nanopore electrical signals. It converts continuous ionic current measurements into discrete token sequences while preserving the original temporal resolution of the signal. The model combines a fully convolutional dilated encoder with a production-oriented Residual Finite Scalar Quantization (Residual FSQ) module to generate hierarchical discrete representations suitable for downstream foundation models.
Unlike conventional neural codecs that compress the temporal dimension, PoreCodec maintains a one-to-one correspondence between signal samples and latent tokens. Each input sample produces one discrete token, enabling accurate temporal alignment for biological sequence modeling, retrieval, and representation learning.
Instead of learned vector codebooks, the codec employs deterministic finite scalar quantization with exhaustive codebooks stored directly inside the model checkpoint, providing stable optimization, deterministic encoding, and constant-time decoding.
Raw Nanopore Signal
│
▼
Dilated CNN Encoder
│
▼
512-D Latent Features
│
▼
Linear Projection
│
▼
Residual Finite Scalar Quantization
│
├──────────────► Hierarchical Token IDs
│
▼
Quantized Latent Features
│
▼
Linear Projection
│
▼
Dilated CNN Decoder
│
▼
Reconstructed Signal
The model consists of three major components.
The encoder extracts local electrical signal patterns using a five-layer one-dimensional dilated convolutional network.
Unlike conventional neural codecs, the encoder does not perform temporal downsampling. Progressive dilation enlarges the receptive field while preserving the original sequence length, allowing every input signal sample to correspond to one latent representation.
| Property | Value |
|---|---|
| Input Channels | 1 |
| Output Channels | 512 |
| Downsampling Factor | ×1 |
| Receptive Field | 37 Samples |
| Architecture | Five-layer Dilated CNN |
The latent representation is discretized using a production-oriented Residual Finite Scalar Quantization (Residual FSQ) module.
Instead of learning vector embeddings as in conventional VQ-VAE methods, PoreCodec performs deterministic scalar quantization over a finite Cartesian lattice.
Each residual stage progressively quantizes the remaining reconstruction error, producing increasingly accurate hierarchical representations.
Compared with learned vector quantizers, Residual FSQ provides:
All exhaustive codebooks are precomputed and stored directly inside the model checkpoint.
| Parameter | Value |
|---|---|
| Levels | 7 7 7 7 |
| Codebook Size | 2401 |
| Residual Quantizers | 2 |
| Quantization Type | Residual FSQ |
Each latent position produces hierarchical residual quantization indices.
Latent Vector
↓
Residual Quantizer 1
↓
Residual Quantizer 2
↓
Residual Indices
↓
Unified Token ID
Supported hierarchy levels:
| layer | Description |
|---|---|
| 1 | First residual quantizer |
| 2 | First two residual quantizers |
| 0 | All available quantizers |
Since the encoder preserves the original temporal resolution, the number of generated tokens is identical to the number of input signal samples.
The accompanying FeatureExtractor automatically preprocesses raw nanopore electrical signals before inference.
Pipeline:
Supported preprocessing strategies:
import numpy as np
from transformers import AutoFeatureExtractor, AutoModel
model_name = "ShuaiAnwo/pore-codec-rsq742c36a-512"
feature_extractor = AutoFeatureExtractor.from_pretrained(
model_name,
trust_remote_code=True,
)
model = AutoModel.from_pretrained(
model_name,
trust_remote_code=True,
)
model.eval()
raw_signal = np.random.normal(
loc=70,
scale=8,
size=1855,
).astype(np.float32)
signal = feature_extractor(
raw_signal,
return_tensors="pt",
)["signal"]
token_ids = model.encode_signal(
signal,
layer=2,
)
reconstructed = model.decode_token(
token_ids,
layer=2,
)
print(signal.shape)
print(token_ids.shape)
print(reconstructed.shape)
Expected output
torch.Size([1, 1, 1855])
torch.Size([1, 1855])
torch.Size([1, 1, 1855])
Convert a normalized nanopore signal into unified discrete token IDs.
token_ids = model.encode_signal(
signal,
layer=2,
)
Returns
[B, N]
Reconstruct normalized nanopore signals directly from unified token IDs.
signal = model.decode_token(
token_ids,
layer=2,
)
Convert hierarchical residual quantization indices into unified token IDs.
token_ids = model.tokenize_indices(
level_indices,
layer=2,
)
Reconstruct signals directly from hierarchical residual indices.
signal = model.decode_indices(
level_indices,
layer=2,
)
Perform complete end-to-end encoding and decoding.
reconstruction, level_indices = model(signal)
Returns:
Unlike conventional neural codecs that reduce temporal resolution, PoreCodec preserves the original signal length throughout the encoding pipeline.
For an input signal of length N, the model produces exactly N discrete tokens.
This one-to-one temporal correspondence simplifies downstream integration with biological foundation models, retrieval systems, sequence alignment algorithms, and multimodal learning pipelines.
The released checkpoint has been validated using the provided evaluation pipeline.
| Validation Item | Status |
|---|---|
| AutoConfig Loading | ✅ |
| AutoFeatureExtractor Loading | ✅ |
| AutoModel Loading | ✅ |
| End-to-End Encoding | ✅ |
| End-to-End Decoding | ✅ |
| Token Length = Signal Length | ✅ |
| Reconstruction Length = Signal Length | ✅ |
| Multi-layer Decoding | ✅ |
| Parameter | Value |
|---|---|
| CNN Architecture | Five-layer Dilated CNN |
| CNN Output Dimension | 512 |
| Downsampling Factor | ×1 |
| Receptive Field | 37 |
| FSQ Levels | 7 7 7 7 |
| Residual Quantizers | 2 |
| Codebook Size | 2401 |
| Data Type | float32 |
PoreCodec is suitable for:
| PoreCodec Residual FSQ | Conventional VQ |
|---|---|
| Deterministic encoding | Learned codebooks |
| No codebook collapse | Codebook collapse possible |
| No dead entries | Dead vectors possible |
| Stable optimization | Sensitive optimization |
| O(1) decoding lookup | Embedding search |
| Exhaustive finite lattice | Learned embeddings |
| Sample-level temporal alignment | Often temporally compressed |
This model is designed for preprocessed nanopore electrical current signals using the accompanying FeatureExtractor.
The model produces discrete signal representations and signal reconstructions. It is not intended to perform direct DNA basecalling or nucleotide sequence prediction.
If you use PoreCodec in your research, please cite:
@misc{jiao2026porecodec,
title={PoreCodec: Residual Finite Scalar Quantization for Full-Resolution Nanopore Signal Tokenization},
author={Shuai Jiao},
year={2026}
}
This model is released under the Apache-2.0 License.