Downloads · 30 days
10
19% of all-time downloads
evenfarther/DeepSeek-R1-Distill-Qwen-14b-chemical-synthesis-adapter
DeepSeek-R1-Distill-Qwen-14b-chemical-synthesis-adapter is a machine learning model from evenfarther. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as apache-2.0.
This repository contains the LoRA adapter for a DeepSeek‑R1‑Distill‑Qwen‑14B model fine‑tuned to classify chemical synthesizability (P = synthesizable, U = unsynthesizable). Training uses QLoRA on an imbalanced P/U da…
Downloads · 30 days
10
19% of all-time downloads
All-time downloads
52
Public
Repo size
1.2 GB
Likes
0
Public
Click a slice to open those files.
.safetensors1.1 GB · 93%
From the Hugging Face model README
This repository contains the LoRA adapter for a DeepSeek‑R1‑Distill‑Qwen‑14B model fine‑tuned to classify chemical synthesizability (P = synthesizable, U = unsynthesizable). Training uses QLoRA on an imbalanced P/U dataset; evaluation scores each example with logsumexp(P) − logsumexp(U) at the final token under the SFT‑aligned prompt.
train_pu_hem.jsonl (316,442 samples)validate_pu_hem.jsonl (79,114 samples)adapter_model.safetensors)checkpoint-992 (best Balanced Accuracy among evaluated epochs)The checkpoint includes a chat_template.jinja to ensure prompt formatting matches SFT conditions.
Evaluation and recommended usage preserve the SFT formatting and avoid think tokens:
You are a helpful assistant for P/U classification of synthesizability.As chief synthesis scientist, judge {composition} critically. Avoid bias. P=synthesizable, U=not:<think>Implementation notes for faithful scoring/inference:
add_generation_prompt=False and read logits right after the assistant start (trim the trailing EOS if present).attn_implementation="eager" for stability.| Metric | Value |
|---|---|
| TPR (P Recall) | 0.9641 |
| TNR (U Specificity) | 0.9049 |
Source: sft/deepseek_14b_sft_outputs/validation_metrics.csv (loader: transformers).
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
base = "unsloth/DeepSeek-R1-Distill-Qwen-14B-bnb-4bit" # Base model repo or equivalent local path
adapter = "<this-repo-or-local-checkpoint-dir>" # This adapter (checkpoint-992)
bnb = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
)
tok = AutoTokenizer.from_pretrained(base, use_fast=True)
tok.padding_side = "right"
if tok.pad_token is None:
tok.pad_token = tok.eos_token
model = AutoModelForCausalLM.from_pretrained(
base,
quantization_config=bnb,
device_map="auto",
attn_implementation="eager",
)
model = PeftModel.from_pretrained(model, adapter)
model.eval()
# Build messages using the included chat template
messages = [
{"role": "system", "content": "You are a helpful assistant for P/U classification of synthesizability."},
{"role": "user", "content": "As chief synthesis scientist, judge FeCrNiMn high-entropy alloy critically. Avoid bias. P=synthesizable, U=not:"},
{"role": "assistant", "content": None}, # empty assistant prefill (no <think>)
]
ids = tok.apply_chat_template(messages, tokenize=True, add_generation_prompt=False, return_tensors="pt").to(model.device)
out = model(input_ids=ids, use_cache=False)
logits = out.logits[0, -1]
# Compare logsumexp over token ids for P vs U to obtain the score.
train_pu_hem.jsonl — 316,442 samples
P (10.96%), 281,757 U (89.04%)validate_pu_hem.jsonl — 79,114 samples
P (10.96%), 70,440 U (89.04%)messages = [{role: "user", content: pattern above}, {role: "assistant", content: "P"|"U"}]add_generation_prompt=False, appending EOS.q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_projr=32, alpha=32, dropout=0.0gamma=2.0, alpha_P=8.12, alpha_U=1.0pad_token = eos_token if undefinedcheckpoint-992 corresponds to Epoch 4The training/validation corpus combines multiple public sources and internal curation:
After de-duplication across sources, the validation split contains 79,114 samples with an imbalanced label ratio (~11% P / 89% U).
attn_implementation="eager" to avoid SDPA instabilitychat_template.jinja and avoid inserting <think> tokens.config.json (e.g., model_type), which can reinitialize weights and corrupt metrics.