OpenLLaMA Code Instruct: An Open Reproduction of LLaMA
This is an OpenLlama model that has been fine-tuned on 1 epoch of the
AlpacaCode dataset (122K rows).
Prompt Template
### Instruction:
{query}
### Response:
<Leave new line for model to respond>
Usage
fromtransformersimportAutoTokenizer,AutoModelForCausalLM,pipelinetokenizer=AutoTokenizer.from_pretrained("mwitiderrick/open_llama_3b_code_instruct_0.1")model=AutoModelForCausalLM.from_pretrained("mwitiderrick/open_llama_3b_code_instruct_0.1")query="Write a quick sort algorithm in Python"text_gen=pipeline(task="text-generation",model=model,tokenizer=tokenizer,max_length=200)output=text_gen(f"### Instruction:\n{query}\n### Response:\n")print(output[0]['generated_text'])"""
### Instruction:
write a quick sort algorithm in Python
### Response:
def quick_sort(arr):
if len(arr) <= 1:
return arr
else:
pivot = arr[len(arr) // 2]
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
return quick_sort(left) + middle + quick_sort(right)
arr = [5,2,4,3,1]
print(quick_sort(arr))
"""[1,2,3,4,5]"""