News from this site

 Rental advertising space, please contact the webmaster if you need cooperation


+focus
focused

classification  

no classification

tag  

no tag

date  

no datas

ChatGPT的N种用法(持续更新中。。。)

posted on 2023-05-21 16:54     read(373)     comment(0)     like(3)     collect(3)



foreword

ChatGPT today is a powerful language model that can help you create great products and increase your business success. ChatGPT utilizes large-scale natural language processing and machine learning algorithms to conduct natural and fluent conversations and understand natural language questions and answers. You can use ChatGPT to build a variety of products such as smart customer service, smart assistant, text auto-completion, speech recognition and machine translation. ChatGPT can quickly adapt to new data and new scenarios. With ChatGPT, you can easily achieve personalized, efficient and all-weather services. Let ChatGPT help you grow your business!

1. Grammatical correction

Purpose : Polishing articles, papers, etc.
insert image description here

2. Text translation

Uses : daily study, business translation, etc.
insert image description here

3. Language conversion

3-1、Python–>JAVA

Purpose : For work purposes, it is more convenient for cooperation between different language engineers.
insert image description here

import numpy as np
import plotly.express as px

def thresholding_algo(y, lag, threshold):
    """
    :param y: 输入列表
    :param lag: 滑动窗口大小
    :param threshold: 调节系数,用于调节容忍范围的大小。
    :return:
    """
    # signals:信号列表
    signals = np.zeros(len(y))
    avgFilter = np.zeros(len(y))

    # 初始化平均值列表、差值列表
    avgFilter[lag - 1] = np.mean(y[0:lag])
    dif_li = [0] * len(y)

    for i in range(lag, len(y)):
        if i < len(y) - lag - 30:
            for j in range(i + 11, len(y)):
                if y[j] >= y[i - 1]:
                    break
            if j >= len(y) - 30:
                back = y[i - 1]
            else:
                back = np.mean(y[j + 11:j + 20 + lag])
        else:
            back = y[i - 1]

        # 前后均值差值计算
        tmp = abs(back - avgFilter[i - 1])
        dif = (tmp if tmp > 1 else 1)

        if abs(y[i] - avgFilter[i - 1]) > dif * threshold:
            signals[i] = (1 if y[i] > avgFilter[i - 1] else -1)
            avgFilter[i] = np.mean(y[(i - lag):i])
            y[i] = avgFilter[i - 1]
        else:
            signals[i] = 0
            avgFilter[i] = np.mean(y[(i - lag):i])

        dif_li[i] = dif

    return dict(signals=np.asarray(signals),
                avgFilter=np.asarray(avgFilter),
                y=np.asarray(y),
                dif=np.asarray(dif_li),
                )

insert image description here

public static Map<String, double[]> thresholding_algo(double[] y, int lag, double threshold) {

    double[] signals = new double[y.length];
    double[] avgFilter = new double[y.length];
    Arrays.fill(avgFilter, 0.0);

    avgFilter[lag - 1] = mean(Arrays.copyOfRange(y, 0, lag));
    double[] dif_li = new double[y.length];
    Arrays.fill(dif_li, 0.0);

    for (int i = lag; i < y.length; i++) {
        int j;
        if (i < y.length - lag - 30) {
            for (j = i + 11; j < y.length; j++) {
                if (y[j] >= y[i - 1]) {
                    break;
                }
            }
            double back;
            if (j >= y.length - 30) {
                back = y[i - 1];
            } else {
                back = mean(Arrays.copyOfRange(y, j + 11, j + 20 + lag));
            }
        } else {
            back = y[i - 1];
        }

        double tmp = Math.abs(back - avgFilter[i - 1]);
        double dif = tmp > 1 ? tmp : 1;

        if (Math.abs(y[i] - avgFilter[i - 1]) > dif * threshold) {
            signals[i] = y[i] > avgFilter[i - 1] ? 1 : -1;
            avgFilter[i] = mean(Arrays.copyOfRange(y, i - lag, i));
            y[i] = avgFilter[i - 1];
        } else {
            signals[i] = 0;
            avgFilter[i] = mean(Arrays.copyOfRange(y, i - lag, i));
        }

        dif_li[i] = dif;
    }

    Map<String, double[]> result = new HashMap<>();
    result.put("signals", signals);
    result.put("avgFilter", avgFilter);
    result.put("y", y);
    result.put("dif", dif_li);

    return result;
}

private static double mean(double[] array) {
    double sum = 0.0;
    for (double d : array) {
        sum += d;
    }
    return sum / array.length;
}

4. Code Explanation-1

Purpose : When we come to a new company and find that the former engineer has left a pile of codes that no one can understand, at this time, if someone can help us explain what these codes mean, then we will not be too happy.
insert image description here

def Fusion_algorithm(y_list):
    """
    最终的融合算法
    1、第一次遍历列表: 处理掉小于上一个值的点,使其等于上一个值。
    2、第二次使用z-score来处理异常点:一种基于统计方法的时序异常检测算法借鉴了一些经典的统计方法,比如Z-score和移动平均线
    该算法将时间序列中的每个数据点都看作是来自一个正态分布,通过计算每个数据点与其临接数据点的平均值和标准差,可以获得Z-score
    并将其用于检测异常值,将z-score大于3的数据点视为异常值,缺点:如果异常点太多,则该算法的准确性较差。
    3:param y_list: 传入需要处理的时间序列
    :return:
    """
    # 第一次处理
    for i in range(1, len(y_list)):
        difference = y_list[i] - y_list[i - 1]
        if difference <= 0:
            y_list[i] = y_list[i - 1]
        # 基于突变检测的方法:如果一个数据点的值与前一个数据点的值之间的差异超过某个阈值,
        # 则该数据点可能是一个突变的异常点。这种方法需要使用一些突变检测算法,如Z-score突变检测、CUSUM(Cumulative Sum)
        # else:
        #     if abs(difference) > 2 * np.mean(y_list[:i]):
        #         y_list[i] = y_list[i - 1]

    # 第二次处理
    # 计算每个点的移动平均值和标准差
    ma = np.mean(y_list)
    # std = np.std(np.array(y_list))
    std = np.std(y_list)
    # 计算Z-score
    z_score = [(x - ma) / std for x in y_list]
    # 检测异常值
    for i in range(len(y_list)):
        # 如果z-score大于3,则为异常点,去除
        if z_score[i] > 3:
            print(y_list[i])
            y_list[i] = y_list[i - 1]

    return y_list

insert image description here

5. Code Explanation-2

Remarks : In the previous code explanation, we can see that the answer may be affected by the comments in the code. Let's delete the comments and try again. For some points in the explanation that we don't understand, we can continue to ask!

insert image description here

import numpy as np
from sklearn.ensemble import IsolationForest
import plotly.express as px
import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
import json

def Fusion_algorithm(y_list):
    for i in range(1, len(y_list)):
        difference = y_list[i] - y_list[i - 1]
        if difference <= 0:
            y_list[i] = y_list[i - 1]
    
        # else:
        #     if abs(difference) > 2 * np.mean(y_list[:i]):
        #         y_list[i] = y_list[i - 1]


    ma = np.mean(y_list)
    std = np.std(y_list)
    z_score = [(x - ma) / std for x in y_list]
    for i in range(len(y_list)):
        if z_score[i] > 3:
            print(y_list[i])
            y_list[i] = y_list[i - 1]

    return y_list

insert image description here
insert image description here

6. Fix code errors

Purpose : Find an error after writing a piece of code? Let chatGPT help you!
insert image description here

### Buggy Python
import Random
a = random.randint(1,12)
b = random.randint(1,12)
for i in range(10):
    question = "What is "+a+" x "+b+"? "
    answer = input(question)
    if answer = a*b
        print (Well done!)
    else:
        print("No.")

insert image description here

7. As an encyclopedia

Uses : chatGPT can explain all your questions! However, the function of listing novels is a bit stretched. After testing, only the science fiction column is okay, and other genres are not so good. Maybe the chatgpt training engineer is a science fiction fan!
insert image description here

8. Information Extraction

Purpose : As a large model in the field of natural language processing , how can information extraction be missing?
insert image description here

9. Chatting with friends

Purpose : Enter the character of the other party to simulate chatting. The function in this aspect is not perfect, and there may be new ways to play that I haven't discovered yet.
insert image description here
insert image description here

10. Idea Generator

Purpose : Do you often encounter thinking bottlenecks in innovation and don't know how to do it? Don't worry, let chatGPT help you generate ideas!

10-1. Combination of VR and Chamber of Secrets

insert image description here

10-2. Combined with AR

insert image description here

11. Interview Questions

Purpose : Maybe you are a media worker and don't know how to write interview questions? chatGPT can help you solve it.

11-1. List of interview questions

insert image description here

11-2. List of interview questions and give corresponding answers

insert image description here

12. Thesis Outline

Purpose : This function is not too cool for graduate students. I have been depressed about how to write the outline. Listing the outline directly has really helped me a lot! For points that are not understood in the outline, directly ask chatGPT for further explanation. Codes are also available! The content of that chapter is not very good at writing, so let chatGPT arrange it directly, so that a paper will be written soon!

12-1. Create a thesis outline

insert image description here

12-2. Explain the content of the outline

insert image description here

class PBA(nn.Module):
    def __init__(self, PerformanceThreshold, DistributionType, AttentionWeightRange):
        super(PBA, self).__init__()
        self.PerformanceThreshold = PerformanceThreshold
        self.DistributionType = DistributionType
        self.AttentionWeightRange = AttentionWeightRange
        
    def forward(self, input, performance_scores):
        # 计算注意力分数
        attention_scores = []
        for i in range(len(input)):
            if performance_scores[i] > self.PerformanceThreshold:
                attention_scores.append(performance_scores[i])
            else:
                attention_scores.append(0.0)
                
        # 将性能分数映射到注意力权重
        if self.DistributionType == "softmax":
            attention_weights = F.softmax(torch.tensor(attention_scores), dim=0)
        elif self.DistributionType == "sigmoid":
            attention_weights = torch.sigmoid(torch.tensor(attention_scores))
        else:
            raise ValueError("Unknown distribution type: {}".format(self.DistributionType))
        
        # 缩放注意力权重到指定范围
        attention_weights = attention_weights * (self.AttentionWeightRange[1] - self.AttentionWeightRange[0]) + self.AttentionWeightRange[0]
        
        # 计算加权输入
        weighted_input = torch.mul(input, attention_weights.unsqueeze(1).expand_as(input))
        output = torch.sum(weighted_input, dim=0)
        
        return output

13. Story Creation

Purpose : This function is really awesome. I can write novels after I make an outline myself!

13-1. Love story

insert image description here

13-2. Horror stories

insert image description here
insert image description here

Fourteen, problem analogy

Uses : This is a great feature when you want to make a metaphor.
insert image description here

15. Create SQL requirements

Purpose : Writing SQL is sometimes a headache, and I can't remember it for a long time.

insert image description here

16. Sentiment Analysis

Purpose : This function reminds me of the sentiment analysis task I did in the previous company.
insert image description here

17. Turn product descriptions into ads

Uses : This feature is awesome for merchants.
insert image description here

18. Keyword extraction

Purpose : The important role of NLP tasks, keyword extraction!
insert image description here

19. Chatbots

Purpose : Not much to say about this, it’s really good experience for chatting.
insert image description here
insert image description here
insert image description here


20. Summary

emmm, there are too many chatGPT chats for free today, the request request has been banned, so please request another day~



Category of website: technical article > Blog

Author:Believesinkinto

link:http://www.pythonblackhole.com/blog/article/25290/c6a3dd9fbcf1cc56a54f/

source:python black hole net

Please indicate the source for any form of reprinting. If any infringement is discovered, it will be held legally responsible.

3 0
collect article
collected

Comment content: (supports up to 255 characters)