--- base_model: unsloth/phi-4-unsloth-bnb-4bit tags: - text-generation-inference - transformers - unsloth - llama - trl license: apache-2.0 language: - en datasets: - iamtarun/python_code_instructions_18k_alpaca --- # Model Description This model is fine-tuned from **microsoft/phi-4**. 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. ## To perform inference using these LoRA adapters, please use the following code: ````Python # 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 ```` ````Python from unsloth import FastLanguageModel model, tokenizer = FastLanguageModel.from_pretrained( model_name = "MouezYazidi/Py-phi-4-coder_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 """Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.. if you gonna use any external libraries you need to import it first""", # 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) ```` ````Markdown The Outout is: 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: Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.. if you gonna use any external libraries you need to import it first ### Input: ### Response: def twoSum(nums, target): # Create a dictionary to store the numbers and their indices num_dict = {} for i, num in enumerate(nums): # Check if the complement of the current number is in the dictionary if target - num in num_dict: return [num_dict[target - num], i] # Add the current number to the dictionary num_dict[num] = i<|im_end|> ```` # Uploaded model - **Developed by:** MouezYazidi - **License:** apache-2.0 - **Finetuned from model :** unsloth/phi-4-unsloth-bnb-4bit This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library. [](https://github.com/unslothai/unsloth)