Run this model with HF Jobs
Run ComCom/gpt2-small on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/ComCom/gpt2-small. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/ComCom/gpt2-small on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/ComCom/gpt2-small. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/ComCom/gpt2-small. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use ComCom/gpt2-small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ComCom/gpt2-small with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ComCom/gpt2-small")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ComCom/gpt2-small") model = AutoModelForCausalLM.from_pretrained("ComCom/gpt2-small", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ComCom/gpt2-small with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ComCom/gpt2-small" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ComCom/gpt2-small", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ComCom/gpt2-small
- SGLang
How to use ComCom/gpt2-small with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "ComCom/gpt2-small" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ComCom/gpt2-small", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "ComCom/gpt2-small" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ComCom/gpt2-small", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ComCom/gpt2-small with Docker Model Runner:
docker model run hf.co/ComCom/gpt2-small
forked from https://huggingface.co/gpt2
Browse filesFiles changed (8)
- README.md+163
- config.jsonAdded+39
- merges.txtAdded
- pytorch_model.binAdded+3
- special_tokens_map.jsonAdded+6
- tokenizer.jsonAdded
- tokenizer_config.jsonAdded+10
- vocab.jsonAdded
123---license: mit---123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166---language: entags:- exbertlicense: mit---This repository has been forked from https://huggingface.co/gpt2---# GPT-2Test the whole generation capabilities here: https://transformer.huggingface.co/doc/gpt2-largePretrained model on English language using a causal language modeling (CLM) objective. It was introduced in[this paper](https://d4mucfpksywv.cloudfront.net/better-language-models/language_models_are_unsupervised_multitask_learners.pdf)and first released at [this page](https://openai.com/blog/better-language-models/).Disclaimer: The team releasing GPT-2 also wrote a[model card](https://github.com/openai/gpt-2/blob/master/model_card.md) for their model. Content from this model cardhas been written by the Hugging Face team to complete the information they provided and give specific examples of bias.## Model descriptionGPT-2 is a transformers model pretrained on a very large corpus of English data in a self-supervised fashion. Thismeans it was pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lotsof 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 thepredictions 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 featuresuseful for downstream tasks. The model is best at what it was pretrained for however, which is generating texts from aprompt.## Intended uses & limitationsYou can use the raw model for text generation or fine-tune it to a downstream task. See the[model hub](https://huggingface.co/models?filter=gpt2) to look for fine-tuned versions on a task that interests you.### How to useYou can use this model directly with a pipeline for text generation. Since the generation relies on some randomness, weset a seed for reproducibility:```python>>> from transformers import pipeline, set_seed>>> generator = pipeline('text-generation', model='gpt2')>>> set_seed(42)>>> generator("Hello, I'm a language model,", max_length=30, num_return_sequences=5)[{'generated_text': "Hello, I'm a language model, a language for thinking, a language for expressing thoughts."},{'generated_text': "Hello, I'm a language model, a compiler, a compiler library, I just want to know how I build this kind of stuff. I don"},{'generated_text': "Hello, I'm a language model, and also have more than a few of your own, but I understand that they're going to need some help"},{'generated_text': "Hello, I'm a language model, a system model. I want to know my language so that it might be more interesting, more user-friendly"},{'generated_text': 'Hello, I\'m a language model, not a language model"\n\nThe concept of "no-tricks" comes in handy later with new'}]```Here is how to use this model to get the features of a given text in PyTorch:```pythonfrom transformers import GPT2Tokenizer, GPT2Modeltokenizer = GPT2Tokenizer.from_pretrained('gpt2')model = GPT2Model.from_pretrained('gpt2')text = "Replace me by any text you'd like."encoded_input = tokenizer(text, return_tensors='pt')output = model(**encoded_input)```and in TensorFlow:```pythonfrom transformers import GPT2Tokenizer, TFGPT2Modeltokenizer = GPT2Tokenizer.from_pretrained('gpt2')model = TFGPT2Model.from_pretrained('gpt2')text = "Replace me by any text you'd like."encoded_input = tokenizer(text, return_tensors='tf')output = model(encoded_input)```### Limitations and biasThe training data used for this model has not been released as a dataset one can browse. We know it contains a lot ofunfiltered content from the internet, which is far from neutral. As the openAI team themselves point out in their[model card](https://github.com/openai/gpt-2/blob/master/model_card.md#out-of-scope-use-cases):> Because large-scale language models like GPT-2 do not distinguish fact from fiction, we don’t support use-cases> that require the generated text to be true.>> Additionally, language models like GPT-2 reflect the biases inherent to the systems they were trained on, so we do> not recommend that they be deployed into systems that interact with humans > unless the deployers first carry out a> study of biases relevant to the intended use-case. We found no statistically significant difference in gender, race,> and religious bias probes between 774M and 1.5B, implying all versions of GPT-2 should be approached with similar> levels of caution around use cases that are sensitive to biases around human attributes.Here's an example of how the model can have biased predictions:```python>>> from transformers import pipeline, set_seed>>> generator = pipeline('text-generation', model='gpt2')>>> set_seed(42)>>> generator("The White man worked as a", max_length=10, num_return_sequences=5)[{'generated_text': 'The White man worked as a mannequin for'},{'generated_text': 'The White man worked as a maniser of the'},{'generated_text': 'The White man worked as a bus conductor by day'},{'generated_text': 'The White man worked as a plumber at the'},{'generated_text': 'The White man worked as a journalist. He had'}]>>> set_seed(42)>>> generator("The Black man worked as a", max_length=10, num_return_sequences=5)[{'generated_text': 'The Black man worked as a man at a restaurant'},{'generated_text': 'The Black man worked as a car salesman in a'},{'generated_text': 'The Black man worked as a police sergeant at the'},{'generated_text': 'The Black man worked as a man-eating monster'},{'generated_text': 'The Black man worked as a slave, and was'}]```This bias will also affect all fine-tuned versions of this model.## Training dataThe OpenAI team wanted to train this model on a corpus as large as possible. To build it, they scraped all the webpages from outbound links on Reddit which received at least 3 karma. Note that all Wikipedia pages were removed fromthis dataset, so the model was not trained on any part of Wikipedia. The resulting dataset (called WebText) weights40GB of texts but has not been publicly released. You can find a list of the top 1,000 domains present in WebText[here](https://github.com/openai/gpt-2/blob/master/domains.txt).## Training procedure### PreprocessingThe texts are tokenized using a byte-level version of Byte Pair Encoding (BPE) (for unicode characters) and avocabulary size of 50,257. The inputs are sequences of 1024 consecutive tokens.The larger model was trained on 256 cloud TPU v3 cores. The training duration was not disclosed, nor were the exactdetails of training.## Evaluation resultsThe model achieves the following results without any fine-tuning (zero-shot):| Dataset | LAMBADA | LAMBADA | CBT-CN | CBT-NE | WikiText2 | PTB | enwiki8 | text8 | WikiText103 | 1BW ||:--------:|:-------:|:-------:|:------:|:------:|:---------:|:------:|:-------:|:------:|:-----------:|:-----:|| (metric) | (PPL) | (ACC) | (ACC) | (ACC) | (PPL) | (PPL) | (BPB) | (BPC) | (PPL) | (PPL) || | 35.13 | 45.99 | 87.65 | 83.4 | 29.41 | 65.85 | 1.16 | 1,17 | 37.50 | 75.20 |### BibTeX entry and citation info```bibtex@article{radford2019language,title={Language Models are Unsupervised Multitask Learners},author={Radford, Alec and Wu, Jeff and Child, Rewon and Luan, David and Amodei, Dario and Sutskever, Ilya},year={2019}}```<a href="https://huggingface.co/exbert/?model=gpt2"><img width="300px" src="https://cdn-media.huggingface.co/exbert/button.png"></a>
123456789101112131415161718192021222324252627282930313233343536373839{ "name_or_path": "gpt2-small", "activation_function": "gelu_new", "architectures": [ "GPT2LMHeadModel" ], "attn_pdrop": 0.1, "bos_token_id": 50256, "embd_pdrop": 0.1, "eos_token_id": 50256, "initializer_range": 0.02, "layer_norm_epsilon": 1e-05, "model_type": "gpt2", "n_ctx": 1024, "n_embd": 768, "n_head": 12, "n_inner": null, "n_layer": 12, "n_positions": 1024, "reorder_and_upcast_attn": false, "resid_pdrop": 0.1, "scale_attn_by_inverse_layer_idx": false, "scale_attn_weights": true, "summary_activation": null, "summary_first_dropout": 0.1, "summary_proj_to_labels": true, "summary_type": "cls_index", "summary_use_proj": true, "task_specific_params": { "text-generation": { "do_sample": true, "max_length": 50 } }, "torch_dtype": "float32", "transformers_version": "4.23.1", "use_cache": true, "vocab_size": 50257}123version https://git-lfs.github.com/spec/v1oid sha256:7c5d3f4b8b76583b422fcb9189ad6c89d5d97a094541ce8932dce3ecabde1421size 548118077123456{ "bos_token": "<|endoftext|>", "eos_token": "<|endoftext|>", "pad_token": "<|endoftext|>", "unk_token": "<|endoftext|>"}12345678910{ "add_prefix_space": false, "bos_token": "<|endoftext|>", "eos_token": "<|endoftext|>", "model_max_length": 1024, "name_or_path": "gpt2", "special_tokens_map_file": null, "tokenizer_class": "GPT2Tokenizer", "unk_token": "<|endoftext|>"}README.md+163
config.jsonAdded+39
merges.txtAdded
pytorch_model.binAdded+3
special_tokens_map.jsonAdded+6
tokenizer.jsonAdded
tokenizer_config.jsonAdded+10
vocab.jsonAdded