mjbuehler commited on
Commit
5dd3e30
·
verified ·
1 Parent(s): 1affbce

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +40 -0
README.md CHANGED
@@ -109,3 +109,43 @@ target = np.random.rand(12)
109
  SMILES=design_from_target (model, tokenizer, target, messages=[]])
110
  print (SMILES)
111
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  SMILES=design_from_target (model, tokenizer, target, messages=[]])
110
  print (SMILES)
111
  ```
112
+
113
+ Calculate molecular properties:
114
+
115
+ ```python
116
+ def properties_from_SMILES(
117
+ model,
118
+ tokenizer,
119
+ target,
120
+ temperature=0.1,
121
+ top_k=128,
122
+ top_p=0.9,
123
+ num_beams=1,
124
+ repetition_penalty=1.0
125
+ ):
126
+ # Format the target line for molecular property calculation
127
+ line = f'CalculateMolecularProperties<{target}>'
128
+
129
+ # Initialize messages and add the formatted line
130
+ messages = [{"role": "user", "content": line}]
131
+
132
+ # Apply chat template with optional tokenization
133
+ line = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
134
+
135
+ # Generate response with specified parameters
136
+ result = generate_response(
137
+ model,
138
+ tokenizer,
139
+ text_input=line,
140
+ num_return_sequences=1,
141
+ temperature=temperature,
142
+ top_k=top_k,
143
+ top_p=top_p,
144
+ max_new_tokens=256
145
+ )[0]
146
+
147
+ # Extract relevant part of the result and convert to float list
148
+ result = extract_start_and_end(result, start_token='[', end_token=']')
149
+ return [float(i) for i in result.split(',')]
150
+ ```
151
+