Downloads · 30 days
22
3% of all-time downloads
erfanzar/LGeM-7B
LGeM-7B is a text generation model from erfanzar. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as mit.
Downloads · 30 days
22
3% of all-time downloads
All-time downloads
668
Public
Repo size
31.5 GB
Likes
9
Public
Click a slice to open those files.
.bin13.5 GB · 100%
From the Hugging Face model README
I used Alpaca Prompting Method
def prompt_to_instruction(instruction, input_=None, response_=None, eos='<|endoftext|>'):
if input_ is None:
st1_prompting = f'Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n### Instruction:\n\n{instruction}\n\n'
else:
st1_prompting = f'Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n### Instruction:\n\n{instruction}\n\n### Input:\n\n{input_}\n\n'
resp = f'### Response:\n\n{response_}{eos}' if response_ is not None else '### Response:\n\n'
return st1_prompting + resp
import torch
from transformers import GenerationConfig, LlamaTokenizer, LlamaForCausalLM
# Loading Tokenizer
tokenizer = LlamaTokenizer.from_pretrained("erfanzar/LGeM-7B")
# Generation Config
gf = GenerationConfig(
temperature=1,
top_p=0.75,
top_k=40,
max_new_tokens=256,
num_beams=4,
)
# Loading Model
model = LlamaForCausalLM.from_pretrained(
"erfanzar/LGeM-7B",
load_in_8bit=True,
device_map="auto",
torch_dtype=torch.float16,
)
while True:
instruction = input('=> ')
input_ = None
prompt = prompt_to_instruction(instruction, input_)
input_ids = tokenizer(prompt, return_tensors="pt")["input_ids"]
input_ids = input_ids.to(model.device)
with torch.no_grad():
prediction = model.generate(
input_ids=input_ids,
return_dict_in_generate=True,
generation_config=gc,
output_scores=True,
)
response = tokenizer.decode(prediction.sequences[0], skip_special_tokens=True)
print('\n\n\n')
print(response[len(prompt)+1:])
print('\n\n')
what is LGeM, LGeM is a CausalLM Model that is trained on self instruct data (Alpaca data) and for initialization of the first train of the main model (weights are available) I used pre weights from Alpaca LoRA (open source)
it's Decoder Only
built-in Pytorch
you can simply import models like
from modules import LGeMForCausalLM
python3 LGeM-train.py