Downloads · 30 days
5
20% of all-time downloads
kr-manish/Llama-2-7b-chat-fine-tune-text-to-python
Llama-2-7b-chat-fine-tune-text-to-python is a machine learning model from kr-manish. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft.
should probably proofread and complete it, then remove this comment. --
Downloads · 30 days
5
20% of all-time downloads
All-time downloads
25
Public
Repo size
135 MB
Likes
0
Public
Click a slice to open those files.
.safetensors134 MB · 98%
From the Hugging Face model README
#dataset-used: codeparrot/xlcost-text-to-code
#github notebook: https://github.com/manishzed/LLM-Fine-tune/blob/main/Llama_2_7b_chat_fine_tune_text_to_python.ipynb
#code
#testing and loading model
import torch, gc
gc.collect()
torch.cuda.empty_cache()
import numpy as np
import pandas as pd
import os
from tqdm import tqdm
import bitsandbytes as bnb
import torch
import torch.nn as nn
import transformers
from datasets import Dataset
from peft import LoraConfig, PeftConfig
from trl import SFTTrainer
from transformers import (AutoModelForCausalLM,
AutoTokenizer,
BitsAndBytesConfig,
TrainingArguments,
pipeline,
logging)
from sklearn.metrics import (accuracy_score,
classification_report,
confusion_matrix)
from sklearn.model_selection import train_test_split
from datasets import load_dataset
#testing----1
# Ruta del modelo guardado en el dataset de Kaggle
from peft import LoraConfig, PeftModel
device_map = {"": 0}
PEFT_MODEL = "kr-manish/Llama-2-7b-chat-fine-tune-text-to-python"
#model_name = "NousResearch/Llama-2-7b-hf"
# Cargar la configuración del modelo
config = PeftConfig.from_pretrained(PEFT_MODEL)
# Cargar el modelo
model = AutoModelForCausalLM.from_pretrained(
config.base_model_name_or_path,
low_cpu_mem_usage=True,
return_dict=True,
#quantization_config=bnb_config,
device_map="auto",
#trust_remote_code=True,
torch_dtype=torch.float16,
)
# Cargar el tokenizador
tokenizer=AutoTokenizer.from_pretrained(config.base_model_name_or_path)
tokenizer.pad_token = tokenizer.eos_token
# Cargar el modelo PEFT
load_model = PeftModel.from_pretrained(model, PEFT_MODEL)
input_text ="Program to convert Centimeters to Pixels | Function to convert centimeters to pixels ; Driver Code"
prompt_test = input_text
pipe_test = pipeline(task="text-generation",
model=load_model,
tokenizer=tokenizer,
max_length =200,
#max_new_tokens =25,
)
#result_test = pipe_test(prompt_test)
#answer_test = result_test[0]['generated_text']
#answer_test
#or
result = pipe_test(f"<s>[INST] {input_text} [/INST]")
print(result[0]['generated_text'])
#Program to convert Centimeters to Pixels | Function to convert centimeters to pixels ; Driver Code [/code] def convertCentimetersToPixels ( cm ) : NEW_LINE INDENT pixels =
#code
This model is a fine-tuned version of NousResearch/Llama-2-7b-chat-hf on the None dataset. It achieves the following results on the evaluation set:
More information needed
More information needed
More information needed
The following hyperparameters were used during training:
| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 0.7836 | 1.0 | 463 | 0.7746 |