什么是生成式 AI?

已完成

人工智能 (AI) 通过使用机器学习与环境交互并执行任务来模仿人类行为,而无需明确指示要输出的内容。

生成式 AI 描述 AI 中用于创建原创内容的一类功能。 人员通常与聊天应用程序中内置的生成式 AI 交互。 此类应用程序的一个常用示例是 ChatGPT,这是一个由 OpenAI 创建的聊天机器人,OpenAI 是一家与 Microsoft 密切合作的 AI 研究公司。

生成式 AI 应用程序接受自然语言输入,并以自然语言、图像或代码等各种格式返回适当的响应。

自然语言生成

要生成自然语言响应,可以提交诸如“请提供三种关于含辣椒的健康早餐的想法”之类的请求。

生成式 AI 应用程序可能会响应此类请求,如下所示:

好的,下面是三种含辣椒的健康早餐:

1. 辣椒炒蛋:将一些青椒切成丁,放入平底锅中炒至微微变软。 然后加入打散的鸡蛋液,将所有食材混合在一起翻炒。 再搭配全麦吐司,一道美味的营养早餐即成。

2. 辣椒牛油果吐司:烤一片全麦面包,在上面加入青椒块、涂上牛油果泥,再撒上盐和胡椒粉。 这是从牛油果中获取健康脂肪以及从辣椒中获取维生素 C 的好方法。

3. 搭配辣椒的早餐玉米卷饼:将一些切丁的青椒、洋葱和炒鸡蛋一起放入锅中炒。 然后,将炒好的混合物舀到全麦玉米饼上,并在上面涂上一些莎莎酱或辣椒酱。 卷起来即可享用一顿满意又营养的早餐。

图像生成

某些生成式 AI 应用程序可以解释自然语言请求并生成适当的图像。 例如,可以提交类似“创建大象吃汉堡的图像”的请求。

生成式 AI 应用程序随后可以根据提供的说明返回原创的新图像,如下所示:

Illustration of an elephant eating a burger.

代码生成

某些生成式 AI 应用程序旨在帮助软件开发人员编写代码。 例如,提交类似“请演示如何使用 Python 编写 tic-tac-toe 游戏代码”的请求就会生成以下响应:

好的,下面是使用 Python 编写 Tic-Tac-Toe 游戏的一些基本代码:

board = [' ' for x in range(9)]  
  
def print_board():  
    row1 = '| {} | {} | {} |'.format(board[0], board[1], board[2])  
    row2 = '| {} | {} | {} |'.format(board[3], board[4], board[5])  
    row3 = '| {} | {} | {} |'.format(board[6], board[7], board[8])  
    print()  
    print(row1)  
    print(row2)  
    print(row3)  
    print()  
  
def player_move(icon):  
    if icon == 'X':  
        number = 1  
    elif icon == 'O':  
        number = 2  
    print('Your turn player {}'.format(number))  
    choice = int(input('Enter your move (1-9): ').strip())  
    if board[choice - 1] == ' ':  
        board[choice - 1] = icon  
    else:  
        print()  
        print('That space is taken!')  
  
def is_victory(icon):  
    if (board[0] == icon and board[1] == icon and board[2] == icon) or \  
       (board[3] == icon and board[4] == icon and board[5] == icon) or \  
       (board[6] == icon and board[7] == icon and board[8] == icon) or \  
       (board[0] == icon and board[3] == icon and board[6] == icon) or \  
       (board[1] == icon and board[4] == icon and board[7] == icon) or \  
       (board[2] == icon and board[5] == icon and board[8] == icon) or \  
       (board[0] == icon and board[4] == icon and board[8] == icon) or \  
       (board[2] == icon and board[4] == icon and board[6] == icon):  
        return True  
    else:  
        return False  
  
def is_draw():  
    if ' ' not in board:  
        return True  
    else:  
        return False  
  
while True:  
    print_board()  
    player_move('X')  
    print_board()  
    if is_victory('X'):  
        print('X Wins! Congratulations!')  
        break  
    elif is_draw():  
        print('The game is a draw!')  
        break  
    player_move('O')  
    if is_victory('O'):  
        print_board()  
        print('O Wins! Congratulations!')  
        break  
    elif is_draw():  
        print('The game is a draw!')  
        break  

这只是游戏的基本实现,可以通过错误处理和输入验证等附加功能进行改进。