li2017dailydialog/daily_dialog
Updated • 10k • 157
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")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("jinymusim/dialogmodel")
model = AutoModelForCausalLM.from_pretrained("jinymusim/dialogmodel")How to use jinymusim/dialogmodel with vLLM:
# 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?"
}
]
}'docker model run hf.co/jinymusim/dialogmodel
How to use jinymusim/dialogmodel with SGLang:
# 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?"
}
]
}'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?"
}
]
}'How to use jinymusim/dialogmodel with Docker Model Runner:
docker model run hf.co/jinymusim/dialogmodel
Basic Dialog Model from DialoGPT-small. Finetuned on Dialog dataset. (Daily Dialog, MultiWoz)
For better usage. Use repo https://github.com/jinymusim/Daily-Dialog-GPT
If used with repo https://github.com/jinymusim/Daily-Dialog-GPT
User only needs to start the ds.py script. Otherwise use following
Use it as any torch python Language Model
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
tokenizer = AutoTokenizer.from_pretrained("jinymusim/dialogmodel")
model = AutoModelForCausalLM.from_pretrained("jinymusim/dialogmodel")
# Take user Input
user_utterance = input('USER> ')
user_utterance = user_utterance.strip()
tokenized_context = tokenizer.encode(user_utterance + tokenizer.eos_token, return_tensors='pt')
# generated a response, limit max_lenght to resonable size
out_response = model.generate(tokenized_context,
max_length=100,
num_beams=2,
no_repeat_ngram_size=2,
early_stopping=True,
pad_token_id=self.tokenizer.eos_token_id)
# Truncate User Input
decoded_response = self.tokenizer.decode(out_response[0], skip_special_tokens=True)[len(user_utterance):]
print(f'SYSTEM> {decoded_response}')
docker model run hf.co/jinymusim/dialogmodel