huggingface.co
Total runs: 12.6K
24-hour runs: -62
7-day runs: 865
30-day runs: -1.1K
Model's Last Updated: January 03 2023
text-generation

Introduction of gpt2

Model Details of gpt2

GPT-2

Test the whole generation capabilities here: https://transformer.huggingface.co/doc/gpt2-large

Pretrained model on English language using a causal language modeling (CLM) objective. It was introduced in this paper and first released at this page .

Disclaimer: The team releasing GPT-2 also wrote a model card for their model. Content from this model card has been written by the Hugging Face team to complete the information they provided and give specific examples of bias.

Model description

GPT-2 is a transformers model pretrained on a very large corpus of English data in a self-supervised fashion. This means it was pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lots of publicly available data) with an automatic process to generate inputs and labels from those texts. More precisely, it was trained to guess the next word in sentences.

More precisely, inputs are sequences of continuous text of a certain length and the targets are the same sequence, shifted one token (word or piece of word) to the right. The model uses internally a mask-mechanism to make sure the predictions for the token i only uses the inputs from 1 to i but not the future tokens.

This way, the model learns an inner representation of the English language that can then be used to extract features useful for downstream tasks. The model is best at what it was pretrained for however, which is generating texts from a prompt.

Intended uses & limitations

You can use the raw model for text generation or fine-tune it to a downstream task. See the model hub to look for fine-tuned versions on a task that interests you.

How to use

Here is how to use the ONNX models of gpt2 to get the features of a given text:

Example using transformers.pipelines:

from transformers import AutoTokenizer, pipeline
from optimum.onnxruntime import ORTModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("gpt2")
model = ORTModelForCausalLM.from_pretrained("gpt2", from_transformers=True)
onnx_gen = pipeline("text-generation", model=model, tokenizer=tokenizer)

text = "My name is Philipp and I live in Germany."
gen = onnx_gen(text)

Example of text generation:

from transformers import AutoTokenizer
from optimum.onnxruntime import ORTModelForCausalLM
import torch

tokenizer = AutoTokenizer.from_pretrained("optimum/gpt2")
model = ORTModelForCausalLM.from_pretrained("optimum/gpt2")

inputs = tokenizer("My name is Arthur and I live in", return_tensors="pt")

gen_tokens = model.generate(**inputs,do_sample=True,temperature=0.9, min_length=20,max_length=20)
tokenizer.batch_decode(gen_tokens)

Runs of optimum gpt2 on huggingface.co

12.6K
Total runs
-62
24-hour runs
-48
3-day runs
865
7-day runs
-1.1K
30-day runs

More Information About gpt2 huggingface.co Model

More gpt2 license Visit here:

https://choosealicense.com/licenses/mit

gpt2 huggingface.co

gpt2 huggingface.co is an AI model on huggingface.co that provides gpt2's model effect (), which can be used instantly with this optimum gpt2 model. huggingface.co supports a free trial of the gpt2 model, and also provides paid use of the gpt2. Support call gpt2 model through api, including Node.js, Python, http.

optimum gpt2 online free

gpt2 huggingface.co is an online trial and call api platform, which integrates gpt2's modeling effects, including api services, and provides a free online trial of gpt2, you can try gpt2 online for free by clicking the link below.

optimum gpt2 online free url in huggingface.co:

https://huggingface.co/optimum/gpt2

gpt2 install

gpt2 is an open source model from GitHub that offers a free installation service, and any user can find gpt2 on GitHub to install. At the same time, huggingface.co provides the effect of gpt2 install, users can directly use gpt2 installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

gpt2 install url in huggingface.co:

https://huggingface.co/optimum/gpt2

Url of gpt2

Provider of gpt2 huggingface.co

optimum
ORGANIZATIONS

Other API from optimum

huggingface.co

Total runs: 68.3K
Run Growth: 1.8K
Growth Rate: 2.68%
Updated: January 20 2023
huggingface.co

Total runs: 65
Run Growth: 12
Growth Rate: 18.46%
Updated: November 23 2023
huggingface.co

Total runs: 2
Run Growth: -13
Growth Rate: -650.00%
Updated: September 06 2023