GPT-2 Medium
Model Details
Model Description: GPT-2 Medium is the 355M parameter version of GPT-2, a transformer-based language model created and released by OpenAI. The model is a pretrained model on English language using a causal language modeling (CLM) objective.
Parameter-Efficient Fine-tuning (PEFT)
Parameter-Efficient Fine-tuning (PEFT) is a technique used to improve the performance of pre-trained language models (LLMs) on specific downstream tasks without fine-tuning all the model's parameters. This is done by freezing most of the model's parameters and only fine-tuning a small number of parameters that are specific to the downstream task.
Training Data
the model is trained on 'b-mc2/sql-create-context' dataset upto 5000rows
Usage:
please install transformers
, and peft
:
!pip install transformers peft
To use the model, you can run the following:
import torch
from peft import PeftModel, PeftConfig
from transformers import AutoModelForCausalLM, AutoTokenizer
config = PeftConfig.from_pretrained("Naveengo/gpt2-medium-on-sql-create-context")
model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, return_dict=True, load_in_8bit=False)
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
# Load the Lora model
model = PeftModel.from_pretrained(model,"Naveengo/gpt2-medium-on-sql-create-context")
from IPython.display import display, Markdown
def make_inference(question, context):
batch = tokenizer(f"Below is an SQL instruction that describes a task, paired with an input that provides further context. Write an SQL query that appropriately completes the request using your expertise in SQL. ### Instruction: {question}### Input: {context}### Response:", return_tensors='pt')
with torch.cuda.amp.autocast():
output_tokens = model.generate(**batch, max_new_tokens=100)
display(Markdown((tokenizer.decode(output_tokens[0], skip_special_tokens=True))))
#give question and context to function
make_inference(your_question_here, your_context_here)
Training procedure
The following bitsandbytes
quantization config was used during training:
- quant_method: bitsandbytes
- load_in_8bit: False
- load_in_4bit: True
- llm_int8_threshold: 6.0
- llm_int8_skip_modules: None
- llm_int8_enable_fp32_cpu_offload: False
- llm_int8_has_fp16_weight: False
- bnb_4bit_quant_type: nf4
- bnb_4bit_use_double_quant: True
- bnb_4bit_compute_dtype: float16
The following bitsandbytes
quantization config was used during training:
- quant_method: bitsandbytes
- load_in_8bit: False
- load_in_4bit: True
- llm_int8_threshold: 6.0
- llm_int8_skip_modules: None
- llm_int8_enable_fp32_cpu_offload: False
- llm_int8_has_fp16_weight: False
- bnb_4bit_quant_type: nf4
- bnb_4bit_use_double_quant: True
- bnb_4bit_compute_dtype: float16
Framework versions
PEFT 0.5.0
PEFT 0.5.0
- Downloads last month
- 69