ligeti commited on
Commit
129dbcf
1 Parent(s): fe7f825

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +181 -4
README.md CHANGED
@@ -1,8 +1,185 @@
 
 
 
 
 
1
  ## ProkBERT-mini Model
2
 
3
- ProkBERT-mini-k6s2
 
4
 
 
5
 
6
- ---
7
- license: cc-by-nc-4.0
8
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-4.0
3
+ ---
4
+
5
+
6
  ## ProkBERT-mini Model
7
 
8
+ ProkBERT-mini-k6s2 is part of the ProkBERT family of genomic language models, specifically designed for microbiome applications. This model model can provide extended context size up to 4kb sequence by implementing the LCA tokenization with k-mer=6 and shift 2. This model showed comparable performance compare to other family member models.
9
+
10
 
11
+ ## Simple Usage Example
12
 
13
+ The following example demonstrates how to use the ProkBERT-mini model for processing a DNA sequence:
14
+
15
+ ```python
16
+ from transformers import MegatronBertForMaskedLM
17
+ from prokbert.prokbert_tokenizer import ProkBERTTokenizer
18
+
19
+ # Tokenization parameters
20
+ tokenization_parameters = {
21
+ 'kmer': 6,
22
+ 'shift': 2
23
+ }
24
+ # Initialize the tokenizer and model
25
+ tokenizer = ProkBERTTokenizer(tokenization_params=tokenization_parameters, operation_space='sequence')
26
+ model = MegatronBertForMaskedLM.from_pretrained("nerualbioinfo/prokbert-mini-k6s2")
27
+ # Example DNA sequence
28
+ sequence = 'ATGTCCGCGGGACCT'
29
+ # Tokenize the sequence
30
+ inputs = tokenizer(sequence, return_tensors="pt")
31
+ # Ensure that inputs have a batch dimension
32
+ inputs = {key: value.unsqueeze(0) for key, value in inputs.items()}
33
+ # Generate outputs from the model
34
+ outputs = model(**inputs)
35
+ ```
36
+
37
+ ### Model Details
38
+
39
+ **Developed by:** Neural Bioinformatics Research Group
40
+
41
+ **Architecture:** ProkBERT-mini-k6s2 is based on the MegatronBert architecture, a variant of the BERT model optimized for large-scale training. The model employs a learnable relative key-value positional embedding, mapping input vectors into a 384-dimensional space.
42
+
43
+
44
+ **Tokenizer:** The model uses a 6-mer tokenizer with a shift of 2 (k6s2), specifically designed to handle DNA sequences efficiently.
45
+
46
+ **Parameters:**
47
+
48
+ | Parameter | Description |
49
+ |----------------------|--------------------------------------|
50
+ | Model Size | 20.6 million parameters |
51
+ | Max. Context Size | 1024 bp |
52
+ | Training Data | 206.65 billion nucleotides |
53
+ | Layers | 6 |
54
+ | Attention Heads | 6 |
55
+
56
+ ### Intended Use
57
+
58
+ **Intended Use Cases:** ProkBERT-mini-k6-s2 is intended for bioinformatics researchers and practitioners focusing on genomic sequence analysis, including:
59
+ - sequence classification tasks
60
+ - Exploration of genomic patterns and features
61
+
62
+ ## Segmentation and Tokenization in ProkBERT Models
63
+
64
+ ### Preprocessing Sequence Data
65
+ Transformer models, including ProkBERT, have a context size limitation. ProkBERT's design accommodates context sizes significantly larger than an average gene but smaller than the average bacterial genome.
66
+ The initial stage of our pipeline involves two primary steps: segmentation and tokenization.
67
+ For more details about tokenization, please see the following notebook: [Tokenization Notebook in Google Colab](https://colab.research.google.com/github/nbrg-ppcu/prokbert/blob/main/examples/Tokenization.ipynb).
68
+
69
+ For more details about segmentation, please see the following notebook: [Segmentation Notebook in Google Colab](https://colab.research.google.com/github/nbrg-ppcu/prokbert/blob/main/examples/Segmentation.ipynb).
70
+
71
+ #### Segmentation
72
+ Segmentation is crucial for Genomic Language Models (GLMs) as they process limited-size chunks of sequence data, typically ranging from 0 to 4kb. The sequence is divided into smaller parts through segmentation, which can be either contiguous, splitting the sequence into disjoint segments, or random, involving randomly sampling segments of length L.
73
+
74
+ The first practical step in segmentation involves loading the sequence from a FASTA file, often including the reverse complement of the sequence.
75
+
76
+ **Segmentation process:**
77
+ ![Segmentation Process](https://github.com/nbrg-ppcu/prokbert/blob/main/assets/Figure2_segmentation.png?raw=true)
78
+
79
+ #### Tokenization Process
80
+ After segmentation, sequences are encoded into a vector format. The LCA method allows the model to use a broader context and reduce computational demands while maintaining the information-rich local context.
81
+
82
+ ## Basic Steps for Preprocessing:
83
+
84
+ 1. **Load Fasta Files**: Begin by loading the raw sequence data from FASTA files.
85
+ 2. **Segment the Raw Sequences**: Apply segmentation parameters to split the sequences into manageable segments.
86
+ 3. **Tokenize the Segmented Database**: Use the defined tokenization parameters to convert the segments into tokenized forms.
87
+ 4. **Create a Padded/Truncated Array**: Generate a uniform array structure, padding or truncating as necessary.
88
+ 5. **Save the Array to HDF**: Store the processed data in an HDF (Hierarchical Data Format) file for efficient retrieval and use in training models.
89
+
90
+
91
+ ### Installation of ProkBERT (if needed)
92
+
93
+ For setting up ProkBERT in your environment, you can install it using the following command (if not already installed):
94
+
95
+ ```python
96
+ try:
97
+ import prokbert
98
+ print("ProkBERT is already installed.")
99
+ except ImportError:
100
+ !pip install prokbert
101
+ print("Installed ProkBERT.")
102
+ ```
103
+
104
+ ### Training Data and Process
105
+
106
+ **Overview:** The model was pretrained on a comprehensive dataset of genomic sequences to ensure broad coverage and robust learning.
107
+
108
+ **Training Process:**
109
+ - **Masked Language Modeling (MLM):** The MLM objective was modified for genomic sequences for masking overlapping k-mers.
110
+ - **Training Phases:** The model underwent initial training with complete sequence restoration and selective masking, followed by a succeeding phase with variable-length datasets for increased complexity.
111
+
112
+ ### Evaluation Results for ProkBERT-mini
113
+
114
+ | Model | L | Avg. Ref. Rank | Avg. Top1 | Avg. Top3 | Avg. AUC |
115
+ |-------------------|------|----------------|-----------|-----------|-----------|
116
+ | ProkBERT-mini | 128 | 0.9315 | 0.4497 | 0.8960 | 0.9998 |
117
+ | ProkBERT-mini | 256 | 0.8433 | 0.4848 | 0.9130 | 0.9998 |
118
+ | ProkBERT-mini | 512 | 0.8098 | 0.5056 | 0.9179 | 0.9998 |
119
+ | ProkBERT-mini | 1024 | 0.7825 | 0.5169 | 0.9227 | 0.9998 |
120
+
121
+
122
+ *Masking performance of the ProkBERT family.*
123
+
124
+ ### Evaluation of Promoter Prediction Tools on E-coli Sigma70 Dataset
125
+
126
+ | Tool | Accuracy | MCC | Sensitivity | Specificity |
127
+ |-----------------------|----------|-------|-------------|-------------|
128
+ | ProkBERT-mini | **0.87** | **0.74** | 0.90 | 0.85 |
129
+ | ProkBERT-mini-c | **0.87** | 0.73 | 0.88 | 0.85 |
130
+ | ProkBERT-mini-long | **0.87** | **0.74** | 0.89 | 0.85 |
131
+ | CNNProm | 0.72 | 0.50 | 0.95 | 0.51 |
132
+ | iPro70-FMWin | 0.76 | 0.53 | 0.84 | 0.69 |
133
+ | 70ProPred | 0.74 | 0.51 | 0.90 | 0.60 |
134
+ | iPromoter-2L | 0.64 | 0.37 | 0.94 | 0.37 |
135
+ | Multiply | 0.50 | 0.05 | 0.81 | 0.23 |
136
+ | bTSSfinder | 0.46 | -0.07 | 0.48 | 0.45 |
137
+ | BPROM | 0.56 | 0.10 | 0.20 | 0.87 |
138
+ | IBPP | 0.50 | -0.03 | 0.26 | 0.71 |
139
+ | Promotech | 0.71 | 0.43 | 0.49 | **0.90** |
140
+ | Sigma70Pred | 0.66 | 0.42 | 0.95 | 0.41 |
141
+ | iPromoter-BnCNN | 0.55 | 0.27 | **0.99** | 0.18 |
142
+ | MULTiPly | 0.54 | 0.19 | 0.92 | 0.22 |
143
+
144
+ *The ProkBERT family models exhibit remarkably consistent performance across the metrics assessed. With respect to accuracy, all three tools achieve an impressive*
145
+
146
+ | Metric | ProkBERT-mini | ProkBERT-mini-c | ProkBERT-mini-long | Promotech | Sigma70Pred | iPromoter-BnCNN | MULTiPly |
147
+ |--------------|---------------|-----------------|--------------------|-----------|-------------|-----------------|----------|
148
+ | Accuracy | 0.81 | 0.79 | 0.81 | 0.61 | 0.62 | 0.61 | 0.58 |
149
+ | F1 | 0.81 | 0.78 | 0.81 | 0.43 | 0.58 | 0.65 | 0.58 |
150
+ | MCC | 0.63 | 0.57 | 0.62 | 0.29 | 0.24 | 0.21 | 0.16 |
151
+ | Sensitivity | 0.81 | 0.75 | 0.79 | 0.29 | 0.52 | 0.66 | 0.57 |
152
+ | Specificity | 0.82 | 0.82 | 0.83 | 0.93 | 0.71 | 0.55 | 0.59 |
153
+
154
+ *Promoter prediction performance metrics on a diverse test set. A comparative analysis of various promoter prediction tools, showcasing their performance across key metrics including accuracy, F1 score, MCC, sensitivity, and specificity.*
155
+
156
+
157
+
158
+ ### Ethical Considerations and Limitations
159
+
160
+ As with all models in the bioinformatics domain, ProkBERT-mini-k6-s2 should be used responsibly. Testing and evaluation have been conducted within specific genomic contexts, and the model's outputs in other scenarios are not guaranteed. Users should exercise caution and perform additional testing as necessary for their specific use cases.
161
+
162
+ ### Reporting Issues
163
+
164
+ Please report any issues with the model or its outputs to the Neural Bioinformatics Research Group through the following means:
165
+
166
+ - **Model issues:** [GitHub repository link](https://github.com/nbrg-ppcu/prokbert)
167
+ - **Feedback and inquiries:** [[email protected]](mailto:[email protected])
168
+
169
+ ## Reference
170
+ If you use ProkBERT-mini in your research, please cite the following paper:
171
+
172
+
173
+ ```
174
+ @ARTICLE{10.3389/fmicb.2023.1331233,
175
+ AUTHOR={Ligeti, Balázs and Szepesi-Nagy, István and Bodnár, Babett and Ligeti-Nagy, Noémi and Juhász, János},
176
+ TITLE={ProkBERT family: genomic language models for microbiome applications},
177
+ JOURNAL={Frontiers in Microbiology},
178
+ VOLUME={14},
179
+ YEAR={2024},
180
+ URL={https://www.frontiersin.org/articles/10.3389/fmicb.2023.1331233},
181
+ DOI={10.3389/fmicb.2023.1331233},
182
+ ISSN={1664-302X},
183
+ ABSTRACT={...}
184
+ }
185
+ ```