最新ChatGPT GPT-4 NLU实战之文档问答类ChatPDF功能(附ipynb与python源码及视频)——开源DataWhale发布入门ChatGPT技术新手从0到1必备使用指南手册(五)

目录

  • 前言
  • 最新ChatGPT GPT-4 自然语言理解NLU实战之文档问答类ChatPDF功能
    • 引言
    • ChatGPT 接口
    • Qdrant数据库Embedding存储
    • 核心代码
    • 测试
  • 其它NLU应用及实战
    • 相关文献
  • 参考资料
  • 其它资料下载

在这里插入图片描述

前言

最近,研究人员开始探索使用ChatGPT来进行文档问答(QA)的任务。与传统的文档问答系统相比,这种方法的优点在于可以利用ChatGPT强大的生成能力来产生更为准确、详细的答案。在此过程中,ChatGPT通过阅读相关文档并提取问题所需的信息来寻找答案。这种方法不仅可以提高QA的准确性,还可以提高系统的可扩展性和适应性。

其中最火的莫过于ChatPDF,它是国外小哥Mathis Lichtenberger开发的一个应用。通过上传PDF文件到ChatPDF,就能实现和PDF跨语言对话,并根据PDF内容回答的提问。即,通过ChatPDF能够实现和PDF聊天。跨语言是指如果PDF是英文,你可以输入中文和它对话,反之亦然。而该应用的核心方法就是基于OpenAI的 Chat API,给PDF的每一段创建语义索引,然后使用关联最密切的段落去提示 (prompt) Chat API。

这是ChatPDF主页对其介绍:

  • 无论是课本、讲义还是演示文稿,都可以轻松理解。无需再花费数小时翻阅研究论文和学术文章,让我们更有效地支持学术成长。

  • ChatPDF可以帮助我们更好地学习。无论是课本、讲义还是演示文稿,都可以轻松理解。无需再花费数小时翻阅研究论文和学术文章,让我们更有效地支持学术成长。

  • 通过ChatPDF,我们可以轻松地解锁无尽知识。从历史文档到诗歌、文学作品,无论是什么语言,ChatPDF都能理解并用喜欢的语言回复。让好奇心得到满足,拓宽视野,这个工具能回答任何来自PDF文件的问题。

本文也将给大家从0到1为大家展示关于NLU应用之文档问答的底层技术及应用。

最新ChatGPT GPT-4 自然语言理解NLU实战之文档问答类ChatPDF功能

引言

  文档问答和QA有点类似,不过要稍微复杂一点。它会先用QA的方法召回一个相关的文档,然后让模型在这个文档中找出问题的答案。一般的流程还是先召回相关文档,然后做阅读理解任务。阅读理解和实体提取任务有些类似,但它预测的不是具体某个标签,而是答案的Index,即start和end的位置。

  还是举个例子。假设我们的问题是:“北京奥运会举办于哪一年?”

  召回的文档可能是含有北京奥运会举办的新闻,比如类似下面这样的:

第29届夏季奥林匹克运动会(Beijing 2008; Games of the XXIX Olympiad),又称2008年北京奥运会,2008年8月8日晚上8时整在中国首都北京开幕。8月24日闭幕。

  标注就是「2008年」这个答案的索引。

  当然,一个文档里可能有不止一个问题,比如上面的文档,还可以问:“北京奥运会啥时候开幕?”,“北京奥运会什么时候闭幕”,“北京奥运会是第几届奥运会”等问题。

  根据之前的NLP方法,这里实际做起来方案会比较多,也有一定的复杂度;不过总的来说还是分类任务。现在我们有了LLM,问题就变得简单了。依然是两步:

  • 召回:与QA类似,这次召回的是Doc,这一步其实就是相似Embedding选择最相似的。
  • 回答:将召回来的文档和问题以Prompt的方式提交给Completion/ChatCompletion接口,直接得到答案。

ChatGPT 接口

  我们分别用两种不同的接口各举一例,首先看看Completion接口:

import openai
OPENAI_API_KEY = "填入专属的API key"openai.api_key = OPENAI_API_KEY
def complete(prompt):response = openai.Completion.create(prompt=prompt,temperature=0,max_tokens=300,top_p=1,frequency_penalty=0,presence_penalty=0,model="text-davinci-003")ans = response["choices"][0]["text"].strip(" \n")return ans
# 来自官方文档
prompt = """Answer the question as truthfully as possible using the provided text, and if the answer is not contained within the text below, say "I don't know"Context:
The men's high jump event at the 2020 Summer Olympics took place between 30 July and 1 August 2021 at the Olympic Stadium.
33 athletes from 24 nations competed; the total possible number depended on how many nations would use universality places 
to enter athletes in addition to the 32 qualifying through mark or ranking (no universality places were used in 2021).
Italian athlete Gianmarco Tamberi along with Qatari athlete Mutaz Essa Barshim emerged as joint winners of the event following
a tie between both of them as they cleared 2.37m. Both Tamberi and Barshim agreed to share the gold medal in a rare instance
where the athletes of different nations had agreed to share the same medal in the history of Olympics. 
Barshim in particular was heard to ask a competition official "Can we have two golds?" in response to being offered a 
'jump off'. Maksim Nedasekau of Belarus took bronze. The medals were the first ever in the men's high jump for Italy and 
Belarus, the first gold in the men's high jump for Italy and Qatar, and the third consecutive medal in the men's high jump
for Qatar (all by Barshim). Barshim became only the second man to earn three medals in high jump, joining Patrik Sjöberg
of Sweden (1984 to 1992).Q: Who won the 2020 Summer Olympics men's high jump?
A:"""
complete(prompt)
'Gianmarco Tamberi and Mutaz Essa Barshim emerged as joint winners of the event.'

  上面的Context就是我们召回的文档。

  再看ChatCompletion接口:

prompt = """请根据以下Context回答问题,直接输出答案即可,不用附带任何上下文。Context:
诺曼人(诺曼人:Nourmands;法语:Normands;拉丁语:Normanni)是在10世纪和11世纪将名字命名为法国诺曼底的人。他们是北欧人的后裔(丹麦人,挪威人和挪威人)的海盗和海盗,他们在首相罗洛(Rollo)的领导下向西弗朗西亚国王查理三世宣誓效忠。经过几代人的同化,并与法兰克和罗马高卢人本地居民融合,他们的后代将逐渐与以西卡罗来纳州为基础的加洛林人文化融合。诺曼人独特的文化和种族身份最初出现于10世纪上半叶,并在随后的几个世纪中持续发展。问题:
诺曼底在哪个国家/地区?
"""
def ask(content):response = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "user", "content": content}])ans = response.get("choices")[0].get("message").get("content")return ans
ans = ask(prompt)
print(ans)
法国。

  看起来还行,我们接下来就把整个流程串起来,先用Completion接口实现(便宜),不过也很方便替换过去,毕竟输入都不变(都是Prompt)。

  首先是加载数据集,取自:openai-cookbook/olympics-1-collect-data.ipynb at 1f6c2304b401e931928e74e978d9a0b8a40d1cf7 · openai/openai-cookbook

import pandas as pd
df = pd.read_csv("./dataset/olympics_sections_text.csv")
df.shape
(3964, 4)
df.head()
titleheadingcontenttokens
02020 Summer OlympicsSummaryThe 2020 Summer Olympics (Japanese: 2020年夏季オリン...726
12020 Summer OlympicsHost city selectionThe International Olympic Committee (IOC) vote...126
22020 Summer OlympicsImpact of the COVID-19 pandemicIn January 2020, concerns were raised about th...374
32020 Summer OlympicsQualifying event cancellation and postponementConcerns about the pandemic began to affect qu...298
42020 Summer OlympicsEffect on doping testsMandatory doping tests were being severely res...163

Qdrant数据库Embedding存储

  我们这次不用Redis,换一个工具:Qdrant - Vector Search Engine,Qdrant相比Redis的单线程更容易扩展。但我们切记,要根据实际情况选择工具,很多时候过度优化是原罪,适合的就是最好的。我们真正需要做的是将业务逻辑抽象,做到尽量不依赖任何工具,换工具只需要换一个适配器就好。

  依然使用Docker,启动很简单:

docker run -p 6333:6333 -v $(pwd)/qdrant_storage:/qdrant/storage qdrant/qdrant`

  自然也少不了客户端的安装:

pip install qdrant-client

  不过首先还是生成Embedding,这一步可以使用get_embedding接口:

from openai.embeddings_utils import get_embedding, cosine_similarity

  或者也可以直接使用原生的Embedding接口,还支持多条一次请求:

def get_embedding_direct(inputs):embed_model = "text-embedding-ada-002"res = openai.Embedding.create(input=inputs, engine=embed_model)return res
texts = [v.content for v in df.itertuples()]
len(texts)
3964
import pnlp
emds = []
for idx, batch in enumerate(pnlp.generate_batches_by_size(texts, 200)):response = get_embedding_direct(batch)for v in response.data:emds.append(v.embedding)print(f"batch: {idx} done")
batch: 0 done
batch: 1 done
batch: 2 done
batch: 3 done
batch: 4 done
batch: 5 done
batch: 6 done
batch: 7 done
batch: 8 done
batch: 9 done
batch: 10 done
batch: 11 done
batch: 12 done
batch: 13 done
batch: 14 done
batch: 15 done
batch: 16 done
batch: 17 done
batch: 18 done
batch: 19 done
len(emds), len(emds[0])
(3964, 1536)

  接下来是创建索引:

from qdrant_client import QdrantClient
client = QdrantClient(host="localhost", port=6333)

  值得注意的是,qdrant还支持内存/文件库,也就是说,可以直接:

# client = QdrantClient(":memory:")
# 或
# client = QdrantClient(path="path/to/db")

  我们还是用server的方式:

from qdrant_client.models import Distance, VectorParamsclient.recreate_collection(collection_name="doc_qa",vectors_config=VectorParams(size=1536, distance=Distance.COSINE),
)
True
# client.delete_collection("doc_qa")

  然后是把向量入库:

payload=[{"content": v.content, "heading": v.heading, "title": v.title, "tokens": v.tokens} for v in df.itertuples()
]
client.upload_collection(collection_name="doc_qa",vectors=emds,payload=payload
)

  接下来进行查询:

query = "Who won the 2020 Summer Olympics men's high jump?"
query_vector = get_embedding(query, engine="text-embedding-ada-002")
hits = client.search(collection_name="doc_qa",query_vector=query_vector,limit=5
)
hits
[ScoredPoint(id=236, version=3, score=0.90316474, payload={'content': 'The men\'s high jump event at the 2020 Summer Olympics took place between 30 July and 1 August 2021 at the Olympic Stadium. 33 athletes from 24 nations competed; the total possible number depended on how many nations would use universality places to enter athletes in addition to the 32 qualifying through mark or ranking (no universality places were used in 2021). Italian athlete Gianmarco Tamberi along with Qatari athlete Mutaz Essa Barshim emerged as joint winners of the event following a tie between both of them as they cleared 2.37m. Both Tamberi and Barshim agreed to share the gold medal in a rare instance where the athletes of different nations had agreed to share the same medal in the history of Olympics. Barshim in particular was heard to ask a competition official "Can we have two golds?" in response to being offered a \'jump off\'. Maksim Nedasekau of Belarus took bronze. The medals were the first ever in the men\'s high jump for Italy and Belarus, the first gold in the men\'s high jump for Italy and Qatar, and the third consecutive medal in the men\'s high jump for Qatar (all by Barshim). Barshim became only the second man to earn three medals in high jump, joining Patrik Sjöberg of Sweden (1984 to 1992).', 'heading': 'Summary', 'title': "Athletics at the 2020 Summer Olympics – Men's high jump", 'tokens': 275}, vector=None),ScoredPoint(id=313, version=4, score=0.88258004, payload={'content': "The men's long jump event at the 2020 Summer Olympics took place between 31 July and 2 August 2021 at the Japan National Stadium. Approximately 35 athletes were expected to compete; the exact number was dependent on how many nations use universality places to enter athletes in addition to the 32 qualifying through time or ranking (1 universality place was used in 2016). 31 athletes from 20 nations competed. Miltiadis Tentoglou won the gold medal, Greece's first medal in the men's long jump. Cuban athletes Juan Miguel Echevarría and Maykel Massó earned silver and bronze, respectively, the nation's first medals in the event since 2008.", 'heading': 'Summary', 'title': "Athletics at the 2020 Summer Olympics – Men's long jump", 'tokens': 136}, vector=None),ScoredPoint(id=284, version=4, score=0.8821836, payload={'content': "The men's pole vault event at the 2020 Summer Olympics took place between 31 July and 3 August 2021 at the Japan National Stadium. 29 athletes from 18 nations competed. Armand Duplantis of Sweden won gold, with Christopher Nilsen of the United States earning silver and Thiago Braz of Brazil taking bronze. It was Sweden's first victory in the event and first medal of any color in the men's pole vault since 1952. Braz, who had won in 2016, became the ninth man to earn multiple medals in the pole vault.", 'heading': 'Summary', 'title': "Athletics at the 2020 Summer Olympics – Men's pole vault", 'tokens': 112}, vector=None),ScoredPoint(id=222, version=3, score=0.876395, payload={'content': "The men's triple jump event at the 2020 Summer Olympics took place between 3 and 5 August 2021 at the Japan National Stadium. Approximately 35 athletes were expected to compete; the exact number was dependent on how many nations use universality places to enter athletes in addition to the 32 qualifying through time or ranking (2 universality places were used in 2016). 32 athletes from 19 nations competed. Pedro Pichardo of Portugal won the gold medal, the nation's second victory in the men's triple jump (after Nelson Évora in 2008). China's Zhu Yaming took silver, while Hugues Fabrice Zango earned Burkina Faso's first Olympic medal in any event.", 'heading': 'Summary', 'title': "Athletics at the 2020 Summer Olympics – Men's triple jump", 'tokens': 139}, vector=None),ScoredPoint(id=205, version=3, score=0.86075026, payload={'content': "The men's 110 metres hurdles event at the 2020 Summer Olympics took place between 3 and 5 August 2021 at the Olympic Stadium. Approximately forty athletes were expected to compete; the exact number was dependent on how many nations used universality places to enter athletes in addition to the 40 qualifying through time or ranking (1 universality place was used in 2016). 40 athletes from 29 nations competed. Hansle Parchment of Jamaica won the gold medal, the nation's second consecutive victory in the event. His countryman Ronald Levy took bronze. American Grant Holloway earned silver, placing the United States back on the podium in the event after the nation missed the medals for the first time in Rio 2016 (excluding the boycotted 1980 Games).", 'heading': 'Summary', 'title': "Athletics at the 2020 Summer Olympics – Men's 110 metres hurdles", 'tokens': 149}, vector=None)]

核心代码

  接下来将这个过程包装在Prompt生成过程中:

MAX_SECTION_LEN = 500
SEPARATOR = "\n* "
separator_len = 3
def construct_prompt(question: str):query_vector = get_embedding(question, engine="text-embedding-ada-002")hits = client.search(collection_name="doc_qa",query_vector=query_vector,limit=5)choose = []length = 0indexes = []for hit in hits:doc = hit.payloadlength += doc["tokens"] + separator_lenif length > MAX_SECTION_LEN:breakchoose.append(SEPARATOR + doc["content"].replace("\n", " "))indexes.append(doc["title"] + doc["heading"])# Useful diagnostic informationprint(f"Selected {len(choose)} document sections:")print("\n".join(indexes))header = """Answer the question as truthfully as possible using the provided context, and if the answer is not contained within the text below, say "I don't know."\n\nContext:\n"""return header + "".join(choose) + "\n\n Q: " + question + "\n A:"
prompt = construct_prompt("Who won the 2020 Summer Olympics men's high jump?")print("===\n", prompt)
Selected 2 document sections:
Athletics at the 2020 Summer Olympics – Men's high jumpSummary
Athletics at the 2020 Summer Olympics – Men's long jumpSummary
===Answer the question as truthfully as possible using the provided context, and if the answer is not contained within the text below, say "I don't know."Context:* The men's high jump event at the 2020 Summer Olympics took place between 30 July and 1 August 2021 at the Olympic Stadium. 33 athletes from 24 nations competed; the total possible number depended on how many nations would use universality places to enter athletes in addition to the 32 qualifying through mark or ranking (no universality places were used in 2021). Italian athlete Gianmarco Tamberi along with Qatari athlete Mutaz Essa Barshim emerged as joint winners of the event following a tie between both of them as they cleared 2.37m. Both Tamberi and Barshim agreed to share the gold medal in a rare instance where the athletes of different nations had agreed to share the same medal in the history of Olympics. Barshim in particular was heard to ask a competition official "Can we have two golds?" in response to being offered a 'jump off'. Maksim Nedasekau of Belarus took bronze. The medals were the first ever in the men's high jump for Italy and Belarus, the first gold in the men's high jump for Italy and Qatar, and the third consecutive medal in the men's high jump for Qatar (all by Barshim). Barshim became only the second man to earn three medals in high jump, joining Patrik Sjöberg of Sweden (1984 to 1992).
* The men's long jump event at the 2020 Summer Olympics took place between 31 July and 2 August 2021 at the Japan National Stadium. Approximately 35 athletes were expected to compete; the exact number was dependent on how many nations use universality places to enter athletes in addition to the 32 qualifying through time or ranking (1 universality place was used in 2016). 31 athletes from 20 nations competed. Miltiadis Tentoglou won the gold medal, Greece's first medal in the men's long jump. Cuban athletes Juan Miguel Echevarría and Maykel Massó earned silver and bronze, respectively, the nation's first medals in the event since 2008.Q: Who won the 2020 Summer Olympics men's high jump?A:
def complete(prompt):response = openai.Completion.create(prompt=prompt,temperature=0,max_tokens=300,top_p=1,frequency_penalty=0,presence_penalty=0,model="text-davinci-003")ans = response["choices"][0]["text"].strip(" \n")return ans
complete(prompt)
'Gianmarco Tamberi and Mutaz Essa Barshim emerged as joint winners of the event following a tie between both of them as they cleared 2.37m. Both Tamberi and Barshim agreed to share the gold medal.'

  试试ChatCompletion(ChatGPT)接口:

def ask(content):response = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "user", "content": content}])ans = response.get("choices")[0].get("message").get("content")return ans

测试

ans = ask(prompt)
ans
"Gianmarco Tamberi and Mutaz Essa Barshim shared the gold medal in the men's high jump event at the 2020 Summer Olympics."

  再看几个例子:

query = "Why was the 2020 Summer Olympics originally postponed?"
prompt = construct_prompt(query)
answer = complete(prompt)print(f"\nQ: {query}\nA: {answer}")
Selected 1 document sections:
Concerns and controversies at the 2020 Summer OlympicsSummaryQ: Why was the 2020 Summer Olympics originally postponed?
A: The 2020 Summer Olympics were originally postponed due to the COVID-19 pandemic.
query = "In the 2020 Summer Olympics, how many gold medals did the country which won the most medals win?"
prompt = construct_prompt(query)
answer = complete(prompt)print(f"\nQ: {query}\nA: {answer}")
Selected 2 document sections:
2020 Summer Olympics medal tableSummary
List of 2020 Summer Olympics medal winnersSummaryQ: In the 2020 Summer Olympics, how many gold medals did the country which won the most medals win?
A: The United States won the most medals overall, with 113, and the most gold medals, with 39.
# ChatGPT
answer = ask(prompt)print(f"\nQ: {query}\nA: {answer}")
Q: In the 2020 Summer Olympics, how many gold medals did the country which won the most medals win?
A: The country that won the most medals at the 2020 Summer Olympics was the United States, with 113 medals, including 39 gold medals.
query = "What is the tallest mountain in the world?"
prompt = construct_prompt(query)
answer = complete(prompt)print(f"\nQ: {query}\nA: {answer}")
Selected 3 document sections:
Sport climbing at the 2020 Summer Olympics – Men's combinedRoute-setting
Ski mountaineering at the 2020 Winter Youth Olympics – Boys' individualSummary
Ski mountaineering at the 2020 Winter Youth Olympics – Girls' individualSummaryQ: What is the tallest mountain in the world?
A: I don't know.
# ChatGPT
answer = ask(prompt)print(f"\nQ: {query}\nA: {answer}")
Q: What is the tallest mountain in the world?
A: I don't know.

其它NLU应用及实战

最新ChatGPT GPT-4 NLU实战之实体分类识别与模型微调

最新ChatGPT GPT-4 NLU实战之智能多轮对话机器人

相关文献

  • 【1】GPT3 和它的 In-Context Learning | Yam
  • 【2】ChatGPT Prompt 工程:设计、实践与思考 | Yam
  • 【3】一些 ChatGPT Prompt 示例 | Yam
  • 【4】dair-ai/Prompt-Engineering-Guide: 🐙 Guides, papers, lecture, notebooks and resources for prompt engineering
  • 【5】Best practices for prompt engineering with OpenAI API | OpenAI Help Center
  • 【6】ChatGPT Prompts and Products | PromptVine
  • 【7】Prompt Vibes
  • 【8】ShareGPT: Share your wildest ChatGPT conversations with one click.
  • 【9】Awesome ChatGPT Prompts | This repo includes ChatGPT prompt curation to use ChatGPT better.
  • 【10】Learn Prompting | Learn Prompting
  • 【11】Fine-tuning - OpenAI API
  • 【12】[PUBLIC] Best practices for fine-tuning GPT-3 to classify text - Google Docs
  • 【13】hscspring/chatbot: Lab for Chatbot

memo:

  • openai-cookbook/text_explanation_examples.md at main · openai/openai-cookbook
  • openai-cookbook/Fine-tuned_classification.ipynb at main · openai/openai-cookbook
  • openai-cookbook/Gen_QA.ipynb at main · openai/openai-cookbook
  • openai-cookbook/Question_answering_using_embeddings.ipynb at main · openai/openai-cookbook
  • openai-cookbook/Fine-tuned_classification.ipynb at main · openai/openai-cookbook

参考资料

ChatGPT 使用指南:句词分类 @长琴

相关视频讲解

其它资料下载

如果大家想继续了解人工智能相关学习路线和知识体系,欢迎大家翻阅我的另外一篇博客《重磅 | 完备的人工智能AI 学习——基础知识学习路线,所有资料免关注免套路直接网盘下载》
这篇博客参考了Github知名开源平台,AI技术平台以及相关领域专家:Datawhale,ApacheCN,AI有道和黄海广博士等约有近100G相关资料,希望能帮助到所有小伙伴们。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/13822.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

最新ChatGPT GPT-4 自然语言理解NLU与句词分类技术详解(附ipynb与python源码及视频讲解)——开源DataWhale发布入门ChatGPT技术新手从0到1必备使用指南手册(四)

目录 前言最新ChatGPT GPT-4 自然语言理解NLU与句词分类技术详解1. NLU基础1.1 句子级别的分类1.2 Token级别的分类 2. 相关API2.1 LMAS GPT API2.2 ChatGPT Style 相关NLU应用及实战相关文献 参考资料其它资料下载 前言 自然语言理解(NLU)是人工智能&a…

新手小白利用chatgpt解决kali网络配置问题

在启动卡kali的时候发现没有网络 通过ifconfig -a发现没有获取到ip 经过一番查询,尝试用dhclient eth0去手动获取ip,发现成功了 但是每次重启kali都要手动获取一遍ip太麻烦,想着问题还是出在配置文件这里,无奈于小白不懂原理&…

chatgpt赋能python:Python怎么取消tab

Python怎么取消tab 在Python编程中,Tab键是一种重要的缩进方式,但在某些情况下,可能会遇到需要取消Tab缩进的情况。因此,了解如何取消Tab缩进是Python编程中的必经之路。本文将介绍Python的Tab缩进机制以及如何取消Tab缩进的方式…

为什么ClassPathResource可以读取到流?- 第465篇

历史文章(文章累计460) 《国内最全的Spring Boot系列之一》 《国内最全的Spring Boot系列之二》 《国内最全的Spring Boot系列之三》 《国内最全的Spring Boot系列之四》 《国内最全的Spring Boot系列之五》 《国内最全的Spring Boot系列之六》 S…

javascript截取两个符号之间的字符串(2):lastIndexOf匹配和正则表达式匹配

lastIndexOf匹配和正则表达式匹配 项目需求1.规范的字符串2.不规范的字符串3-1.万能封装3-2.ChatGPT的优化写法4.正则表达式的用法5.补充知识:lastIndexOf的用法 项目需求 javascript中截取字符串中最后一个“/”和“?”之间的内容。 1.规范的字符串 https://tes…

chatgpt赋能Python-python_quine

Python Quine: 在Python编程中理解自我复制的魅力 如果您已经开始了编程学习之旅,您就可能听说过Quine。Quine是一种程序,它可以输出自己的源代码,并被称为自我复制程序。这种程序很少出现在编程实践中,但在计算机科学中却发挥着…

chatgpt赋能python:Python分隔符怎么用?

Python分隔符怎么用? 在Python编程中,分隔符是一个非常重要的概念。它可以帮助我们在代码中分隔不同的元素,从而让代码更加易读和易于管理。在本文中,我们将深入探讨Python中分隔符的使用方法。 什么是分隔符? 在Py…

chatgpt赋能Python-python3_8怎么换行

Python是一种高级编程语言,其易用性和简洁语法深受程序员的喜爱。而在Python中,换行是一项必不可少的操作。今天,我们将介绍如何在Python3.8中进行换行,并提供一些有用的技巧。 Python3.8中的换行操作 在Python中,我…

chatgpt赋能python:Python中符号详解

Python中符号详解 Python是一种高级编程语言,使用简洁、优雅的语法非常受欢迎。在Python中,有很多符号,这些符号对于写出优雅、高效的代码至关重要。在本文中,我们将详细介绍Python中的常见符号。 1. 等号(&#xff…

《Java黑皮书基础篇第10版》 第10章【习题】

Java语言程序设计 习题第十章 10.2章节习题 10.1 如果重新定义程序清单102中的Loan类,去掉其中的设置方法,这个类是不可改变的吗? 这个类依然是可以改变的,因为每一笔贷款作为一个对象,都是可以改变的 10.3章节习题 10.2 程序…

【人工智能与机器学习】——线性回归、逻辑回归与分类评价指标(学习笔记)

📖 前言:线性回归(Lincar Regression)模型是最简单的线性模型之一,简而言之就像一元一次函数,是所有机器学习初学者的起点。而逻辑回归(Logistic Regression)则稍显复杂,…

阿里巴巴正在为投资者投下一颗“重磅炸弹”

来源:猛兽财经 作者:猛兽财经 在本文中,猛兽财经将围绕:马云在这个时候回国的意义、阿里巴巴拆分为六大业务集团、为什么张勇将阿里巴巴拆分为六大集团对投资者有利、拆分后阿里巴巴各个集团业务的估值分析、阿里巴巴的财务业绩、…

iOS 摸鱼周报 #82 | 去中心化社交软件 Damus

本期概要 本期话题:设计开发加速器线下活动:女性开发者社区日;本周学习:Python 如何调用 Swift 程序内容推荐:涵盖现代 SwiftUI 编程探讨、可变视图、NSTimer、Swift Charts 等方面的内容摸一下鱼:去中心化…

这才是Excel未来的样子,口喊求和什么的弱爆了

Alex 发自 凹非寺量子位 | 公众号 QbitAI 不知各位是否有过被Excel支配的恐惧? 试想一下表格中密密麻麻的数据、让人云里雾里的工具菜单,还有一堆记不清楚的公式…… 现在,有位大聪明为了简化操作,搞出了一个为Excel而生的AI助手。…

中产,疯狂搞“香港身份”

作者| Mr.K 编辑| Emma 来源| 技术领导力(ID:jishulingdaoli) 风水轮流转,今朝到香港。去年K哥身边有几个朋友去了新加坡,今年才刚到四月份,就又有朋友开始在想办法搞香港身份了。这些人都是妥妥的中产,年龄在四五十…

聚观早报 | 首个国产新冠药停产;阿里巴巴创始人马云已回国内

今日要闻:首个国产新冠药停产;阿里巴巴创始人马云已回国内;家乐福中国内地首店关闭;好丽友漏税22万被罚12万;苹果iOS 16.4正式版来了 首个国产新冠药停产 腾盛博药的首款商业化产品,新冠中和抗体药物“安巴…

万字长文:一文看懂GPT风口,有哪些创业机会?

“故事发生在未来,2040年通用人工智能系统已经接管了城市的管理。其中一个AI系统的管理者因为妻子的背叛,修改AI系统的一个底层参数——让AI对人类的谎言、背叛怀有深深的厌恶。之后AI在每天对社交平台的监控中看到了无数谎言、背叛,报复的动…

硅谷新王登国会山,呼吁加强 AI 监管;马斯克任命推特新 CEO;数字媒体巨头申请破产;欧盟通过全球首个全面监管加密资产框架 | 经济学人第 21 周

1. 硅谷新王登国会山,呼吁加强 AI 监管 Sam Altman, the chief executive of OpenAI, the firm behind the ChatGPT chatbot, called for tighter regulation of rapidly developing generative artificial intelligence, such as by forcing disclosure on images …

chatgpt赋能python:Python找钱方案:让你的货币计算更加精准

Python找钱方案:让你的货币计算更加精准 Python作为一门流行的编程语言,广泛应用于数据分析、自然语言处理、Web开发等领域。在货币计算方面,Python同样具有优秀的表现,并能够帮助你处理找零、税率等问题。本文将介绍Python中常见…

chatgpt赋能python:Python中的Locals:简介

Python中的Locals: 简介 在Python编程中,locals()函数是一个非常有用的内置函数,它可以返回当前命名空间中的所有局部变量和它们的值。这个函数一般在调试和测试阶段使用,以便帮助开发者跟踪和调试代码中的变量。 在这篇文章中,…