Text Generation
Transformers
PyTorch
English
gpt_neox
text-generation-inference
Inference Endpoints
File size: 11,797 Bytes
58551ed
 
23a3fab
 
2cc64dc
 
95667a6
59ce757
95667a6
7f36397
95667a6
7f36397
95667a6
 
7f36397
95667a6
 
7f36397
95667a6
 
7f36397
95667a6
 
7f36397
95667a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59ce757
 
 
 
 
 
58551ed
23a3fab
3c09771
23a3fab
3c09771
3b3a1f2
 
23a3fab
3c09771
 
 
4a73d90
 
23a3fab
 
 
 
 
 
 
 
 
0d2653d
 
23a3fab
 
2cc64dc
0d2653d
23a3fab
0d2653d
 
23a3fab
0d2653d
 
 
 
 
 
23a3fab
3c09771
 
23a3fab
 
0d2653d
 
 
 
 
 
 
 
23a3fab
0d2653d
 
 
23a3fab
 
 
 
2cc64dc
0d2653d
 
 
 
 
 
 
 
 
23a3fab
 
0d2653d
 
23a3fab
0d2653d
 
 
 
 
 
23a3fab
3c09771
 
0d2653d
23a3fab
0d2653d
 
 
 
 
 
 
 
23a3fab
0d2653d
 
 
23a3fab
 
 
 
 
0d2653d
 
23a3fab
0d2653d
 
 
 
 
 
23a3fab
3c09771
 
23a3fab
0d2653d
 
 
 
 
 
 
 
23a3fab
0d2653d
 
 
23a3fab
 
0d2653d
 
23a3fab
 
 
 
 
 
 
 
 
 
 
 
 
3c09771
23a3fab
 
 
 
 
3c09771
659a034
23a3fab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3c09771
23a3fab
 
 
 
 
 
 
 
 
 
 
 
 
 
3c09771
23a3fab
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
---
license: apache-2.0
language:
- en
datasets:
- togethercomputer/RedPajama-Data-1T
- togethercomputer/RedPajama-Data-Instruct
widget:
- text: |-
    Label the sentences as either 'positive', 'negative', 'mixed', or 'neutral': 

    Sentence: I can say that there isn't anything I would change.
    Label: positive

    Sentence: I'm not sure about this.
    Label: neutral

    Sentence: I liked some parts but I didn't like other parts.
    Label: mixed

    Sentence: I think the background image could have been better.
    Label: negative

    Sentence: I really like it.
    Label:
  example_title: Sentiment Analysis
- text: |-
    Please answer the following question:

    Question: What is the capital of Canada?
    Answer: Ottawa

    Question: What is the currency of Switzerland?
    Answer: Swiss franc

    Question: In which country is Wisconsin located?
    Answer:
  example_title: Question Answering
- text: >-
    Given a news article, classify its topic.

    Possible labels: 1. World 2. Sports 3. Business 4. Sci/Tech


    Article: A nearby star thought to harbor comets and asteroids now appears to
    be home to planets, too.

    Label: Sci/Tech


    Article: Soaring crude prices plus worries about the economy and the outlook
    for earnings are expected to hang over the stock market next week during the
    depth of the summer doldrums.

    Label: Business


    Article: Murtagh a stickler for success Northeastern field hockey coach
    Cheryl Murtagh doesn't want the glare of the spotlight that shines on her to
    detract from a team that has been the America East champion for the past
    three years and has been to the NCAA tournament 13 times.

    Label::
  example_title: Topic Classification
- text: |-
    Paraphrase the given sentence into a different sentence.

    Input: Can you recommend some upscale restaurants in New York?
    Output: What upscale restaurants do you recommend in New York?

    Input: What are the famous places we should not miss in Paris?
    Output: Recommend some of the best places to visit in Paris?

    Input: Could you recommend some hotels that have cheap price in Zurich?
    Output:
  example_title: Paraphrasing
- text: >-
    Given a review from Amazon's food products, the task is to generate a short
    summary of the given review in the input.


    Input: I have bought several of the Vitality canned dog food products and
    have found them all to be of good quality. The product looks more like a
    stew than a processed meat and it smells better. My Labrador is finicky and
    she appreciates this product better than most.

    Output: Good Quality Dog Food


    Input: Product arrived labeled as Jumbo Salted Peanuts...the peanuts were
    actually small sized unsalted. Not sure if this was an error or if the
    vendor intended to represent the product as 'Jumbo'.

    Output: Not as Advertised


    Input: My toddler loves this game to a point where he asks for it. That's a
    big thing for me. Secondly, no glitching unlike one of their competitors
    (PlayShifu). Any tech I don’t have to reach out to support for help is a
    good tech for me. I even enjoy some of the games and activities in this.
    Overall, this is a product that shows that the developers took their time
    and made sure people would not be asking for refund. I’ve become bias
    regarding this product and honestly I look forward to buying more of this
    company’s stuff. Please keep up the great work.

    Output:
  example_title: Text Summarization
- text: |-
    Identify which sense of a word is meant in a given context.

    Context: The river overflowed the bank.
    Word: bank
    Sense: river bank

    Context: A mouse takes much more room than a trackball.
    Word: mouse
    Sense: computer mouse

    Context: The bank will not be accepting cash on Saturdays.
    Word: bank
    Sense: commercial (finance) banks

    Context: Bill killed the project
    Word: kill
    Sense:
  example_title: Word Sense Disambiguation
- text: >-
    Given a pair of sentences, choose whether the two sentences agree
    (entailment)/disagree (contradiction) with each other.

    Possible labels: 1. entailment 2. contradiction


    Sentence 1: The skier was on the edge of the ramp. Sentence 2: The skier was
    dressed in winter clothes.

    Label: entailment


    Sentence 1: The boy skated down the staircase railing. Sentence 2: The boy
    is a newbie skater.

    Label: contradiction


    Sentence 1: Two middle-aged people stand by a golf hole. Sentence 2: A
    couple riding in a golf cart.

    Label:
  example_title: Natural Language Inference
inference:
  parameters:
    temperature: 0.7
    top_p: 0.7
    top_k: 50
    max_new_tokens: 128
---

# RedPajama-INCITE-7B-Instruct

RedPajama-INCITE-7B-Instruct was developed by Together and leaders from the open-source AI community including Ontocord.ai, ETH DS3Lab, AAI CERC, Université de Montréal, MILA - Québec AI Institute, Stanford Center for Research on Foundation Models (CRFM), Stanford Hazy Research research group and LAION. 

The model was fine-tuned for few-shot applications on the data of [GPT-JT](https://huggingface.co/togethercomputer/GPT-JT-6B-v1), with exclusion of tasks that overlap with the HELM core scenarios.

  - Base Model: [RedPajama-INCITE-7B-Base](https://huggingface.co/togethercomputer/RedPajama-INCITE-7B-Base)
  - Instruction-tuned Version: [RedPajama-INCITE-7B-Instruct](https://huggingface.co/togethercomputer/RedPajama-INCITE-7B-Instruct)
  - Chat Version: [RedPajama-INCITE-7B-Chat](https://huggingface.co/togethercomputer/RedPajama-INCITE-7B-Chat)


## Model Details
- **Developed by**: Together Computer.
- **Model type**: Language Model
- **Language(s)**: English
- **License**: Apache 2.0
- **Model Description**: A 6.9B parameter pretrained language model.

# Quick Start

Please note that the model requires `transformers` version >= 4.25.1.

## GPU Inference

This requires a GPU with 16GB memory.

```python
import torch
import transformers
from transformers import AutoTokenizer, AutoModelForCausalLM

MIN_TRANSFORMERS_VERSION = '4.25.1'

# check transformers version
assert transformers.__version__ >= MIN_TRANSFORMERS_VERSION, f'Please upgrade transformers to version {MIN_TRANSFORMERS_VERSION} or higher.'

# init
tokenizer = AutoTokenizer.from_pretrained("togethercomputer/RedPajama-INCITE-7B-Instruct")
model = AutoModelForCausalLM.from_pretrained("togethercomputer/RedPajama-INCITE-7B-Instruct", torch_dtype=torch.float16)
model = model.to('cuda:0')
# infer
prompt = "Q: The capital of France is?\nA:"
inputs = tokenizer(prompt, return_tensors='pt').to(model.device)
input_length = inputs.input_ids.shape[1]
outputs = model.generate(
    **inputs, max_new_tokens=128, do_sample=True, temperature=0.7, top_p=0.7, top_k=50, return_dict_in_generate=True
)
token = outputs.sequences[0, input_length:]
output_str = tokenizer.decode(token)
print(output_str)
"""
Paris
"""
```

## GPU Inference in Int8

This requires a GPU with 12GB memory.

To run inference with int8, please ensure you have installed accelerate and bitandbytes. You can install them with the following command:

```bash
pip install accelerate
pip install bitsandbytes
```

Then you can run inference with int8 as follows:

```python
import torch
import transformers
from transformers import AutoTokenizer, AutoModelForCausalLM

MIN_TRANSFORMERS_VERSION = '4.25.1'

# check transformers version
assert transformers.__version__ >= MIN_TRANSFORMERS_VERSION, f'Please upgrade transformers to version {MIN_TRANSFORMERS_VERSION} or higher.'

# init
tokenizer = AutoTokenizer.from_pretrained("togethercomputer/RedPajama-INCITE-7B-Instruct")
model = AutoModelForCausalLM.from_pretrained("togethercomputer/RedPajama-INCITE-7B-Instruct", device_map='auto', torch_dtype=torch.float16, load_in_8bit=True)

# infer
prompt = "Q: The capital of France is?\nA:"
inputs = tokenizer(prompt, return_tensors='pt').to(model.device)
input_length = inputs.input_ids.shape[1]
outputs = model.generate(
    **inputs, max_new_tokens=128, do_sample=True, temperature=0.7, top_p=0.7, top_k=50, return_dict_in_generate=True
)
token = outputs.sequences[0, input_length:]
output_str = tokenizer.decode(token)
print(output_str)
"""
Paris
"""
```

## CPU Inference

```python
import torch
import transformers
from transformers import AutoTokenizer, AutoModelForCausalLM

MIN_TRANSFORMERS_VERSION = '4.25.1'

# check transformers version
assert transformers.__version__ >= MIN_TRANSFORMERS_VERSION, f'Please upgrade transformers to version {MIN_TRANSFORMERS_VERSION} or higher.'

# init
tokenizer = AutoTokenizer.from_pretrained("togethercomputer/RedPajama-INCITE-7B-Instruct")
model = AutoModelForCausalLM.from_pretrained("togethercomputer/RedPajama-INCITE-7B-Instruct", torch_dtype=torch.bfloat16)
# infer
prompt = "Q: The capital of France is?\nA:"
inputs = tokenizer(prompt, return_tensors='pt').to(model.device)
input_length = inputs.input_ids.shape[1]
outputs = model.generate(
    **inputs, max_new_tokens=128, do_sample=True, temperature=0.7, top_p=0.7, top_k=50, return_dict_in_generate=True
)
token = outputs.sequences[0, input_length:]
output_str = tokenizer.decode(token)
print(output_str)
"""
Paris
"""
```

Please note that since `LayerNormKernelImpl` is not implemented in fp16 for CPU, we use `bfloat16` for CPU inference.


# Uses

## Direct Use 

Excluded uses are described below.

### Misuse, Malicious Use, and Out-of-Scope Use

It is the responsibility of the end user to ensure that the model is used in a responsible and ethical manner.

#### Out-of-Scope Use

RedPajama-INCITE-7B-Instruct is a language model and may not perform well for other use cases outside of its intended scope. 
For example, it may not be suitable for use in safety-critical applications or for making decisions that have a significant impact on individuals or society. 
It is important to consider the limitations of the model and to only use it for its intended purpose.

#### Misuse and Malicious Use

RedPajama-INCITE-7B-Instruct is designed for language modeling.
Misuse of the model, such as using it to engage in illegal or unethical activities, is strictly prohibited and goes against the principles of the project.

Using the model to generate content that is cruel to individuals is a misuse of this model. This includes, but is not limited to:

- Generating fake news, misinformation, or propaganda
- Promoting hate speech, discrimination, or violence against individuals or groups
- Impersonating individuals or organizations without their consent
- Engaging in cyberbullying or harassment
- Defamatory content
- Spamming or scamming
- Sharing confidential or sensitive information without proper authorization
- Violating the terms of use of the model or the data used to train it
- Creating automated bots for malicious purposes such as spreading malware, phishing scams, or spamming

## Limitations

RedPajama-INCITE-7B-Instruct, like other language models, has limitations that should be taken into consideration. 
For example, the model may not always provide accurate or relevant answers, particularly for questions that are complex, ambiguous, or outside of its training data. 
We therefore welcome contributions from individuals and organizations, and encourage collaboration towards creating a more robust and inclusive chatbot.

## Training

**Training Data**

Please refer to [togethercomputer/RedPajama-Data-1T](https://huggingface.co/datasets/togethercomputer/RedPajama-Data-1T)

**Training Procedure**

- **Hardware:** 8 A100
- **Optimizer:** Adam
- **Gradient Accumulations**: 1
- **Num of Tokens:** 1B tokens
- **Learning rate:** 1e-5

## Community

Join us on [Together Discord](https://discord.gg/6ZVDU8tTD4)