Views
No views yet

llama-2-7b-chat-hf model fine-tuned using QLoRA (4-bit precision) on the bosbos/french_english_instruct dataset.1# pip install transformers accelerate
2
3from transformers import AutoTokenizer
4import transformers
5import torch
6
7model = "bosbos/bosbos_chat"
8prompt = "what is prediction in frensh ?"
9
10tokenizer = AutoTokenizer.from_pretrained(model)
11pipeline = transformers.pipeline(
12 "text-generation",
13 model=model,
14 torch_dtype=torch.float16,
15 device_map="auto",
16)
17
18sequences = pipeline(
19 f'<s>[INST] {prompt} [/INST]',
20 do_sample=True,
21 top_k=10,
22 num_return_sequences=1,
23 eos_token_id=tokenizer.eos_token_id,
24 max_length=200,
25)
26for seq in sequences:
27 print(f"Result: {seq['generated_text']}")1# !pip install -q accelerate==0.21.0 peft==0.4.0 bitsandbytes==0.40.2 transformers==4.31.0 trl==0.4.7
2
3import torch
4from transformers import (
5 AutoModelForCausalLM,
6 AutoTokenizer,
7 BitsAndBytesConfig,
8 pipeline,
9
10)
11
12###############################################################################
13# bitsandbytes parameters
14################################################################################
15
16# Activate 4-bit precision base model loading
17use_4bit = True
18
19# Compute dtype for 4-bit base models
20bnb_4bit_compute_dtype = "float16"
21
22# Quantization type (fp4 or nf4)
23bnb_4bit_quant_type = "nf4"
24
25# Activate nested quantization for 4-bit base models (double quantization)
26use_nested_quant = False
27
28################################################################################
29# SFT parameters
30################################################################################
31
32# Maximum sequence length to use
33max_seq_length = None
34
35# Pack multiple short examples in the same input sequence to increase efficiency
36packing = False
37
38# Load the entire model on the GPU 0
39device_map = {"": 0}
40
41model_name="bosbos/bosbos_chat"
42# Load tokenizer and model with QLoRA configuration
43compute_dtype = getattr(torch, bnb_4bit_compute_dtype)
44
45bnb_config = BitsAndBytesConfig(
46 load_in_4bit=use_4bit,
47 bnb_4bit_quant_type=bnb_4bit_quant_type,
48 bnb_4bit_compute_dtype=compute_dtype,
49 bnb_4bit_use_double_quant=use_nested_quant,
50)
51# Load base model
52model = AutoModelForCausalLM.from_pretrained(
53 model_name,
54 quantization_config=bnb_config,
55 device_map=device_map
56)
57model.config.use_cache = False
58model.config.pretraining_tp = 1
59
60# Load LLaMA tokenizer
61tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
62tokenizer.pad_token = tokenizer.eos_token
63tokenizer.padding_side = "right" # Fix weird overflow issue with fp16 training
64
65# Run text generation pipeline with our next model
66prompt = "what is prediction in frensh ?"
67pipe = pipeline(task="text-generation", model=model, tokenizer=tokenizer, max_length=200)
68result = pipe(f"<s>[INST] {prompt} [/INST]")
69print(result[0]['generated_text'])"Prédiction" is a noun that refers to the act of making a forecast or an estimate of something that will happen in the future. It can also refer to the result of such a forecast or estimate.
For example:
- "La prédiction de la météo est que il va pleuvoir demain." (The weather forecast is that it will rain tomorrow.)
- "La prédiction de la course de chevaux est que le favori va gagner." (The prediction of the horse race is that the favorite will win.) In English, the word "prediction" is often used in a similar way, but it can also refer to a statement or a prophecy about something that has already happened or is happening.