当前位置: 首页 > news >正文

南通网站开发招聘物联网卡在哪里买呢

南通网站开发招聘,物联网卡在哪里买呢,大型门户网站建设的意义,仙游网站建设感觉这个目前没有什么用,因为客户可以直接问通用chatGPT,实时了解你网站内的信息,除非你的网站chatGPT无法访问。 不过自动预订、买票等用嵌入还是挺有用的。 什么是嵌入? OpenAI的嵌入(embeddings)是一种…

感觉这个目前没有什么用,因为客户可以直接问通用chatGPT,实时了解你网站内的信息,除非你的网站chatGPT无法访问。
不过自动预订、买票等用嵌入还是挺有用的。

什么是嵌入?

OpenAI的嵌入(embeddings)是一种技术,它能够将文本、代码或者其他类型的数据转换成数值向量。这些数值向量捕捉了原始数据的关键特征和含义,使得计算机和算法能更有效地处理和分析数据。

将数据传递给模型的过程通常涉及以下几个步骤:

  1. 数据准备:首先,您需要准备您想要分析或处理的数据。这可能是文本、图片、音频或其他类型的数据。

  2. 格式转换:将数据转换成模型能够理解的格式。对于文本数据,这通常意味着将其转换为字符串形式。

  3. 使用API:如果您使用OpenAI的API,您需要按照API的要求格式化您的数据,并通过HTTP请求将其发送给API。这通常涉及到编写一些代码,使用像Python这样的编程语言。

  4. 处理响应:模型会处理您的数据,并以某种形式返回结果。这个结果通常也是一个数值向量,或者是其他类型的数据,例如生成的文本、图片等。

  5. 后处理:根据您的需求,您可能需要对模型的输出进行进一步的处理或分析。

对于不同类型的数据和不同的应用场景,这个过程可能会有所不同,但基本的原则是相似的。如果您具体想知道如何使用某个特定的OpenAI模型或API,通常最好的做法是查阅该模型或API的官方文档,那里会有详细的说明和示例代码。

构建一个可以回答有关您网站问题的 AI步骤:

1抓取网站

从根 URL 开始,访问每个页面,查找其他链接,并访问这些页面。
爬网程序遍历所有可访问的链接并将这些页面转换为文本文件(去掉html的tag)。
(内容如果太长,需分解成更小的块)
转为csv结构。

2使用 Embeddings API 将抓取的页面转换为嵌入

第一步是将嵌入转换为 NumPy 数组(基它形式的也可以)

import numpy as np
from openai.embeddings_utils import distances_from_embeddingsdf=pd.read_csv('processed/embeddings.csv', index_col=0)
df['embeddings'] = df['embeddings'].apply(eval).apply(np.array)df.head()

关于NumPy 数组 Certainly! Here’s a simple example using NumPy, a powerful
library for numerical processing in Python. This example will
demonstrate how to create a NumPy array and perform some basic
operations:


# Creating a simple NumPy array array = np.array([1, 2, 3, 4, 5]) print("Original Array:", array)# Performing basic operations
# Adding a constant to each element added_array = array + 10 print("Array after adding 10 to each element:", added_array)# Multiplying each element by 2 multiplied_array = array * 2 print("Array after multiplying each element by 2:", multiplied_array)# Computing the mean of the array mean_value = np.mean(array) print("Mean of the array:", mean_value)# Reshaping the array into a 2x3 matrix
# Note: The total number of elements must remain the same. reshaped_array = np.reshape(array, (2, 2))  # Only possible with an
array of 4 elements print("Reshaped array into a 2x2 matrix:\n",
reshaped_array) ```In this example, we first import the NumPy library. Then, we create a
basic array and perform operations like addition, multiplication, and
calculating the mean. Finally, we reshape the array into a 2x2 matrix.
Keep in mind that the reshape function requires the total number of
elements to remain the same, so in this example, you would need to
modify the original array or the shape to ensure they match.

3创建一个基本的搜索功能,允许用户询问有关嵌入信息的问题

现在数据已经准备好了,根据检索到的文本生成一个自然的答案。

def create_context(question, df, max_len=1800, size="ada"
):"""Create a context for a question by finding the most similar context from the dataframe"""# Get the embeddings for the questionq_embeddings = client.embeddings.create(input=question, engine='text-embedding-ada-002')['data'][0]['embedding']# Get the distances from the embeddingsdf['distances'] = distances_from_embeddings(q_embeddings, df['embeddings'].values, distance_metric='cosine')returns = []cur_len = 0# Sort by distance and add the text to the context until the context is too longfor i, row in df.sort_values('distances', ascending=True).iterrows():# Add the length of the text to the current lengthcur_len += row['n_tokens'] + 4# If the context is too long, breakif cur_len > max_len:break# Else add it to the text that is being returnedreturns.append(row["text"])# Return the contextreturn "\n\n###\n\n".join(returns)

回答提示将尝试从检索到的上下文中提取相关事实,以制定连贯的答案。如果没有相关答案,提示将返回“我不知道”。

def answer_question(df,model="gpt-3.5-turbo",question="Am I allowed to publish model outputs to Twitter, without a human review?",max_len=1800,size="ada",debug=False,max_tokens=150,stop_sequence=None
):"""Answer a question based on the most similar context from the dataframe texts"""context = create_context(question,df,max_len=max_len,size=size,)# If debug, print the raw model responseif debug:print("Context:\n" + context)print("\n\n")try:# Create a chat completion using the question and contextresponse = client.chat.completions.create(model="gpt-3.5-turbo",messages=[{"role": "system", "content": "Answer the question based on the context below, and if the question can't be answered based on the context, say \"I don't know\"\n\n"},{"role": "user", f"content": "Context: {context}\n\n---\n\nQuestion: {question}\nAnswer:"}],temperature=0,max_tokens=max_tokens,top_p=1,frequency_penalty=0,presence_penalty=0,stop=stop_sequence,)return response.choices[0].message.strip()except Exception as e:print(e)return ""

测试问答系统

测试来查看输出的质量。
如果系统无法回答预期的问题,则值得搜索原始文本文件,以查看预期已知的信息是否实际上最终被嵌入。

http://www.yayakq.cn/news/279174/

相关文章:

  • 查询网站备案网络规划的内容
  • 如何判断一个网站的关键词是否难做星际网络泰安网络公司
  • 2018年网站设计公司潍坊哪家网站制作公司好
  • 做自己视频教程的网站wordpress后台演示
  • 中国建设银行网站评价一般做网站宽度是多少
  • 怎么做一个网站怎么样电商网站建设成本
  • 网站后台如何开发网站实现留言功能吗
  • 无锡网站建设推广公司网站维护好做吗
  • 怎么用2013做网站南京网站建设企业
  • 网站建设服务费记入什么科目有了空间怎么做网站
  • 台州网站建设选浙江华企网站内容建设流程
  • 网站制作说明中国住房和城乡建设部网站建造师
  • 建设工程资料下载网站wordpress后台设置教程
  • 从客户—管理者为某一公司做一份电子商务网站管理与维护的方案惠州最专业的网站建设公司
  • 建设网站需要什么手续php网站开发实例教程 传智播客
  • 稳稳在哪个网站做的消防直播自考网页制作与网站建设
  • 注册新公司网上核名网站郑州最出名的不孕不育医院
  • 做的好的商城网站设计打开网站notfound
  • 哪有网站给光头强做面优秀的网站开发
  • 在哪儿可以找到网站开发的需求网店代运营怎么做
  • 建设银行公积金查询网站首页官方网站的要素
  • 深圳网站建设企业名录营销推广网
  • 如何建设好网站烟台网站建设 烟台网亿网络公司
  • 定远建设局官方网站网站建设网站公司哪家好
  • 哪家公司做网站最好网站优化哪家专业
  • 一个可以看qq空间的网站安通建设有限公司网站
  • 设计网站排名可以做淘宝联盟的免费网站
  • 宜城网站建设建设厅焊工证查询官网
  • 查看网站外链wordpress 评论框插件
  • 假山网站建设移动网站设计心得