shinession

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

  •  
  •   shinession · Dec 7, 2022 · 4834 views
    This topic created in 1429 days ago, the information mentioned may be changed or developed.
    起因是有个部门分享的 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 replies  •  2022-12-12 19:15:11 +08:00
    Vitta
    Vitta
    Dec 7, 2022
    1
    问他个 flutter Semantics 的问题都不告诉我
    FishingRabbit
    FishingRabbit
    Dec 7, 2022
    2
    确实很强,我试了下之前百度谷歌很久没找到答案的问题,它直接就给我解决了,太强了,省去了长时间搜索找答案的过程
    lifanxi
    lifanxi
    Dec 7, 2022❤️3
    3
    要小心,它经常会一本正经地告诉你一个看上去头头是道的答案,推理、分析都很详尽,代码也有模有样,但是实际上是完全错的。
    shinession
    shinession
    OP
    Dec 7, 2022
    4
    @lifanxi 是的,我有看到别人贴的长回答, 车轱辘话一堆.
    yazoox
    yazoox
    Dec 7, 2022
    5
    China 不支持,你是怎么注册帐号玩这个的? thx
    neptuno
    neptuno
    Dec 7, 2022
    6
    @yazoox 1 、使用新加坡等国家 ip 登陆,2 、用接码平台,印度手机号绑定
    silencil
    silencil
    Dec 7, 2022
    8
    我直接提了个列表转树的需求,把数据结构输进去,给出的答案是递归,代码完全能用,甚至命名都不需要修改,只需要加我自己要使用的其他业务逻辑。
    minamike
    minamike
    Dec 7, 2022 via iPhone
    9
    @lifanxi 一本正经地胡说八道 AI 界的一本道😆
    updateing
    updateing
    Dec 7, 2022 via Android
    10
    @shinession 甚至不一定是车轱辘话,我遇到过它有板有眼地告诉我去运行一个根本不存在的指令
    xieqiqiang00
    xieqiqiang00
    Dec 7, 2022 via Android
    11
    @updateing 你要指出这是错的,他会改正
    lifanxi
    lifanxi
    Dec 7, 2022
    12
    @shinession 车轱辘话没有危害,一眼就看出来是没用的信息。最怕是精炼肯定地告诉你一个错误的答案。
    @xieqiqiang00 不一定,我试过几次,它很倔强的,对自己非常有信心,不肯轻易认错。
    shinession
    shinession
    OP
    Dec 8, 2022
    13
    @lifanxi 不可能 100%信任 AI 的, 要不然还要程序猿干嘛? 不过用在学习语言还不错, 至少我们熟悉一种语言,可以判断结果是不是正确的
    amwyyyy
    amwyyyy
    Dec 8, 2022
    14
    现有一笼子,里面有鸡和兔子若干只,数一数,共有头 14 个,腿 38 条,求鸡和兔子各有多少只?

    鸡兔同笼问题它能答对不
    comsjtros
    comsjtros
    Dec 8, 2022
    15
    @amwyyyy #14 刚刚试了一下答错了
    aigonna
    aigonna
    Dec 8, 2022
    16
    下面是一个使用 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
    shinession
    OP
    Dec 8, 2022
    17
    @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
    zzm88104
    Dec 12, 2022 via iPhone
    18
    我经常质疑他,他就很快承认错误,再给你正确答案。或者你说自己的理解,跟他确认,他会告诉你他认不认可。这些特点其实跟人很像啊,而且是个智者了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2774 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 63ms · UTC 13:25 · PVG 21:25 · LAX 05:25 · JFK 08:25
    ♥ Do have faith in what you're doing.