File size: 2,109 Bytes
572de6e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
612fdeb
572de6e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
license: apache-2.0
language:
- en
base_model:
- Qwen/Qwen2.5-Coder-7B-Instruct
pipeline_tag: text-generation
library_name: peft
tags:
- lora
- peft
- qwen2.5
- miniscript
- code
---

# miniscript-code-helper-lora

This repository contains a LoRA adapter for `Qwen/Qwen2.5-Coder-7B-Instruct`, fine-tuned to help answer questions about the MiniScript programming language.

The adapter was trained on a small MiniScript Q&A corpus. On its own, it improves MiniScript awareness somewhat, but best results come when it is used together with a RAG pipeline over MiniScript reference materials.

## Base model

- Qwen/Qwen2.5-Coder-7B-Instruct

## What this repo contains

- PEFT/LoRA adapter weights only
- Not the full base model

## Intended use

- Answering questions about MiniScript
- Assisting with MiniScript syntax and examples
- Best used with retrieval augmentation (RAG)

## Limitations

- The adapter alone is not fully reliable
- It may still fall back to Python-flavored assumptions from the base model
- For best accuracy, pair it with a MiniScript documentation retriever

## Example usage

```python
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer

base_model_id = "Qwen/Qwen2.5-Coder-7B-Instruct"
adapter_id = "JoeStrout/miniscript-code-helper-lora"

tokenizer = AutoTokenizer.from_pretrained(base_model_id)

base_model = AutoModelForCausalLM.from_pretrained(
    base_model_id,
    torch_dtype="auto",
    device_map="auto",
)

model = PeftModel.from_pretrained(base_model, adapter_id)
model.eval()

messages = [
    {"role": "system", "content": "You are a helpful assistant specializing in MiniScript programming."},
    {"role": "user", "content": "How do I iterate over a map in MiniScript?"},
]

text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True,
)
inputs = tokenizer([text], return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=512)
response = tokenizer.decode(
    output[0][len(inputs.input_ids[0]):],
    skip_special_tokens=True,
)

print(response)
```