Text Generation
Transformers
Safetensors
llama
chemistry
chain-of-thought
reasoning-faithfulness
grpo
conversational
text-generation-inference
Instructions to use phenixace/Chem-R-Faithful with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use phenixace/Chem-R-Faithful with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="phenixace/Chem-R-Faithful") 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("phenixace/Chem-R-Faithful") model = AutoModelForCausalLM.from_pretrained("phenixace/Chem-R-Faithful", 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 phenixace/Chem-R-Faithful with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "phenixace/Chem-R-Faithful" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "phenixace/Chem-R-Faithful", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/phenixace/Chem-R-Faithful
- SGLang
How to use phenixace/Chem-R-Faithful 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 "phenixace/Chem-R-Faithful" \ --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": "phenixace/Chem-R-Faithful", "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 "phenixace/Chem-R-Faithful" \ --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": "phenixace/Chem-R-Faithful", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use phenixace/Chem-R-Faithful with Docker Model Runner:
docker model run hf.co/phenixace/Chem-R-Faithful
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,3 +1,73 @@
|
|
| 1 |
---
|
| 2 |
-
license:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: cc-by-4.0
|
| 3 |
+
base_model: weidawang/Chem-R-8B
|
| 4 |
+
tags:
|
| 5 |
+
- chemistry
|
| 6 |
+
- chain-of-thought
|
| 7 |
+
- reasoning-faithfulness
|
| 8 |
+
- grpo
|
| 9 |
+
library_name: transformers
|
| 10 |
---
|
| 11 |
+
|
| 12 |
+
# Chem-R-Faithful
|
| 13 |
+
|
| 14 |
+
Chem-R-8B continued with GRPO under a **verification-grounded process reward**: the accuracy term
|
| 15 |
+
is paid only when the reasoning trace is clean, i.e. when every functional-group claim it makes is
|
| 16 |
+
supported by the input, the predicted molecule, or the reference.
|
| 17 |
+
|
| 18 |
+
The point is not accuracy. An answer-level reward cannot distinguish a correct answer reached
|
| 19 |
+
through a faithful trace from the same answer reached through a fabricating one, because the
|
| 20 |
+
reward does not depend on the trace at all. Gating it on a structural check of the trace makes
|
| 21 |
+
those two cases score differently.
|
| 22 |
+
|
| 23 |
+
## What it changes
|
| 24 |
+
|
| 25 |
+
Measured over twelve generative task variants (ChEBI-20 caption↔molecule, USPTO-50k
|
| 26 |
+
retrosynthesis, nine S²-Bench subtasks), against the Chem-R checkpoint it was trained from.
|
| 27 |
+
All four rows are the `R1_stage_ladder` sheet of the code repository's Source Data, so they can be
|
| 28 |
+
checked against one shipped row:
|
| 29 |
+
|
| 30 |
+
| | Chem-R | Chem-R-Faithful |
|
| 31 |
+
|---|---|---|
|
| 32 |
+
| per-claim fabrication rate | 22.56% | **4.35%** |
|
| 33 |
+
| mean ER (fabrication score, 0–100) | 10.60 | **1.73** |
|
| 34 |
+
| clean-trace rate (ER = 0) | 40.63% | **88.05%** |
|
| 35 |
+
| task performance | 50.09 | **51.45** |
|
| 36 |
+
|
| 37 |
+
Fabrication drops roughly five-fold and the clean-trace rate doubles, with task performance
|
| 38 |
+
slightly up rather than traded away.
|
| 39 |
+
|
| 40 |
+
## Usage
|
| 41 |
+
|
| 42 |
+
```python
|
| 43 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 44 |
+
m = AutoModelForCausalLM.from_pretrained("phenixace/Chem-R-Faithful", torch_dtype="bfloat16")
|
| 45 |
+
t = AutoTokenizer.from_pretrained("phenixace/Chem-R-Faithful")
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
It answers in `<think>…</think><answer>…</answer>` form. The answer span is what should be parsed;
|
| 49 |
+
the trace span is what the detector audits.
|
| 50 |
+
|
| 51 |
+
## Training
|
| 52 |
+
|
| 53 |
+
GRPO, 936 steps on 4×H200 (~26.6 h). Reward
|
| 54 |
+
`0.1·format + 0.4·accuracy + 0.4·(1 − hallucination) + 0.2·grounded`, with the accuracy term gated
|
| 55 |
+
on ER = 0. Config, launcher, the exact training parquets, and the EasyR1/verl patch the
|
| 56 |
+
per-task reward dispatch requires are in the code repository.
|
| 57 |
+
|
| 58 |
+
## Code, data, and the detector
|
| 59 |
+
|
| 60 |
+
https://github.com/phenixace/MolReHallu — the structural claim detector, the evaluation pipeline,
|
| 61 |
+
the released model responses and per-claim diagnosis records, and the training recipe. The
|
| 62 |
+
detector and the reward gate can both be exercised on a CPU in under a minute.
|
| 63 |
+
|
| 64 |
+
## Limitations
|
| 65 |
+
|
| 66 |
+
The verifier decides functional groups, ring systems and molecular classes from the molecular
|
| 67 |
+
graph. It does not certify a complete chemical argument, and ER is a fabrication rate over the
|
| 68 |
+
explicit, structurally decidable claims it recovers rather than a recall-complete audit of the
|
| 69 |
+
reasoning. Fabrication is reduced, not eliminated.
|
| 70 |
+
|
| 71 |
+
## License
|
| 72 |
+
|
| 73 |
+
CC BY 4.0. Derived from `weidawang/Chem-R-8B`, which remains subject to its own license.
|