yys commited on
Commit
9b1e490
1 Parent(s): 192228d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +11 -36
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
- We use [Firefly](https://github.com/yangjianxin1/Firefly) to train the model with LoRA.
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
- We evaluate our models on [Open LLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard), they achieve good performance.
19
-
20
 
21
  ## Usage
22
- The chat template of our chat models is similar as Official gemma-7b-it:
23
  ```text
24
  <bos><start_of_turn>user
25
- hello, who are you?<end_of_turn>
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
- from transformers import AutoModelForCausalLM, AutoTokenizer
33
- import torch
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
- prompt = "Compose an engaging travel blog post about a recent trip to Hawaii, highlighting cultural experiences and must-see attractions. "
46
- text = f"""
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
- generated_ids = model.generate(
54
- model_inputs.input_ids,
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
  ```