Unlocking the Power of Large Language Models (LLMs) for Business Applications
•
1
#Call built in library
import logging
# lets call library and start logging
logging.basicConfig(level=logging.DEBUG) #you can add more format specifier
# It will show on the console since we did not added filename to save logs
logging.debug('Here we go for debug message')
logging.info('Here we go for info message')
logging.warning('Here we go for warning message')
logging.error('Here we go for error message')
logging.critical('Here we go for critical message')
#Note:
# If you want to add anything in the log then do like this way
records=100
logging.debug('There are total %s number of records.', records)
# same like string format
lost=20
logging.debug('There are total %s number of records from which %s are lost', records, lost)
import logging
# Saving the log to a file. The logs will be written to app.log
logging.basicConfig(filename='app.log', level=logging.DEBUG)
logging.debug('Here we go for debug message')
logging.info('Here we go for info message')
logging.warning('Here we go for warning message')
logging.error('Here we go for error message')
logging.critical('Here we go for critical message')
from transformers import AutoModelForSequenceClassification, Trainer, TrainingArguments
from peft import LoraConfig, get_peft_model
from datasets import load_dataset
# Loading the pre-trained BERT model
model = AutoModelForSequenceClassification.from_pretrained('bert-base-uncased', num_labels=2)
# Configuring the LoRA parameters
lora_config = LoraConfig(
r=8,
lora_alpha=16,
lora_dropout=0.1,
bias="none"
)
# Applying LoRA to the model
model = get_peft_model(model, lora_config)
# Loading dataset for classification
dataset = load_dataset("glue", "sst2")
train_dataset = dataset["train"]
# Setting the training arguments
training_args = TrainingArguments(
output_dir="./results",
per_device_train_batch_size=16,
num_train_epochs=3,
logging_dir="./logs",
)
# Creating a Trainer instance for fine-tuning
trainer = Trainer(
model=model,
args=training_args,
train_dataset=train_dataset,
)
# Finally we can fine-tune the model
trainer.train()
That is very useful. Thanks!
Sign bit:
Indicates whether the number is positive (0) or negative (1).
Exponent:
Determines the scale of the number (i.e., how large or small it is by shifting the decimal point).
Mantissa (or fraction):
Represents the actual digits of the number.