Instructions to use Ashishkr/Gpt2-paraphrase_generation with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Ashishkr/Gpt2-paraphrase_generation with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Ashishkr/Gpt2-paraphrase_generation")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Ashishkr/Gpt2-paraphrase_generation") model = AutoModelForCausalLM.from_pretrained("Ashishkr/Gpt2-paraphrase_generation", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Ashishkr/Gpt2-paraphrase_generation with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Ashishkr/Gpt2-paraphrase_generation" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Ashishkr/Gpt2-paraphrase_generation", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Ashishkr/Gpt2-paraphrase_generation
- SGLang
How to use Ashishkr/Gpt2-paraphrase_generation 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 "Ashishkr/Gpt2-paraphrase_generation" \ --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": "Ashishkr/Gpt2-paraphrase_generation", "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 "Ashishkr/Gpt2-paraphrase_generation" \ --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": "Ashishkr/Gpt2-paraphrase_generation", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Ashishkr/Gpt2-paraphrase_generation with Docker Model Runner:
docker model run hf.co/Ashishkr/Gpt2-paraphrase_generation
Author: Ashish Kumar, Head of Platforms, AI & Data at Tata Group ยท ashishkumar.ai ยท Wikidata
Use this model to generate variations to augment the training data used for NLU systems.
from transformers import AutoTokenizer, AutoModelWithLMHead
import torch
if torch.cuda.is_available():
device = torch.device("cuda")
else :
device = "cpu"
tokenizer = AutoTokenizer.from_pretrained("Ashishkr/Gpt2-paraphrase_generation")
model = AutoModelWithLMHead.from_pretrained("Ashishkr/Gpt2-paraphrase_generationn").to(device)
input_query="every moment is a fresh beginning"
query= input_query + " ~~ "
input_ids = tokenizer.encode(query.lower(), return_tensors='pt').to(device)
sample_outputs = model.generate(input_ids,
do_sample=True,
num_beams=1,
max_length=128,
temperature=0.9,
top_p= 0.99,
top_k = 30,
num_return_sequences=40)
paraphrases = []
for i in range(len(sample_outputs)):
r = tokenizer.decode(sample_outputs[i], skip_special_tokens=True).split('||')[0]
r = r.split(' ~~ ')[1]
if r not in paraphrases:
paraphrases.append(r)
print(paraphrases)
To evaluate if a paraphrase is a semantic variation to the input query or just a surface level variation & rank the generated paraphrases, use the following model:
- Downloads last month
- 688