Downloads · 30 days
8
30% of all-time downloads
kr-manish/Llama-2-7b-chat-finetune-for-textGeneration
Llama-2-7b-chat-finetune-for-textGeneration 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.
- Developed by: [More Information Needed] - Funded by [optional]: [More Information Needed] - Shared by [optional]: [More Information Needed] - Model type: [More Information Needed] - Language(s) (NLP): [More Informat…
Downloads · 30 days
8
30% of all-time downloads
All-time downloads
27
Public
Repo size
135 MB
Likes
0
Public
Click a slice to open those files.
.safetensors134 MB · 98%
From the Hugging Face model README
#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
from peft import LoraConfig, PeftModel
device_map = {"": 0}
PEFT_MODEL = "kr-manish/Llama-2-7b-chat-finetune-for-textGeneration"
#model_name = "NousResearch/Llama-2-7b-hf"
config = PeftConfig.from_pretrained(PEFT_MODEL)
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,
)
tokenizer=AutoTokenizer.from_pretrained(config.base_model_name_or_path)
tokenizer.pad_token = tokenizer.eos_token
load_model = PeftModel.from_pretrained(model, PEFT_MODEL)
test1 ="How to own a plane in the United States?"
prompt_test = test1
pipe_test = pipeline(task="text-generation",
model=load_model,
tokenizer=tokenizer,
#max_length =20,
max_new_tokens =25,
temperature = 0.0,
)
result_test = pipe_test(prompt_test)
#answer = result[0]['generated_text'].split("=")[-1]
answer_test = result_test[0]['generated_text']
answer_test
#How to own a plane in the United States?\n\nIn the United States, owning a plane is a significant investment and requires careful planning and research. Here are
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
Use the code below to get started with the model.
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
BibTeX:
[More Information Needed]
APA:
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]