mrm8488 commited on
Commit
322cbad
β€’
1 Parent(s): 00f378f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +8 -8
README.md CHANGED
@@ -21,7 +21,7 @@ pipeline_tag: text-generation
21
  </div>
22
 
23
 
24
- # Gemma Coder πŸ¦™πŸ‘©β€πŸ’»
25
  **Gemma 2B** fine-tuned on the **CodeAlpaca 20k instructions dataset** by using the method **QLoRA** with [PEFT](https://github.com/huggingface/peft) library.
26
 
27
  ## Model description 🧠
@@ -95,15 +95,15 @@ def create_prompt(instruction):
95
 
96
  def generate(
97
  instruction,
98
- max_new_tokens=128,
99
  temperature=0.1,
100
  top_p=0.75,
101
  top_k=40,
102
- num_beams=4,
103
  **kwargs,
104
  ):
105
- prompt = create_prompt(instruction)
106
- print(prompt)
107
  inputs = tokenizer(prompt, return_tensors="pt")
108
  input_ids = inputs["input_ids"].to("cuda")
109
  attention_mask = inputs["attention_mask"].to("cuda")
@@ -120,13 +120,13 @@ def generate(
120
  attention_mask=attention_mask,
121
  generation_config=generation_config,
122
  return_dict_in_generate=True,
123
- output_scores=True,
124
  max_new_tokens=max_new_tokens,
125
  early_stopping=True
126
  )
127
  s = generation_output.sequences[0]
128
- output = tokenizer.decode(s)
129
- return output.split("### Solution:")[1].lstrip("\n")
130
 
131
  instruction = """
132
  Edit the following XML code to add a navigation bar to the top of a web page
 
21
  </div>
22
 
23
 
24
+ # Gemma Coder πŸ‘©β€πŸ’»
25
  **Gemma 2B** fine-tuned on the **CodeAlpaca 20k instructions dataset** by using the method **QLoRA** with [PEFT](https://github.com/huggingface/peft) library.
26
 
27
  ## Model description 🧠
 
95
 
96
  def generate(
97
  instruction,
98
+ max_new_tokens=256,
99
  temperature=0.1,
100
  top_p=0.75,
101
  top_k=40,
102
+ num_beams=2,
103
  **kwargs,
104
  ):
105
+ system = f"<bos><|system|>\nYou are a helpful coding assistant.<eos>\n"
106
+ prompt = f"{system}<|user|>\n{instruction}<eos>\n<|assistant|>\n"
107
  inputs = tokenizer(prompt, return_tensors="pt")
108
  input_ids = inputs["input_ids"].to("cuda")
109
  attention_mask = inputs["attention_mask"].to("cuda")
 
120
  attention_mask=attention_mask,
121
  generation_config=generation_config,
122
  return_dict_in_generate=True,
123
+ #output_scores=True,
124
  max_new_tokens=max_new_tokens,
125
  early_stopping=True
126
  )
127
  s = generation_output.sequences[0]
128
+ output = tokenizer.decode(s, skip_special_tokens=True)
129
+ return output.split("<|assistant|>")[1]
130
 
131
  instruction = """
132
  Edit the following XML code to add a navigation bar to the top of a web page