Update README.md
Browse files
README.md
CHANGED
@@ -7,61 +7,36 @@ basemodel: google/gemma-7b-it
|
|
7 |
## Model Card for Firefly-Gemma
|
8 |
|
9 |
[gemma-7B-it-firefly](https://huggingface.co/yys/gemma-7B-it-firefly) is trained based on [gemma-7b-it](https://huggingface.co/google/gemma-7b-it) to act as a helpful and harmless AI assistant.
|
10 |
-
|
11 |
|
12 |
|
13 |
<img src="gemma-7B-it-firefly.jpg" width="250">
|
14 |
|
15 |
-
We advise you to install transformers>=4.38.2.
|
16 |
|
17 |
## Performance
|
18 |
-
|
19 |
-
|
20 |
|
21 |
## Usage
|
22 |
-
The chat template of our chat models is
|
23 |
```text
|
24 |
<bos><start_of_turn>user
|
25 |
-
hello
|
26 |
<start_of_turn>model
|
27 |
-
I am a AI program developed by Firefly<eos>
|
28 |
```
|
29 |
|
30 |
You can also use the following code:
|
31 |
```python
|
32 |
-
|
33 |
-
import
|
34 |
|
35 |
model_name_or_path = "yys/gemma-7B-it-firefly"
|
36 |
-
model = AutoModelForCausalLM.from_pretrained(
|
37 |
-
model_name_or_path,
|
38 |
-
trust_remote_code=True,
|
39 |
-
low_cpu_mem_usage=True,
|
40 |
-
torch_dtype=torch.float16,
|
41 |
-
device_map='auto',
|
42 |
-
)
|
43 |
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
|
|
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
<bos><start_of_turn>user
|
48 |
-
{prompt}<end_of_turn>
|
49 |
-
<start_of_turn>model
|
50 |
-
""".strip()
|
51 |
-
model_inputs = tokenizer([text], return_tensors="pt").to('cuda')
|
52 |
|
53 |
-
|
54 |
-
|
55 |
-
max_new_tokens=1500,
|
56 |
-
top_p = 0.9,
|
57 |
-
temperature = 0.35,
|
58 |
-
repetition_penalty = 1.0,
|
59 |
-
eos_token_id=tokenizer.encode('<eos>', add_special_tokens=False)
|
60 |
-
)
|
61 |
-
generated_ids = [
|
62 |
-
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
63 |
-
]
|
64 |
|
65 |
-
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
66 |
-
print(response)
|
67 |
```
|
|
|
7 |
## Model Card for Firefly-Gemma
|
8 |
|
9 |
[gemma-7B-it-firefly](https://huggingface.co/yys/gemma-7B-it-firefly) is trained based on [gemma-7b-it](https://huggingface.co/google/gemma-7b-it) to act as a helpful and harmless AI assistant.
|
10 |
+
we trained the model on [firefly-train-1.1M](https://huggingface.co/datasets/YeungNLP/firefly-train-1.1M) dataset with LoRA.
|
11 |
|
12 |
|
13 |
<img src="gemma-7B-it-firefly.jpg" width="250">
|
14 |
|
|
|
15 |
|
16 |
## Performance
|
17 |
+
we evaluate the model on [Open LLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard)
|
|
|
18 |
|
19 |
## Usage
|
20 |
+
The chat template of our chat models is same as Official gemma-7b-it:
|
21 |
```text
|
22 |
<bos><start_of_turn>user
|
23 |
+
Write a hello world program<end_of_turn>
|
24 |
<start_of_turn>model
|
|
|
25 |
```
|
26 |
|
27 |
You can also use the following code:
|
28 |
```python
|
29 |
+
|
30 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
31 |
|
32 |
model_name_or_path = "yys/gemma-7B-it-firefly"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
|
34 |
+
model = AutoModelForCausalLM.from_pretrained(model_name_or_path)
|
35 |
|
36 |
+
input_text = "给我写一首关于机器学习的诗歌。"
|
37 |
+
input_ids = tokenizer(input_text, return_tensors="pt")
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
+
outputs = model.generate(**input_ids)
|
40 |
+
print(tokenizer.decode(outputs[0]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
|
|
|
|
42 |
```
|