đ Protein Sequence Classifier with Transformers.js
This project uses the base model AmelieSchreiber/esm2_t6_8M_UR50D_sequence_classifier_v1
and the transformers.js
library for zero - shot text classification. It provides an ONNX - compatible version of the model for use in JavaScript environments.
đ Quick Start
đĻ Installation
If you haven't already, you can install the Transformers.js JavaScript library from NPM using:
npm i @xenova/transformers
đģ Usage Examples
đ Basic Usage
Example: Protein sequence classification w/ Xenova/esm2_t6_8M_UR50D_sequence_classifier_v1
.
import { pipeline } from '@xenova/transformers';
const classifier = await pipeline('text-classification', 'Xenova/esm2_t6_8M_UR50D_sequence_classifier_v1');
const new_sequences_0 = [
'ACGYLKTPKLADPPVLRGDSSVTKAICKPDPVLEK',
'GVALDECKALDYLPGKPLPMDGKVCQCGSKTPLRP',
'VLPGYTCGELDCKPGKPLPKCGADKTQVATPFLRG',
'TCGALVQYPSCADPPVLRGSDSSVKACKKLDPQDK',
'GALCEECKLCPGADYKPMDGDRLPAAATSKTRPVG',
'PAVDCKKALVYLPKPLPMDGKVCRGSKTPKTRPYG',
'VLGYTCGALDCKPGKPLPKCGADKTQVATPFLRGA',
'CGALVQYPSCADPPVLRGSDSSVKACKKLDPQDKT',
'ALCEECKLCPGADYKPMDGDRLPAAATSKTRPVGK',
'AVDCKKALVYLPKPLPMDGKVCRGSKTPKTRPYGR',
]
const new_sequences_1 = [
'VGQRFYGGRQKNRHCELSPLPSACRGSVQGALYTD',
'KDQVLTVPTYACRCCPKMDSKGRVPSTLRVKSARS',
'PLAGVACGRGLDYRCPRKMVPGDLQVTPATQRPYG',
'CGVRLGYPGCADVPLRGRSSFAPRACMKKDPRVTR',
'RKGVAYLYECRKLRCRADYKPRGMDGRRLPKASTT',
'RPTGAVNCKQAKVYRGLPLPMMGKVPRVCRSRRPY',
'RLDGGYTCGQALDCKPGRKPPKMGCADLKSTVATP',
'LGTCRKLVRYPQCADPPVMGRSSFRPKACCRQDPV',
'RVGYAMCSPKLCSCRADYKPPMGDGDRLPKAATSK',
'QPKAVNCRKAMVYRPKPLPMDKGVPVCRSKRPRPY',
]
const new_sequences_2 = [
'VGKGFRYGSSQKRYLHCQKSALPPSCRRGKGQGSAT',
'KDPTVMTVGTYSCQCPKQDSRGSVQPTSRVKTSRSK',
'PLVGKACGRSSDYKCPGQMVSGGSKQTPASQRPSYD',
'CGKKLVGYPSSKADVPLQGRSSFSPKACKKDPQMTS',
'RKGVASLYCSSKLSCKAQYSKGMSDGRSPKASSTTS',
'RPKSAASCEQAKSYRSLSLPSMKGKVPSKCSRSKRP',
'RSDVSYTSCSQSKDCKPSKPPKMSGSKDSSTVATPS',
'LSTCSKKVAYPSSKADPPSSGRSSFSMKACKKQDPPV',
'RVGSASSEPKSSCSVQSYSKPSMSGDSSPKASSTSK',
'QPSASNCEKMSSYRPSLPSMSKGVPSSRSKSSPPYQ',
]
const new_sequences = [...new_sequences_0, ...new_sequences_1, ...new_sequences_2];
const predictions = await classifier(new_sequences);
for (let i = 0; i < predictions.length; ++i) {
console.log(`Sequence: ${new_sequences[i]}, Predicted class: '${predictions[i].label}'`)
}
â ī¸ Important 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
).
đ Documentation
The model is based on https://huggingface.co/AmelieSchreiber/esm2_t6_8M_UR50D_sequence_classifier_v1 with ONNX weights to be compatible with Transformers.js.
Information Table
Property |
Details |
Base Model |
AmelieSchreiber/esm2_t6_8M_UR50D_sequence_classifier_v1 |
Library Name |
transformers.js |
Pipeline Tag |
zero - shot - classification |
Tags |
text - classification |