Instructions to use alexdjulin/lafontaine-gpt with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use alexdjulin/lafontaine-gpt with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="alexdjulin/lafontaine-gpt")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("alexdjulin/lafontaine-gpt", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use alexdjulin/lafontaine-gpt with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "alexdjulin/lafontaine-gpt" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "alexdjulin/lafontaine-gpt", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/alexdjulin/lafontaine-gpt
- SGLang
How to use alexdjulin/lafontaine-gpt 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 "alexdjulin/lafontaine-gpt" \ --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": "alexdjulin/lafontaine-gpt", "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 "alexdjulin/lafontaine-gpt" \ --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": "alexdjulin/lafontaine-gpt", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use alexdjulin/lafontaine-gpt with Docker Model Runner:
docker model run hf.co/alexdjulin/lafontaine-gpt
Lafontaine GPT Model
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.
Using the Model with Gradio
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()
Model Details
- Architecture: Transformer-based bigram language model
- Dataset: La Fontaine's fables
How to Use
You can use this model in your own projects by loading the model weights and running it on your input text.
Evaluation results
- Perplexity on La Fontaine's Fablesself-reported15.200