Metaphor(EXA) 基于大语言模型的搜索引擎


文章目录


关于 Metaphor

Metaphor是基于大语言模型的搜索引擎,允许用户使用完整的句子和自然语言搜索,还可以模拟人们在互联网上分享和谈论链接的方式进行查询内容。

Metaphor同时还能与LLMs结合使用,允许LLMs连接互联网,查询自己知识库外部的内容。


相关教程


使用示例

安装环境

shell 复制代码
!pip install exa_py
!pip install langchain 
!pip install llama_hub  
!pip install llama_index   

  • api_key 为从官网 https://exa.ai 注册后,个人的 key
  • 过去使用 MetaphorToolSpec,后面改为使用 ExaToolSpec
python 复制代码
from llama_hub.tools.exa.base import ExaToolSpec 
metaphor_tool = ExaToolSpec( api_key="xxx" )

metaphor_tool_list = metaphor_tool.to_tool_list() 

for tool in metaphor_tool_list:
    print(tool.metadata.name)


'''
search
retrieve_documents
search_and_retrieve_documents
search_and_retrieve_highlights
find_similar
current_date
'''

metaphor_tool.search('machine learning transformers', num_results=3)
'''
[Exa Tool] Autoprompt: Here's an insightful article on machine learning transformers:
[{'title': 'On the potential of Transformers in Reinforcement Learning',
  'url': 'https://lorenzopieri.com/rl_transformers/',
  'id': 'snjxQqPfYVWKEmVXunkqhg'},
 {'title': 'How Transformers work in deep learning and NLP: an intuitive introduction | AI Summer',
  'url': 'https://theaisummer.com/transformer/',
  'id': 'kzGcf36vWzWeyL28Az1fNQ'},
 {'title': 'Transformers in Computer Vision: Farewell Convolutions!',
  'url': 'https://towardsdatascience.com/transformers-in-computer-vision-farewell-convolutions-f083da6ef8ab?gi=a1d0a9a2896c',
  'id': 'xF0V2oTHAfVmfS5UvJIFDA'}]
'''

python 复制代码
# 使用 Mataphor 设置 OpenAI Agent

from llama_index.agent import OpenAIAgent
agent = OpenAIAgent.from_tools(
    metaphor_tool_list,
    verbose=True,
)

# 直接查询
agent.chat('what are the best restaurants in torando?')

python 复制代码
from llama_index.tools.tool_spec.load_and_search.base import LoadAndSearchToolSpec

# The search_and_retrieve_documents tool is the third in the tool list, as seen above
wrapped_retrieve = LoadAndSearchToolSpec.from_defaults(
  metaphor_tool_list[2],
)

# Just pass the wrapped tools and the get_date utility
agent = OpenAIAgent.from_tools(
  [*wrapped_retrieve.to_tool_list(), metaphor_tool_list[4]],
  verbose=True,
)
agent.chat('Can you summarize everything published in the last month regarding news on superconductors')

伊织 2024-01-27(六)

相关推荐
mit6.8242 小时前
[Agent可视化] 配置系统 | 实现AI模型切换 | 热重载机制 | fsnotify库(go)
开发语言·人工智能·golang
Percent_bigdata3 小时前
百分点科技发布中国首个AI原生GEO产品Generforce,助力品牌决胜AI搜索新时代
人工智能·科技·ai-native
Gloria_niki3 小时前
YOLOv4 学习总结
人工智能·计算机视觉·目标跟踪
FriendshipT3 小时前
目标检测:使用自己的数据集微调DEIMv2进行物体检测
人工智能·pytorch·python·目标检测·计算机视觉
海森大数据3 小时前
三步破局:一致性轨迹强化学习开启扩散语言模型“又快又好”推理新时代
人工智能·语言模型·自然语言处理
Tencent_TCB3 小时前
云开发CloudBase AI+实战:快速搭建AI小程序全流程指南
人工智能·ai·小程序·ai编程·云开发
Sunhen_Qiletian3 小时前
基于OpenCV与Python的身份证号码识别案例详解
人工智能·opencv·计算机视觉
AustinCyy3 小时前
【论文笔记】Introduction to Explainable AI
论文阅读·人工智能
岁月宁静3 小时前
在富文本编辑器中封装实用的 AI 写作助手功能
前端·vue.js·人工智能
bestcxx3 小时前
0.3、AI Agent 知识库、召回、Recall、Embedding等 相关的概念
embedding·知识库·dify·rag·ai agent·recall·召回