Skip to main content
Position Weight Generator

This generator is open source. Any third-party models, product names, or trademarks referenced are the property of their respective owners, and Proto is not affiliated with them.


Source
proto-bio/proto-language/proto_language/generator/position_weight_generator.py
View source
Convert logit distributions into discrete proposal sequences. Reads seq.logits from each proposal sequence, applies softmax, and writes the decoded string back to seq.sequence. Supports deterministic argmax decoding or stochastic categorical sampling. Designed for gradient-based optimizers that update seq.logits directly and need discrete sequences for handoff or tracking.

API Reference

ConfigPositionWeightGeneratorConfig Source
Configuration for position-specific sequence sampling.This generator is intended for optimizers that own position-specific sequence distributions and need to materialize discrete proposal sequences for the rest of the framework.
sampling_mode
enum
default:"argmax"
How to convert position-specific distributions into discrete proposals.Options: argmax, categorical
temperature
number
default:"1.0"
Softmax temperature on logits before decoding. Below 1 sharpens; above 1 flattens. Must be > 0.
sequence_bias
SequenceLogitBiasConfig
Optional declarative sequence-symbol bias applied before decoding.
logit_scale
number
default:"1.0"
Optional scale factor applied to logits before adding sequence_bias and decoding.
peak_probability_positions
array
Position indices used in the mean per-position peak-probability metric; None averages over all.

Usage

python
>>> segment = Segment(sequence="ACGT", sequence_type="dna")
>>> gen = PositionWeightGenerator(PositionWeightGeneratorConfig(sampling_mode="argmax"))
>>> gen.assign(segment)
>>> segment.proposal_sequences[0].logits = np.array([[5, 0, 0, 0], [0, 4, 0, 0], [0, 0, 3, 0], [0, 0, 0, 2]])
>>> gen.sample()
>>> segment.proposal_sequences[0].sequence
'ACGT'

Metadata

PropertyValue
Keyposition-weight
ClassPositionWeightGenerator
Categorygradient
Input Typelogits
Uses GPUFalse
Supported Sequence Typesdna, rna, protein
Allows Empty StartFalse