Views
No views yet
Yes / No) of STI policy labels"Yes" or "No" as the first generated token(s) after the answer cue⚠️ This model is designed as a decision-support component in a human-in-the-loop pipeline, not as a fully automated policy encoder.
"Yes" if the label is in the gold annotation for that initiative"No" otherwise"Yes" / "No"2e-4transformers and peft.model_id to your model name.1pip install transformers peft accelerate sentencepiece
2
3
4### 2. Load the model and tokenizer
5
6from transformers import AutoTokenizer
7from peft import AutoPeftModelForCausalLM
8
9# Change this to your model repo name
10model_id = "vtt-qsts-ai/Mistral-7B-Instruct-v0.3-ft-stip-orig_label-validator"
11
12tokenizer = AutoTokenizer.from_pretrained(model_id)
13model = AutoPeftModelForCausalLM.from_pretrained(
14 model_id,
15 device_map="auto",
16)
17model.eval()
18
19### 3. Building Prompt
20
21label_code = "Label..."
22label_title = "title..."
23label_def = "Label Def..."
24evidence_sentences = [
25 "Sent 1...",
26 "Sent 2...",
27]
28
29bullets = "\n".join(f"- {s}" for s in evidence_sentences)
30
31prompt = f"""You are an expert in Science, Technology and Innovation (STI) policy.
32Decide whether the evidence sentences describe the following policy label.
33
34Label: {label_code} - {label_title} - {label_def}
35
36Evidence sentences:
37{bullets}
38
39Answer strictly with 'Yes' or 'No'. Return 'Yes' only if the evidence clearly
40matches the definition of the label, return 'No' otherwise.
41
42Answer:"""
43
44### 4. Get a Yes/No decision
45
46inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
47
48with torch.no_grad():
49 outputs = model.generate(
50 **inputs,
51 max_new_tokens=2,
52 do_sample=False,
53 temperature=0.0,
54 )
55
56generated = tokenizer.decode(
57 outputs[0][inputs["input_ids"].shape[1]:],
58 skip_special_tokens=True,
59).strip()
60
61print("Model answer:", generated) # Expected: "Yes" or "No"
62