mrm8488 commited on
Commit
73180e6
β€’
1 Parent(s): 7ac4c74

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +105 -0
README.md ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - generated_from_trainer
4
+ - code
5
+ - coding
6
+ model-index:
7
+ - name: FalCoder
8
+ results: []
9
+ license: apache-2.0
10
+ language:
11
+ - code
12
+ thumbnail: https://huggingface.co/mrm8488/falcoder-7b/resolve/main/falcoder.png
13
+ datasets:
14
+ - HuggingFaceH4/CodeAlpaca_20K
15
+ pipeline_tag: text-generation
16
+ ---
17
+
18
+ <div style="text-align:center;width:250px;height:250px;">
19
+ <img src="https://huggingface.co/mrm8488/falcoder-7b/resolve/main/falcoder.png" alt="falcoder logo"">
20
+ </div>
21
+
22
+ <!-- This model card has been generated automatically according to the information the Trainer had access to. You
23
+ should probably proofread and complete it, then remove this comment. -->
24
+
25
+ # LlaMa 2 CoderπŸ¦™πŸ‘©β€πŸ’»
26
+ **LlaMa-2 7b** fine-tuned on the **CodeAlpaca 20k instructions dataset** by using the method **QLoRA** with [PEFT](https://github.com/huggingface/peft) library.
27
+
28
+ ## Model description 🧠
29
+
30
+ [Llama-2](https://huggingface.co/tiiuae/falcon-7b)
31
+
32
+
33
+ ## Training and evaluation data πŸ“š
34
+
35
+ [CodeAlpaca_20K](https://huggingface.co/datasets/HuggingFaceH4/CodeAlpaca_20K): contains 20K instruction-following data used for fine-tuning the Code Alpaca model.
36
+
37
+
38
+ ### Training hyperparameters βš™
39
+
40
+ TBA
41
+
42
+ ### Training results πŸ—’οΈ
43
+
44
+ | Step | Training Loss | Validation Loss |
45
+ |------|---------------|-----------------|
46
+ | 100 | 0.798500 | 0.767996 |
47
+ | 200 | 0.725900 | 0.749880 |
48
+ | 300 | 0.669100 | 0.748029 |
49
+ | 400 | 0.687300 | 0.742342 |
50
+ | 500 | 0.579900 | 0.736735 |
51
+
52
+
53
+
54
+ ### Example of usage πŸ‘©β€πŸ’»
55
+ ```py
56
+ import torch
57
+ from transformers import AutoModelForCausalLM, AutoTokenizer, AutoTokenizer
58
+
59
+ model_id = "mrm8488/falcoder-7b"
60
+
61
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
62
+
63
+ model = AutoModelForCausalLM.from_pretrained(model_id).to("cuda")
64
+
65
+ def generate(
66
+ instruction,
67
+ max_new_tokens=128,
68
+ temperature=0.1,
69
+ top_p=0.75,
70
+ top_k=40,
71
+ num_beams=4,
72
+ **kwargs
73
+ ):
74
+ prompt = instruction + "\n### Solution:\n"
75
+ print(prompt)
76
+ inputs = tokenizer(prompt, return_tensors="pt")
77
+ input_ids = inputs["input_ids"].to("cuda")
78
+ attention_mask = inputs["attention_mask"].to("cuda")
79
+ generation_config = GenerationConfig(
80
+ temperature=temperature,
81
+ top_p=top_p,
82
+ top_k=top_k,
83
+ num_beams=num_beams,
84
+ **kwargs,
85
+ )
86
+ with torch.no_grad():
87
+ generation_output = model.generate(
88
+ input_ids=input_ids,
89
+ attention_mask=attention_mask,
90
+ generation_config=generation_config,
91
+ return_dict_in_generate=True,
92
+ output_scores=True,
93
+ max_new_tokens=max_new_tokens,
94
+ early_stopping=True
95
+ )
96
+ s = generation_output.sequences[0]
97
+ output = tokenizer.decode(s)
98
+ return output.split("### Solution:")[1].lstrip("\n")
99
+
100
+ instruction = "Design a class for representing a person in Python."
101
+ print(generate(instruction))
102
+ ```
103
+
104
+ ### Citation
105
+