Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,79 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
+
tags:
|
4 |
+
- code
|
5 |
---
|
6 |
+
|
7 |
+
## Cerebras-GPT-2.7B-Alpaca-SP
|
8 |
+
|
9 |
+
Cerebras-GPT-2.7B-Alpaca-SP is [cerebras/Cerebras-GPT-2.7B](https://huggingface.co/cerebras/Cerebras-GPT-2.7B) finetuned on a modified [Alpaca dataset](https://github.com/tloen/alpaca-lora/blob/main/alpaca_data_cleaned.json) with a shorter prompt structure (`Human:...\n\nAssistant:`). This contains the float16 model merged with [lxe/lora-cerebras-gpt2.7b-alpaca-shortprompt](https://huggingface.co/lxe/lora-cerebras-gpt2.7b-alpaca-shortprompt) LoRA.
|
10 |
+
|
11 |
+
### Basic Usage:
|
12 |
+
|
13 |
+
```
|
14 |
+
tokenizer = transformers.AutoTokenizer.from_pretrained('lxe/Cerebras-GPT-2.7B-Alpaca-SP')
|
15 |
+
|
16 |
+
model = transformers.AutoModelForCausalLM.from_pretrained(
|
17 |
+
`lxe/Cerebras-GPT-2.7B-Alpaca-SP`,
|
18 |
+
load_in_8bit=True,
|
19 |
+
torch_dtype=torch.float16,
|
20 |
+
device_map={"": 0},
|
21 |
+
)
|
22 |
+
|
23 |
+
prompt = "Human: how old is the sun?\n\nAssistant:"
|
24 |
+
input_ids = tokenizer.encode(prompt, return_tensors="pt").cuda()
|
25 |
+
|
26 |
+
with torch.no_grad():
|
27 |
+
output = model.generate(
|
28 |
+
input_ids=input_ids,
|
29 |
+
max_length=100,
|
30 |
+
early_stopping=True,
|
31 |
+
)
|
32 |
+
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
33 |
+
print(generated_text)
|
34 |
+
```
|
35 |
+
|
36 |
+
```
|
37 |
+
Human: how old is the sun?
|
38 |
+
|
39 |
+
Assistant: The sun is approximately 4.5 billion years old.
|
40 |
+
```
|
41 |
+
|
42 |
+
### Example Outputs:
|
43 |
+
|
44 |
+
**Human**: how old is the sun? <br />
|
45 |
+
**Assistant**: The sun is approximately 4.5 billion years old.
|
46 |
+
|
47 |
+
|
48 |
+
**Human**: what are the highest grossing films of the 2000-2010 decade? <br />
|
49 |
+
**Assistant**: The highest grossing film in 2010 was Avatar, which earned $2.5 billion worldwide and is currently ranked as one of the top 10 movies ever made by Box Office Mojo. Other notable high-grossing films include Titanic ($1.8 billion), Jurassic World ($1.6 billion) and Harry Potter And The Deathly Hallows Part 2 ($1.4 billion).
|
50 |
+
|
51 |
+
|
52 |
+
**Human**: how is cheese made? <br />
|
53 |
+
**Assistant**: Cheese making involves the process of curdling milk, separating it into a liquid and solid phase, then heating that mixture to create a semi-solid mass. The resulting product can be either hard or soft depending on its composition. Hard cheeses are typically produced from cow's milk while softer varieties come from sheep's milk.
|
54 |
+
|
55 |
+
|
56 |
+
**Human**: print all letters of the alphabet in reverse <br />
|
57 |
+
**Assistant**: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
|
58 |
+
|
59 |
+
|
60 |
+
**Human**: write a javascript function that sorts an array using quicksort algorithm <br />
|
61 |
+
**Assistant**:
|
62 |
+
```
|
63 |
+
function quicksort(array) {
|
64 |
+
if (array.length < 2) {
|
65 |
+
return array;
|
66 |
+
}
|
67 |
+
var pivot = array[0];
|
68 |
+
var left = quicksort(array, 0, array.length - 1);
|
69 |
+
var right = quicksort(array, array.length - 1, 0);
|
70 |
+
if (left < pivot) {
|
71 |
+
left = pivot;
|
72 |
+
}
|
73 |
+
if (right > pivot) {
|
74 |
+
right = pivot;
|
75 |
+
}
|
76 |
+
if (left < right) {
|
77 |
+
quicksort(array, left, right);
|
78 |
+
}
|
79 |
+
```
|