updated Readme
Browse files
README.md
CHANGED
@@ -14,4 +14,75 @@ widget:
|
|
14 |
language:
|
15 |
- en
|
16 |
pipeline_tag: text-generation
|
17 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
language:
|
15 |
- en
|
16 |
pipeline_tag: text-generation
|
17 |
+
---
|
18 |
+
|
19 |
+
# Gemma-2b-it-finetuned-python-codes
|
20 |
+
|
21 |
+
This model card corresponds to the 2B finetuned version of the Gemma-2b-it model. You can visit the model card of the [2B Gemma Instruct](https://huggingface.co/google/gemma-2b-it).
|
22 |
+
|
23 |
+
**Author**: Dishank Shah
|
24 |
+
|
25 |
+
## Model Information
|
26 |
+
|
27 |
+
Summary description and brief definition of inputs and outputs.
|
28 |
+
|
29 |
+
### Description
|
30 |
+
|
31 |
+
Gemma is a family of lightweight, state-of-the-art open models from Google,
|
32 |
+
built from the same research and technology used to create the Gemini models.
|
33 |
+
They are text-to-text, decoder-only large language models, available in English,
|
34 |
+
with open weights, pre-trained variants, and instruction-tuned variants. Gemma
|
35 |
+
models are well-suited for a variety of text generation tasks, including
|
36 |
+
question answering, summarization, and reasoning. Their relatively small size
|
37 |
+
makes it possible to deploy them in environments with limited resources such as
|
38 |
+
a laptop, desktop or your own cloud infrastructure, democratizing access to
|
39 |
+
state of the art AI models and helping foster innovation for everyone.
|
40 |
+
|
41 |
+
### Usage
|
42 |
+
|
43 |
+
Below we share some code snippets on how to get quickly started with running the model. First make sure to `pip install -U transformers`, then copy the snippet from the section that is relevant for your usecase.
|
44 |
+
|
45 |
+
#### Running the model on Google Colab CPU
|
46 |
+
|
47 |
+
```python
|
48 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
49 |
+
|
50 |
+
model_name = "shahdishank/gemma-2b-it-finetune-python-codes"
|
51 |
+
HUGGING_FACE_TOKEN = "YOUR_TOKEN"
|
52 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, token="HUGGING_FACE_TOKEN")
|
53 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, token="HUGGING_FACE_TOKEN")
|
54 |
+
|
55 |
+
prompt_template = """\
|
56 |
+
user:\n{query} \n\n assistant:\n
|
57 |
+
"""
|
58 |
+
prompt = prompt_template.format(query="write a simple python function") # write your query here
|
59 |
+
|
60 |
+
input_ids = tokenizer(prompt, return_tensors="pt", add_special_tokens=True)
|
61 |
+
outputs = model.generate(**input_ids, max_new_tokens=2000, do_sample=True, pad_token_id=tokenizer.eos_token_id)
|
62 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
63 |
+
print(response)
|
64 |
+
```
|
65 |
+
|
66 |
+
## Model Data
|
67 |
+
|
68 |
+
Data used for model training [python-codes-25k](https://huggingface.co/datasets/flytech/python-codes-25k).
|
69 |
+
|
70 |
+
### Training Dataset
|
71 |
+
|
72 |
+
These models were trained on a dataset of text data that includes a wide variety
|
73 |
+
of python codes. Here are the key components:
|
74 |
+
|
75 |
+
* Instruction: The instructional task to be performed / User input.
|
76 |
+
* Input: Very short, introductive part of AI response or empty.
|
77 |
+
* Output: Python code that accomplishes the task.
|
78 |
+
* Text: All fields combined together.
|
79 |
+
|
80 |
+
This diverse data source is crucial for training a powerful
|
81 |
+
language model that can handle a wide variety of different tasks.
|
82 |
+
|
83 |
+
### Usage
|
84 |
+
|
85 |
+
This LLM can be used for:
|
86 |
+
* Code generation
|
87 |
+
* Debugging
|
88 |
+
* Learn and understand various python coding styles
|