aakothari commited on
Commit
6f13cdc
·
verified ·
1 Parent(s): 2a3b71d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +17 -14
README.md CHANGED
@@ -114,26 +114,23 @@ at this scale reporting a single seed is measuring noise.
114
 
115
  ## Usage
116
 
117
- The model consumes **BRAID strings, not SMILES.** You must encode first. The codec is
118
- vendored into this repository so the snippet below runs standalone:
 
 
 
 
119
 
120
  ```python
121
- import importlib.util
122
- from huggingface_hub import hf_hub_download
123
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
124
 
125
- # load the BRAID codec shipped with this repo (requires: pip install rdkit)
126
- path = hf_hub_download("aakothari/BRAIDBERTa-v9", "braids_codec.py")
127
- spec = importlib.util.spec_from_file_location("braids_codec", path)
128
- braids = importlib.util.module_from_spec(spec)
129
- spec.loader.exec_module(braids)
130
-
131
  tok = AutoTokenizer.from_pretrained("aakothari/BRAIDBERTa-v9")
132
  model = AutoModelForSequenceClassification.from_pretrained(
133
  "aakothari/BRAIDBERTa-v9", num_labels=2
134
  )
135
 
136
- braid = braids.smiles_to_braid("CC(=O)Oc1ccccc1C(=O)O") # encode SMILES -> BRAID
137
  inputs = tok(braid, return_tensors="pt", truncation=True, max_length=128)
138
  logits = model(**inputs).logits
139
  ```
@@ -142,10 +139,16 @@ logits = model(**inputs).logits
142
  > characters — it will simply produce a meaningless tokenization and a plausible-looking,
143
  > wrong prediction. Always encode with `smiles_to_braid` first.
144
 
145
- The full reference implementation (encoder, decoder, valence state machine, stereo handling,
146
- tokenizer/`Vocab` builder, and the test suites) lives at:
 
 
 
 
147
 
148
- <!-- TODO: link the GitHub repo, or delete this line if the vendored codec is the only distribution -->
 
 
149
 
150
  ### Verified codec behaviour
151
 
 
114
 
115
  ## Usage
116
 
117
+ The model consumes **BRAID strings, not SMILES**, so you need the codec:
118
+
119
+ ```bash
120
+ pip install rdkit transformers
121
+ pip install git+https://github.com/aakothari/braids.git
122
+ ```
123
 
124
  ```python
125
+ from braids import smiles_to_braid
 
126
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
127
 
 
 
 
 
 
 
128
  tok = AutoTokenizer.from_pretrained("aakothari/BRAIDBERTa-v9")
129
  model = AutoModelForSequenceClassification.from_pretrained(
130
  "aakothari/BRAIDBERTa-v9", num_labels=2
131
  )
132
 
133
+ braid = smiles_to_braid("CC(=O)Oc1ccccc1C(=O)O") # -> CC>1=OOC=CC=CC=C^5C>1=OO
134
  inputs = tok(braid, return_tensors="pt", truncation=True, max_length=128)
135
  logits = model(**inputs).logits
136
  ```
 
139
  > characters — it will simply produce a meaningless tokenization and a plausible-looking,
140
  > wrong prediction. Always encode with `smiles_to_braid` first.
141
 
142
+ **Encode in the same mode the model was pretrained in.** The codec has Kekulé (default) and
143
+ aromatic modes, and they produce different strings for the same molecule
144
+ (`C=CC=CC=C^5` vs `cccccc^5`). Mixing modes between pretraining and inference silently
145
+ degrades performance.
146
+
147
+ <!-- TODO: state which mode the ZINC 100k pretraining corpus used -->
148
 
149
+ The reference implementation encoder, decoder, valence state machine, stereo handling,
150
+ tokenizer/`Vocab` builder, and the test suites — lives at
151
+ **[github.com/aakothari/braids](https://github.com/aakothari/braids)**.
152
 
153
  ### Verified codec behaviour
154