
## How to use🦙:
```py
import torch
import bitsandbytes as bnb
from peft import PeftModel, PeftConfig, prepare_model_for_int8_training, LoraConfig, get_peft_model
from transformers import LlamaTokenizer, LlamaForCausalLM, GenerationConfig

peft_model_id = "tbboukhari/Alpaca_instruction_fine_tune_French"
config = PeftConfig.from_pretrained(peft_model_id)

tokenizer = LlamaTokenizer.from_pretrained(config.base_model_name_or_path)
model = LlamaForCausalLM.from_pretrained(config.base_model_name_or_path,
                                          load_in_8bit=True,
                                          device_map="auto",)
# Load the Lora model
model = PeftModel.from_pretrained(model, peft_model_id)

# Based on the inference code by `tloen/alpaca-lora`
def generate_prompt(instruction, entree=None):
    if entree :
        return f"""Vous trouverez ci-dessous des instructions décrivant une tâche, ainsi qu'une entrée qui fournit plus de contexte. Rédigez une réponse qui complète convenablement la demande.
### instructions:
{instruction}
### entrée:
{entree}
### sortie:"""

    else:
        return f"""Vous trouverez ci-dessous des instructions décrivant une tâche, ainsi qu'une entrée qui fournit plus de contexte. Rédigez une réponse qui complète convenablement la demande.

### instructions:
{instruction}
### sortie:"""

# Inputs to instantiate the model:
generation_config = GenerationConfig(
    temperature=0.2,
    top_p=0.75,
    num_beams=4,
)
# Evaluate the model:
def evaluate(instruction, input=None):
    prompt = generate_prompt(instruction, input)
    inputs = tokenizer(prompt, return_tensors="pt")
    input_ids = inputs["input_ids"].cuda()
    generation_output = model.generate(
        input_ids=input_ids,
        generation_config=generation_config,
        return_dict_in_generate=True,
        output_scores=True,
        max_new_tokens=256
    )
    for s in generation_output.sequences:
        output = tokenizer.decode(s)
        print("sortie:", output.split("### sortie:")[1].strip())

evaluate(input("instructions: "))
```
{"language": ["fr"], "library_name": "transformers", "tags": ["Alpaca", "Instruction-fine-tuning", "NLP", "Instruct Alpaca", "PEFT", "LoRA"], "datasets": ["tbboukhari/Alpaca_french_instruct"]}
transformers Alpaca Instruction-fine-tuning NLP Instruct Alpaca PEFT LoRA fr dataset:tbboukhari/Alpaca_french_instruct endpoints_compatible region:us
TAGS
#transformers #Alpaca #Instruction-fine-tuning #NLP #Instruct Alpaca #PEFT #LoRA #fr #dataset-tbboukhari/Alpaca_french_instruct #endpoints_compatible #region-us 


## How to use:

## How to use:
TAGS
#transformers #Alpaca #Instruction-fine-tuning #NLP #Instruct Alpaca #PEFT #LoRA #fr #dataset-tbboukhari/Alpaca_french_instruct #endpoints_compatible #region-us 
 ## How to use:
TAGS
#transformers #Alpaca #Instruction-fine-tuning #NLP #Instruct Alpaca #PEFT #LoRA #fr #dataset-tbboukhari/Alpaca_french_instruct #endpoints_compatible #region-us 
## How to use: