bmaxin commited on
Commit
35cbcc7
·
verified ·
1 Parent(s): 002e62a

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +83 -0
README.md ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: llama3.1
3
+ language:
4
+ - en
5
+ - py
6
+ library_name: transformers
7
+ tags:
8
+ - llama-3.1
9
+ - python
10
+ - code-generation
11
+ - instruction-following
12
+ - fine-tune
13
+ - alpaca
14
+ - unsloth
15
+ base_model: meta-llama/Meta-Llama-3.1-8B-Instruct
16
+ datasets:
17
+ - iamtarun/python_code_instructions_18k_alpaca
18
+ ---
19
+ ---
20
+
21
+ # Llama-3.1-8B-Instruct-Python-Alpaca-Unsloth
22
+
23
+ This is a fine-tuned version of Meta's **`Llama-3.1-8B-Instruct`** model, specialized for Python code generation. It was trained on the high-quality **`iamtarun/python_code_instructions_18k_alpaca`** dataset using the **Unsloth** library for significantly faster training and reduced memory usage.
24
+
25
+ The result is a powerful and responsive coding assistant, designed to follow instructions and generate accurate, high-quality Python code.
26
+
27
+ ---
28
+ ## ## Model Details 🛠️
29
+
30
+ * **Base Model:** `meta-llama/Meta-Llama-3.1-8B-Instruct`
31
+ * **Dataset:** `iamtarun/python_code_instructions_18k_alpaca` (18,000 instruction-following examples for Python)
32
+ * **Fine-tuning Technique:** QLoRA (4-bit Quantization with LoRA adapters)
33
+ * **Framework:** Unsloth (for up to 2x faster training and optimized memory)
34
+
35
+ ---
36
+ ## ## How to Use 👨‍💻
37
+
38
+ This model is designed to be used with the Unsloth library for maximum performance, but it can also be used with the standard Hugging Face `transformers` library. For the best results, always use the Llama 3 chat template.
39
+
40
+ ### ### Using with Unsloth (Recommended)
41
+
42
+ ```python
43
+ from unsloth import FastLanguageModel
44
+ import torch
45
+
46
+ model, tokenizer = FastLanguageModel.from_pretrained(
47
+ model_name = "YOUR_USERNAME/YOUR_MODEL_NAME", # REMEMBER TO REPLACE THIS
48
+ max_seq_length = 4096,
49
+ dtype = None,
50
+ load_in_4bit = True,
51
+ )
52
+
53
+ # Prepare the model for faster inference
54
+ FastLanguageModel.for_inference(model)
55
+
56
+ messages = [
57
+ {
58
+ "role": "system",
59
+ "content": "You are a helpful Python coding assistant. Please provide a clear, concise, and correct Python code response to the user's request."
60
+ },
61
+ {
62
+ "role": "user",
63
+ "content": "Create a Python function that finds the nth Fibonacci number using recursion."
64
+ },
65
+ ]
66
+
67
+ input_ids = tokenizer.apply_chat_template(
68
+ messages,
69
+ add_generation_prompt=True,
70
+ return_tensors="pt"
71
+ ).to(model.device)
72
+
73
+ outputs = model.generate(
74
+ input_ids,
75
+ max_new_tokens=200,
76
+ do_sample=True,
77
+ temperature=0.6,
78
+ top_p=0.9,
79
+ eos_token_id=tokenizer.eos_token_id
80
+ )
81
+
82
+ response = outputs[0][input_ids.shape[-1]:]
83
+ print(tokenizer.decode(response, skip_special_tokens=True))