CoolFace
Modelpublic

YeungNLP/firefly-gemma-7b

sourceHugging Faceapache-2.0updated 3y agoView on Hugging Face
1likes68downloads
Model Card

Model Card for Firefly-Gemma

firefly-gemma-7b is trained based on gemma-7b to act as a helpful and harmless AI assistant. We use Firefly to train the model on a single V100 GPU with QLoRA.

Our model outperforms the official gemma-7b-it, zephyr-7b-gemma-v0.1, Qwen1.5-7B-Chat and Zephyr-7B-Beta on Open LLM Leaderboard.

<img src="openllmleaderboard.png" width="800">

We advise you to install transformers>=4.38.1.

Performance

We evaluate our models on Open LLM Leaderboard, they achieve good performance.

ModelAverageARCHellaSwagMMLUTruthfulQAWinograndeGSM8K
firefly-gemma-7b62.9362.1279.7761.5749.4175.4549.28
zephyr-7b-gemma-v0.162.4158.4583.4860.6852.0774.1945.56
firefly-qwen1.5-en-7b-dpo-v0.162.3654.3576.0461.2156.472.0654.13
zephyr-7b-beta61.9562.0384.3661.0757.4577.7429.04
firefly-qwen1.5-en-7b61.4453.4175.5161.6751.9670.7255.34
vicuna-13b-v1.555.4157.0881.2456.6751.5174.6611.3
Xwin-LM-13B-V0.155.2962.5482.856.5345.9674.279.63
Qwen1.5-7B-Chat55.1555.8978.5661.6553.5467.7213.57
gemma-7b-it53.5651.4571.9653.5247.2967.9629.19

Usage

The chat template of our chat models is similar as Official gemma-7b-it:

text
<bos><start_of_turn>user
hello, who are you?<end_of_turn>
<start_of_turn>model
I am a AI program developed by Firefly<eos>

You can use script to inference in Firefly.

You can also use the following code:

python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model_name_or_path = "YeungNLP/firefly-gemma-7b"
model = AutoModelForCausalLM.from_pretrained(
    model_name_or_path,
    trust_remote_code=True,
    low_cpu_mem_usage=True,
    torch_dtype=torch.float16,
    device_map='auto',
)
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)

prompt = "Compose an engaging travel blog post about a recent trip to Hawaii, highlighting cultural experiences and must-see attractions. "
text = f"""
<bos><start_of_turn>user
{prompt}<end_of_turn>
<start_of_turn>model
""".strip()
model_inputs = tokenizer([text], return_tensors="pt").to('cuda')

generated_ids = model.generate(
    model_inputs.input_ids,
    max_new_tokens=1500,
    top_p = 0.9,
    temperature = 0.35,
    repetition_penalty = 1.0,
    eos_token_id=tokenizer.encode('<eos>', add_special_tokens=False)
)
generated_ids = [
    output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]

response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(response)