Views
No views yet
<|user|>\nQuestion <|end|>\n<|assistant|><|user|>
How to explain Internet for a medieval knight?<|end|>
<|assistant|><|user|>
I am going to Paris, what should I see?<|end|>
<|assistant|>
Paris, the capital of France, is known for its stunning architecture, art museums, historical landmarks, and romantic atmosphere. Here are some of the top attractions to see in Paris:\n\n1. The Eiffel Tower: The iconic Eiffel Tower is one of the most recognizable landmarks in the world and offers breathtaking views of the city.\n2. The Louvre Museum: The Louvre is one of the world's largest and most famous museums, housing an impressive collection of art and artifacts, including the Mona Lisa.\n3. Notre-Dame Cathedral: This beautiful cathedral is one of the most famous landmarks in Paris and is known for its Gothic architecture and stunning stained glass windows.\n\nThese are just a few of the many attractions that Paris has to offer. With so much to see and do, it's no wonder that Paris is one of the most popular tourist destinations in the world."<|end|>
<|user|>
What is so great about #1?<|end|>
<|assistant|>bitsandbytes and PEFT config was used during training:1################################################################################
2# bitsandbytes parameters
3################################################################################
4# Activate 4-bit precision base model loading
5use_4bit = True
6# Compute dtype for 4-bit base models
7bnb_4bit_compute_dtype = "bfloat16"
8# Quantization type (fp4 or nf4)
9bnb_4bit_quant_type = "nf4"
10# Activate nested quantization for 4-bit base models (double quantization)
11use_double_quant = True
12
13
14################################################################################
15# LoRA parameters
16################################################################################
17# LoRA attention dimension
18lora_r = 16
19# Alpha parameter for LoRA scaling
20lora_alpha = 16
21# Dropout probability for LoRA layers
22lora_dropout = 0.05
23# Modules
24target_modules= ['k_proj', 'q_proj', 'v_proj', 'o_proj', "gate_proj", "down_proj", "up_proj"]1 evaluation_strategy="steps",
2 do_eval=True,
3 optim="paged_adamw_8bit",
4 per_device_train_batch_size=4,
5 gradient_accumulation_steps=8,
6 per_device_eval_batch_size=4,
7 log_level="debug",
8 save_strategy="epoch",
9 logging_steps=100,
10 learning_rate=1e-4,
11 fp16 = not torch.cuda.is_bf16_supported(),
12 bf16 = torch.cuda.is_bf16_supported(),
13 eval_steps=100,
14 num_train_epochs=3,
15 warmup_ratio=0.1,
16 lr_scheduler_type="linear",
17 report_to="wandb",1Step Training Loss Validation Loss
2100 1.142200 0.662472
3200 0.623800 0.600241
4300 0.593200 0.590614
5400 0.592600 0.585953
6500 0.579400 0.583388
7600 0.586800 0.581465
8700 0.571100 0.579619
9800 0.572900 0.578471
10900 0.585800 0.577197
111000 0.573200 0.576328
121100 0.573600 0.575592
131200 0.563800 0.575420
141300 0.576900 0.574614
151400 0.566800 0.574540
161500 0.567500 0.574162
171600 0.569300 0.5741461Rouge 1 Mean: 56.65322508234244
2Rouge 2 Mean: 37.547274096577084
3Rouge L Mean: 51.08407579855678
4Rouge Lsum Mean: 56.2560163848030751import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_id = "edumunozsala/phi3-mini-python-code-20k"
5
6tokenizer = AutoTokenizer.from_pretrained(hf_model_repo,trust_remote_code=True)
7model = AutoModelForCausalLM.from_pretrained(hf_model_repo, trust_remote_code=True, torch_dtype="auto", device_map="cuda")
8
9
10instruction="Create an algorithm in Python to sort an array of numbers."
11input="[9, 3, 5, 1, 6]"
12
13prompt = f"""### Instruction:
14Below is an instruction that describes a task. Write a response that appropriately completes the request.
15
16### Instruction:
17{instruction}
18
19### Input:
20{input}
21
22### Output:
23"""
24
25pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
26
27# Function to execute inference on a prompt
28def test_inference(prompt):
29 prompt = pipe.tokenizer.apply_chat_template([{"role": "user", "content": prompt}], tokenize=False, add_generation_prompt=True)
30 outputs = pipe(prompt, max_new_tokens=256, do_sample=True, num_beams=1, temperature=0.3, top_k=50, top_p=0.95,
31 max_time= 180) #, eos_token_id=eos_token)
32 return outputs[0]['generated_text'][len(prompt):].strip()
33
34
35test_inference(prompt)
36@misc {edumunozsala_2023,
author = { {Eduardo Muñoz} },
title = { phi3-mini-4k-qlora-python-code-20k },
year = 2024,
url = { https://huggingface.co/edumunozsala/phi3-mini-4k-qlora-python-code-20k },
publisher = { Hugging Face }
}