Instructions to use anaghaa/Resonance-8B-S2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use anaghaa/Resonance-8B-S2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="anaghaa/Resonance-8B-S2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("anaghaa/Resonance-8B-S2") model = AutoModelForCausalLM.from_pretrained("anaghaa/Resonance-8B-S2", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.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(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use anaghaa/Resonance-8B-S2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "anaghaa/Resonance-8B-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-8B-S2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/anaghaa/Resonance-8B-S2
- SGLang
How to use anaghaa/Resonance-8B-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-8B-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-8B-S2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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-8B-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-8B-S2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use anaghaa/Resonance-8B-S2 with Docker Model Runner:
docker model run hf.co/anaghaa/Resonance-8B-S2
Resonance-8B-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-8B - Training: full fine-tune, 3 epochs (2,229 steps), lr 1e-5, on 47,492 verified-correct S1 samples
- USPTO-50k test, Top-1 exact match (N = 5,000): 38.9%
- 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 short system prompt; every 8B student evaluation used it):
SYSTEM: You are an expert organic chemist specializing in the forward prediction of organic reactions. Your task is to predict the major product(s) of organic reactions given starting materials and reagents.
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). 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-8B-S2")
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
- 6