Views
No views yet
| Parameter | Value |
|---|---|
| LoRA Rank | 16 |
| LoRA Alpha | 32 |
| Dropout | 0.05 |
| Learning Rate | 1e-4 |
| Epochs | 3 |
| Max Sequence Length | 2048 |
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4model_name = "tokhey/egyptian-mcq-generator-mistral-7b"
5
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7
8model = AutoModelForCausalLM.from_pretrained(
9 model_name,
10 torch_dtype=torch.float16,
11 device_map="auto",
12)
13
14messages = [
15 {
16 "role": "system",
17 "content": (
18 "You are a Senior English Assessment Specialist. "
19 "Generate official Egyptian Ministry of Education English MCQs. "
20 "Return valid JSON only."
21 ),
22 },
23 {
24 "role": "user",
25 "content": (
26 "Generate 10 official Egyptian Ministry English MCQs "
27 "about Past Perfect / Past Perfect Continuous."
28 ),
29 },
30]
31
32text = tokenizer.apply_chat_template(
33 messages,
34 tokenize=False,
35 add_generation_prompt=True,
36)
37
38inputs = tokenizer(
39 text,
40 return_tensors="pt",
41).to(model.device)
42
43outputs = model.generate(
44 **inputs,
45 max_new_tokens=1500,
46 temperature=0.7,
47)
48
49print(
50 tokenizer.decode(
51 outputs[0][inputs.input_ids.shape[1]:],
52 skip_special_tokens=True,
53 )
54)1{
2 "statement": "...",
3 "correct_answer": "...",
4 "plausible_distractors": [
5 "...",
6 "...",
7 "..."
8 ],
9 "explanation": "..."
10}