Downloads · 30 days
1
17% of all-time downloads
alexdjulin/lafontaine-gpt
lafontaine-gpt is a text generation model from alexdjulin. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
This is a language model based on La Fontaine's fables. It uses a transformer-based architecture to generate text inspired by La Fontaine's style.
Downloads · 30 days
1
17% of all-time downloads
All-time downloads
6
Public
Repo size
97 MB
Likes
0
Public
Click a slice to open those files.
.pth52.7 MB · 100%
From the Hugging Face model README
This is a language model based on La Fontaine's fables. It uses a transformer-based architecture to generate text inspired by La Fontaine's style.
To interact with the model, you can use the following Gradio script:
import gradio as gr
import torch
# Assuming 'BigramLanguageModel' and 'decode' are defined as in your model code
class GradioInterface:
def __init__(self, model_path="lafontaine_gpt_v1.pth"):
self.device = 'cuda' if torch.cuda.is_available() else 'cpu'
self.model = self.load_model(model_path)
self.model.eval()
def load_model(self, model_path):
model = BigramLanguageModel().to(self.device)
model.load_state_dict(torch.load(model_path, map_location=self.device))
return model
def generate_text(self, input_text, max_tokens=100):
context = torch.tensor([encode(input_text)], dtype=torch.long, device=self.device)
output = self.model.generate(context, max_new_tokens=max_tokens)
return decode(output[0].tolist())
# Load the model
model_interface = GradioInterface()
# Define Gradio interface
gr_interface = gr.Interface(
fn=model_interface.generate_text,
inputs=["text", gr.Slider(50, 500)],
outputs="text",
description="Bigram Language Model text generation. Enter some text, and the model will continue it.",
examples=[["Once upon a time"]]
)
# Launch the interface
gr_interface.launch()
You can use this model in your own projects by loading the model weights and running it on your input text.