metadata
base_model: AmelieSchreiber/esm2_t6_8M_UR50D_sequence_classifier_v1
library_name: transformers.js
pipeline_tag: zero-shot-classification
tags:
- text-classification
https://huggingface.co/AmelieSchreiber/esm2_t6_8M_UR50D_sequence_classifier_v1 with ONNX weights to be compatible with Transformers.js.
Usage (Transformers.js)
If you haven't already, you can install the Transformers.js JavaScript library from NPM using:
npm i @xenova/transformers
Example: Protein sequence classification w/ Xenova/esm2_t6_8M_UR50D_sequence_classifier_v1
.
import { pipeline } from '@xenova/transformers';
// Create text classification pipeline
const classifier = await pipeline('text-classification', 'Xenova/esm2_t6_8M_UR50D_sequence_classifier_v1');
// Suppose these are your new sequences that you want to classify
// Additional Family 0: Enzymes
const new_sequences_0 = [
'ACGYLKTPKLADPPVLRGDSSVTKAICKPDPVLEK',
'GVALDECKALDYLPGKPLPMDGKVCQCGSKTPLRP',
'VLPGYTCGELDCKPGKPLPKCGADKTQVATPFLRG',
'TCGALVQYPSCADPPVLRGSDSSVKACKKLDPQDK',
'GALCEECKLCPGADYKPMDGDRLPAAATSKTRPVG',
'PAVDCKKALVYLPKPLPMDGKVCRGSKTPKTRPYG',
'VLGYTCGALDCKPGKPLPKCGADKTQVATPFLRGA',
'CGALVQYPSCADPPVLRGSDSSVKACKKLDPQDKT',
'ALCEECKLCPGADYKPMDGDRLPAAATSKTRPVGK',
'AVDCKKALVYLPKPLPMDGKVCRGSKTPKTRPYGR',
]
// Additional Family 1: Receptor Proteins
const new_sequences_1 = [
'VGQRFYGGRQKNRHCELSPLPSACRGSVQGALYTD',
'KDQVLTVPTYACRCCPKMDSKGRVPSTLRVKSARS',
'PLAGVACGRGLDYRCPRKMVPGDLQVTPATQRPYG',
'CGVRLGYPGCADVPLRGRSSFAPRACMKKDPRVTR',
'RKGVAYLYECRKLRCRADYKPRGMDGRRLPKASTT',
'RPTGAVNCKQAKVYRGLPLPMMGKVPRVCRSRRPY',
'RLDGGYTCGQALDCKPGRKPPKMGCADLKSTVATP',
'LGTCRKLVRYPQCADPPVMGRSSFRPKACCRQDPV',
'RVGYAMCSPKLCSCRADYKPPMGDGDRLPKAATSK',
'QPKAVNCRKAMVYRPKPLPMDKGVPVCRSKRPRPY',
]
// Additional Family 2: Structural Proteins
const new_sequences_2 = [
'VGKGFRYGSSQKRYLHCQKSALPPSCRRGKGQGSAT',
'KDPTVMTVGTYSCQCPKQDSRGSVQPTSRVKTSRSK',
'PLVGKACGRSSDYKCPGQMVSGGSKQTPASQRPSYD',
'CGKKLVGYPSSKADVPLQGRSSFSPKACKKDPQMTS',
'RKGVASLYCSSKLSCKAQYSKGMSDGRSPKASSTTS',
'RPKSAASCEQAKSYRSLSLPSMKGKVPSKCSRSKRP',
'RSDVSYTSCSQSKDCKPSKPPKMSGSKDSSTVATPS',
'LSTCSKKVAYPSSKADPPSSGRSSFSMKACKKQDPPV',
'RVGSASSEPKSSCSVQSYSKPSMSGDSSPKASSTSK',
'QPSASNCEKMSSYRPSLPSMSKGVPSSRSKSSPPYQ',
]
// Merge all sequences
const new_sequences = [...new_sequences_0, ...new_sequences_1, ...new_sequences_2];
// Get the predicted class for each sequence
const predictions = await classifier(new_sequences);
// Output the predicted class for each sequence
for (let i = 0; i < predictions.length; ++i) {
console.log(`Sequence: ${new_sequences[i]}, Predicted class: '${predictions[i].label}'`)
}
// Sequence: ACGYLKTPKLADPPVLRGDSSVTKAICKPDPVLEK, Predicted class: 'Enzymes'
// ... (truncated)
// Sequence: AVDCKKALVYLPKPLPMDGKVCRGSKTPKTRPYGR, Predicted class: 'Enzymes'
// Sequence: VGQRFYGGRQKNRHCELSPLPSACRGSVQGALYTD, Predicted class: 'Receptor Proteins'
// ... (truncated)
// Sequence: QPKAVNCRKAMVYRPKPLPMDKGVPVCRSKRPRPY, Predicted class: 'Receptor Proteins'
// Sequence: VGKGFRYGSSQKRYLHCQKSALPPSCRRGKGQGSAT, Predicted class: 'Structural Proteins'
// ... (truncated)
// Sequence: QPSASNCEKMSSYRPSLPSMSKGVPSSRSKSSPPYQ, Predicted class: 'Structural Proteins'
Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using 🤗 Optimum and structuring your repo like this one (with ONNX weights located in a subfolder named onnx
).