anon8231489123/ShareGPT_Vicuna_unfiltered
Updated β’ 195k β’ 880
How to use erfanzar/LGeM-7B with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="erfanzar/LGeM-7B") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("erfanzar/LGeM-7B")
model = AutoModelForCausalLM.from_pretrained("erfanzar/LGeM-7B")How to use erfanzar/LGeM-7B with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "erfanzar/LGeM-7B"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "erfanzar/LGeM-7B",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/erfanzar/LGeM-7B
How to use erfanzar/LGeM-7B with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "erfanzar/LGeM-7B" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "erfanzar/LGeM-7B",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "erfanzar/LGeM-7B" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "erfanzar/LGeM-7B",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use erfanzar/LGeM-7B with Docker Model Runner:
docker model run hf.co/erfanzar/LGeM-7B
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
docker model run hf.co/erfanzar/LGeM-7B