legolasyiu commited on
Commit
790474d
·
verified ·
1 Parent(s): ecc95c4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +99 -0
README.md CHANGED
@@ -10,6 +10,105 @@ tags:
10
  - gemma
11
  - trl
12
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  # Uploaded model
15
 
 
10
  - gemma
11
  - trl
12
  ---
13
+ ## Model Information
14
+
15
+ Summary description and brief definition of inputs and outputs.
16
+
17
+ ### Description
18
+
19
+ Athene CodeGemma 2 7B v1.1 is a collection of lightweight open code models built on top of Gemma. CodeGemma models are text-to-text and text-to-code decoder-only models and are available as a 7 billion pretrained variant that specializes in code completion and code generation tasks, a 7 billion parameter instruction-tuned variant for code chat and instruction following and a 2 billion parameter pretrained variant for fast code completion.
20
+ Supervised Fine-tuning with coding datasets.
21
+
22
+ similar to:
23
+
24
+ | | [codegemma-2b](https://huggingface.co/google/codegemma-2b) | [codegemma-7b](https://huggingface.co/google/codegemma-7b) | [**codegemma-7b-it**](https://huggingface.co/google/codegemma-7b-it) |
25
+ |----------------------------------|:----------------------------------------------------------------:|:----------------------------------------------------------:|:----------------------------------------------------------------:|
26
+ | Code Completion | ✅ | ✅ | |
27
+ | Generation from natural language | | ✅ | ✅ |
28
+ | Chat | | | ✅ |
29
+ | Instruction Following | | | ✅ |
30
+
31
+ ### Sample Usage
32
+
33
+ This model is intended to answer questions about code fragments, to generate code from natural language, or to engage in a conversation with the user about programming or technical problems. If you need to use code completion (for example, integrated in an IDE), we recommend you use one of the pre-trained models instead: [CodeGemma 7B](https://huggingface.co/google/codegemma-7b), or [CodeGemma 2B](https://huggingface.co/google/codegemma-2b).
34
+
35
+ #### For Code Generation
36
+
37
+ ```python
38
+ from transformers import GemmaTokenizer, AutoModelForCausalLM
39
+ tokenizer = GemmaTokenizer.from_pretrained("EpistemeAI/Athene-codegemma-7b-it-alpaca-v1.1")
40
+ model = AutoModelForCausalLM.from_pretrained("EpistemeAI/Athene-codegemma-7b-it-alpaca-v1.1")
41
+ input_text = "Write me a Python function to calculate the nth fibonacci number."
42
+ input_ids = tokenizer(input_text, return_tensors="pt")
43
+ outputs = model.generate(**input_ids)
44
+ print(tokenizer.decode(outputs[0]))
45
+ ```
46
+
47
+ #### Chat Template
48
+
49
+ The instruction-tuned models use a chat template that must be adhered to for conversational use.
50
+ The easiest way to apply it is using the tokenizer's built-in chat template, as shown in the following snippet.
51
+
52
+ Let's load the model and apply the chat template to a conversation. In this example, we'll start with a single user interaction:
53
+
54
+ ```py
55
+ from transformers import AutoTokenizer, AutoModelForCausalLM
56
+ import transformers
57
+ import torch
58
+ model_id = "EpistemeAI/Athene-codegemma-2-7b-it-alpaca-v1"
59
+ dtype = torch.bfloat16
60
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
61
+ model = AutoModelForCausalLM.from_pretrained(
62
+ model_id,
63
+ device_map="cuda",
64
+ torch_dtype=dtype,
65
+ )
66
+ chat = [
67
+ { "role": "user", "content": "Write a hello world program" },
68
+ ]
69
+ prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
70
+ ```
71
+
72
+ At this point, the prompt contains the following text:
73
+
74
+ ```
75
+ <bos><start_of_turn>user
76
+ Write a hello world program<end_of_turn>
77
+ <start_of_turn>model
78
+ ```
79
+
80
+ As you can see, each turn is preceded by a `<start_of_turn>` delimiter and then the role of the entity
81
+ (either `user`, for content supplied by the user, or `model` for LLM responses). Turns finish with
82
+ the `<end_of_turn>` token.
83
+
84
+ You can follow this format to build the prompt manually, if you need to do it without the tokenizer's
85
+ chat template.
86
+
87
+ After the prompt is ready, generation can be performed like this:
88
+
89
+ ```py
90
+ inputs = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
91
+ outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=150)
92
+ ```
93
+
94
+ ### Inputs and Outputs
95
+
96
+ Inputs
97
+ : For pretrained model variants: code prefix and/or suffix for code completion and generation scenarios, or natural language text or prompt
98
+ : For instruction tuned model variant: natural language text or prompt
99
+
100
+ Outputs
101
+ : For pretrained model variants: fill-in-the-middle code completion, code and natural language
102
+ : For instruction tuned model variant: code and natural language
103
+
104
+ ## Model Data
105
+
106
+ Data used for model training and how the data was processed.
107
+
108
+ ### Training Dataset
109
+
110
+ Using Gemma as the base model, Athene CodeGemma 2 7B pretrained variants are further trained on an additional 500 billion tokens of primarily English language data from publicly available code repositories, open source mathematics datasets and synthetically generated code.
111
+
112
 
113
  # Uploaded model
114