Views
No views yet
HuggingFaceTB/SmolLM3-3B, tuned on the
LitTune literary mixture (Biographical + PG-Fiction) using the 0-shot prompt style.<think>...</think> tokens instead of a label. Pass
enable_thinking=False to the chat template (as shown below) and strip any residual <think>
span from the output.1import re
2import torch
3from transformers import AutoModelForCausalLM, AutoTokenizer
4from peft import PeftModel
5
6BASE = "HuggingFaceTB/SmolLM3-3B"
7ADAPTER = "Despina/SmolLM3-3B-re_littune-0-shot"
8
9tokenizer = AutoTokenizer.from_pretrained(ADAPTER)
10model = AutoModelForCausalLM.from_pretrained(BASE, torch_dtype=torch.bfloat16, device_map="auto")
11model = PeftModel.from_pretrained(model, ADAPTER)
12model.eval()
13
14system_prompt = (
15 "You are a relation extraction system. Be concise and direct. "
16 "Output ONLY the relation type that holds between the two mentioned entities. "
17 "Do not output any explanation, punctuation, or extra text — only the label."
18)
19user_prompt = (
20 "Sentence: Elizabeth married Mr. Darcy at Pemberley.\n"
21 "Entity 1: Elizabeth\n"
22 "Entity 2: Mr. Darcy\n"
23 "Relation:"
24)
25
26messages = [
27 {"role": "system", "content": system_prompt},
28 {"role": "user", "content": user_prompt},
29]
30inputs = tokenizer.apply_chat_template(
31 messages, add_generation_prompt=True, enable_thinking=False, return_tensors="pt"
32).to(model.device)
33
34out = model.generate(inputs, max_new_tokens=16, do_sample=False)
35text = tokenizer.decode(out[0, inputs.shape[-1]:], skip_special_tokens=True)
36text = re.sub(r"<think>.*?</think>", "", text, flags=re.DOTALL).strip()
37print(text)| Base model | HuggingFaceTB/SmolLM3-3B |
| Method | QLoRA (4-bit NF4, bf16 compute, double quant) |
| LoRA | r = 64, α = 128, dropout = 0.05; targets: q/k/v/o + gate/up/down proj |
| Training data | Despina/re_littune (LitTune literary mixture), 0-shot prompts |
| Objective | Generate the relation label only |
| Epochs | 2 |
| Learning rate | 1e-4 |
| Effective batch | 4 × 2 grad-accum = 8 |
| Max sequence length | 1024 |
enable_thinking=False (see above), or it may output <think> tokens.Despina/re_littune1@article{christou2026subbillion,
2 title = {Sub-Billion, Super-Frontier: Small Language Models Rival
3 Zero-Shot Frontier LLMs on General and Literary Relation Extraction},
4 author = {Christou, Despina and Tsoumakas, Grigorios},
5 journal = {arXiv preprint arXiv:2606.22606},
6 year = {2026},
7 url = {https://arxiv.org/abs/2606.22606}
8}