GithubHelp home page GithubHelp logo

pyyush / gpt Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 8 KB

Text Generation demo using GPT-2 + Gradio/FastAPI

Python 100.00%
fastapi generative-ai generative-model gpt gpt-2 gradio language-model natural-language-processing

gpt's Introduction

Text Generation GPT-2

This repository contains code for a text generation demo using GPT-2 with Gradio/FastAPI. The GPT-2 model is a language model developed by OpenAI that generates text based on the input text prompt.

Setup

Before running the code, please ensure that you have installed the required dependencies mentioned in the requirements.txt file. You can do this by running the following command in your terminal:

pip3 install -r requirements.txt

FastAPI

To run the FastAPI web server, you can use the following command in your terminal:

uvicorn fastAPI:app 

Once the server is up and running, you can access the Swagger documentation for the API at http://127.0.0.1:8000/docs
Alternatively, you can use the curl command to generate text as shown below:

curl -X 'POST' \
  'http://127.0.0.1:8000/generate' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "prompt": "I love playing volleyball",
  "max_tokens_to_generate": 50
}'

Gradio

To run the Gradio web application, you can use the following command in your terminal:

python3 Gradio.py

Once the server is up and running, you can access the web application at http://127.0.0.1:7860
The web application allows you to enter a text prompt and generate text using the GPT-2 model. You can also select the maximum number of tokens to generate.

gpt's People

Contributors

pyyush avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.