小智头像图片
AI教程 2025年01月16日
0 收藏 0 点赞 565 浏览 4270 个字
摘要 :

面向开发者的LLM入门课程-评估英文版提(1): 英文版提示 1.创建LLM应用 from langchain.chains import RetrievalQA from langchain.chat_models import ChatOpenAI fr……

哈喽!伙伴们,我是小智,你们的AI向导。欢迎来到每日的AI学习时间。今天,我们将一起深入AI的奇妙世界,探索“面向开发者的LLM入门课程-评估英文版提(1)”,并学会本篇文章中所讲的全部知识点。还是那句话“不必远征未知,只需唤醒你的潜能!”跟着小智的步伐,我们终将学有所成,学以致用,并发现自身的更多可能性。话不多说,现在就让我们开始这场激发潜能的AI学习之旅吧。

面向开发者的LLM入门课程-评估英文版提(1)

面向开发者的LLM入门课程-评估英文版提(1):

英文版提示

1.创建LLM应用

from langchain.chains import RetrievalQA
from langchain.chat_models import ChatOpenAI
from langchain.document_loaders import CSVLoader
from langchain.indexes import VectorstoreIndexCreator
from langchain.vectorstores import DocArrayInMemorySearch
from langchain.evaluation.qa import QAGenerateChain
import pandas as pd

file = ‘../data/OutdoorClothingCatalog_1000.csv’
loader = CSVLoader(file_path=file)
data = loader.load()

test_data = pd.read_csv(file,skiprows=0,usecols=[1,2])
display(test_data.head())

llm = ChatOpenAI(temperature = 0.0)

index = VectorstoreIndexCreator(
vectorstore_cls=DocArrayInMemorySearch
).from_loaders([loader])

qa = RetrievalQA.from_chain_type(
llm=llm,
chain_type=”stuff”,
retriever=index.vectorstore.as_retriever(),
verbose=True,
chain_type_kwargs = {
“document_separator”: “<<<<>>>>>”
}
)

print(data[10],”n”)
print(data[11],”n”)

examples = [
{
“query”: “Do the Cozy Comfort Pullover Set have side pockets?”,
“answer”: “Yes”
},
{
“query”: “What collection is the Ultra-Lofty 850 Stretch Down Hooded
Jacket from?”,
“answer”: “The DownTek collection”
}
]

example_gen_chain = QAGenerateChain.from_llm(ChatOpenAI())

from langchain.evaluation.qa import QAGenerateChain #导入QA生成链,它将接收文档,并从
每个文档中创建一个问题答案对
example_gen_chain = QAGenerateChain.from_llm(ChatOpenAI())#通过传递chat open AI语言
模型来创建这个链
new_examples = example_gen_chain.apply([{“doc”: t} for t in data[:5]])

#查看用例数据
print(new_examples)

examples += [ v for item in new_examples for k,v in item.items()]
qa.run(examples[0][“query”])

面向开发者的LLM入门课程-评估英文版提(1)

page_content=”: 10nname: Cozy Comfort Pullover Set, Stripendescription: Perfect
for lounging, this striped knit set lives up to its name. We used ultrasoft
fabric and an easy design that’s as comfortable at bedtime as it is when we have
to make a quick run out.nnSize & Fitn- Pants are Favorite Fit: Sits lower on
the waist.n- Relaxed Fit: Our most generous fit sits farthest from the
body.nnFabric & Caren- In the softest blend of 63% polyester, 35% rayon and 2%
spandex.nnAdditional Featuresn- Relaxed fit top with raglan sleeves and
rounded hem.n- Pull-on pants have a wide elastic waistband and drawstring, side
pockets and a modern slim leg.nnImported.” metadata={‘source’:
‘../data/OutdoorClothingCatalog_1000.csv’, ‘row’: 10}
page_content=’: 11nname: Ultra-Lofty 850 Stretch Down Hooded
Jacketndescription: This technical stretch down jacket from our DownTek
collection is sure to keep you warm and comfortable with its full-stretch
construction providing exceptional range of motion. With a slightly fitted style
that falls at the hip and best with a midweight layer, this jacket is suitable
for light activity up to 20° and moderate activity up to -30°. The soft and
durable 100% polyester shell offers complete windproof protection and is
insulated with warm, lofty goose down. Other features include welded baffles for
a no-stitch construction and excellent stretch, an adjustable hood, an interior
media port and mesh stash pocket and a hem drawcord. Machine wash and dry.
Imported.’ metadata={‘source’: ‘../data/OutdoorClothingCatalog_1000.csv’, ‘row’:
11}
[{‘qa_pairs’: {‘query’: “What is the description of the Women’s Campside
Oxfords?”, ‘answer’: “The description of the Women’s Campside Oxfords is that
they are an ultracomfortable lace-to-toe Oxford made of super-soft canvas. They
have thick cushioning and quality construction, providing a broken-in feel from
the first time they are worn.”}}, {‘qa_pairs’: {‘query’: ‘What are the dimensions
of the small and medium sizes of the Recycled Waterhog Dog Mat, Chevron Weave?’,
‘answer’: ‘The dimensions of the small size of the Recycled Waterhog Dog Mat,
Chevron Weave are 18″ x 28″. The dimensions of the medium size are 22.5″ x
34.5″.’}}, {‘qa_pairs’: {‘query’: “What are the features of the Infant and
Toddler Girls’ Coastal Chill Swimsuit, Two-Piece?”, ‘answer’: “The swimsuit has
bright colors, ruffles, and exclusive whimsical prints. It is made of four-waystretch and chlorine-resistant fabric, which keeps its shape and resists snags.
The fabric is UPF 50+ rated, providing the highest rated sun protection possible
by blocking 98% of the sun’s harmful rays. The swimsuit also has crossover noslip straps and a fully lined bottom for a secure fit and maximum coverage.”}},
{‘qa_pairs’: {‘query’: ‘What is the fabric composition of the Refresh Swimwear,
V-Neck Tankini Contrasts?’, ‘answer’: ‘The Refresh Swimwear, V-Neck Tankini
Contrasts is made of 82% recycled nylon and 18% Lycra® spandex for the body, and
90% recycled nylon with 10% Lycra® spandex for the lining.’}}, {‘qa_pairs’:
{‘query’: ‘What is the fabric composition of the EcoFlex 3L Storm Pants?’,
‘answer’: ‘The EcoFlex 3L Storm Pants are made of 100% nylon, exclusive of
trim.’}}]

> Entering new RetrievalQA chain…
> Finished chain.

‘Yes, the Cozy Comfort Pullover Set does have side pockets.’

面向开发者的LLM入门课程-评估英文版提(2)
面向开发者的LLM入门课程-评估英文版提(2):英文版提示 2.人工评估 import langchain langchain.debug = True #重新运行...

嘿,伙伴们,今天我们的AI探索之旅已经圆满结束。关于“面向开发者的LLM入门课程-评估英文版提(1)”的内容已经分享给大家了。感谢你们的陪伴,希望这次旅程让你对AI能够更了解、更喜欢。谨记,精准提问是解锁AI潜能的钥匙哦!如果有小伙伴想要了解学习更多的AI知识,请关注我们的官网“AI智研社”,保证让你收获满满呦!

微信打赏二维码 微信扫一扫

支付宝打赏二维码 支付宝扫一扫

版权: 转载请注明出处:https://www.ai-blog.cn/2723.html

相关推荐

AI编程-用Cursor设计移动app原型新手教程: 本篇文章介绍用Cursor来做移动app原型设计的实践,对比…

小智头像图片
111

AI写作-AI写小说教程-创建个人小说智能体(4): 2.4 生成小说架构 1.滑到下方记忆模块中,长期记…

小智头像图片
565

AI写作-AI写小说教程-创建个人小说智能体(3): 2.3 添加插件​ 1.返回Bot主页后,我们点击插件中…

小智头像图片
565

AI写作-300+网文爽点大全教程: 一、用法​ 很多人可能在网上看过许多惯用的技巧,有些甚至可以追溯…

小智头像图片
150

AI写作-AI写小说教程-创建个人小说智能体(2): 2.2 导入知识库​ 1.接着我们导入知识库,点击➕号​…

小智头像图片
565

AI写作-AI写小说教程-创建个人小说智能体(1): 二、 创建个人小说智能体​ 2.1 构建智能体​ 1.我…

小智头像图片
565

AI写作-AI写小说教程-确定主题: 很多人会想,有了AI写小说会不会更容易?AI会代替人类写小说吗?…

小智头像图片
565

AI绘画-Stable Diffusion解决报错教程-显存不足​: 显存不足​ (base) D:openai.wikistable-diffusi…

小智头像图片
565
发表评论
暂无评论

还没有评论呢,快来抢沙发~

助力原创内容

快速提升站内名气成为大牛

扫描二维码

手机访问本站

二维码
vip弹窗图片