当前位置: 首页 > 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

http://www.lryc.cn/news/401961.html

相关文章:

  • vue、js截取视频任意一帧图片
  • STM32智能家居系统教程
  • uniapp 开发 App 对接官方更新功能
  • 【PostgreSQL】PostgreSQL 教程
  • Qt类 | QLabel类详解
  • 深入剖析 Android 开源库 EventBus 的源码详解
  • End-to-End Object Detection with Transformers【目标检测-方法详细解读】
  • CSS3实现提示工具的渐入渐出效果及CSS3动画简介
  • JVM 垃圾回收算法
  • 吴恩达大模型系列课程《Prompt Compression and Query Optimization》中文学习打开方式
  • 2.javaWeb_请求和响应的处理(Request,Response)
  • 用C++、Python、Rust编写的有安全问题的B树
  • 问题:当直齿圆柱齿轮的齿数少于?时,可采用 变位的办法来避免根切。 #学习方法#其他
  • 请你谈谈:spring bean的生命周期 - 阶段2:Bean实例化阶段
  • 【开发指南】HTML和JS编写多用户VR应用程序的框架
  • C语言第6天作业 7月17日
  • 【BES2500x系列 -- RTX5操作系统】深入探索CMSIS-RTOS RTX -- 配置篇 -- flash的使用 --(八)
  • vue视频、图片自动轮播并伴随进度条
  • Android Studio环境安装指南
  • CentOS 7 初始化环境配置详细
  • 数据结构(双向链表)
  • 关于Kafka的17个问题
  • Redis 散列
  • ip地址错误无法上网怎么修复
  • 数据库管理的艺术(MySQL):DDL、DML、DQL、DCL及TPL的实战应用(上:数据定义与控制)
  • 成为CMake砖家(5): VSCode CMake Tools 插件基本使用
  • 【简洁明了】调节大模型的prompt的方法【带案例】
  • 【操作系统】文件管理——文件存储空间管理(个人笔记)
  • 微软GraphRAG +本地模型+Gradio 简单测试笔记
  • 数学建模-Topsis(优劣解距离法)