Downloads · 30 days
9
5% of all-time downloads
SoorajK1/gpt2-hinglish-finetuned
gpt2-hinglish-finetuned is a text generation model from SoorajK1. Use it when you need the model to write or continue text. The card lists the license as apache-2.0.
This is a GPT-2 model fine-tuned on a Hinglish conversational dataset. It is trained to generate Hinglish text and predict the next word in code-mixed scenarios.
Downloads · 30 days
9
5% of all-time downloads
All-time downloads
180
Public
Parameters
124M
498 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors498 MB · 100%
From the Hugging Face model README
This is a GPT-2 model fine-tuned on a Hinglish conversational dataset. It is trained to generate Hinglish text and predict the next word in code-mixed scenarios.
This model predicts the first complete next word using the input context.
from transformers import GPT2Tokenizer, GPT2LMHeadModel
import torch, re
def clean_generated_text(text):
text = re.sub(r'^[^\w]+|[^\w]+$', '', text)
return text.strip()
def predict_first_complete_word(input_text, max_new_tokens=10):
tokenizer = GPT2Tokenizer.from_pretrained("SoorajK1/gpt2-hinglish-finetuned")
model = GPT2LMHeadModel.from_pretrained("SoorajK1/gpt2-hinglish-finetuned")
input_ids = tokenizer.encode(input_text, return_tensors="pt")
output = model.generate(input_ids, max_new_tokens=max_new_tokens)
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
continuation = generated_text[len(input_text):].lstrip()
next_match = re.match(r'^(\w+)', continuation)
return clean_generated_text(next_match.group(1) if next_match else "")