V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
shinession
V2EX  ›  分享发现

今天试了下 Chat GPT, 惊了, 可以提高生产力, 取代大部分 stack overflow 功能

  •  
  •   shinession · 2022-12-07 14:05:38 +08:00 · 3383 次点击
    这是一个创建于 477 天前的主题,其中的信息可能已经有所发展或是发生改变。
    起因是有个部门分享的 data 是 power BI 数据源 API,我想把这些数据用 python 读取到 pandas 里面,昨天花了很久研究 M query, 不会转换双引号:(, 拿不到 token,刚刚试了下 ChatGPT 给的 code,一次成功.
    太厉害了, 以后不用去 stack overflow 了

    我: can you convert power bi m code to python?

    ChatGPT: Yes, it is possible to convert Power BI M code to Python. However, the conversion process may not be straightforward and will depend on the specific M code that you are trying to convert. Power BI M code is a proprietary language used in the Power BI platform, while Python is a general-purpose programming language that is widely used in data analysis and scientific computing.

    If you have specific M code that you would like to convert to Python, I would recommend that you provide the code and I can try to assist you with the conversion. It would also be helpful to know the reason why you want to convert the M code to Python and what you plan to do with the resulting Python code.

    我:
    let body1 ="{
    ""username"": " & username &",
    ""password"": "& password &"

    }",



    getToken =
    Web.Contents(server & tokenAddress, [Content=Text.ToBinary(body1)]),



    token1 = "Bearer " & Text.FromBinary(getToken),

    ChatGPT: This Power BI M code is defining several variables and making a web request to get a token. The body1 variable is defining the body of the request as a string containing the username and password values. The getToken variable is making a web request to the server & tokenAddress URL with the body1 content. Finally, the token1 variable is constructing a string by concatenating the Bearer string with the response from the getToken web request.

    In Python, you can use the requests library to make web requests and parse the response. Here is an example of how the above Power BI M code could be converted to Python:

    Copy code
    import requests

    username = "your_username"
    password = "your_password"
    server = "http://your_server.com"
    tokenAddress = "/api/get_token"

    body1 = {
    "username": username,
    "password": password
    }

    getToken = requests.post(server + tokenAddress, json=body1)
    token1 = "Bearer " + getToken.text
    Note that this is just an example and may not work exactly as shown if the actual Power BI M code is different from what you provided. You may need to adjust the code depending on the details of your specific use case.
    18 条回复    2022-12-12 19:15:11 +08:00
    Vitta
        1
    Vitta  
       2022-12-07 14:06:44 +08:00
    问他个 flutter Semantics 的问题都不告诉我
    FishingRabbit
        2
    FishingRabbit  
       2022-12-07 14:54:37 +08:00
    确实很强,我试了下之前百度谷歌很久没找到答案的问题,它直接就给我解决了,太强了,省去了长时间搜索找答案的过程
    lifanxi
        3
    lifanxi  
       2022-12-07 15:16:10 +08:00   ❤️ 3
    要小心,它经常会一本正经地告诉你一个看上去头头是道的答案,推理、分析都很详尽,代码也有模有样,但是实际上是完全错的。
    shinession
        4
    shinession  
    OP
       2022-12-07 15:32:09 +08:00
    @lifanxi 是的,我有看到别人贴的长回答, 车轱辘话一堆.
    yazoox
        5
    yazoox  
       2022-12-07 16:30:38 +08:00
    China 不支持,你是怎么注册帐号玩这个的? thx
    neptuno
        6
    neptuno  
       2022-12-07 16:44:35 +08:00
    @yazoox 1 、使用新加坡等国家 ip 登陆,2 、用接码平台,印度手机号绑定
    ciming
        7
    ciming  
       2022-12-07 17:29:20 +08:00
    silencil
        8
    silencil  
       2022-12-07 17:55:26 +08:00
    我直接提了个列表转树的需求,把数据结构输进去,给出的答案是递归,代码完全能用,甚至命名都不需要修改,只需要加我自己要使用的其他业务逻辑。
    minamike
        9
    minamike  
       2022-12-07 18:03:21 +08:00 via iPhone
    @lifanxi 一本正经地胡说八道 AI 界的一本道😆
    updateing
        10
    updateing  
       2022-12-07 18:07:49 +08:00 via Android
    @shinession 甚至不一定是车轱辘话,我遇到过它有板有眼地告诉我去运行一个根本不存在的指令
    xieqiqiang00
        11
    xieqiqiang00  
       2022-12-07 19:33:03 +08:00 via Android
    @updateing 你要指出这是错的,他会改正
    lifanxi
        12
    lifanxi  
       2022-12-07 22:10:50 +08:00
    @shinession 车轱辘话没有危害,一眼就看出来是没用的信息。最怕是精炼肯定地告诉你一个错误的答案。
    @xieqiqiang00 不一定,我试过几次,它很倔强的,对自己非常有信心,不肯轻易认错。
    shinession
        13
    shinession  
    OP
       2022-12-08 07:50:24 +08:00
    @lifanxi 不可能 100%信任 AI 的, 要不然还要程序猿干嘛? 不过用在学习语言还不错, 至少我们熟悉一种语言,可以判断结果是不是正确的
    amwyyyy
        14
    amwyyyy  
       2022-12-08 10:50:54 +08:00
    现有一笼子,里面有鸡和兔子若干只,数一数,共有头 14 个,腿 38 条,求鸡和兔子各有多少只?

    鸡兔同笼问题它能答对不
    comstrojs
        15
    comstrojs  
       2022-12-08 11:46:30 +08:00
    @amwyyyy #14 刚刚试了一下答错了
    aigonna
        16
    aigonna  
       2022-12-08 12:43:41 +08:00
    下面是一个使用 PyTorch 实现知识蒸馏的简化代码例子:
    # 首先,我们需要导入必要的库
    import torch
    import torch.nn as nn

    # 定义数据集
    X = ... # 输入数据
    y = ... # 标签

    # 定义大型预训练模型
    pretrained_model = ...

    # 使用大型预训练模型对数据集进行预测
    # 这些预测将作为辅助标签
    soft_labels = pretrained_model(X)

    # 定义较小的模型
    small_model = ...

    # 定义损失函数
    # 这里,我们将使用交叉熵损失函数
    # 并将辅助标签作为目标
    loss_fn = nn.CrossEntropyLoss(reduction="mean")
    loss = loss_fn(y, soft_labels)

    # 使用随机梯度下降优化器优化模型参数
    optimizer = torch.optim.SGD(small_model.parameters(), lr=0.001)
    optimizer.zero_grad()
    loss.backward()
    optimizer.step()

    NLP 也凑合能用
    shinession
        17
    shinession  
    OP
       2022-12-08 13:26:25 +08:00
    @amwyyyy 假设鸡有 x 只,兔子有 y 只,鸡和兔子的腿总数量可以用如下方程来表示:

    2x + 4y = 38

    鸡和兔子的头总数量可以用如下方程来表示:

    x + y = 14

    现在我们已经有了两个方程,就可以求出 x 和 y 的值。首先,我们可以把第二个方程中的 y 带入第一个方程中,得到:

    2x + 4(14 - x) = 38

    化简得到:

    2x + 56 - 4x = 38

    再次化简得到:

    -2x = -18

    因此,x = 9 。由于 x + y = 14 ,所以 y = 14 - 9 = 5 。因此,鸡有 9 只,兔子有 5 只。

    总结一下,当鸡和兔子的头总数为 14 个,腿总数为 38 条时,鸡有 9 只,兔子有 5 只。

    试了一下, 没问题
    zzm88104
        18
    zzm88104  
       2022-12-12 19:15:11 +08:00 via iPhone
    我经常质疑他,他就很快承认错误,再给你正确答案。或者你说自己的理解,跟他确认,他会告诉你他认不认可。这些特点其实跟人很像啊,而且是个智者了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2711 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 15:38 · PVG 23:38 · LAX 08:38 · JFK 11:38
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.