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

llama-index,uncharted and llama2:7b run locally to generate Index

题意:本地运行 llama-indexuncharted 以及 llama2:7b 来生成索引

问题背景:

I wanted to use llama-index locally with ollama and llama3:8b to index utf-8 json file. I dont have a gpu. I use uncharted to convert docs into json. Now If it is not possible to use llama-index locally without GPU I wanted to use hugging face inference API. But I am not certain if it is free. Can anyone suggest a way?

This is my python code:

from llama_index.core import Document, SimpleDirectoryReader, VectorStoreIndexfrom llama_index.llms.ollama import Ollamaimport jsonfrom llama_index.core import Settings# Convert the JSON document into LlamaIndex Document objectswith open('data/UBER_2019.json', 'r',encoding='utf-8') as f:json_doc = json.load(f)documents = [Document(text=str(doc)) for doc in json_doc]# Initialize Ollama with the local LLMollama_llm = Ollama(model="llama3:8b")Settings.llm = ollama_llm# Create the index using the local LLMindex = VectorStoreIndex.from_documents(documents)#, llm=ollama_llm)

But i keep getting error that there is no OPENAI key. I wanted to use llama2 so that i dont require OPENAI key

Can anyone suggest what i am doing wrong? Also can i use huggingfaceinference API to do indexing of a local json file for free?

问题解决:

You are not setting the embedding model, so I think Llama Index is defaulting to OpenAI.
You must specify an embedding model that does not require an API key.

You can use Ollama:

from llama_index.embeddings.ollama import OllamaEmbedding# Using Nomic
Settings.embed_model = OllamaEmbedding(model_name="nomic-embed-text")# Using Llama
Settings.embed_model = OllamaEmbedding(model_name="llama2")

But there are many options in the documentation like this, this, this

相关文章:

  • C语言从头学35——struct结构
  • Web开发:卡片翻转效果(HTML、CSS)
  • 文心一言:如何备考软考架构师
  • MySQL第一次作业
  • 数据库day2
  • 伪元素::before :: after的用法?
  • 微软GraphRAG +本地模型+Gradio 简单测试笔记
  • 【C#】Array和List
  • 深入解析公有IP与私有IP:地址分配与使用限制
  • 智慧农业新纪元:解锁新质生产力,加速产业数字化转型
  • liosam复现
  • 测试面试宝典(六)—— 请回答集成测试和系统测试的区别,以及它们的应用场景主要是什么?
  • 索引堆及其优化
  • Qt模型/视图架构——委托(delegate)
  • 【日常记录】【CSS】display:inline 的样式截断
  • 【许晓笛】 EOS 智能合约案例解析(3)
  • 4月23日世界读书日 网络营销论坛推荐《正在爆发的营销革命》
  • JavaScript学习总结——原型
  • Java比较器对数组,集合排序
  • Java反射-动态类加载和重新加载
  • java正则表式的使用
  • js算法-归并排序(merge_sort)
  • spring学习第二天
  • TypeScript实现数据结构(一)栈,队列,链表
  • Vue UI框架库开发介绍
  • 从0实现一个tiny react(三)生命周期
  • 记录一下第一次使用npm
  • 我与Jetbrains的这些年
  • 移动互联网+智能运营体系搭建=你家有金矿啊!
  • 云大使推广中的常见热门问题
  • 中国人寿如何基于容器搭建金融PaaS云平台
  • 如何通过报表单元格右键控制报表跳转到不同链接地址 ...
  • $L^p$ 调和函数恒为零
  • (11)MSP430F5529 定时器B
  • (4)事件处理——(7)简单事件(Simple events)
  • (板子)A* astar算法,AcWing第k短路+八数码 带注释
  • (六)DockerCompose安装与配置
  • (牛客腾讯思维编程题)编码编码分组打印下标(java 版本+ C版本)
  • (十六)Flask之蓝图
  • (十七)Flink 容错机制
  • (转)IOS中获取各种文件的目录路径的方法
  • (转)我也是一只IT小小鸟
  • .apk 成为历史!
  • .bat批处理(四):路径相关%cd%和%~dp0的区别
  • .gitignore不生效的解决方案
  • .NET Core 成都线下面基会拉开序幕
  • .Net Core与存储过程(一)
  • .net 微服务 服务保护 自动重试 Polly
  • .net 中viewstate的原理和使用
  • .NET/ASP.NETMVC 深入剖析 Model元数据、HtmlHelper、自定义模板、模板的装饰者模式(二)...
  • .net利用SQLBulkCopy进行数据库之间的大批量数据传递
  • .NET应用UI框架DevExpress XAF v24.1 - 可用性进一步增强
  • .net中生成excel后调整宽度
  • @cacheable 是否缓存成功_Spring Cache缓存注解
  • @transaction 提交事务_【读源码】剖析TCCTransaction事务提交实现细节