This is a fine-tuned version of the GPT-2 model designed for text generation tasks. The model has been fine-tuned to improve its performance on generating coherent and contextually relevant text.
To use this model for text generation via the Hugging Face API, use the following Python code snippet:
1import requests
2
3api_url = "https://api-inference.huggingface.co/models/rahul77/gpt-2-finetune"
4headers = {
5 "Authorization": "Bearer YOUR_API_TOKEN", # Replace with your Hugging Face API token
6 "Content-Type": "application/json"
7}
8
9data = {
10 "inputs": "What is a large language model?",
11 "parameters": {
12 "max_length": 50
13 }
14}
15
16response = requests.post(api_url, headers=headers, json=data)
17
18if response.status_code == 200:
19 print(response.json())
20else:
21 print(f"Error: {response.status_code}")
22 print(response.json())