Text Generation
Transformers
PyTorch
Safetensors
English
gpt2
conversational
text-generation-inference
Instructions to use jinymusim/dialogmodel with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jinymusim/dialogmodel with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="jinymusim/dialogmodel")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("jinymusim/dialogmodel") model = AutoModelForCausalLM.from_pretrained("jinymusim/dialogmodel", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use jinymusim/dialogmodel with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "jinymusim/dialogmodel" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jinymusim/dialogmodel", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/jinymusim/dialogmodel
- SGLang
How to use jinymusim/dialogmodel 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 "jinymusim/dialogmodel" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jinymusim/dialogmodel", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "jinymusim/dialogmodel" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jinymusim/dialogmodel", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use jinymusim/dialogmodel with Docker Model Runner:
docker model run hf.co/jinymusim/dialogmodel
Update README.md
Browse files
README.md
CHANGED
|
@@ -6,4 +6,34 @@ language:
|
|
| 6 |
- en
|
| 7 |
---
|
| 8 |
Basic Dialog Model from DialoGPT-small.
|
| 9 |
-
Finetuned on Daily Dialog dataset.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
- en
|
| 7 |
---
|
| 8 |
Basic Dialog Model from DialoGPT-small.
|
| 9 |
+
Finetuned on Daily Dialog dataset.
|
| 10 |
+
|
| 11 |
+
### How to use
|
| 12 |
+
|
| 13 |
+
Use it as any torch python Language Model
|
| 14 |
+
|
| 15 |
+
```python
|
| 16 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 17 |
+
import torch
|
| 18 |
+
|
| 19 |
+
tokenizer = AutoTokenizer.from_pretrained("gpt")
|
| 20 |
+
model = AutoModelForCausalLM.from_pretrained("jinymusim/dialogmodel")
|
| 21 |
+
|
| 22 |
+
# Take user Input
|
| 23 |
+
user_utterance = input('USER> ')
|
| 24 |
+
user_utterance = user_utterance.strip()
|
| 25 |
+
tokenized_context = tokenizer.encode(user_utterance + tokenizer.eos_token, return_tensors='pt')
|
| 26 |
+
|
| 27 |
+
# generated a response, limit max_lenght to resonable size
|
| 28 |
+
out_response = model.generate(tokenized_context,
|
| 29 |
+
max_length=30,
|
| 30 |
+
num_beams=2,
|
| 31 |
+
no_repeat_ngram_size=2,
|
| 32 |
+
early_stopping=True,
|
| 33 |
+
pad_token_id=self.tokenizer.eos_token_id)
|
| 34 |
+
|
| 35 |
+
# Truncate User Input
|
| 36 |
+
decoded_response = self.tokenizer.decode(out_response[0], skip_special_tokens=True)[len(user_utterance):]
|
| 37 |
+
|
| 38 |
+
print(f'SYSTEM> {decoded_response}')
|
| 39 |
+
```
|