TechxGenus
commited on
Commit
•
3ae390a
1
Parent(s):
d18a139
Upload README.md
Browse files
README.md
CHANGED
@@ -19,10 +19,10 @@ We've fine-tuned Gemma-2b with an additional 0.7 billion high-quality, code-rela
|
|
19 |
|
20 |
### Usage
|
21 |
|
22 |
-
Here give
|
23 |
|
24 |
```python
|
25 |
-
from transformers import
|
26 |
import torch
|
27 |
PROMPT = """### Instruction
|
28 |
{instruction}
|
@@ -30,6 +30,29 @@ PROMPT = """### Instruction
|
|
30 |
"""
|
31 |
instruction = <Your code instruction here>
|
32 |
prompt = PROMPT.format(instruction=instruction)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
generator = pipeline(
|
34 |
model="TechxGenus/CodeGemma-2b",
|
35 |
task="text-generation",
|
|
|
19 |
|
20 |
### Usage
|
21 |
|
22 |
+
Here give some examples of how to use our model:
|
23 |
|
24 |
```python
|
25 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
26 |
import torch
|
27 |
PROMPT = """### Instruction
|
28 |
{instruction}
|
|
|
30 |
"""
|
31 |
instruction = <Your code instruction here>
|
32 |
prompt = PROMPT.format(instruction=instruction)
|
33 |
+
tokenizer = AutoTokenizer.from_pretrained("TechxGenus/CodeGemma-2b")
|
34 |
+
model = AutoModelForCausalLM.from_pretrained(
|
35 |
+
"TechxGenus/CodeGemma-2b",
|
36 |
+
torch_dtype=torch.bfloat16,
|
37 |
+
device_map="auto",
|
38 |
+
)
|
39 |
+
inputs = tokenizer.encode(prompt, return_tensors="pt")
|
40 |
+
outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=2048)
|
41 |
+
print(tokenizer.decode(outputs[0]))
|
42 |
+
```
|
43 |
+
|
44 |
+
With text-generation pipeline:
|
45 |
+
|
46 |
+
|
47 |
+
```python
|
48 |
+
from transformers import pipeline
|
49 |
+
import torch
|
50 |
+
PROMPT = """<bos>### Instruction
|
51 |
+
{instruction}
|
52 |
+
### Response
|
53 |
+
"""
|
54 |
+
instruction = <Your code instruction here>
|
55 |
+
prompt = PROMPT.format(instruction=instruction)
|
56 |
generator = pipeline(
|
57 |
model="TechxGenus/CodeGemma-2b",
|
58 |
task="text-generation",
|