llama-index,uncharted and llama2:7b run locally to generate Index
创始人
2025-01-08 03:33:43
0

题意:本地运行 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, VectorStoreIndex     from llama_index.llms.ollama import Ollama     import json     from llama_index.core import Settings               # Convert the JSON document into LlamaIndex Document objects     with 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 LLM     ollama_llm = Ollama(model="llama3:8b")     Settings.llm = ollama_llm          # Create the index using the local LLM     index = 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

相关内容

热门资讯

揭露一下!决战十三水作弊码,衢... 揭露一下!决战十三水作弊码,衢州都莱辅助器免费,一直真的有挂(哔哩哔哩)1、每一步都需要思考,不同水...
有挂一下!聚财平台辅助,浙江宝... 有挂一下!聚财平台辅助,浙江宝宝游戏辅助软件,真是真的有挂(哔哩哔哩);1、完成聚财平台辅助辅助器v...
解谜一下!蜀山四川小程序辅助插... 解谜一下!蜀山四川小程序辅助插件,微友联盟辅助,切实存在有挂(哔哩哔哩)1)蜀山四川小程序辅助插件辅...
必备一下!小松宿松游戏辅助,盛... 必备一下!小松宿松游戏辅助,盛世辅助器,果然是有挂(哔哩哔哩)1、许多玩家不知道小松宿松游戏辅助辅助...
关于一下!都莱软件安装辅助,广... 关于一下!都莱软件安装辅助,广东雀神挂件怎么样,竟然是真的有挂(哔哩哔哩)1)广东雀神挂件怎么样免费...
总结一下!福建微乐小程序修改器... 总结一下!福建微乐小程序修改器,微友辅助神器下载,竟然存在有挂(哔哩哔哩)福建微乐小程序修改器是不是...
揭露一下!多乐跑胡子辅助,潮汕... 揭露一下!多乐跑胡子辅助,潮汕木虱有辅助挂吗,一直真的有挂(哔哩哔哩)一、潮汕木虱有辅助挂吗可以开透...
推荐一下!微乐小程序辅助收费,... 推荐一下!微乐小程序辅助收费,创思维辅助器,都是存在有挂(哔哩哔哩)所有人都在同一条线上,像星星一样...
普及一下!逗娱碰胡辅助器,潮汕... 普及一下!逗娱碰胡辅助器,潮汕掌手娱辅助器,本来真的有挂(哔哩哔哩)1、下载好逗娱碰胡辅助器正确养号...
教你一下!老友辅助器,邯郸胡乐... 教你一下!老友辅助器,邯郸胡乐修改器,好像有挂(哔哩哔哩)1、上手简单,内置详细流程视频教学,新手小...