ChatGPT怎么用

最开始了解ChatGPT居然是抖音上看到的,之前了解过GPT-3,最开始认为可能类似的语言模型,上手以后才发现,这玩意挺有意思,某些方面,比百度强,但是比人还差十万八千里,智力不好说,最起码现在能计算1+1=2,能解一元一次方程,可能更复杂的问题,比如leetcode的题,都是可以求解的(没试过,不清楚和搜索引擎上的答案差别多少)。

美国有一部电视剧,讲的就是一个强大的AI模型,可以预测未来发生的任何事情,阻止悲剧的发生,openai做的事情,感觉不仅仅是能成为一个强大的搜索引擎,他们的目标估计更远大。

预训练的大模型这些年特别火,从Bert开始,大模型能干的事情越来越多了,openai还是牛逼!

现在还有基于RL绘图的,有人演示一次性能出一批精美的文案(广告等等)。

国内也有,比如,百度,华为,智源的悟道等等。当然,我们都还在发展当中,有人不看好国内技术的发展,现在一提“自研”,免不了很多的酸酸的字眼。 现在研究上,这种级别的大模型,普通高校是做不了的,但是有人拿这个去解决自监督,无监督,多模态的问题,其实也是思路。

下面给大家演示一下怎么使用吧。

  1. 注册openai的账号。当然需要科学的过程才行。
  2. 去vscode弄一个ChatGPT的插件,有个中文的,现在很慢,你也可以用上面的账号,试一试理解代码和debug的功能,挺有意思的。
  3. 弄一个反向代理。网上搜一下就行。比如:chartgpt

具体能干嘛呢?

ChatGPT怎么用_第1张图片

ChatGPT怎么用_第2张图片

能做的事情很多。

我测试的有:

  1. 写一个用于ncnn的nms的代码
  2. 一堆废话了

下面是写的;虽然没写全,可能是网速的原因,但是写的还不错,当然,搜索引擎也是能够做到的,这个不算是很复杂的逻辑。


#include 
#include 

// Include the NCNN header
#include "ncnn/net.h"

// A struct representing a bounding box
struct BoundingBox {
    int x1, y1, x2, y2;
    float score;
};

// Compute the intersection-over-union (IOU) of two bounding boxes
float iou(const BoundingBox& b1, const BoundingBox& b2) {
    // Compute the coordinates of the intersection rectangle
    int x1 = std::max(b1.x1, b2.x1);
    int y1 = std::max(b1.y1, b2.y1);
    int x2 = std::min(b1.x2, b2.x2);
    int y2 = std::min(b1.y2, b2.y2);

    // Compute the area of the intersection
    int w = std::max(0, x2 - x1 + 1);
    int h = std::max(0, y2 - y1 + 1);
    int intersection_area = w * h;

    // Compute the area of the union
    int b1_area = (b1.x2 - b1.x1 + 1) * (b1.y2 - b1.y1 + 1);
    int b2_area = (b2.x2 - b2.x1 + 1) * (b2.y2 - b2.y1 + 1);
    int union_area = b1_area + b2_area - intersection_area;

    // Return the IOU
    return intersection_area / union_area;
}

// Perform soft-NMS on a list of bounding boxes
// with a given overlap threshold and a sigma value
void soft_nms(std::vector& boxes, float overlap_threshold, float sigma) {
    // Sort the bounding boxes by their score in descending order
    std::sort(boxes.begin(), boxes.end(), [](const BoundingBox& b1, const BoundingBox& b2) {
        return b1.score > b2.score;
    });

    // Iterate through the bounding boxes in order of score
    for (int i = 0; i < boxes.size(); i++) {
        // Skip boxes that have already been removed
        if (boxes[i].x1 == -1) continue;

        // Iterate through the remaining bounding boxes
        for (int j = i + 1; j < boxes.size(); j++) {
            // Skip boxes that have already been removed
            if (boxes[j].x1 == -1) continue;

            // Compute the IOU of the two bounding boxes
            float iou_val = iou(boxes[i], boxes[j]);

            // If

 一堆废话的过程

ChatGPT怎么用_第3张图片

今天似乎不行了。

ChatGPT怎么用_第4张图片

 ChatGPT怎么用_第5张图片

这种简单的代码写的很快,没仔细去和网上的对比,他这个注释,不知道是如何生成的,并且语言的表达如此的准确。

ChatGPT怎么用_第6张图片

这玩意还能理解上下文信息。

ChatGPT怎么用_第7张图片 今天死活就不写代码了,估计英文会好使?

ChatGPT怎么用_第8张图片

目前还不支持创造性方面,作为程序员也可以放心了,毕竟很多工作都是要理解业务场景才能写出来的。很少有人工作当中一直写冒泡吧。 

ChatGPT怎么用_第9张图片

不得不承认,是一个好工具。 

当然,他也会格外的发挥,比如:

//
// Created by kanghaidong on 2022/12/10.
//
// Define a threshold for the minimum confidence score
// that a detection must have in order to be considered
const float threshold = 0.5;

// Loop over all the detections in the image
for (int i = 0; i < detections.size(); i++) {
// Get the confidence score for the current detection
float score = detections[i].score;

// If the score is less than the threshold, skip this detection
if (score < threshold) {
continue;
}

// Otherwise, keep this detection and suppress all other detections
// in its bounding box
for (int j = 0; j < detections.size(); j++) {
if (i == j) {
continue;
}

// Check if the bounding box of the current detection overlaps
// with the bounding box of the other detection
if (overlaps(detections[i].bbox, detections[j].bbox)) {
// If the other detection has a lower score, suppress it
if (detections[j].score < score) {
detections[j].score = 0;
}
}
}
}



// Define the overlap threshold for NMS
const float overlap_threshold = 0.5;

// Define the top-k parameter for NMS
const int top_k = 100;

// Perform NMS on the input data using the specified parameters
std::vector indices;
ncnn::Mat::nms(bboxes, scores, indices, overlap_threshold, top_k);




// Create a neural network object
ncnn::Net ssdlite;

// Load the network parameters and weights from a trained SSD-Lite model
ssdlite.load_param("ssdlite.param");
ssdlite.load_model("ssdlite.bin");

// Define the input data for the network
ncnn::Mat in = ...;

// Run the network on the input data and get the output detections
ncnn::Mat out;
ssdlite.forward(in, out);

// Extract the bounding boxes and confidence scores from the output detections
std::vector bboxes;
std::vector scores;
extract_bboxes_and_scores(out, bboxes, scores);

// Perform NMS on the output detections using the specified parameters
std::vector indices;
ncnn::Mat::nms(bboxes, scores, indices, overlap_threshold, top_k);



ncnn::Mat::nms is a method of the ncnn::Mat class in the ncnn library, which is a high-performance neural network inference framework for mobile platforms. The ncnn::Mat class represents a multi-dimensional matrix of data, and the ncnn::Mat::nms method performs non-maximum suppression (NMS) on a set of bounding boxes and confidence scores using the specified overlap threshold and top-k parameter.

The ncnn::Mat::nms method takes three arguments: the bounding boxes, the confidence scores, and a vector of indices representing the detections that were kept after NMS. The method applies NMS to the input data using the specified overlap threshold and top-k parameter, and returns the indices of the detections that were kept.

Here is an example of how you might use the ncnn::Mat::nms method:


// Define the overlap threshold for NMS
const float overlap_threshold = 0.5;

// Define the top-k parameter for NMS
const int top_k = 100;

// Perform NMS on the input data using the specified parameters
std::vector indices;
ncnn::Mat::nms(bboxes, scores, indices, overlap_threshold, top_k);

实际上,Mat是不存在nms的。

你可以实现不同语言之间的转换,比如python2c++,但是正确性就不保证了。

你可能感兴趣的:(deep,learning,linux,nlp,深度学习,pytorch,python)