iamtarun/python_code_instructions_18k_alpaca
Viewer • Updated • 18.6k • 24.7k • 344
How to use MouezYazidi/Falcon3Coder-10B-Base_LoRA with Transformers:
# Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("MouezYazidi/Falcon3Coder-10B-Base_LoRA", dtype="auto")How to use MouezYazidi/Falcon3Coder-10B-Base_LoRA with Unsloth Studio:
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for MouezYazidi/Falcon3Coder-10B-Base_LoRA to start chatting
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for MouezYazidi/Falcon3Coder-10B-Base_LoRA to start chatting
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for MouezYazidi/Falcon3Coder-10B-Base_LoRA to start chatting
pip install unsloth
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name="MouezYazidi/Falcon3Coder-10B-Base_LoRA",
max_seq_length=2048,
)This model is fine-tuned from Falcon3-10B-Base. This model is enhanced to improve coding capabilities, particularly in Python, as it was fine-tuned on a dataset of 18,000 Python samples using Alpaca prompt instructions.
Please refer to this repository when using the model.
# Installs Unsloth, Xformers (Flash Attention) and all other packages!
!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
!pip install --no-deps "xformers<0.0.27" "trl<0.9.0" peft accelerate bitsandbytes
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "MouezYazidi/Falcon3Coder-10B-Base_LoRA",
max_seq_length = 2048,
dtype = None,
load_in_4bit = True,
)
FastLanguageModel.for_inference(model) # Enable native 2x faster inference
alpaca_prompt = """Below is an instruction describing a task, along with an input providing additional context. Your task is to generate a clear, concise, and accurate Python code response that fulfills the given request.
### Instruction:
{}
### Input:
{}
### Response:
{}"""
inputs = tokenizer(
[
alpaca_prompt.format(
"", # instruction
"""Write a Python function that generates and prints the first n rows of Pascal's Triangle. Ensure the function accepts a positive integer n as input and produces the rows in a well-formatted structure (e.g., lists within a list or as strings). If you use any external libraries, make sure to explicitly import them in your code.""", # input
"", # output - leave this blank for generation!
)
], return_tensors = "pt").to("cuda")
from transformers import TextStreamer
text_streamer = TextStreamer(tokenizer)
_ = model.generate(**inputs, streamer = text_streamer, max_new_tokens = 512)
The Outout is:
<s> Below is an instruction describing a task, along with an input providing additional context. Your task is to generate a clear, concise, and accurate Python code response that fulfills the given request.
### Instruction:
### Input:
Write a Python function that generates and prints the first n rows of Pascal's Triangle. Ensure the function accepts a positive integer n as input and produces the rows in a well-formatted structure (e.g., lists within a list or as strings). If you use any external libraries, make sure to explicitly import them in your code.
### Response:
def pascal_triangle(n):
triangle = [[1]]
for i in range(1, n):
row = [1]
for j in range(1, i):
row.append(triangle[i-1][j-1] + triangle[i-1][j])
row.append(1)
triangle.append(row)
return triangle
print(pascal_triangle(5))</s>
This llama model was trained 2x faster with Unsloth and Huggingface's TRL library.
Base model
tiiuae/Falcon3-10B-Base
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("MouezYazidi/Falcon3Coder-10B-Base_LoRA", dtype="auto")