Instructions to use rmihaylov/gpt2-medium-bg with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use rmihaylov/gpt2-medium-bg with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="rmihaylov/gpt2-medium-bg", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("rmihaylov/gpt2-medium-bg", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("rmihaylov/gpt2-medium-bg", trust_remote_code=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use rmihaylov/gpt2-medium-bg with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "rmihaylov/gpt2-medium-bg" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rmihaylov/gpt2-medium-bg", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/rmihaylov/gpt2-medium-bg
- SGLang
How to use rmihaylov/gpt2-medium-bg 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 "rmihaylov/gpt2-medium-bg" \ --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": "rmihaylov/gpt2-medium-bg", "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 "rmihaylov/gpt2-medium-bg" \ --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": "rmihaylov/gpt2-medium-bg", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use rmihaylov/gpt2-medium-bg with Docker Model Runner:
docker model run hf.co/rmihaylov/gpt2-medium-bg
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
inference: false
|
| 3 |
+
language:
|
| 4 |
+
- bg
|
| 5 |
+
license: mit
|
| 6 |
+
datasets:
|
| 7 |
+
- oscar
|
| 8 |
+
- chitanka
|
| 9 |
+
- wikipedia
|
| 10 |
+
tags:
|
| 11 |
+
- torch
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# GPT-2
|
| 15 |
+
|
| 16 |
+
Pretrained model on Bulgarian language using a causal language modeling (CLM) objective. It was introduced in
|
| 17 |
+
[this paper](https://d4mucfpksywv.cloudfront.net/better-language-models/language_models_are_unsupervised_multitask_learners.pdf)
|
| 18 |
+
and first released at [this page](https://openai.com/blog/better-language-models/).
|
| 19 |
+
|
| 20 |
+
## Model description
|
| 21 |
+
|
| 22 |
+
This is the **MEDIUM** version.
|
| 23 |
+
|
| 24 |
+
The training data is Bulgarian text from [OSCAR](https://oscar-corpus.com/post/oscar-2019/), [Chitanka](https://chitanka.info/) and [Wikipedia](https://bg.wikipedia.org/).
|
| 25 |
+
|
| 26 |
+
## Intended uses & limitations
|
| 27 |
+
|
| 28 |
+
You can use the raw model for:
|
| 29 |
+
- text generation
|
| 30 |
+
- auto-complete
|
| 31 |
+
- spelling correction
|
| 32 |
+
|
| 33 |
+
Or fine-tune it to a downstream task.
|
| 34 |
+
|
| 35 |
+
### How to use
|
| 36 |
+
|
| 37 |
+
Here is how to use this model in PyTorch:
|
| 38 |
+
|
| 39 |
+
```python
|
| 40 |
+
>>> from transformers import AutoModel, AutoTokenizer
|
| 41 |
+
>>>
|
| 42 |
+
>>> model_id = "rmihaylov/gpt2-medium-bg"
|
| 43 |
+
>>> tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 44 |
+
>>> model = AutoModel.from_pretrained(model_id, trust_remote_code=True)
|
| 45 |
+
>>>
|
| 46 |
+
>>> input_ids = tokenizer.encode(
|
| 47 |
+
>>> "Здравей,",
|
| 48 |
+
>>> add_special_tokens=False,
|
| 49 |
+
>>> return_tensors='pt')
|
| 50 |
+
>>>
|
| 51 |
+
>>> output_ids = model.generate(
|
| 52 |
+
>>> input_ids,
|
| 53 |
+
>>> do_sample=True,
|
| 54 |
+
>>> max_length=50,
|
| 55 |
+
>>> top_p=0.92,
|
| 56 |
+
>>> pad_token_id=2,
|
| 57 |
+
>>> top_k=0)
|
| 58 |
+
>>>
|
| 59 |
+
>>> output = tokenizer.decode(output_ids[0])
|
| 60 |
+
>>>
|
| 61 |
+
>>> output = output.replace('<|endoftext|>', '\n\n\n')
|
| 62 |
+
>>> output = output.replace('<|unknown|>', '')
|
| 63 |
+
>>> output = output.replace('▁', ' ')
|
| 64 |
+
>>> output = output.replace('<|n|>', '\n')
|
| 65 |
+
>>>
|
| 66 |
+
>>> print(output)
|
| 67 |
+
|
| 68 |
+
Здравей, господин Фиш. — Добс забеляза как пребледня Ривера.
|
| 69 |
+
— Не си тръгвайте още. Имам да ви задам няколко въпроса.
|
| 70 |
+
— Благодаря, благодаря. — Фиш не изчака да му покаже, че е забелязал жеста й
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
### Limitations and bias
|
| 74 |
+
|
| 75 |
+
As the openAI team themselves point out in their
|
| 76 |
+
[model card](https://github.com/openai/gpt-2/blob/master/model_card.md#out-of-scope-use-cases):
|
| 77 |
+
|
| 78 |
+
> Because large-scale language models like GPT-2 do not distinguish fact from fiction, we don’t support use-cases
|
| 79 |
+
> that require the generated text to be true.
|
| 80 |
+
>
|
| 81 |
+
> Additionally, language models like GPT-2 reflect the biases inherent to the systems they were trained on, so we do
|
| 82 |
+
> not recommend that they be deployed into systems that interact with humans > unless the deployers first carry out a
|
| 83 |
+
> study of biases relevant to the intended use-case. We found no statistically significant difference in gender, race,
|
| 84 |
+
> and religious bias probes between 774M and 1.5B, implying all versions of GPT-2 should be approached with similar
|
| 85 |
+
> levels of caution around use cases that are sensitive to biases around human attributes.
|