我写了一篇名为“高于平均水平”的时事通讯,其中我谈论了大型科技公司正在发生的一切背后的二阶见解。如果您热衷于科技并且不想成为平庸的人,请订阅它。
推断本质上是一种在与法学硕士互动时使用巧妙的提示来提取见解、情绪和趋势的方法。
以前,在法学硕士之前,每项任务都需要自己的模型、培训以及部署和维护。但随着 OpenAI 和其他法学硕士的爆炸式增长,推理允许您利用法学硕士来改进您的产品,而且您不必成为数据科学家或机器学习工程师即可这样做。
示例 1:假设您运营一个电子商务网站,想要提取客户评论的情绪。您可以使用以下提示来执行此操作。在本例中,我将提供审阅文本以及您可以在其上使用的提示。您可以使用您最喜欢的方式针对 Open AI 的 API 运行它。我在亚马逊上对我为此示例购买的灯箱进行了真实的评论。
from openai import OpenAI client = OpenAI() client.api_key = 'YOUR_SECRET_KEY' amazon_review = f""" This softbox lighting system is a great value for the price. They were super easy to set and offer multiple types of lighting, with dimmer and remotes for each light. They are lightweight which means they can topple over if bumped. But that was an easy problem to solve. I just created some weights out of an old pair of socks and some dried beans. You could use rice or sand also. Or just buy sandbags. I like to DIY. Anywho, I highly recommend this lighting system. """ story = """ prompt = f""" Identify the following items from the review text: - Sentiment (positive or negative) - Is the reviewer expressing anger? (true or false) - Item purchased by reviewer - Company that made the item The review is delimited with triple backticks. \ Format your response as a JSON object with \ "Sentiment", "Anger", "Item" and "Brand" as the keys. If the information isn't present, use "unknown" \ as the value. Make your response as short as possible. Format the Anger value as a boolean. Review text: '''{amazon_review}''' """ response = client.chat.completions.create( model="gpt-4", messages=[ { "role": "user", "content": prompt } ], temperature=0, #max_tokens=64, #top_p=1 ) print(response.choices[0].message.content)
我得到的输出如下:
{“情绪”:“积极”,“愤怒”:错误,“项目”:“柔光箱照明系统”,“品牌”:“未知”}
这是一个很酷的示例,展示了使用 Open AI 的 API 进行推理的强大功能。现在,亚马逊是一家已经使用人工智能来发布功能的大公司,最近对该页面的更新之一似乎是关于总结该产品下的所有评论。以下是寻找相同产品的方式。
您认为可以通过推断一组客户评论来重新创建它吗?我想是这样。如果您能解决这个问题,请通过Twitter联系我并告诉我。
示例 2:假设您运营一个新闻网站,并且您希望在不实际阅读文章的情况下找到该文章的主题。你能使用提示来完成并推断它吗?是的你可以。这是一篇示例文章,我从中推断出该文章中提到的主题。
from openai import OpenAI client = OpenAI() client.api_key = 'YOUR_SECRET_KEY' article = """ It hasn't been the best start to 2024 for Elon Musk. The owner of X, formerly known as Twitter, appealed to YouTube's biggest star MrBeast to post his videos on the platform, and was promptly rejected. On Dec. 30, 2023, MrBeast, whose real name is Jimmy Donaldson, posted on X to announce his latest video release was available on YouTube: "I uploaded, go watch or I'll drop kick you." Donaldson had uploaded a 20-minute long video to YouTube, in which he chronicled spending a week in solitary confinement. These types of videos, in which Donaldson challenges either himself or an individual with an extreme task, have earned him worldwide notoriety. The social media mastermind earned an estimated $82 million in 2023, and with more than 225 million subscribers on his main channel alone, is the platform's biggest name. After Donaldson posted the appeal to head to YouTube on X, one fan replied: "Upload on this platform too," which is when Elon Musk chimed in with: "Yeah." Musk, the CEO of Tesla and owner of X, has been trying to drum up interest from video viewers since taking over the social media platform in 2022. Schemes have included launching a media partnership with heiress Paris Hilton—which has since been axed—as well as streaming shows from the likes of former Fox star Tucker Carlson. Musk, now with the help of CEO Linda Yaccarino, has also attempted to drum up revenue by launching premium subscription services on the site, which—among other things—allow for users to appear as "verified" and send DMs to other accounts. The moves have been necessary after droves of advertisers left the site over fears their branding would appear beside unregulated content. Musk, a fierce proponent of free speech, has refused to cow to concern from advertisers about how X will prevent their messages from reportedly appearing beside Nazi propaganda, for example. But Musk's attempt to get MrBeast's content on his site—not even exclusively—was rebuffed by the creator. Donaldson replied to Musk directly: "My videos cost millions to make and even if they got a billion views on X it wouldn't fund a fraction of it :/ I'm down though to test stuff once monetization is really cranking!" The polite rebuttal contrasts with the firm interest Donaldson had previously taken in Twitter. Indeed, Donaldson's bio still reads "X Super Official CEO," harking back to the times when speculation was rife about who would take over the day-to-day running of the platform from the ever-busy Musk. """ prompt = f""" Determine five topics that are being discussed in the \ following text, which is delimited by triple backticks. Make each item one or two words long. Format your response as a list of items separated by commas. Text sample: '''{article}''' """ response = client.chat.completions.create( model="gpt-4", messages=[ { "role": "user", "content": prompt } ], temperature=0, #max_tokens=64, #top_p=1 ) print(response.choices[0].message.content)
输出是:
Elon Musk, Social Media Platforms, YouTube Content, Advertising Concerns, Monetization Strategies
非常准确,对吧?
AI 产品创意提醒: Shopify 应用程序可从客户评论中总结并提取见解。此应用程序应在 Shopify 应用商店中启动。如果 Shopify 原生推出此功能,我不会感到惊讶。只需使用开放式 AI API 进行快速工程,这将是一个可以在几天内启动的应用程序。
这就是第 3 天的内容。
在Twitter上关注我,了解 AI 100 天的最新动态,或将此页面添加为书签。
也发布在这里。