Views
No views yet
Llama-3.2-3B for Artificial Intelligence tutoring and exam-oriented responses.1from unsloth import FastLanguageModel
2import torch
3
4model, tokenizer = FastLanguageModel.from_pretrained(
5 model_name = "binaryecheos/ai-tutor-llama3-lora",
6 max_seq_length = 1024,
7 load_in_4bit = True,
8)
9
10FastLanguageModel.for_inference(model)1system_prompt = (
2 "You are an expert AI tutor helping university students "
3 "understand Artificial Intelligence concepts clearly and accurately."
4)
5
6user_prompt = "Explain A* algorithm in detail."
7
8prompt = f"""<|begin_of_text|><|start_header_id|>system<|end_header_id|>
9
10{system_prompt}<|eot_id|><|start_header_id|>user<|end_header_id|>
11
12{user_prompt}<|eot_id|><|start_header_id|>assistant<|end_header_id|>
13
14"""
15
16inputs = tokenizer(
17 prompt,
18 return_tensors="pt"
19).to("cuda")
20
21eot_token = tokenizer.convert_tokens_to_ids("<|eot_id|>")
22
23outputs = model.generate(
24 **inputs,
25 max_new_tokens = 500,
26 temperature = 0.4,
27 top_p = 0.9,
28 repetition_penalty = 1.15,
29 do_sample = True,
30 eos_token_id = eot_token,
31 pad_token_id = tokenizer.eos_token_id,
32)
33
34response = tokenizer.decode(
35 outputs[0][inputs["input_ids"].shape[1]:],
36 skip_special_tokens=True
37)
38
39print(response)