Views
No views yet
Qwen/Qwen2.5-7B-Instruct with these LoRA adapters merged into the base weights:1System: You are a retrosynthesis assistant. Return valid JSON only.
2User: Task: predict_reactants
3Product SMILES: CC(=O)Oc1ccccc1C(=O)O
4Return JSON with keys: reactants_smiles, confidence, rationale.1System: You are a reaction condition assistant. Return valid JSON only.
2User: Task: predict_conditions
3Product SMILES: CC(=O)Oc1ccccc1C(=O)O
4Reactants SMILES: CC(=O)O.Oc1ccccc1C(=O)O
5Return JSON with keys: solvent, reagents, catalyst, temperature_celsius, time, confidence, rationale.1System: You are a retrosynthesis assistant. Return valid JSON only.
2User: Task: retrosynthesis_step
3Target product SMILES: CC(=O)Oc1ccccc1C(=O)O
4Return one JSON object with keys: reactants_smiles, conditions, confidence, rationale.1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_id = "<your-namespace>/retro-agent-qwen25-7b-merged-fp16"
5
6tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 torch_dtype=torch.float16,
10 device_map="auto",
11 trust_remote_code=True,
12)
13
14messages = [
15 {"role": "system", "content": "You are a retrosynthesis assistant. Return valid JSON only."},
16 {"role": "user", "content": "Task: retrosynthesis_step\nTarget product SMILES: CC(=O)Oc1ccccc1C(=O)O\nReturn one JSON object with keys: reactants_smiles, conditions, confidence, rationale."},
17]
18
19text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
20inputs = tokenizer(text, return_tensors="pt").to(model.device)
21
22with torch.no_grad():
23 output_ids = model.generate(
24 **inputs,
25 max_new_tokens=512,
26 temperature=0.1,
27 do_sample=False,
28 )
29
30new_tokens = output_ids[0][inputs.input_ids.shape[-1]:]
31print(tokenizer.decode(new_tokens, skip_special_tokens=True))1export HF_TOKEN=hf_...
2
3curl https://router.huggingface.co/v1/chat/completions \
4 -H "Authorization: Bearer $HF_TOKEN" \
5 -H "Content-Type: application/json" \
6 -d '{
7 "model": "<your-namespace>/retro-agent-qwen25-7b-merged-fp16",
8 "messages": [
9 {"role": "system", "content": "You are a retrosynthesis assistant. Return valid JSON only."},
10 {"role": "user", "content": "Task: retrosynthesis_step\nTarget product SMILES: CC(=O)Oc1ccccc1C(=O)O"}
11 ],
12 "temperature": 0.1,
13 "max_tokens": 512,
14 "stream": false
15 }'1export HF_TOKEN=hf_...
2export ENDPOINT_URL=https://<your-endpoint>.<region>.<provider>.endpoints.huggingface.cloud
3
4curl "$ENDPOINT_URL" \
5 -X POST \
6 -H "Authorization: Bearer $HF_TOKEN" \
7 -H "Content-Type: application/json" \
8 -d '{
9 "inputs": "Task: retrosynthesis_step\nTarget product SMILES: CC(=O)Oc1ccccc1C(=O)O\nReturn one JSON object with keys: reactants_smiles, conditions, confidence, rationale.",
10 "parameters": {
11 "max_new_tokens": 512,
12 "temperature": 0.1,
13 "return_full_text": false
14 }
15 }'