Downloads · 30 days
11
15% of all-time downloads
ShuaiAnwo/pore-codec-rsq742c12a-514
pore-codec-rsq742c12a-514 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
11
15% of all-time downloads
All-time downloads
73
Public
Parameters
1.2M
4.7 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors4.7 MB · 99%
From the Hugging Face model README

PoreCodec-RSQ742C12A is a lightweight neural codec for nanopore electrical signals. It converts continuous ionic current measurements into compact hierarchical discrete token sequences using a convolutional encoder followed by a production-oriented Residual Finite Scalar Quantization (Residual FSQ) module.
Unlike traditional VQ-VAE based codecs, PoreCodec employs deterministic finite scalar quantization with exhaustive codebooks stored directly inside the model checkpoint, eliminating codebook collapse while enabling efficient constant-time decoding.
The resulting discrete representations are designed to serve as the interface between raw nanopore signals and transformer-based foundation models.
Raw Nanopore Signal
│
▼
CNN Encoder
│
▼
512-D Latent Features
│
▼
Linear Projection
│
▼
Residual Finite Scalar Quantization
│
├──────────────► Hierarchical Token IDs
│
▼
Quantized Latent Features
│
▼
Linear Projection
│
▼
CNN Decoder
│
▼
Reconstructed Signal
The model consists of three major components:
The encoder extracts local electrical signal patterns through a deep one-dimensional convolutional network.
| Property | Value |
|---|---|
| Input channels | 1 |
| Output channels | 512 |
| Downsampling factor | ×4 |
| Receptive field | 33 samples |
The encoder transforms raw nanopore current measurements into compact latent representations while preserving local temporal structures.
Instead of learning vector codebooks as in conventional VQ-VAE methods, PoreCodec performs deterministic residual scalar quantization over a finite Cartesian lattice.
Each residual stage quantizes the reconstruction error produced by previous stages, progressively refining the latent representation.
Unlike learned vector quantizers:
All exhaustive codebooks are precomputed and stored directly inside the model checkpoint, allowing constant-time lookup during decoding.
| Parameter | Value |
|---|---|
| Levels | 7 7 7 7 |
| Codebook size | 2401 |
| Residual quantizers | 2 |
Each latent position produces multiple residual quantization indices
Latent Vector
↓
Residual Quantizer 1
↓
Residual Quantizer 2
↓
Level Indices
↓
Unified Token IDs
Different hierarchy depths may be selected:
| layer | Description |
|---|---|
| 1 | First residual quantizer |
| 2 | First two residual quantizers |
| 0 | All available quantizers |
Higher layers generally provide improved reconstruction quality at the expense of larger token vocabulary.
The accompanying FeatureExtractor performs automatic preprocessing before inference.
Pipeline:
Available preprocessing strategies:
import numpy as np
from transformers import AutoFeatureExtractor, AutoModel
model_name = "ShuaiAnwo/pore-codec-rsq742c12a-513"
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,
)
Convert normalized nanopore signals into discrete token IDs.
token_ids = model.encode_signal(signal, layer=2)
Returns
[B, N]
Reconstruct signals directly from token IDs.
reconstructed = model.decode_token(
token_ids,
layer=2,
)
Complete end-to-end codec inference.
reconstruction, level_indices = model(signal)
Returns
Convert hierarchical residual indices into unified token IDs.
token_ids = model.tokenize_indices(
level_indices,
layer=2,
)
Reconstruct signals directly from residual indices.
signal = model.decode_indices(
level_indices,
layer=2,
)
| Parameter | Value |
|---|---|
| CNN output dimension | 512 |
| Downsampling factor | ×4 |
| Receptive field | 33 |
| FSQ Levels | 7 7 7 7 |
| Residual Quantizers | 2 |
| Codebook Size | 2401 |
| Data Type | float32 |
PoreCodec may be used for
| Residual FSQ | Conventional VQ |
|---|---|
| Deterministic | Learned codebook |
| No codebook collapse | Possible collapse |
| No dead entries | Dead vectors possible |
| Stable optimization | Sensitive training |
| O(1) lookup | Embedding search |
| Exhaustive finite lattice | Learned embeddings |
This model is designed for nanopore electrical current signals after preprocessing by the accompanying FeatureExtractor.
It is not intended for direct basecalling or DNA sequence prediction.
If you use PoreCodec in your research, please cite:
@misc{jiao2026porecodec,
title={PoreCodec: Residual Finite Scalar Quantization for Nanopore Signal Tokenization},
author={Shuai Jiao},
year={2026}
}
Released under the Apache-2.0 License.