File size: 1,232 Bytes
48fa959
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
library_name: onnx
tags:
  - text-generation
  - gpt2
  - onnx
  - inference4j
license: mit
pipeline_tag: text-generation
---

# GPT-2 — ONNX

ONNX export of [GPT-2](https://huggingface.co/openai-community/gpt2) (124M parameters) with KV cache support for efficient autoregressive generation.

Converted for use with [inference4j](https://github.com/inference4j/inference4j), an inference-only AI library for Java.

## Original Source

- **Repository:** [OpenAI](https://huggingface.co/openai-community/gpt2)
- **License:** MIT

## Usage with inference4j

```java
try (Gpt2TextGenerator gen = Gpt2TextGenerator.builder().build()) {
    GenerationResult result = gen.generate("Once upon a time");
    System.out.println(result.text());
}
```

## Model Details

| Property | Value |
|----------|-------|
| Architecture | GPT-2 (124M parameters, 12 layers, 768 hidden, 12 heads) |
| Task | Text generation |
| Context length | 1024 tokens |
| Vocabulary | 50257 tokens (BPE) |
| Original framework | PyTorch (transformers) |
| Export method | Hugging Face Optimum (with KV cache) |

## License

This model is licensed under the [MIT License](https://opensource.org/licenses/MIT). Original model by [OpenAI](https://openai.com/).