Skip to content
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

Add Mask to TextLastHiddenState #997

Merged
merged 30 commits into from
Jan 5, 2023
Merged

Add Mask to TextLastHiddenState #997

merged 30 commits into from
Jan 5, 2023

Conversation

unconst
Copy link
Contributor

@unconst unconst commented Nov 16, 2022

Adds masking to the TextLastHiddenState Synapse.

For a return tensor of size (batch_size, sequence_length, hidden_state), we can now optionally pass a mask as: bittensor.synapse.TextLastHiddenState(mask: Optional[List[int]]). The mask will apply across the sequence_length dimension, i.e. if mask == [0], only the hidden state for the 0th element will be filled. Explicitly, return_tensor[:, 1:, :] would ==0.

Alternatively a list of non-consecutive integers can be passed, e.g. bittensor.synapse.TextLastHiddenState(mask = [0, 5, 3]) would only return non-empty tensors for sequence indices 0, 5, and 3.

This change can drastically decrease the network bandwidth.

Alternatively, the user can specify a random mask
d.text_last_hidden_state ( ... mask = random.choice( seq_len, k), ...)
This random masking can be used for adversarial resistance. Or Jepa style training.

@unconst unconst changed the base branch from master to nobunaga November 16, 2022 17:08
@joeylegere joeylegere changed the title Synapse update Add Mask to TextLastHiddenState Jan 3, 2023
test.ipynb Outdated Show resolved Hide resolved
bittensor/_synapse/__init__.py Outdated Show resolved Hide resolved
bittensor/_synapse/__init__.py Outdated Show resolved Hide resolved
Copy link
Contributor

@Eugene-hu Eugene-hu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@joeylegere joeylegere merged commit cbee757 into nobunaga Jan 5, 2023
@joeylegere joeylegere deleted the synapse_update branch January 5, 2023 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants