Instructions to use anaghaa/Resonance-27B-S2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use anaghaa/Resonance-27B-S2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="anaghaa/Resonance-27B-S2") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("anaghaa/Resonance-27B-S2") model = AutoModelForMultimodalLM.from_pretrained("anaghaa/Resonance-27B-S2", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use anaghaa/Resonance-27B-S2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "anaghaa/Resonance-27B-S2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "anaghaa/Resonance-27B-S2", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/anaghaa/Resonance-27B-S2
- SGLang
How to use anaghaa/Resonance-27B-S2 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "anaghaa/Resonance-27B-S2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "anaghaa/Resonance-27B-S2", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "anaghaa/Resonance-27B-S2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "anaghaa/Resonance-27B-S2", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use anaghaa/Resonance-27B-S2 with Docker Model Runner:
docker model run hf.co/anaghaa/Resonance-27B-S2
Resonance-27B-S2
S2: rejection-sampling SFT from S1. Part of Resonance, from the preprint Distillation, Self-Training, and the Fragility of Learned Chemical Reasoning (Aneesh, Ibarraran, Hu, Liu, Rotskoff, 2026).
Given the SMILES of a starting material and reagents, the model reasons in a <think> block and
returns the predicted major product as SMILES between <answer> and </answer>.
- Base model:
Qwen/Qwen3.8-27B - Training: LoRA r128 merged into S1; 1 epoch (3,086 steps) on 98,731 difficulty-mixed examples
- USPTO-50k test, Top-1 exact match (N = 5,000): 79.3%
- LoRA adapter:
adapter/(apply toanaghaa/Resonance-27B-S1) - Code: https://github.com/rotskoff-group/resonance-rxn-reasoning
- Data (teacher traces, training sets, every model's test outputs): https://huggingface.co/datasets/anaghaa/resonance
Prompt
The evaluation prompt used in the paper (the long system prompt; every 27B evaluation used it):
SYSTEM: You are an expert organic chemist ... (the long system prompt, with four reactivity principles)
USER: Here are the SMILES of the starting material and reagent(s).
Starting material: <SMILES>
Reagents: <SMILES, comma-separated, or "No reagents">
Predict the single most likely primary product of the chemical reaction in SMILES format. ...
Return the answer between <answer> and </answer> tags.
The full user template is ForwardRxnPrompt in the code repository
(src/resonance/data/prompts/benchmark/forward_rxn.py) and, for 27B, src/resonance/configs/paper/qwen3_8_27b/prompts.json. Decoding: thinking enabled,
temperature 0.6, top-p 0.95, top-k 20, up to 16,384 new tokens. The prediction is the last
<answer> block, compared to the recorded product after RDKit canonicalisation.
from vllm import LLM, SamplingParams
llm = LLM("anaghaa/Resonance-27B-S2", tensor_parallel_size=2, limit_mm_per_prompt={"image": 0, "video": 0})
params = SamplingParams(temperature=0.6, top_p=0.95, top_k=20, max_tokens=16384)
out = llm.chat([[{"role": "system", "content": SYSTEM}, {"role": "user", "content": USER}]], params)
Citation
@misc{aneesh2026resonance,
title = {Distillation, Self-Training, and the Fragility of Learned Chemical Reasoning},
author = {Aneesh, Anagha and Ibarraran, Sebastian and Hu, Frank and Liu, Jason and Rotskoff, Grant},
year = {2026},
note = {Preprint}
}
- Downloads last month
- 16
Model tree for anaghaa/Resonance-27B-S2
Base model
Qwen/Qwen3.8-27B