mjbuehler commited on
Commit
1affbce
·
verified ·
1 Parent(s): 2cccbfa

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +44 -0
README.md CHANGED
@@ -65,3 +65,47 @@ res=generate_XLoRA_Gemma( system_prompt='You design materials.', prompt=q, max_n
65
  display (Markdown(res))
66
  ```
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  display (Markdown(res))
66
  ```
67
 
68
+ ### Example: Molecular design
69
+
70
+ ```python
71
+ def design_from_target(
72
+ model,
73
+ tokenizer,
74
+ target,
75
+ temperature=0.1,
76
+ num_beams=1,
77
+ top_k=50,
78
+ top_p=0.95,
79
+ repetition_penalty=1.0,
80
+ messages=[]
81
+ ):
82
+ # Format the target line for molecular property generation
83
+ line = f'GenerateMolecularProperties<{return_str(target)}>'
84
+
85
+ # Add the line to the message history
86
+ messages.append({"role": "user", "content": line})
87
+
88
+ # Apply chat template with optional tokenization
89
+ line = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
90
+
91
+ # Generate response with specified parameters
92
+ result = generate_response(
93
+ model,
94
+ tokenizer,
95
+ text_input=line,
96
+ num_return_sequences=1,
97
+ temperature=temperature,
98
+ top_k=top_k,
99
+ top_p=top_p,
100
+ max_new_tokens=256
101
+ )[0]
102
+
103
+ return result
104
+ ```
105
+ Use case:
106
+ ```python
107
+ import numpy as np
108
+ target = np.random.rand(12)
109
+ SMILES=design_from_target (model, tokenizer, target, messages=[]])
110
+ print (SMILES)
111
+ ```