Update README.md
Browse files
README.md
CHANGED
|
@@ -13,7 +13,26 @@ pip install --upgrade git+https://github.com/huggingface/transformers.git
|
|
| 13 |
pip install torch
|
| 14 |
```
|
| 15 |
|
| 16 |
-
A small snippet of code is given here in order to
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
```
|
| 19 |
import numpy as np
|
|
|
|
| 13 |
pip install torch
|
| 14 |
```
|
| 15 |
|
| 16 |
+
A small snippet of code is given here in order to **generate sequences from a pipeline (high-level)**.
|
| 17 |
+
|
| 18 |
+
```
|
| 19 |
+
# Load pipeline
|
| 20 |
+
from transformers import pipeline
|
| 21 |
+
pipe = pipeline(model="InstaDeepAI/ChatNT-text-generation-pipeline", trust_remote_code=True)
|
| 22 |
+
|
| 23 |
+
# Define custom inputs (note that the number of <DNA> token in the english sequence must be equal to len(dna_sequences))
|
| 24 |
+
english_sequence = "A chat between a curious user and an artificial intelligence assistant that can handle bio sequences. The assistant gives helpful, detailed, and polite answers to the user's questions. USER: Is there any evidence of an acceptor splice site in this sequence <DNA> ?"
|
| 25 |
+
dna_sequences = ["ATCGGAAAAAGATCCAGAAAGTTATACCAGGCCAATGGGAATCACCTATTACGTGGATAATAGCGATAGTATGTTACCTATAAATTTAACTACGTGGATATCAGGCAGTTACGTTACCAGTCAAGGAGCACCCAAAACTGTCCAGCAACAAGTTAATTTACCCATGAAGATGTACTGCAAGCCTTGCCAACCAGTTAAAGTAGCTACTCATAAGGTAATAAACAGTAATATCGACTTTTTATCCATTTTGATAATTGATTTATAACAGTCTATAACTGATCGCTCTACATAATCTCTATCAGATTACTATTGACACAAACAGAAACCCCGTTAATTTGTATGATATATTTCCCGGTAAGCTTCGATTTTTAATCCTATCGTGACAATTTGGAATGTAACTTATTTCGTATAGGATAAACTAATTTACACGTTTGAATTCCTAGAATATGGAGAATCTAAAGGTCCTGGCAATGCCATCGGCTTTCAATATTATAATGGACCAAAAGTTACTCTATTAGCTTCCAAAACTTCGCGTGAGTACATTAGAACAGAAGAATAACCTTCAATATCGAGAGAGTTACTATCACTAACTATCCTATG"]
|
| 26 |
+
|
| 27 |
+
# Generate sequence
|
| 28 |
+
generated_english_sequence = pipe(
|
| 29 |
+
inputs={"english_sequence": english_sequence, "dna_sequences": dna_sequences},
|
| 30 |
+
english_tokens_max_length=512, # this value is used to pad or truncate the english tokens
|
| 31 |
+
bio_tokens_max_length=512, # this value is used to pad or truncate the DNA tokens
|
| 32 |
+
)
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
A small snippet of code is given here in order to **infer with the model without any abstraction (low-level)**.
|
| 36 |
|
| 37 |
```
|
| 38 |
import numpy as np
|