Views
No views yet
| Model | Parameters | LLM-as-a-Judge Pass Rate |
|---|---|---|
| Llama 3.2 1B Instruct (base) | 1B | 45.1% |
| Llama 3.2 3B Instruct (base) | 3B | 60.4% |
| Llama 3.2 1B Instruct (this model) | 1B | 61.1% |
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4model_id = "distillabs/distil-siemens-s7-1200-docs-llama-1b"
5
6tokenizer = AutoTokenizer.from_pretrained(model_id)
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 torch_dtype=torch.bfloat16,
10 device_map="auto",
11)
12
13system_prompt = """You are a problem solving model working on task_description XML block:
14<task_description>Answer technical questions about an industrial automation system (The S7-1200 Programmable controller) using information provided in the context passage. Make sure to provide answers that are complete and include all relevant details from the context; do not miss critical information from the context.</task_description>
15You will be given a single question and a context passage. Answer the question based on the context."""
16
17# In a RAG pipeline, `context` comes from your retriever
18context = "The maximum cold junction error is ±1.5°C..."
19question = "What is the maximum cold junction error for the SM 1231 Thermocouple module?"
20
21user_message = f"""Now for the real task, solve the task in question block based on the context in context block.
22Generate only the solution, do not generate anything else
23<context>{context}</context>
24<question>{question}</question>"""
25
26messages = [
27 {"role": "system", "content": system_prompt},
28 {"role": "user", "content": user_message},
29]
30
31input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(model.device)
32
33with torch.no_grad():
34 output = model.generate(input_ids, max_new_tokens=256, temperature=0.6, top_p=0.9)
35
36response = tokenizer.decode(output[0][input_ids.shape[-1]:], skip_special_tokens=True)
37print(response)