Use Github and Railway to build your own ChatGPT

王林
Release: 2023-04-13 20:31:01
forward
1833 people have browsed it

ChatGPT

What is ChatGPT

ChatGPT is a natural language processing model based on artificial neural network technology, developed by OpenAI. It can understand and generate natural language for tasks such as conversation, translation, text summarization, and more. ChatGPT is one of the most advanced natural language processing models currently. It uses a large amount of pre-training data and deep learning algorithms to achieve high-quality natural language processing capabilities.

How ChatGPT works

ChatGPT is a natural language processing model based on the Transformer model. Its working principle can be divided into two stages: pre-training and fine-tuning. These two stages are introduced in detail below.

  1. Pre-training stage

ChatGPT uses a large amount of text data for unsupervised pre-training, thereby learning the representation of natural language. In this phase, ChatGPT uses a technique called “masked language modeling” to train the model. Specifically, it randomly masks out some words in the input text, and then lets the model predict these masked words. This training method allows the model to learn the relationship between words, thereby obtaining better language representation capabilities.

  1. Fine-tuning phase

After the pre-training is completed, ChatGPT can be fine-tuned to adapt to specific tasks. For example, for conversational tasks, we can fine-tune the model by giving ChatGPT some known conversation history and current responses, making it better at generating meaningful responses. In the fine-tuning phase, ChatGPT usually uses a supervised learning method, that is, using annotated data for training and updating the model parameters by optimizing the loss function. In summary, ChatGPT works by learning natural language representations through two stages of pre-training and fine-tuning, and using these representations in specific tasks to generate meaningful output.

ChatGPT usage scenarios

ChatGPT is a general natural language processing model with a wide range of usage scenarios. The following are some of the main application scenarios of ChatGPT:

  1. Dialogue system: ChatGPT can be used to build chat robots, intelligent customer service and other dialogue systems, and generate natural and smooth responses by learning a large amount of dialogue data.
  2. Machine translation: ChatGPT can be used to perform machine translation tasks, that is, automatically translating text in one language into text in another language.
  3. Text summarization: ChatGPT can be used to perform text summarization tasks, that is, to extract key information from a longer article and generate a concise summary.
  4. Question and answer system: ChatGPT can be used to build a question and answer system, that is, to answer user questions. In this scenario, ChatGPT usually needs to read and understand the input question and generate the answer through search or reasoning.
  5. Text classification: ChatGPT can be used for text classification tasks, such as sentiment analysis, spam detection, etc. In this scenario, ChatGPT needs to learn how to map text to different categories.

Hey, wait, isn’t this all nonsense? Where is it used?

It depends on your specific needs. For example, the content above this article was written by ChatGPT.

Use Github and Railway to build your own ChatGPT

For example, I asked it to help me write a step to create a pipeline.

Use Github and Railway to build your own ChatGPT

Isn’t this better than Baidu?

The following is a guide to build a ChatGPT that does not require scientific Internet access.

Register ChatGPT

The registration steps are not complicated and mainly include the following steps:

  1. Register ChatGPT account
  2. Through SMS code receiving platform [https://sms-activate.org/](https://sms-activate.org/)Complete mobile phone verification
  3. pass[https://chat.openai.com/chat](https: //chat.openai.com/chat) Log in and use

to obtain the API Token

After the account registration is completed, log in through https://platform.openai.com/.

Use Github and Railway to build your own ChatGPT

image.png

Then click Personal to get API Keys.

Use Github and Railway to build your own ChatGPT

Create a new Secret Key.

Use Github and Railway to build your own ChatGPT

Get the Github code

Write the project yourself?

impossible! Prostitution is fragrant only if it is free.

Fork the https://github.com/Chanzhaoyu/chatgpt-web project into your own warehouse.

Use Github and Railway to build your own ChatGPT

Isn’t this pleasant?

Start deployment

Buy a server? install software? Install Docker?

No! ! !

The cost is too high. Here we directly use foreign deployment websites, currently the more famous ones are:

  • fly.io
  • render.com
  • railway.app
  • vercel.com

We choose raliway.app to carry out our deployment work. Visit: https://railway.app/, click Login, select Github to log in, and perform relevant authorization:

Use Github and Railway to build your own ChatGPT

Create Project

Click New Project.

Use Github and Railway to build your own ChatGPT

Then select Deploy from Github repo.

Use Github and Railway to build your own ChatGPT

Then select the chatgpt-web project.

Use Github and Railway to build your own ChatGPT

Then click Deploy Now.

During the deployment process, the image will be built and you can view the specific logs.

Use Github and Railway to build your own ChatGPT

But now the application cannot start normally because we have not configured the ChatGPT API Key, and the error is as follows:

Use Github and Railway to build your own ChatGPT

Add configuration

In order to start normally, we need to add the OPENAI_API_KEY or OPENAI_ACCESS_TOKEN parameter. I use the former here, and also add a PORT parameter, the default port is 3002. In addition, I also added the AUTH_SECRET_KEY parameter, mainly to add a layer of access control to our own GPT to prevent anyone from using it.

After the addition is completed, the following is as follows:

Use Github and Railway to build your own ChatGPT

Let’s look at the application log again. The application started successfully.

Use Github and Railway to build your own ChatGPT

Access

1. We can generate a random domain name in Settings, as follows:

Use Github and Railway to build your own ChatGPT

Then you can use a random domain name to access.

Use Github and Railway to build your own ChatGPT

#2. To use a custom domain name, the premise is that you need to prepare an available domain name yourself.

First, add a custom domain name.

Use Github and Railway to build your own ChatGPT

Then, add a CNAME.

Use Github and Railway to build your own ChatGPT

Then you can have a conversation.

Update

If the main code is updated, we only need to synchronize the latest code on Github.

Use Github and Railway to build your own ChatGPT

Then Railway will update automatically.

About Railway

Railway provides a quota of 5 US dollars and 500 hours/month. When it is used up, you have to recharge or die. You can choose according to the actual situation. It is actually enough for personal use. It's nothing more than getting a few more accounts.

The above is the detailed content of Use Github and Railway to build your own ChatGPT. For more information, please follow other related articles on the PHP Chinese website!

source:51cto.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!